From 4d91615b49a3246654baaf7a08f10f303b79b85a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 Aug 2012 00:54:40 +0100 Subject: Proper-ish support for multi-reel DCPs. --- src/dcp.cc | 158 +++++++++++++++++++++---------------------------------------- 1 file changed, 53 insertions(+), 105 deletions(-) (limited to 'src/dcp.cc') diff --git a/src/dcp.cc b/src/dcp.cc index c0438ebd..3f04d904 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -39,6 +39,7 @@ #include "cpl.h" #include "pkl.h" #include "asset_map.h" +#include "reel.h" using namespace std; using namespace boost; @@ -55,27 +56,9 @@ DCP::DCP (string directory, string name, ContentKind content_kind, int fps, int } void -DCP::add_sound_asset (vector const & files) +DCP::add_reel (shared_ptr reel) { - _assets.push_back (shared_ptr (new SoundAsset (files, _directory, "audio.mxf", &Progress, _fps, _length))); -} - -void -DCP::add_sound_asset (sigc::slot get_path, int channels) -{ - _assets.push_back (shared_ptr (new SoundAsset (get_path, _directory, "audio.mxf", &Progress, _fps, _length, channels))); -} - -void -DCP::add_picture_asset (vector const & files, int width, int height) -{ - _assets.push_back (shared_ptr (new PictureAsset (files, _directory, "video.mxf", &Progress, _fps, _length, width, height))); -} - -void -DCP::add_picture_asset (sigc::slot get_path, int width, int height) -{ - _assets.push_back (shared_ptr (new PictureAsset (get_path, _directory, "video.mxf", &Progress, _fps, _length, width, height))); + _reels.push_back (reel); } void @@ -118,11 +101,7 @@ DCP::write_cpl (string cpl_uuid) const << " \n" << " \n"; - cpl << " \n" - << " urn:uuid:" << make_uuid() << "\n" - << " \n"; - - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { + for (list >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { (*i)->write_to_cpl (cpl); } @@ -153,7 +132,7 @@ DCP::write_pkl (string pkl_uuid, string cpl_uuid, string cpl_digest, int cpl_len << " " << Metadata::instance()->creator << "\n" << " \n"; - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { + for (list >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { (*i)->write_to_pkl (pkl); } @@ -226,7 +205,7 @@ DCP::write_assetmap (string cpl_uuid, int cpl_length, string pkl_uuid, int pkl_l << " \n" << " \n"; - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { + for (list >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { (*i)->write_to_assetmap (am); } @@ -282,47 +261,54 @@ DCP::DCP (string directory) _name = cpl->annotation_text; _content_kind = cpl->content_kind; + _length = 0; + _fps = 0; - shared_ptr cpl_assets = cpl->reels.front()->asset_list; - - /* XXX */ - _fps = cpl_assets->main_picture->frame_rate.numerator; - _length = cpl_assets->main_picture->duration; - - string n = pkl->asset_from_id(cpl_assets->main_picture->id)->original_file_name; - if (n.empty ()) { - n = cpl_assets->main_picture->annotation_text; - } + for (list >::iterator i = cpl->reels.begin(); i != cpl->reels.end(); ++i) { + assert (_fps == 0 || _fps == (*i)->asset_list->main_picture->frame_rate.numerator); + _fps = (*i)->asset_list->main_picture->frame_rate.numerator; + _length += (*i)->asset_list->main_picture->duration; - _assets.push_back (shared_ptr ( - new PictureAsset ( - _directory, - n, - _fps, - _length - ) - )); + string n = pkl->asset_from_id ((*i)->asset_list->main_picture->id)->original_file_name; + if (n.empty ()) { + n = (*i)->asset_list->main_picture->annotation_text; + } + + shared_ptr picture (new PictureAsset ( + _directory, + n, + _fps, + (*i)->asset_list->main_picture->duration + ) + ); + + shared_ptr sound; + + if ((*i)->asset_list->main_sound) { + + n = pkl->asset_from_id ((*i)->asset_list->main_sound->id)->original_file_name; + if (n.empty ()) { + n = (*i)->asset_list->main_sound->annotation_text; + } + + sound.reset (new SoundAsset ( + _directory, + n, + _fps, + (*i)->asset_list->main_sound->duration + ) + ); + } - if (cpl_assets->main_sound) { + assert (files.subtitles.size() < 2); - n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name; - if (n.empty ()) { - n = cpl_assets->main_sound->annotation_text; + shared_ptr subtitle; + if (!files.subtitles.empty ()) { + string const l = files.subtitles.front().substr (_directory.length ()); + subtitle.reset (new SubtitleAsset (_directory, l)); } - - _assets.push_back (shared_ptr ( - new SoundAsset ( - _directory, - n, - _fps, - _length - ) - )); - } - for (list::iterator i = files.subtitles.begin(); i != files.subtitles.end(); ++i) { - string const l = i->substr (_directory.length ()); - _assets.push_back (shared_ptr (new SubtitleAsset (_directory, l))); + _reels.push_back (shared_ptr (new Reel (picture, sound, subtitle))); } } @@ -406,14 +392,14 @@ DCP::equals (DCP const & other, EqualityOptions opt) const } } - if (_assets.size() != other._assets.size()) { - notes.push_back ("asset counts differ"); + if (_reels.size() != other._reels.size()) { + notes.push_back ("reel counts differ"); } - list >::const_iterator a = _assets.begin (); - list >::const_iterator b = other._assets.begin (); + list >::const_iterator a = _reels.begin (); + list >::const_iterator b = other._reels.begin (); - while (a != _assets.end ()) { + while (a != _reels.end ()) { list n = (*a)->equals (*b, opt); notes.merge (n); ++a; @@ -423,41 +409,3 @@ DCP::equals (DCP const & other, EqualityOptions opt) const return notes; } -shared_ptr -DCP::picture_asset () const -{ - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr p = dynamic_pointer_cast (*i); - if (p) { - return p; - } - } - - return shared_ptr (); -} - -shared_ptr -DCP::sound_asset () const -{ - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr s = dynamic_pointer_cast (*i); - if (s) { - return s; - } - } - - return shared_ptr (); -} - -shared_ptr -DCP::subtitle_asset () const -{ - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr s = dynamic_pointer_cast (*i); - if (s) { - return s; - } - } - - return shared_ptr (); -} -- cgit v1.2.3