using boost::optional;
using boost::scoped_ptr;
+int const PlayerProperty::VIDEO_CONTAINER_SIZE = 700;
+int const PlayerProperty::PLAYLIST = 701;
+int const PlayerProperty::FILM_CONTAINER = 702;
+int const PlayerProperty::FILM_VIDEO_FRAME_RATE = 703;
+int const PlayerProperty::DCP_DECODE_REDUCTION = 704;
+
Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist)
: _film (film)
, _playlist (playlist)
}
if (decoder->video && _ignore_video) {
- decoder->video->set_ignore ();
+ decoder->video->set_ignore (true);
}
if (decoder->subtitle && _ignore_subtitle) {
- decoder->subtitle->set_ignore ();
+ decoder->subtitle->set_ignore (true);
}
shared_ptr<DCPDecoder> dcp = dynamic_pointer_cast<DCPDecoder> (decoder);
- if (dcp && _play_referenced) {
+ if (dcp) {
+ dcp->set_decode_referenced (_play_referenced);
if (_play_referenced) {
- dcp->set_decode_referenced ();
+ dcp->set_forced_reduction (_dcp_decode_reduction);
}
- dcp->set_forced_reduction (_dcp_decode_reduction);
}
shared_ptr<Piece> piece (new Piece (i, decoder, frc));
if (decoder->video) {
if (i->video->frame_type() == VIDEO_FRAME_TYPE_3D_LEFT || i->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) {
+ /* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */
decoder->video->Data.connect (bind (&Shuffler::video, _shuffler, weak_ptr<Piece>(piece), _1));
} else {
decoder->video->Data.connect (bind (&Player::video, this, weak_ptr<Piece>(piece), _1));
) {
_have_valid_pieces = false;
- Changed (frequent);
+ Changed (property, frequent);
} else if (
property == SubtitleContentProperty::LINE_SPACING ||
property == VideoContentProperty::FADE_OUT
) {
- Changed (frequent);
+ Changed (property, frequent);
}
}
_black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_container_size, true));
_black_image->make_black ();
- Changed (false);
+ Changed (PlayerProperty::VIDEO_CONTAINER_SIZE, false);
}
void
Player::playlist_changed ()
{
_have_valid_pieces = false;
- Changed (false);
+ Changed (PlayerProperty::PLAYLIST, false);
}
void
*/
if (p == Film::CONTAINER) {
- Changed (false);
+ Changed (PlayerProperty::FILM_CONTAINER, false);
} else if (p == Film::VIDEO_FRAME_RATE) {
/* Pieces contain a FrameRateChange which contains the DCP frame rate,
so we need new pieces here.
*/
_have_valid_pieces = false;
- Changed (false);
+ Changed (PlayerProperty::FILM_VIDEO_FRAME_RATE, false);
} else if (p == Film::AUDIO_PROCESSOR) {
if (_film->audio_processor ()) {
_audio_processor = _film->audio_processor()->clone (_film->audio_frame_rate ());
}
+ } else if (p == Film::AUDIO_CHANNELS) {
+ _audio_merger.clear ();
}
}
_video_container_size,
eyes,
PART_WHOLE,
- PresetColourConversion::all().front().conversion
+ PresetColourConversion::all().front().conversion,
+ boost::weak_ptr<Content>(),
+ boost::optional<Frame>()
)
);
}
if (done) {
_shuffler->flush ();
+ for (list<pair<shared_ptr<PlayerVideo>, DCPTime> >::const_iterator i = _delay.begin(); i != _delay.end(); ++i) {
+ do_emit_video(i->first, i->second);
+ }
}
+
return done;
}
_video_container_size,
video.eyes,
video.part,
- piece->content->video->colour_conversion ()
+ piece->content->video->colour_conversion(),
+ piece->content,
+ video.frame
)
);
_shuffler->clear ();
}
+ _delay.clear ();
+
if (_audio_processor) {
_audio_processor->flush ();
}
void
Player::emit_video (shared_ptr<PlayerVideo> pv, DCPTime time)
{
- optional<PositionImage> subtitles = subtitles_for_frame (time);
- if (subtitles) {
- pv->set_subtitle (subtitles.get ());
+ /* We need a delay to give a little wiggle room to ensure that relevent subtitles arrive at the
+ player before the video that requires them.
+ */
+ _delay.push_back (make_pair (pv, time));
+
+ if (pv->eyes() == EYES_BOTH || pv->eyes() == EYES_RIGHT) {
+ _last_video_time = time + one_video_frame();
}
+ _last_video_eyes = increment_eyes (pv->eyes());
- Video (pv, time);
+ if (_delay.size() < 3) {
+ return;
+ }
+ pair<shared_ptr<PlayerVideo>, DCPTime> to_do = _delay.front();
+ _delay.pop_front();
+ do_emit_video (to_do.first, to_do.second);
+}
+
+void
+Player::do_emit_video (shared_ptr<PlayerVideo> pv, DCPTime time)
+{
if (pv->eyes() == EYES_BOTH || pv->eyes() == EYES_RIGHT) {
- _last_video_time = time + one_video_frame();
_active_subtitles.clear_before (time);
}
- _last_video_eyes = increment_eyes (pv->eyes());
+
+ optional<PositionImage> subtitles = subtitles_for_frame (time);
+ if (subtitles) {
+ pv->set_subtitle (subtitles.get ());
+ }
+
+ Video (pv, time);
}
void
Player::emit_audio (shared_ptr<AudioBuffers> data, DCPTime time)
{
- /* This audio must follow on from the previous */
- DCPOMATIC_ASSERT (!_last_audio_time || time == *_last_audio_time);
+ /* Log if the assert below is about to fail */
+ if (_last_audio_time && time != *_last_audio_time) {
+ _film->log()->log(String::compose("Out-of-sequence emit %1 vs %2", to_string(time), to_string(*_last_audio_time)), LogEntry::TYPE_WARNING);
+ }
+
+ /* This audio must follow on from the previous, but I'll remove this check for the 2.12.x release */
+ // DCPOMATIC_ASSERT (!_last_audio_time || time == *_last_audio_time);
Audio (data, time);
_last_audio_time = time + DCPTime::from_frames (data->frames(), _film->audio_frame_rate());
}
_dcp_decode_reduction = reduction;
_have_valid_pieces = false;
- Changed (false);
+ Changed (PlayerProperty::DCP_DECODE_REDUCTION, false);
}