Bump version
[libdcp.git] / src / interop_subtitle_asset.cc
index 620fed7362d6d1bc206d20326d7de8ab27219506..a2742b78b2716663f0bb772b4a4d89c6acdb0f71 100644 (file)
@@ -52,13 +52,17 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
        _movie_title = xml->string_child ("MovieTitle");
        _load_font_nodes = type_children<dcp::InteropLoadFontNode> (xml, "LoadFont");
 
-       list<cxml::NodePtr> f = xml->node_children ("Font");
        list<shared_ptr<dcp::FontNode> > font_nodes;
-       BOOST_FOREACH (cxml::NodePtr& i, f) {
-               font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, 250)));
+       BOOST_FOREACH (cxml::NodePtr const & i, xml->node_children ("Font")) {
+               font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, 250, "Id")));
        }
 
-       parse_subtitles (xml, font_nodes);
+       list<shared_ptr<dcp::SubtitleNode> > subtitle_nodes;
+       BOOST_FOREACH (cxml::NodePtr const & i, xml->node_children ("Subtitle")) {
+               subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, 250, "Id")));
+       }
+
+       parse_subtitles (xml, font_nodes, subtitle_nodes);
 }
 
 InteropSubtitleAsset::InteropSubtitleAsset ()
@@ -66,7 +70,7 @@ InteropSubtitleAsset::InteropSubtitleAsset ()
 
 }
 
-Glib::ustring
+string
 InteropSubtitleAsset::xml_as_string () const
 {
        xmlpp::Document doc;
@@ -84,7 +88,7 @@ InteropSubtitleAsset::xml_as_string () const
                load_font->set_attribute ("URI", (*i)->uri);
        }
 
-       subtitles_as_xml (root, 250, "");
+       subtitles_as_xml (root, 250, INTEROP);
 
        return doc.write_to_string_formatted ("UTF-8");
 }
@@ -151,15 +155,16 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
                throw FileError ("Could not open file for writing", p, -1);
        }
 
-       Glib::ustring const s = xml_as_string ();
-       fwrite (s.c_str(), 1, s.bytes(), f);
+       string const s = xml_as_string ();
+       /* length() here gives bytes not characters */
+       fwrite (s.c_str(), 1, s.length(), f);
        fclose (f);
 
        _file = p;
 
        BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
                boost::filesystem::path file = p.parent_path() / i->uri;
-               FILE* f = fopen_boost (file, "w");
+               FILE* f = fopen_boost (file, "wb");
                if (!f) {
                        throw FileError ("could not open font file for writing", file, errno);
                }
@@ -168,7 +173,7 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
                        ++j;
                }
                if (j != _fonts.end ()) {
-                       fwrite (j->data.data.get(), 1, j->data.size, f);
+                       fwrite (j->data.data().get(), 1, j->data.size(), f);
                        j->file = file;
                }
                fclose (f);
@@ -176,9 +181,9 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
 }
 
 void
-InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Object> > objects)
+InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Asset> > assets)
 {
-       BOOST_FOREACH (shared_ptr<Object> i, objects) {
+       BOOST_FOREACH (shared_ptr<Asset> i, assets) {
                shared_ptr<FontAsset> font = dynamic_pointer_cast<FontAsset> (i);
                if (!font) {
                        continue;