More automated renaming.
[dcpomatic.git] / src / lib / types.cc
index f31e7a3ec3854f9c1fee5d27592897e20a52628a..7f0bf43057d75f9c770e7369b6ffde721c8b522a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 */
 
 #include "types.h"
+#include "compose.hpp"
 #include "dcpomatic_assert.h"
-#include "raw_convert.h"
+#include <dcp/raw_convert.h>
 #include <libxml++/libxml++.h>
 #include <libcxml/cxml.h>
 
+#include "i18n.h"
+
 using std::max;
 using std::min;
 using std::string;
 using boost::shared_ptr;
+using dcp::raw_convert;
 
 bool operator== (Crop const & a, Crop const & b)
 {
@@ -89,6 +93,44 @@ Crop::as_xml (xmlpp::Node* node) const
        node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
 }
 
+TextType
+string_to_caption_type (string s)
+{
+       if (s == "open") {
+               return CAPTION_OPEN;
+       } else if (s == "closed") {
+               return CAPTION_CLOSED;
+       } else {
+               throw MetadataError (String::compose ("Unknown caption type %1", s));
+       }
+}
+
+string
+caption_type_to_string (TextType t)
+{
+       switch (t) {
+       case CAPTION_OPEN:
+               return "open";
+       case CAPTION_CLOSED:
+               return "closed";
+       default:
+               DCPOMATIC_ASSERT (false);
+       }
+}
+
+string
+caption_type_to_name (TextType t)
+{
+       switch (t) {
+       case CAPTION_OPEN:
+               return _("Subtitles");
+       case CAPTION_CLOSED:
+               return _("Closed captions");
+       default:
+               DCPOMATIC_ASSERT (false);
+       }
+}
+
 string
 video_frame_type_to_string (VideoFrameType t)
 {