X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=c484ecc9a2de03243ebf2bbd3e091615ee4751a0;hb=f9068dcbfbb09082e29e2a779ef1a7a2f6ee849e;hp=5e0d3b315b01f96d6d7e92f947d1e0e025b2f3f6;hpb=295b80852c986f6e3739822551821fa9231b4715;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 5e0d3b315..c484ecc9a 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -46,6 +46,7 @@ #include "dcp_subtitle_decoder.h" #include "audio_processor.h" #include "playlist.h" +#include "referenced_reel_asset.h" #include #include #include @@ -57,7 +58,7 @@ #include "i18n.h" -#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); +#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); using std::list; using std::cout; @@ -167,6 +168,11 @@ Player::setup_pieces () } } + /* It's questionable whether subtitle content should have a video frame rate; perhaps + it should be assumed that any subtitle content has been prepared at the same rate + as simultaneous video content (like we do with audio). + */ + /* SubRipContent */ shared_ptr rc = dynamic_pointer_cast (i); if (rc) { @@ -736,26 +742,49 @@ Player::set_play_referenced () _have_valid_pieces = false; } -list > +list Player::get_reel_assets () { - list > a; + list a; BOOST_FOREACH (shared_ptr i, _playlist->content ()) { shared_ptr j = dynamic_pointer_cast (i); if (!j) { continue; } - /* XXX: hack hack hack */ DCPDecoder decoder (j, false); - if (j->reference_video ()) { - a.push_back (decoder.reels().front()->main_picture ()); - } - if (j->reference_audio ()) { - a.push_back (decoder.reels().front()->main_sound ()); - } - if (j->reference_subtitle ()) { - a.push_back (decoder.reels().front()->main_subtitle ()); + int64_t offset = 0; + BOOST_FOREACH (shared_ptr k, decoder.reels()) { + DCPTime const from = i->position() + DCPTime::from_frames (offset, _film->video_frame_rate()); + if (j->reference_video ()) { + a.push_back ( + ReferencedReelAsset ( + k->main_picture (), + DCPTimePeriod (from, from + DCPTime::from_frames (k->main_picture()->duration(), _film->video_frame_rate())) + ) + ); + } + + if (j->reference_audio ()) { + a.push_back ( + ReferencedReelAsset ( + k->main_sound (), + DCPTimePeriod (from, from + DCPTime::from_frames (k->main_sound()->duration(), _film->video_frame_rate())) + ) + ); + } + + if (j->reference_subtitle ()) { + a.push_back ( + ReferencedReelAsset ( + k->main_subtitle (), + DCPTimePeriod (from, from + DCPTime::from_frames (k->main_subtitle()->duration(), _film->video_frame_rate())) + ) + ); + } + + /* Assume that main picture duration is the length of the reel */ + offset += k->main_picture()->duration (); } }