From: Carl Hetherington Date: Mon, 8 Jun 2015 13:25:10 +0000 (+0100) Subject: Adapt for changes to libdcp API. X-Git-Tag: v2.0.49~7^2~4 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=f07623551706b849190c84059bac455088f8eb1e Adapt for changes to libdcp API. --- diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index f4d9fe4e9..db3a30500 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -29,7 +29,7 @@ #include "dcp_subtitle_content.h" #include "util.h" #include -#include +#include using std::string; using std::list; @@ -87,7 +87,7 @@ content_factory (shared_ptr film, boost::filesystem::path path) content.reset (new SubRipContent (film, path)); } else if (ext == ".xml") { content.reset (new DCPSubtitleContent (film, path)); - } else if (ext == ".mxf" && dcp::SMPTESubtitleContent::valid_mxf (path)) { + } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) { content.reset (new DCPSubtitleContent (film, path)); } diff --git a/src/lib/content_subtitle.cc b/src/lib/content_subtitle.cc index c4cfafad5..4eed8b4b2 100644 --- a/src/lib/content_subtitle.cc +++ b/src/lib/content_subtitle.cc @@ -25,7 +25,7 @@ ContentTextSubtitle::period () const /* XXX: assuming we have some subs and they are all at the same time */ DCPOMATIC_ASSERT (!subs.empty ()); return ContentTimePeriod ( - ContentTime::from_seconds (subs.front().in().to_seconds()), - ContentTime::from_seconds (subs.front().out().to_seconds()) + ContentTime::from_seconds (subs.front().in().as_seconds()), + ContentTime::from_seconds (subs.front().out().as_seconds()) ); } diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 0411ad941..8b2765d44 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -65,20 +65,20 @@ DCPDecoder::pass (PassReason) int64_t const frame = _next.frames (vfr); if ((*_reel)->main_picture ()) { - shared_ptr mxf = (*_reel)->main_picture()->mxf (); - shared_ptr mono = dynamic_pointer_cast (mxf); - shared_ptr stereo = dynamic_pointer_cast (mxf); + shared_ptr asset = (*_reel)->main_picture()->asset (); + shared_ptr mono = dynamic_pointer_cast (asset); + shared_ptr stereo = dynamic_pointer_cast (asset); int64_t const entry_point = (*_reel)->main_picture()->entry_point (); if (mono) { - video (shared_ptr (new J2KImageProxy (mono->get_frame (entry_point + frame), mxf->size())), frame); + video (shared_ptr (new J2KImageProxy (mono->get_frame (entry_point + frame), asset->size())), frame); } else { video ( - shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), mxf->size(), dcp::EYE_LEFT)), + shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_LEFT)), frame ); video ( - shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), mxf->size(), dcp::EYE_RIGHT)), + shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_RIGHT)), frame ); } @@ -86,7 +86,7 @@ DCPDecoder::pass (PassReason) if ((*_reel)->main_sound ()) { int64_t const entry_point = (*_reel)->main_sound()->entry_point (); - shared_ptr sf = (*_reel)->main_sound()->mxf()->get_frame (entry_point + frame); + shared_ptr sf = (*_reel)->main_sound()->asset()->get_frame (entry_point + frame); uint8_t const * from = sf->data (); int const channels = _dcp_content->audio_stream()->channels (); diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index a0d13a722..21ffeda29 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -27,11 +27,11 @@ #include #include #include -#include +#include #include -#include +#include #include -#include +#include #include "i18n.h" @@ -74,10 +74,10 @@ DCPExaminer::DCPExaminer (shared_ptr content) throw DCPError (_("Mismatched frame rates in DCP")); } - shared_ptr mxf = (*i)->main_picture()->mxf (); + shared_ptr asset = (*i)->main_picture()->asset (); if (!_video_size) { - _video_size = mxf->size (); - } else if (_video_size.get() != mxf->size ()) { + _video_size = asset->size (); + } else if (_video_size.get() != asset->size ()) { throw DCPError (_("Mismatched video sizes in DCP")); } @@ -85,17 +85,17 @@ DCPExaminer::DCPExaminer (shared_ptr content) } if ((*i)->main_sound ()) { - shared_ptr mxf = (*i)->main_sound()->mxf (); + shared_ptr asset = (*i)->main_sound()->asset (); if (!_audio_channels) { - _audio_channels = mxf->channels (); - } else if (_audio_channels.get() != mxf->channels ()) { + _audio_channels = asset->channels (); + } else if (_audio_channels.get() != asset->channels ()) { throw DCPError (_("Mismatched audio channel counts in DCP")); } if (!_audio_frame_rate) { - _audio_frame_rate = mxf->sampling_rate (); - } else if (_audio_frame_rate.get() != mxf->sampling_rate ()) { + _audio_frame_rate = asset->sampling_rate (); + } else if (_audio_frame_rate.get() != asset->sampling_rate ()) { throw DCPError (_("Mismatched audio frame rates in DCP")); } @@ -113,9 +113,9 @@ DCPExaminer::DCPExaminer (shared_ptr content) /* Check that we can read the first picture frame */ try { if (!dcp.cpls().empty () && !dcp.cpls().front()->reels().empty ()) { - shared_ptr mxf = dcp.cpls().front()->reels().front()->main_picture()->mxf (); - shared_ptr mono = dynamic_pointer_cast (mxf); - shared_ptr stereo = dynamic_pointer_cast (mxf); + shared_ptr asset = dcp.cpls().front()->reels().front()->main_picture()->asset (); + shared_ptr mono = dynamic_pointer_cast (asset); + shared_ptr stereo = dynamic_pointer_cast (asset); if (mono) { mono->get_frame(0)->xyz_image (); diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index 17874c27e..66cee4ad8 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -19,27 +19,27 @@ #include "dcp_subtitle.h" #include "exceptions.h" -#include -#include +#include +#include #include "i18n.h" using boost::shared_ptr; -shared_ptr +shared_ptr DCPSubtitle::load (boost::filesystem::path file) const { - shared_ptr sc; + shared_ptr sc; try { - sc.reset (new dcp::InteropSubtitleContent (file)); + sc.reset (new dcp::InteropSubtitleAsset (file)); } catch (...) { } if (!sc) { try { - sc.reset (new dcp::SMPTESubtitleContent (file, true)); + sc.reset (new dcp::SMPTESubtitleAsset (file, true)); } catch (...) { } @@ -47,7 +47,7 @@ DCPSubtitle::load (boost::filesystem::path file) const if (!sc) { try { - sc.reset (new dcp::SMPTESubtitleContent (file, false)); + sc.reset (new dcp::SMPTESubtitleAsset (file, false)); } catch (...) { } diff --git a/src/lib/dcp_subtitle.h b/src/lib/dcp_subtitle.h index e15acca44..4b4d4c92a 100644 --- a/src/lib/dcp_subtitle.h +++ b/src/lib/dcp_subtitle.h @@ -24,13 +24,13 @@ #include namespace dcp { - class SubtitleContent; + class SubtitleAsset; } class DCPSubtitle { protected: - boost::shared_ptr load (boost::filesystem::path) const; + boost::shared_ptr load (boost::filesystem::path) const; }; #endif diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 3f9772d59..c457e8474 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -20,8 +20,8 @@ #include "font.h" #include "dcp_subtitle_content.h" #include "raw_convert.h" -#include -#include +#include +#include #include #include @@ -30,6 +30,7 @@ using std::string; using std::list; using boost::shared_ptr; +using boost::dynamic_pointer_cast; DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, boost::filesystem::path path) : Content (film, path) @@ -51,12 +52,20 @@ DCPSubtitleContent::examine (shared_ptr job) { Content::examine (job); - shared_ptr sc = load (path (0)); + shared_ptr sc = load (path (0)); boost::mutex::scoped_lock lm (_mutex); - - _subtitle_language = sc->language (); - _length = DCPTime::from_seconds (sc->latest_subtitle_out().to_seconds ()); + + shared_ptr iop = dynamic_pointer_cast (sc); + if (iop) { + _subtitle_language = iop->language (); + } + shared_ptr smpte = dynamic_pointer_cast (sc); + if (smpte) { + _subtitle_language = smpte->language().get_value_or (""); + } + + _length = DCPTime::from_seconds (sc->latest_subtitle_out().as_seconds ()); BOOST_FOREACH (shared_ptr i, sc->load_font_nodes ()) { _fonts.push_back (shared_ptr (new Font (i->id))); diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 93a122590..95d7bdca4 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -19,7 +19,7 @@ #include "dcp_subtitle_decoder.h" #include "dcp_subtitle_content.h" -#include +#include using std::list; using std::cout; @@ -28,7 +28,7 @@ using boost::shared_ptr; DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content) : SubtitleDecoder (content) { - shared_ptr c (load (content->path (0))); + shared_ptr c (load (content->path (0))); _subtitles = c->subtitles (); _next = _subtitles.begin (); } @@ -40,7 +40,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) _next = _subtitles.begin (); list::const_iterator i = _subtitles.begin (); - while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().to_seconds()) < time) { + while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().as_seconds()) < time) { ++i; } } @@ -75,8 +75,8 @@ DCPSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) c for (list::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { ContentTimePeriod period ( - ContentTime::from_seconds (i->in().to_seconds ()), - ContentTime::from_seconds (i->out().to_seconds ()) + ContentTime::from_seconds (i->in().as_seconds ()), + ContentTime::from_seconds (i->out().as_seconds ()) ); if ((starting && p.contains (period.from)) || (!starting && p.overlaps (period))) { diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index af4712b2b..125e2c818 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -19,7 +19,7 @@ */ #include "util.h" -#include +#include #include /** @file src/dcp_video_frame.h diff --git a/src/lib/encoded_data.h b/src/lib/encoded_data.h index 245a888dd..368f267f1 100644 --- a/src/lib/encoded_data.h +++ b/src/lib/encoded_data.h @@ -18,7 +18,7 @@ */ #include "types.h" -#include +#include #include #include diff --git a/src/lib/film.cc b/src/lib/film.cc index 590acedfd..d67182022 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -220,13 +220,13 @@ Film::info_file () const } boost::filesystem::path -Film::internal_video_mxf_dir () const +Film::internal_video_asset_dir () const { return dir ("video"); } boost::filesystem::path -Film::internal_video_mxf_filename () const +Film::internal_video_asset_filename () const { return video_identifier() + ".mxf"; } @@ -1132,8 +1132,8 @@ bool Film::should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const { /* Create a test file and see if we can hard-link it */ - boost::filesystem::path test = internal_video_mxf_dir() / "test"; - boost::filesystem::path test2 = internal_video_mxf_dir() / "test2"; + boost::filesystem::path test = internal_video_asset_dir() / "test"; + boost::filesystem::path test2 = internal_video_asset_dir() / "test2"; can_hard_link = true; FILE* f = fopen_boost (test, "w"); if (f) { @@ -1147,7 +1147,7 @@ Film::should_be_enough_disk_space (double& required, double& available, bool& ca boost::filesystem::remove (test2); } - boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ()); + boost::filesystem::space_info s = boost::filesystem::space (internal_video_asset_dir ()); required = double (required_disk_space ()) / 1073741824.0f; if (!can_hard_link) { required *= 2; diff --git a/src/lib/film.h b/src/lib/film.h index b0f1a8685..f9dc0ed9c 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -66,8 +66,8 @@ public: boost::filesystem::path info_file () const; boost::filesystem::path j2c_path (int, Eyes, bool) const; - boost::filesystem::path internal_video_mxf_dir () const; - boost::filesystem::path internal_video_mxf_filename () const; + boost::filesystem::path internal_video_asset_dir () const; + boost::filesystem::path internal_video_asset_filename () const; boost::filesystem::path audio_analysis_path (boost::shared_ptr) const; diff --git a/src/lib/util.cc b/src/lib/util.cc index dccf32f4d..b662f8679 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -37,9 +37,9 @@ #include "safe_stringstream.h" #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -676,19 +676,19 @@ write_frame_info (FILE* file, int frame, Eyes eyes, dcp::FrameInfo info) } string -video_mxf_filename (shared_ptr mxf) +video_asset_filename (shared_ptr asset) { - return "j2c_" + mxf->id() + ".mxf"; + return "j2c_" + asset->id() + ".mxf"; } string -audio_mxf_filename (shared_ptr mxf) +audio_asset_filename (shared_ptr asset) { - return "pcm_" + mxf->id() + ".mxf"; + return "pcm_" + asset->id() + ".mxf"; } string -subtitle_content_filename (shared_ptr content) +subtitle_content_filename (shared_ptr asset) { - return "sub_" + content->id() + ".xml"; + return "sub_" + asset->id() + ".xml"; } diff --git a/src/lib/util.h b/src/lib/util.h index 51770c288..957453fb7 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -29,7 +29,7 @@ #include "exceptions.h" #include "dcpomatic_time.h" #include -#include +#include extern "C" { #include #include @@ -43,9 +43,9 @@ extern "C" { #undef check namespace dcp { - class PictureMXF; - class SoundMXF; - class SubtitleContent; + class PictureAsset; + class SoundAsset; + class SubtitleAsset; } /** The maximum number of audio channels that we can have in a DCP */ @@ -102,9 +102,9 @@ extern void set_backtrace_file (boost::filesystem::path); extern dcp::FrameInfo read_frame_info (FILE* file, int frame, Eyes eyes); extern void write_frame_info (FILE* file, int frame, Eyes eyes, dcp::FrameInfo info); extern std::map split_get_request (std::string url); -extern std::string video_mxf_filename (boost::shared_ptr mxf); -extern std::string audio_mxf_filename (boost::shared_ptr mxf); -extern std::string subtitle_content_filename (boost::shared_ptr content); +extern std::string video_asset_filename (boost::shared_ptr asset); +extern std::string audio_asset_filename (boost::shared_ptr asset); +extern std::string subtitle_content_filename (boost::shared_ptr content); #endif diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 650f8ac47..03139a31c 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -34,10 +34,10 @@ #include "version.h" #include "font.h" #include "util.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -100,41 +100,46 @@ Writer::Writer (shared_ptr f, weak_ptr j) */ if (_film->three_d ()) { - _picture_mxf.reset (new dcp::StereoPictureMXF (dcp::Fraction (_film->video_frame_rate (), 1))); + _picture_asset.reset (new dcp::StereoPictureAsset (dcp::Fraction (_film->video_frame_rate (), 1))); } else { - _picture_mxf.reset (new dcp::MonoPictureMXF (dcp::Fraction (_film->video_frame_rate (), 1))); + _picture_asset.reset (new dcp::MonoPictureAsset (dcp::Fraction (_film->video_frame_rate (), 1))); } - _picture_mxf->set_size (_film->frame_size ()); + _picture_asset->set_size (_film->frame_size ()); if (_film->encrypted ()) { - _picture_mxf->set_key (_film->key ()); + _picture_asset->set_key (_film->key ()); } - _picture_mxf->set_file ( - _film->internal_video_mxf_dir() / _film->internal_video_mxf_filename() + _picture_asset->set_file ( + _film->internal_video_asset_dir() / _film->internal_video_asset_filename() ); job->sub (_("Checking existing image data")); - check_existing_picture_mxf (); + check_existing_picture_asset (); - _picture_mxf_writer = _picture_mxf->start_write ( - _film->internal_video_mxf_dir() / _film->internal_video_mxf_filename(), + _picture_asset_writer = _picture_asset->start_write ( + _film->internal_video_asset_dir() / _film->internal_video_asset_filename(), _film->interop() ? dcp::INTEROP : dcp::SMPTE, _first_nonexistant_frame > 0 ); if (_film->audio_channels ()) { - _sound_mxf.reset (new dcp::SoundMXF (dcp::Fraction (_film->video_frame_rate(), 1), _film->audio_frame_rate (), _film->audio_channels ())); + _sound_asset.reset ( + new dcp::SoundAsset (dcp::Fraction (_film->video_frame_rate(), 1), _film->audio_frame_rate (), _film->audio_channels ()) + ); if (_film->encrypted ()) { - _sound_mxf->set_key (_film->key ()); + _sound_asset->set_key (_film->key ()); } - /* Write the sound MXF into the film directory so that we leave the creation + /* Write the sound asset into the film directory so that we leave the creation of the DCP directory until the last minute. */ - _sound_mxf_writer = _sound_mxf->start_write (_film->directory() / audio_mxf_filename (_sound_mxf), _film->interop() ? dcp::INTEROP : dcp::SMPTE); + _sound_asset_writer = _sound_asset->start_write ( + _film->directory() / audio_asset_filename (_sound_asset), + _film->interop() ? dcp::INTEROP : dcp::SMPTE + ); } /* Check that the signer is OK if we need one */ @@ -224,8 +229,8 @@ Writer::fake_write (int frame, Eyes eyes) void Writer::write (shared_ptr audio) { - if (_sound_mxf_writer) { - _sound_mxf_writer->write (audio->data(), audio->frames()); + if (_sound_asset_writer) { + _sound_asset_writer->write (audio->data(), audio->frames()); } } @@ -321,20 +326,20 @@ try switch (qi.type) { case QueueItem::FULL: { - LOG_GENERAL (N_("Writer FULL-writes %1 (%2) to MXF"), qi.frame, qi.eyes); + LOG_GENERAL (N_("Writer FULL-writes %1 (%2)"), qi.frame, qi.eyes); if (!qi.encoded) { qi.encoded.reset (new EncodedData (_film->j2c_path (qi.frame, qi.eyes, false))); } - dcp::FrameInfo fin = _picture_mxf_writer->write (qi.encoded->data(), qi.encoded->size()); + dcp::FrameInfo fin = _picture_asset_writer->write (qi.encoded->data(), qi.encoded->size()); qi.encoded->write_info (_film, qi.frame, qi.eyes, fin); _last_written[qi.eyes] = qi.encoded; ++_full_written; break; } case QueueItem::FAKE: - LOG_GENERAL (N_("Writer FAKE-writes %1 to MXF"), qi.frame); - _picture_mxf_writer->fake_write (qi.size); + LOG_GENERAL (N_("Writer FAKE-writes %1"), qi.frame); + _picture_asset_writer->fake_write (qi.size); _last_written[qi.eyes].reset (); ++_fake_written; break; @@ -441,17 +446,17 @@ Writer::finish () terminate_thread (true); - _picture_mxf_writer->finalize (); - if (_sound_mxf_writer) { - _sound_mxf_writer->finalize (); + _picture_asset_writer->finalize (); + if (_sound_asset_writer) { + _sound_asset_writer->finalize (); } - /* Hard-link the video MXF into the DCP */ - boost::filesystem::path video_from = _picture_mxf->file (); + /* Hard-link the video asset into the DCP */ + boost::filesystem::path video_from = _picture_asset->file (); boost::filesystem::path video_to; video_to /= _film->dir (_film->dcp_name()); - video_to /= video_mxf_filename (_picture_mxf); + video_to /= video_asset_filename (_picture_asset); boost::system::error_code ec; boost::filesystem::create_hard_link (video_from, video_to, ec); @@ -464,23 +469,23 @@ Writer::finish () } } - _picture_mxf->set_file (video_to); + _picture_asset->set_file (video_to); - /* Move the audio MXF into the DCP */ + /* Move the audio asset into the DCP */ - if (_sound_mxf) { + if (_sound_asset) { boost::filesystem::path audio_to; audio_to /= _film->dir (_film->dcp_name ()); - audio_to /= audio_mxf_filename (_sound_mxf); + audio_to /= audio_asset_filename (_sound_asset); - boost::filesystem::rename (_film->file (audio_mxf_filename (_sound_mxf)), audio_to, ec); + boost::filesystem::rename (_film->file (audio_asset_filename (_sound_asset)), audio_to, ec); if (ec) { throw FileError ( - String::compose (_("could not move audio MXF into the DCP (%1)"), ec.value ()), audio_mxf_filename (_sound_mxf) + String::compose (_("could not move audio asset into the DCP (%1)"), ec.value ()), audio_asset_filename (_sound_asset) ); } - _sound_mxf->set_file (audio_to); + _sound_asset->set_file (audio_to); } dcp::DCP dcp (_film->dir (_film->dcp_name())); @@ -496,32 +501,32 @@ Writer::finish () shared_ptr reel (new dcp::Reel ()); - shared_ptr mono = dynamic_pointer_cast (_picture_mxf); + shared_ptr mono = dynamic_pointer_cast (_picture_asset); if (mono) { reel->add (shared_ptr (new dcp::ReelMonoPictureAsset (mono, 0))); dcp.add (mono); } - shared_ptr stereo = dynamic_pointer_cast (_picture_mxf); + shared_ptr stereo = dynamic_pointer_cast (_picture_asset); if (stereo) { reel->add (shared_ptr (new dcp::ReelStereoPictureAsset (stereo, 0))); dcp.add (stereo); } - if (_sound_mxf) { - reel->add (shared_ptr (new dcp::ReelSoundAsset (_sound_mxf, 0))); - dcp.add (_sound_mxf); + if (_sound_asset) { + reel->add (shared_ptr (new dcp::ReelSoundAsset (_sound_asset, 0))); + dcp.add (_sound_asset); } - if (_subtitle_content) { + 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 */ BOOST_FOREACH (shared_ptr i, _fonts) { boost::filesystem::path const from = i->file.get_value_or (liberation); - _subtitle_content->add_font (i->id, from.leaf().string ()); + _subtitle_asset->add_font (i->id, from.leaf().string ()); - boost::filesystem::path to = _film->dir (_film->dcp_name ()) / _subtitle_content->id (); + 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); @@ -538,17 +543,20 @@ Writer::finish () dcp.add (shared_ptr (new dcp::Font (to))); } - _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _subtitle_content->id () / subtitle_content_filename (_subtitle_content)); + _subtitle_asset->write ( + _film->dir (_film->dcp_name ()) / _subtitle_asset->id () / subtitle_content_filename (_subtitle_asset) + ); + reel->add (shared_ptr ( new dcp::ReelSubtitleAsset ( - _subtitle_content, + _subtitle_asset, dcp::Fraction (_film->video_frame_rate(), 1), - _picture_mxf->intrinsic_duration (), + _picture_asset->intrinsic_duration (), 0 ) )); - dcp.add (_subtitle_content); + dcp.add (_subtitle_asset); } cpl->add (reel); @@ -557,11 +565,11 @@ Writer::finish () DCPOMATIC_ASSERT (job); job->sub (_("Computing image digest")); - _picture_mxf->hash (boost::bind (&Job::set_progress, job.get(), _1, false)); + _picture_asset->hash (boost::bind (&Job::set_progress, job.get(), _1, false)); - if (_sound_mxf) { + if (_sound_asset) { job->sub (_("Computing audio digest")); - _sound_mxf->hash (boost::bind (&Job::set_progress, job.get(), _1, false)); + _sound_asset->hash (boost::bind (&Job::set_progress, job.get(), _1, false)); } dcp::XMLMetadata meta; @@ -586,7 +594,7 @@ Writer::finish () } bool -Writer::check_existing_picture_mxf_frame (FILE* mxf, int f, Eyes eyes) +Writer::check_existing_picture_asset_frame (FILE* asset, int f, Eyes eyes) { /* Read the frame info as written */ FILE* file = fopen_boost (_film->info_file (), "rb"); @@ -602,10 +610,10 @@ Writer::check_existing_picture_mxf_frame (FILE* mxf, int f, Eyes eyes) return false; } - /* Read the data from the MXF and hash it */ - dcpomatic_fseek (mxf, info.offset, SEEK_SET); + /* Read the data from the asset and hash it */ + dcpomatic_fseek (asset, info.offset, SEEK_SET); EncodedData data (info.size); - size_t const read = fread (data.data(), 1, data.size(), mxf); + size_t const read = fread (data.data(), 1, data.size(), asset); if (read != static_cast (data.size ())) { LOG_GENERAL ("Existing frame %1 is incomplete", f); return false; @@ -622,12 +630,12 @@ Writer::check_existing_picture_mxf_frame (FILE* mxf, int f, Eyes eyes) } void -Writer::check_existing_picture_mxf () +Writer::check_existing_picture_asset () { - /* Try to open the existing MXF */ - FILE* mxf = fopen_boost (_picture_mxf->file(), "rb"); - if (!mxf) { - LOG_GENERAL ("Could not open existing MXF at %1 (errno=%2)", _picture_mxf->file().string(), errno); + /* Try to open the existing asset */ + FILE* asset = fopen_boost (_picture_asset->file(), "rb"); + if (!asset) { + LOG_GENERAL ("Could not open existing asset at %1 (errno=%2)", _picture_asset->file().string(), errno); return; } @@ -639,14 +647,14 @@ Writer::check_existing_picture_mxf () job->set_progress_unknown (); if (_film->three_d ()) { - if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_LEFT)) { + if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_LEFT)) { break; } - if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_RIGHT)) { + if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_RIGHT)) { break; } } else { - if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_BOTH)) { + if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_BOTH)) { break; } } @@ -655,7 +663,7 @@ Writer::check_existing_picture_mxf () ++_first_nonexistant_frame; } - fclose (mxf); + fclose (asset); } /** @param frame Frame index. @@ -665,7 +673,7 @@ bool Writer::can_fake_write (int frame) const { /* We have to do a proper write of the first frame so that we can set up the JPEG2000 - parameters in the MXF writer. + parameters in the asset writer. */ return (frame != 0 && frame < _first_nonexistant_frame); } @@ -677,16 +685,16 @@ Writer::write (PlayerSubtitles subs) return; } - if (!_subtitle_content) { + if (!_subtitle_asset) { string lang = _film->subtitle_language (); if (lang.empty ()) { lang = "Unknown"; } - _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), lang)); + _subtitle_asset.reset (new dcp::InteropSubtitleAsset (_film->name(), lang)); } for (list::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) { - _subtitle_content->add (*i); + _subtitle_asset->add (*i); } } diff --git a/src/lib/writer.h b/src/lib/writer.h index e63591a8a..fe803d35e 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,15 +37,15 @@ class Job; class Font; namespace dcp { - class MonoPictureMXF; - class MonoPictureMXFWriter; - class StereoPictureMXF; - class StereoPictureMXFWriter; - class PictureMXF; - class PictureMXFWriter; - class SoundMXF; - class SoundMXFWriter; - class InteropSubtitleContent; + class MonoPictureAsset; + class MonoPictureAssetWriter; + class StereoPictureAsset; + class StereoPictureAssetWriter; + class PictureAsset; + class PictureAssetWriter; + class SoundAsset; + class SoundAssetWriter; + class InteropSubtitleAsset; } struct QueueItem @@ -74,11 +74,11 @@ bool operator< (QueueItem const & a, QueueItem const & b); bool operator== (QueueItem const & a, QueueItem const & b); /** @class Writer - * @brief Class to manage writing JPEG2000 and audio data to MXFs on disk. + * @brief Class to manage writing JPEG2000 and audio data to assets on disk. * - * This class creates sound and picture MXFs, then takes EncodedData + * This class creates sound and picture assets, then takes EncodedData * or AudioBuffers objects (containing image or sound data respectively) - * and writes them to the MXFs. + * and writes them to the assets. * * ::write() for EncodedData can be called out of order, and the Writer * will sort it out. write() for AudioBuffers must be called in order. @@ -106,8 +106,8 @@ private: void thread (); void terminate_thread (bool); - void check_existing_picture_mxf (); - bool check_existing_picture_mxf_frame (FILE *, int, Eyes); + void check_existing_picture_asset (); + bool check_existing_picture_asset_frame (FILE *, int, Eyes); bool have_sequenced_image_at_queue_head (); /** our Film */ @@ -149,11 +149,11 @@ private: */ int _pushed_to_disk; - boost::shared_ptr _picture_mxf; - boost::shared_ptr _picture_mxf_writer; - boost::shared_ptr _sound_mxf; - boost::shared_ptr _sound_mxf_writer; - boost::shared_ptr _subtitle_content; + boost::shared_ptr _picture_asset; + boost::shared_ptr _picture_asset_writer; + boost::shared_ptr _sound_asset; + boost::shared_ptr _sound_asset_writer; + boost::shared_ptr _subtitle_asset; std::list > _fonts; }; diff --git a/test/audio_delay_test.cc b/test/audio_delay_test.cc index 63f363114..05384873f 100644 --- a/test/audio_delay_test.cc +++ b/test/audio_delay_test.cc @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include "lib/sndfile_content.h" #include "lib/dcp_content_type.h" @@ -75,11 +75,11 @@ void test_audio_delay (int delay_in_ms) /* Delay in frames */ int const delay_in_frames = delay_in_ms * 48000 / 1000; - while (n < sound_asset->mxf()->intrinsic_duration()) { - shared_ptr sound_frame = sound_asset->mxf()->get_frame (frame++); + while (n < sound_asset->asset()->intrinsic_duration()) { + shared_ptr sound_frame = sound_asset->asset()->get_frame (frame++); uint8_t const * d = sound_frame->data (); - for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->mxf()->channels())) { + for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) { /* Mono input so it will appear on centre */ int const sample = d[i + 7] | (d[i + 8] << 8); diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index 1e2bbb377..2c34c437d 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,51 +66,51 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) shared_ptr sound_asset = check.cpls().front()->reels().front()->main_sound (); BOOST_CHECK (sound_asset); - BOOST_CHECK_EQUAL (sound_asset->mxf()->channels (), 6); + BOOST_CHECK_EQUAL (sound_asset->asset()->channels (), 6); /* Sample index in the DCP */ int n = 0; /* DCP sound asset frame */ int frame = 0; - while (n < sound_asset->mxf()->intrinsic_duration()) { - shared_ptr sound_frame = sound_asset->mxf()->get_frame (frame++); + while (n < sound_asset->asset()->intrinsic_duration()) { + shared_ptr sound_frame = sound_asset->asset()->get_frame (frame++); uint8_t const * d = sound_frame->data (); - for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->mxf()->channels())) { + for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) { - if (sound_asset->mxf()->channels() > 0) { + if (sound_asset->asset()->channels() > 0) { /* L should be silent */ int const sample = d[i + 0] | (d[i + 1] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 1) { + if (sound_asset->asset()->channels() > 1) { /* R should be silent */ int const sample = d[i + 2] | (d[i + 3] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 2) { + if (sound_asset->asset()->channels() > 2) { /* Mono input so it will appear on centre */ int const sample = d[i + 7] | (d[i + 8] << 8); BOOST_CHECK_EQUAL (sample, n); } - if (sound_asset->mxf()->channels() > 3) { + if (sound_asset->asset()->channels() > 3) { /* Lfe should be silent */ int const sample = d[i + 9] | (d[i + 10] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 4) { + if (sound_asset->asset()->channels() > 4) { /* Ls should be silent */ int const sample = d[i + 11] | (d[i + 12] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 5) { + if (sound_asset->asset()->channels() > 5) { /* Rs should be silent */ int const sample = d[i + 13] | (d[i + 14] << 8); BOOST_CHECK_EQUAL (sample, 0); diff --git a/test/recover_test.cc b/test/recover_test.cc index d76c2f716..317b45520 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ */ #include -#include +#include #include "lib/film.h" #include "lib/dcp_content_type.h" #include "lib/image_content.h" @@ -69,10 +69,9 @@ BOOST_AUTO_TEST_CASE (recover_test) film->make_dcp (); wait_for_jobs (); - shared_ptr A (new dcp::StereoPictureMXF ("build/test/recover_test/original.mxf")); - shared_ptr B (new dcp::StereoPictureMXF (video)); + shared_ptr A (new dcp::StereoPictureAsset ("build/test/recover_test/original.mxf")); + shared_ptr B (new dcp::StereoPictureAsset (video)); dcp::EqualityOptions eq; - eq.mxf_filenames_can_differ = true; BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2))); } diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc index d876a0228..9a797aab5 100644 --- a/test/silence_padding_test.cc +++ b/test/silence_padding_test.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,51 +63,51 @@ test_silence_padding (int channels) shared_ptr sound_asset = check.cpls().front()->reels().front()->main_sound (); BOOST_CHECK (sound_asset); - BOOST_CHECK_EQUAL (sound_asset->mxf()->channels (), channels); + BOOST_CHECK_EQUAL (sound_asset->asset()->channels (), channels); /* Sample index in the DCP */ int n = 0; /* DCP sound asset frame */ int frame = 0; - while (n < sound_asset->mxf()->intrinsic_duration()) { - shared_ptr sound_frame = sound_asset->mxf()->get_frame (frame++); + while (n < sound_asset->asset()->intrinsic_duration()) { + shared_ptr sound_frame = sound_asset->asset()->get_frame (frame++); uint8_t const * d = sound_frame->data (); - for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->mxf()->channels())) { + for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) { - if (sound_asset->mxf()->channels() > 0) { + if (sound_asset->asset()->channels() > 0) { /* L should be silent */ int const sample = d[i + 0] | (d[i + 1] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 1) { + if (sound_asset->asset()->channels() > 1) { /* R should be silent */ int const sample = d[i + 2] | (d[i + 3] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 2) { + if (sound_asset->asset()->channels() > 2) { /* Mono input so it will appear on centre */ int const sample = d[i + 7] | (d[i + 8] << 8); BOOST_CHECK_EQUAL (sample, n); } - if (sound_asset->mxf()->channels() > 3) { + if (sound_asset->asset()->channels() > 3) { /* Lfe should be silent */ int const sample = d[i + 9] | (d[i + 10] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 4) { + if (sound_asset->asset()->channels() > 4) { /* Ls should be silent */ int const sample = d[i + 11] | (d[i + 12] << 8); BOOST_CHECK_EQUAL (sample, 0); } - if (sound_asset->mxf()->channels() > 5) { + if (sound_asset->asset()->channels() > 5) { /* Rs should be silent */ int const sample = d[i + 13] | (d[i + 14] << 8); BOOST_CHECK_EQUAL (sample, 0); diff --git a/test/test.cc b/test/test.cc index b7ae1dec9..5dd591ddc 100644 --- a/test/test.cc +++ b/test/test.cc @@ -210,7 +210,6 @@ check_dcp (boost::filesystem::path ref, boost::filesystem::path check) options.max_std_dev_pixel_error = 5; options.max_audio_sample_error = 255; options.cpl_annotation_texts_can_differ = true; - options.mxf_filenames_can_differ = true; options.reel_annotation_texts_can_differ = true; options.reel_hashes_can_differ = true;