Add type for text content (CCAP/subtitle).
[dcpomatic.git] / src / lib / types.cc
index e3bedd667f7a716daee156db5451e2b6b376cc9c..68e00c8d532c55a4fce389721991b9b56a43b6c6 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include "types.h"
+#include "compose.hpp"
 #include "dcpomatic_assert.h"
 #include <dcp/raw_convert.h>
 #include <libxml++/libxml++.h>
@@ -90,6 +91,31 @@ Crop::as_xml (xmlpp::Node* node) const
        node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
 }
 
+TextType
+string_to_text_type (string s)
+{
+       if (s == "subtitle") {
+               return TEXT_SUBTITLE;
+       } else if (s == "ccap") {
+               return TEXT_CLOSED_CAPTION;
+       } else {
+               throw MetadataError (String::compose ("Unknown text type %1", s));
+       }
+}
+
+string
+text_type_to_string (TextType t)
+{
+       switch (t) {
+       case TEXT_SUBTITLE:
+               return "subtitle";
+       case TEXT_CLOSED_CAPTION:
+               return "ccap";
+       default:
+               DCPOMATIC_ASSERT (false);
+       }
+}
+
 string
 video_frame_type_to_string (VideoFrameType t)
 {