Reasonably straightforward stuff; main things are adding
[dcpomatic.git] / src / lib / subtitle_content.cc
index a10e23cafea324a48fe9333e4858c5b30f294771..48c9e9cf6c8fb673df9f8b94582be870ba3d896c 100644 (file)
@@ -24,7 +24,9 @@
 #include "font.h"
 #include "raw_convert.h"
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -43,6 +45,7 @@ int const SubtitleContentProperty::USE_SUBTITLES = 504;
 int const SubtitleContentProperty::BURN_SUBTITLES = 505;
 int const SubtitleContentProperty::SUBTITLE_LANGUAGE = 506;
 int const SubtitleContentProperty::FONTS = 507;
+int const SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE = 508;
 
 SubtitleContent::SubtitleContent (shared_ptr<const Film> film)
        : Content (film)
@@ -83,17 +86,17 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePt
        }
 
        if (version >= 7) {
-               _subtitle_x_offset = node->number_child<float> ("SubtitleXOffset");
-               _subtitle_y_offset = node->number_child<float> ("SubtitleYOffset");
+               _subtitle_x_offset = node->number_child<double> ("SubtitleXOffset");
+               _subtitle_y_offset = node->number_child<double> ("SubtitleYOffset");
        } else {
-               _subtitle_y_offset = node->number_child<float> ("SubtitleOffset");
+               _subtitle_y_offset = node->number_child<double> ("SubtitleOffset");
        }
 
        if (version >= 10) {
-               _subtitle_x_scale = node->number_child<float> ("SubtitleXScale");
-               _subtitle_y_scale = node->number_child<float> ("SubtitleYScale");
+               _subtitle_x_scale = node->number_child<double> ("SubtitleXScale");
+               _subtitle_y_scale = node->number_child<double> ("SubtitleYScale");
        } else {
-               _subtitle_x_scale = _subtitle_y_scale = node->number_child<float> ("SubtitleScale");
+               _subtitle_x_scale = _subtitle_y_scale = node->number_child<double> ("SubtitleScale");
        }
 
        _subtitle_language = node->optional_string_child ("SubtitleLanguage").get_value_or ("");
@@ -268,6 +271,15 @@ SubtitleContent::identifier () const
          << "_" << raw_convert<string> (subtitle_x_offset())
          << "_" << raw_convert<string> (subtitle_y_offset());
 
+       /* XXX: I suppose really _fonts shouldn't be in here, since not all
+          types of subtitle content involve fonts.
+       */
+       BOOST_FOREACH (shared_ptr<Font> f, _fonts) {
+               for (int i = 0; i < FontFiles::VARIANTS; ++i) {
+                       s << "_" << f->file(static_cast<FontFiles::Variant>(i)).get_value_or ("Default");
+               }
+       }
+
        /* The language is for metadata only, and doesn't affect
           how this content looks.
        */