X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Freel_writer.cc;h=e008bf6311ae5acbcbcfa8a1b1d41bbfb75aa225;hb=d2c4aba65a9eb2ee75961cdc860d2f3aa0b1a548;hp=fa2813837bf065d4f57af3f00575367dedd4f107;hpb=ada96204dfa1456da77e2ea7469f492cfc0a5483;p=dcpomatic.git diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index fa2813837..e008bf631 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -88,6 +88,7 @@ ReelWriter::ReelWriter ( if (_film->encrypted ()) { _picture_asset->set_key (_film->key ()); + _picture_asset->set_context_id (_film->context_id ()); } _picture_asset->set_file ( @@ -112,11 +113,13 @@ ReelWriter::ReelWriter ( _sound_asset->set_key (_film->key ()); } + DCPOMATIC_ASSERT (_film->directory()); + /* Write the sound asset into the film directory so that we leave the creation of the DCP directory until the last minute. */ _sound_asset_writer = _sound_asset->start_write ( - _film->directory() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary), + _film->directory().get() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary), _film->interop() ? dcp::INTEROP : dcp::SMPTE ); } @@ -128,13 +131,27 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const { FILE* file = 0; boost::filesystem::path info_file = _film->info_file (_period); - if (boost::filesystem::exists (info_file)) { + + bool const read = boost::filesystem::exists (info_file); + +#ifdef DCPOMATIC_WINDOWS + if (read) { + LOG_GENERAL ( + "Checked %1 (which exists) length is %2 perms are %3", + info_file, boost::filesystem::file_size (info_file), int(boost::filesystem::status(info_file).permissions()) + ); + } else { + LOG_GENERAL ("Checked %1 (which does not exist)", info_file); + } +#endif + + if (read) { file = fopen_boost (info_file, "r+b"); } else { file = fopen_boost (info_file, "wb"); } if (!file) { - throw OpenFileError (info_file); + throw OpenFileError (info_file, errno, read); } dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET); fwrite (&info.offset, sizeof (info.offset), 1, file); @@ -180,12 +197,13 @@ void ReelWriter::check_existing_picture_asset () { /* Try to open the existing asset */ - FILE* asset_file = fopen_boost (_picture_asset->file(), "rb"); + DCPOMATIC_ASSERT (_picture_asset->file()); + FILE* asset_file = fopen_boost (_picture_asset->file().get(), "rb"); if (!asset_file) { - LOG_GENERAL ("Could not open existing asset at %1 (errno=%2)", _picture_asset->file().string(), errno); + LOG_GENERAL ("Could not open existing asset at %1 (errno=%2)", _picture_asset->file()->string(), errno); return; } else { - LOG_GENERAL ("Opened existing asset at %1", _picture_asset->file().string()); + LOG_GENERAL ("Opened existing asset at %1", _picture_asset->file()->string()); } /* Offset of the last dcp::FrameInfo in the info file */ @@ -258,6 +276,7 @@ ReelWriter::finish () { if (!_picture_asset_writer->finalize ()) { /* Nothing was written to the picture asset */ + LOG_GENERAL ("Nothing was written to reel %1 of %2", _reel_index, _reel_count); _picture_asset.reset (); } @@ -268,7 +287,8 @@ ReelWriter::finish () /* Hard-link any video asset file into the DCP */ if (_picture_asset) { - boost::filesystem::path video_from = _picture_asset->file (); + 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()); video_to /= video_asset_filename (_picture_asset, _reel_index, _reel_count, _content_summary); @@ -325,15 +345,21 @@ ReelWriter::create_reel (list const & refs, list k = dynamic_pointer_cast (j.asset); + if (k) { + LOG_GENERAL ("candidate picture asset period is %1-%2", j.period.from.get(), j.period.to.get()); + } if (k && j.period == _period) { reel_picture_asset = k; } } } + LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count); + DCPOMATIC_ASSERT (reel_picture_asset); reel->add (reel_picture_asset); @@ -454,7 +480,7 @@ ReelWriter::write (shared_ptr audio) _sound_asset_writer->write (audio->data(), audio->frames()); } - ++_total_written_audio_frames; + _total_written_audio_frames += audio->frames (); } void @@ -479,11 +505,14 @@ ReelWriter::write (PlayerSubtitles subs) s->set_reel_number (1); s->set_time_code_rate (_film->video_frame_rate ()); s->set_start_time (dcp::Time ()); + if (_film->encrypted ()) { + s->set_key (_film->key ()); + } _subtitle_asset = s; } } - BOOST_FOREACH (dcp::SubtitleString i, subs.text) { + BOOST_FOREACH (SubtitleString i, subs.text) { i.set_in (i.in() - dcp::Time (_period.from.seconds(), i.in().tcr)); i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr)); _subtitle_asset->add (i);