Put Time types in dcpomatic namespace.
[dcpomatic.git] / src / lib / player.cc
index 6e6cd75d7d774b1ef3f3d1c3388ed507fd2b2bcf..e44edd8dc467e0155dea78b256dc942effeea58f 100644 (file)
@@ -75,6 +75,7 @@ using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using boost::scoped_ptr;
+using namespace dcpomatic;
 
 int const PlayerProperty::VIDEO_CONTAINER_SIZE = 700;
 int const PlayerProperty::PLAYLIST = 701;
@@ -467,11 +468,11 @@ static void
 maybe_add_asset (list<ReferencedReelAsset>& a, shared_ptr<dcp::ReelAsset> r, Frame reel_trim_start, Frame reel_trim_end, DCPTime from, int const ffr)
 {
        DCPOMATIC_ASSERT (r);
-       r->set_entry_point (r->entry_point() + reel_trim_start);
-       r->set_duration (r->duration() - reel_trim_start - reel_trim_end);
-       if (r->duration() > 0) {
+       r->set_entry_point (r->entry_point().get_value_or(0) + reel_trim_start);
+       r->set_duration (r->actual_duration() - reel_trim_start - reel_trim_end);
+       if (r->actual_duration() > 0) {
                a.push_back (
-                       ReferencedReelAsset(r, DCPTimePeriod(from, from + DCPTime::from_frames(r->duration(), ffr)))
+                       ReferencedReelAsset(r, DCPTimePeriod(from, from + DCPTime::from_frames(r->actual_duration(), ffr)))
                        );
        }
 }
@@ -508,13 +509,13 @@ Player::get_reel_assets ()
                int64_t offset_from_end = 0;
                BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder->reels()) {
                        /* Assume that main picture duration is the length of the reel */
-                       offset_from_end += k->main_picture()->duration();
+                       offset_from_end += k->main_picture()->actual_duration();
                }
 
                BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder->reels()) {
 
                        /* Assume that main picture duration is the length of the reel */
-                       int64_t const reel_duration = k->main_picture()->duration();
+                       int64_t const reel_duration = k->main_picture()->actual_duration();
 
                        /* See doc/design/trim_reels.svg */
                        Frame const reel_trim_start = min(reel_duration, max(int64_t(0), trim_start - offset_from_start));
@@ -613,8 +614,18 @@ Player::pass ()
 
        switch (which) {
        case CONTENT:
+       {
                earliest_content->done = earliest_content->decoder->pass ();
+               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent>(earliest_content->content);
+               if (dcp && !_play_referenced && dcp->reference_audio()) {
+                       /* We are skipping some referenced DCP audio content, so we need to update _last_audio_time
+                          to `hide' the fact that no audio was emitted during the referenced DCP (though
+                          we need to behave as though it was).
+                       */
+                       _last_audio_time = dcp->end (_film);
+               }
                break;
+       }
        case BLACK:
                emit_video (black_player_video_frame(EYES_BOTH), _black.position());
                _black.set_position (_black.position() + one_video_frame());