Subtitle naming fixes.
[dcpomatic.git] / src / lib / writer.cc
index 7091930f48ab4be5f8245bf513355901fee7a468..7e47c317ee7ff09f8226b26f04e558168de84f73 100644 (file)
@@ -505,48 +505,34 @@ Writer::finish ()
        shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (_picture_asset);
        if (mono) {
                reel->add (shared_ptr<dcp::ReelPictureAsset> (new dcp::ReelMonoPictureAsset (mono, 0)));
-               dcp.add (mono);
        }
 
        shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (_picture_asset);
        if (stereo) {
                reel->add (shared_ptr<dcp::ReelPictureAsset> (new dcp::ReelStereoPictureAsset (stereo, 0)));
-               dcp.add (stereo);
        }
 
        if (_sound_asset) {
                reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (_sound_asset, 0)));
-               dcp.add (_sound_asset);
        }
 
        if (_subtitle_asset) {
                boost::filesystem::path const liberation = shared_path () / "LiberationSans-Regular.ttf";
 
-               /* Add all the fonts to the subtitle content and as assets to the DCP */
+               /* Add all the fonts to the subtitle content */
                BOOST_FOREACH (shared_ptr<Font> i, _fonts) {
-                       boost::filesystem::path const from = i->file.get_value_or (liberation);
-                       _subtitle_asset->add_font (i->id, from.leaf().string ());
-
-                       boost::filesystem::path to = _film->dir (_film->dcp_name ()) / _subtitle_asset->id ();
-                       boost::filesystem::create_directories (to, ec);
-                       if (ec) {
-                               throw FileError (_("Could not create directory"), to);
-                       }
-
-                       to /= from.leaf();
-
-                       boost::system::error_code ec;
-                       boost::filesystem::copy_file (from, to, ec);
-                       if (ec) {
-                               throw FileError ("Could not copy font to DCP", from);
-                       }
-
-                       dcp.add (shared_ptr<dcp::Font> (new dcp::Font (to)));
+                       _subtitle_asset->add_font (i->id, i->file.get_value_or (liberation));
                }
 
-               _subtitle_asset->write (
-                       _film->dir (_film->dcp_name ()) / _subtitle_asset->id () / subtitle_content_filename (_subtitle_asset)
-                       );
+               if (dynamic_pointer_cast<dcp::InteropSubtitleAsset> (_subtitle_asset)) {
+                       boost::filesystem::path directory = _film->dir (_film->dcp_name ()) / _subtitle_asset->id ();
+                       boost::filesystem::create_directories (directory);
+                       _subtitle_asset->write (directory / ("sub_" + _subtitle_asset->id() + ".xml"));
+               } else {
+                       _subtitle_asset->write (
+                               _film->dir (_film->dcp_name ()) / ("sub_" + _subtitle_asset->id() + ".mxf")
+                               );
+               }
                
                reel->add (shared_ptr<dcp::ReelSubtitleAsset> (
                                   new dcp::ReelSubtitleAsset (
@@ -556,8 +542,6 @@ Writer::finish ()
                                           0
                                           )
                                   ));
-               
-               dcp.add (_subtitle_asset);
        }
        
        cpl->add (reel);