diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-07 00:08:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-12-08 14:09:02 +0100 |
| commit | 46b4349fb5a19523e5105812bf79fd0e7df9c51f (patch) | |
| tree | 95911d79061b54d0c0b2d513fb2ce18cefbeebd8 /src | |
| parent | 7d1fb4361e6eec27c9eefb886761293e904f0dff (diff) | |
Make Writer take an output DCP path rather than getting it from the
film itself.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_encoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/reel_writer.cc | 36 | ||||
| -rw-r--r-- | src/lib/reel_writer.h | 9 | ||||
| -rw-r--r-- | src/lib/writer.cc | 16 | ||||
| -rw-r--r-- | src/lib/writer.h | 4 |
5 files changed, 39 insertions, 28 deletions
diff --git a/src/lib/dcp_encoder.cc b/src/lib/dcp_encoder.cc index 345e5511c..1c5b00dd4 100644 --- a/src/lib/dcp_encoder.cc +++ b/src/lib/dcp_encoder.cc @@ -125,7 +125,7 @@ DCPEncoder::go () _finishing = true; _j2k_encoder->end (); - _writer->finish (); + _writer->finish (_film->dir(_film->dcp_name())); } void diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index c1c002d30..e12628c74 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -347,7 +347,7 @@ ReelWriter::repeat_write (Frame frame, Eyes eyes) } void -ReelWriter::finish () +ReelWriter::finish (boost::filesystem::path output_dcp) { if (_picture_asset_writer && !_picture_asset_writer->finalize ()) { /* Nothing was written to the picture asset */ @@ -364,8 +364,7 @@ ReelWriter::finish () if (_picture_asset) { DCPOMATIC_ASSERT (_picture_asset->file()); boost::filesystem::path video_from = _picture_asset->file().get(); - boost::filesystem::path video_to; - video_to /= film()->dir(film()->dcp_name()); + boost::filesystem::path video_to = output_dcp; video_to /= video_asset_filename (_picture_asset, _reel_index, _reel_count, _content_summary); /* There may be an existing "to" file if we are recreating a DCP in the same place without changing any video. @@ -399,8 +398,7 @@ ReelWriter::finish () /* Move the audio asset into the DCP */ if (_sound_asset) { - boost::filesystem::path audio_to; - audio_to /= film()->dir(film()->dcp_name ()); + boost::filesystem::path audio_to = output_dcp; string const aaf = audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary); audio_to /= aaf; @@ -417,8 +415,7 @@ ReelWriter::finish () if (_atmos_asset) { _atmos_asset_writer->finalize (); - boost::filesystem::path atmos_to; - atmos_to /= film()->dir(film()->dcp_name()); + boost::filesystem::path atmos_to = output_dcp; string const aaf = atmos_asset_filename (_atmos_asset, _reel_index, _reel_count, _content_summary); atmos_to /= aaf; @@ -443,7 +440,8 @@ maybe_add_text ( list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts, shared_ptr<const Film> film, - DCPTimePeriod period + DCPTimePeriod period, + boost::filesystem::path output_dcp ) { Frame const period_duration = period.duration().frames_round(film->video_frame_rate()); @@ -457,7 +455,7 @@ maybe_add_text ( } if (dynamic_pointer_cast<dcp::InteropSubtitleAsset> (asset)) { - boost::filesystem::path directory = film->dir (film->dcp_name ()) / asset->id (); + boost::filesystem::path directory = output_dcp / asset->id (); boost::filesystem::create_directories (directory); asset->write (directory / ("sub_" + asset->id() + ".xml")); } else { @@ -469,7 +467,7 @@ maybe_add_text ( dynamic_pointer_cast<dcp::SMPTESubtitleAsset>(asset)->set_intrinsic_duration (picture_duration); asset->write ( - film->dir(film->dcp_name()) / ("sub_" + asset->id() + ".mxf") + output_dcp / ("sub_" + asset->id() + ".mxf") ); } @@ -607,16 +605,24 @@ ReelWriter::create_reel_sound (shared_ptr<dcp::Reel> reel, list<ReferencedReelAs void -ReelWriter::create_reel_text (shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const& fonts, int64_t duration) const +ReelWriter::create_reel_text ( + shared_ptr<dcp::Reel> reel, + list<ReferencedReelAsset> const & refs, + list<shared_ptr<Font> > const& fonts, + int64_t duration, + boost::filesystem::path output_dcp + ) const { - shared_ptr<dcp::ReelSubtitleAsset> subtitle = maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, duration, reel, refs, fonts, film(), _period); + shared_ptr<dcp::ReelSubtitleAsset> subtitle = maybe_add_text<dcp::ReelSubtitleAsset> ( + _subtitle_asset, duration, reel, refs, fonts, film(), _period, output_dcp + ); if (subtitle && !film()->subtitle_languages().empty()) { subtitle->set_language (film()->subtitle_languages().front()); } for (map<DCPTextTrack, shared_ptr<dcp::SubtitleAsset> >::const_iterator i = _closed_caption_assets.begin(); i != _closed_caption_assets.end(); ++i) { shared_ptr<dcp::ReelClosedCaptionAsset> a = maybe_add_text<dcp::ReelClosedCaptionAsset> ( - i->second, duration, reel, refs, fonts, film(), _period + i->second, duration, reel, refs, fonts, film(), _period, output_dcp ); if (a) { a->set_annotation_text (i->first.name); @@ -655,14 +661,14 @@ ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const shared_ptr<dcp::Reel> -ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts) +ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts, boost::filesystem::path output_dcp) { LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count); shared_ptr<dcp::Reel> reel (new dcp::Reel()); shared_ptr<dcp::ReelPictureAsset> reel_picture_asset = create_reel_picture (reel, refs); create_reel_sound (reel, refs); - create_reel_text (reel, refs, fonts, reel_picture_asset->actual_duration()); + create_reel_text (reel, refs, fonts, reel_picture_asset->actual_duration(), output_dcp); create_reel_markers (reel); if (_atmos_asset) { diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 6acf0d21a..c65364567 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -74,8 +74,10 @@ public: void write (PlayerText text, TextType type, boost::optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period); void write (boost::shared_ptr<const dcp::AtmosFrame> atmos, AtmosMetadata metadata); - void finish (); - boost::shared_ptr<dcp::Reel> create_reel (std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<dcpomatic::Font> > const & fonts); + void finish (boost::filesystem::path output_dcp); + boost::shared_ptr<dcp::Reel> create_reel ( + std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<dcpomatic::Font> > const & fonts, boost::filesystem::path output_dcp + ); void calculate_digests (boost::function<void (float)> set_progress); Frame start () const; @@ -104,7 +106,8 @@ private: void create_reel_text ( boost::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<dcpomatic::Font> > const& fonts, - int64_t duration + int64_t duration, + boost::filesystem::path output_dcp ) const; void create_reel_markers (boost::shared_ptr<dcp::Reel> reel) const; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index f7d3bcd25..17184918f 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -517,8 +517,10 @@ Writer::terminate_thread (bool can_throw) } } + +/** @param output_dcp Path to DCP folder to write */ void -Writer::finish () +Writer::finish (boost::filesystem::path output_dcp) { if (!_thread.joinable()) { return; @@ -531,12 +533,12 @@ Writer::finish () LOG_GENERAL_NC ("Finishing ReelWriters"); BOOST_FOREACH (ReelWriter& i, _reels) { - i.finish (); + i.finish (output_dcp); } LOG_GENERAL_NC ("Writing XML"); - dcp::DCP dcp (film()->dir(film()->dcp_name())); + dcp::DCP dcp (output_dcp); shared_ptr<dcp::CPL> cpl ( new dcp::CPL ( @@ -584,7 +586,7 @@ Writer::finish () /* Add reels */ BOOST_FOREACH (ReelWriter& i, _reels) { - cpl->add (i.create_reel (_reel_assets, _fonts)); + cpl->add (i.create_reel(_reel_assets, _fonts, output_dcp)); } /* Add metadata */ @@ -662,11 +664,11 @@ Writer::finish () N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT, %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk ); - write_cover_sheet (); + write_cover_sheet (output_dcp); } void -Writer::write_cover_sheet () +Writer::write_cover_sheet (boost::filesystem::path output_dcp) { boost::filesystem::path const cover = film()->file("COVER_SHEET.txt"); FILE* f = fopen_boost (cover, "w"); @@ -689,7 +691,7 @@ Writer::write_cover_sheet () boost::uintmax_t size = 0; for ( - boost::filesystem::recursive_directory_iterator i = boost::filesystem::recursive_directory_iterator(film()->dir(film()->dcp_name())); + boost::filesystem::recursive_directory_iterator i = boost::filesystem::recursive_directory_iterator(output_dcp); i != boost::filesystem::recursive_directory_iterator(); ++i) { if (boost::filesystem::is_regular_file (i->path ())) { diff --git a/src/lib/writer.h b/src/lib/writer.h index 085cd2a32..1c290e6ca 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -115,7 +115,7 @@ public: void write (std::list<boost::shared_ptr<dcpomatic::Font> > fonts); void write (ReferencedReelAsset asset); void write (boost::shared_ptr<const dcp::AtmosFrame> atmos, dcpomatic::DCPTime time, AtmosMetadata metadata); - void finish (); + void finish (boost::filesystem::path output_dcp); void set_encoder_threads (int threads); @@ -125,7 +125,7 @@ private: bool have_sequenced_image_at_queue_head (); size_t video_reel (int frame) const; void set_digest_progress (Job* job, float progress); - void write_cover_sheet (); + void write_cover_sheet (boost::filesystem::path output_dcp); void calculate_referenced_digests (boost::function<void (float)> set_progress); boost::weak_ptr<Job> _job; |
