From 79cddd181d1fefa930cf4427b896af5c36758f46 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 24 Jun 2015 08:48:45 +0100 Subject: Stuff. --- src/interop_subtitle_asset.cc | 27 +++++++++++++++++---------- src/interop_subtitle_asset.h | 20 +++++++++++++++++++- src/smpte_subtitle_asset.cc | 2 +- src/smpte_subtitle_asset.h | 14 ++++++++++++++ src/subtitle_asset.cc | 16 ---------------- src/subtitle_asset.h | 24 ------------------------ 6 files changed, 51 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index ffa7d50b..c4c8af0e 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -90,10 +90,10 @@ InteropSubtitleAsset::xml_as_string () const } void -InteropSubtitleAsset::add_font (string id, boost::filesystem::path file) +InteropSubtitleAsset::add_font (string load_id, string uuid, boost::filesystem::path file) { - add_font_data (id, file); - _load_font_nodes.push_back (shared_ptr (new InteropLoadFontNode (id, file.leaf().string ()))); + _fonts.push_back (Font (load_id, uuid, file)); + _load_font_nodes.push_back (shared_ptr (new InteropLoadFontNode (load_id, file.leaf().string ()))); } bool @@ -163,11 +163,18 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const if (!f) { throw FileError ("could not open font file for writing", file, errno); } - map::const_iterator j = _fonts.find (i->id); + + list::const_iterator j = _fonts.begin (); + + while (j != _fonts.end() && j->load_id != i->id) { + ++j; + } + if (j != _fonts.end ()) { - fwrite (j->second.data.get(), 1, j->second.size, f); - j->second.file = file; + fwrite (j->data.data.get(), 1, j->data.size, f); + j->file = file; } + fclose (f); } } @@ -183,7 +190,7 @@ InteropSubtitleAsset::resolve_fonts (list > objects) BOOST_FOREACH (shared_ptr j, _load_font_nodes) { if (j->uri == font->file().leaf().string ()) { - add_font_data (j->id, font->file ()); + _fonts.push_back (Font (i->id(), j->id, font->file ())); } } } @@ -192,8 +199,8 @@ InteropSubtitleAsset::resolve_fonts (list > objects) void InteropSubtitleAsset::add_font_assets (list >& assets) { - for (map::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) { - DCP_ASSERT (i->second.file); - assets.push_back (shared_ptr (new FontAsset (i->second.file.get ()))); + for (list::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) { + DCP_ASSERT (i->file); + assets.push_back (shared_ptr (new FontAsset (i->file.get ()))); } } diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h index 41ed83b3..7c727d69 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_subtitle_asset.h @@ -47,7 +47,7 @@ public: std::list > load_font_nodes () const; - void add_font (std::string id, boost::filesystem::path file); + void add_font (std::string font_id, std::string uuid, boost::filesystem::path file); Glib::ustring xml_as_string () const; void write (boost::filesystem::path path) const; @@ -102,6 +102,24 @@ private: std::string _language; std::string _movie_title; std::list > _load_font_nodes; + + class Font + { + public: + Font (std::string load_id_, std::string uuid_, boost::filesystem::path file_) + : load_id (load_id_) + , uuid (uuid_) + , data (file_) + , file (file_) + {} + + std::string load_id; + std::string uuid; + Data data; + mutable boost::optional file; + }; + + std::list _fonts; }; } diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 8ea68362..699f589f 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -144,7 +144,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) } if (j != _load_font_nodes.end ()) { - _fonts[(*j)->id] = FileData (data, buffer.Size ()); + _fonts.push_back (Font ((*j)->id,data, buffer.Size ())); } } } diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h index 444c53e6..9dee7f6d 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_subtitle_asset.h @@ -130,6 +130,20 @@ private: int _time_code_rate; boost::optional