}
ContentTime
-Player::dcp_to_content_subtitle (shared_ptr<const Piece> piece, DCPTime t) const
+Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const
{
DCPTime s = t - piece->content->position ();
s = min (piece->content->length_after_trim(), s);
}
DCPTime
-Player::content_subtitle_to_dcp (shared_ptr<const Piece> piece, ContentTime t) const
+Player::content_time_to_dcp (shared_ptr<const Piece> piece, ContentTime t) const
{
return max (DCPTime (), DCPTime (t - piece->content->trim_start(), piece->frc) + piece->content->position());
}
DCPTime earliest_position;
BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
DCPTime const t = i->content->position() + DCPTime (i->decoder->position(), i->frc);
- if (t < earliest_position) {
+ if (!earliest || t < earliest_position) {
earliest_position = t;
earliest = i;
}
}
+ if (!earliest) {
+ return true;
+ }
+
+ cout << "Pass " << earliest->content->path(0) << "\n";
earliest->decoder->pass ();
- /* XXX: collect audio and maybe emit some */
+ /* Emit any audio that is ready */
+
+ pair<shared_ptr<AudioBuffers>, DCPTime> audio = _audio_merger.pull (earliest_position);
+ if (audio.first->frames() > 0) {
+ DCPOMATIC_ASSERT (audio.second >= _last_audio_time);
+ DCPTime t = _last_audio_time;
+ while (t < audio.second) {
+ /* Silence up to the time of this new audio */
+ DCPTime block = min (DCPTime::from_seconds (0.5), audio.second - t);
+ shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->audio_channels(), block.frames_round(_film->audio_frame_rate())));
+ silence->make_silent ();
+ Audio (silence, t);
+ t += block;
+ }
+
+ Audio (audio.first, audio.second);
+ _last_audio_time = audio.second;
+ }
+
+ return false;
}
void
/* XXX: get subs to burn in and burn them in */
- /* Fill gaps */
-
DCPTime const time = content_video_to_dcp (piece, video.frame.index());
- for (DCPTime i = _last_video_time; i < time; i += DCPTime::from_frames (1, _film->video_frame_rate())) {
- if (_playlist->video_content_at(i) && _last_video) {
- Video (_last_video->clone (i));
- } else {
- Video (black_player_video_frame (i));
+ /* Fill gaps */
+
+ if (_last_video_time) {
+ for (DCPTime i = _last_video_time.get(); i < time; i += DCPTime::from_frames (1, _film->video_frame_rate())) {
+ if (_playlist->video_content_at(i) && _last_video) {
+ Video (_last_video->clone (i));
+ } else {
+ Video (black_player_video_frame (i));
+ }
}
}
_last_video_time = time;
+ cout << "Video @ " << to_string(_last_video_time.get()) << "\n";
Video (_last_video);
}
void
Player::seek (DCPTime time, bool accurate)
{
- /* XXX: seek decoders */
+ BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
+ if (i->content->position() <= time && time < i->content->end()) {
+ i->decoder->seek (dcp_to_content_time (i, time), accurate);
+ }
+ }
if (accurate) {
_last_video_time = time - DCPTime::from_frames (1, _film->video_frame_rate ());
+ } else {
+ _last_video_time = optional<DCPTime> ();
}
}
DCPTime content_video_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
Frame dcp_to_resampled_audio (boost::shared_ptr<const Piece> piece, DCPTime t) const;
DCPTime resampled_audio_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
- ContentTime dcp_to_content_subtitle (boost::shared_ptr<const Piece> piece, DCPTime t) const;
- DCPTime content_subtitle_to_dcp (boost::shared_ptr<const Piece> piece, ContentTime t) const;
+ ContentTime dcp_to_content_time (boost::shared_ptr<const Piece> piece, DCPTime t) const;
+ DCPTime content_time_to_dcp (boost::shared_ptr<const Piece> piece, ContentTime t) const;
boost::shared_ptr<PlayerVideo> black_player_video_frame (DCPTime) const;
std::list<boost::shared_ptr<Piece> > overlaps (DCPTime from, DCPTime to, boost::function<bool (Content *)> valid);
void video (boost::weak_ptr<Piece>, ContentVideo);
bool _play_referenced;
boost::shared_ptr<PlayerVideo> _last_video;
- DCPTime _last_video_time;
+ boost::optional<DCPTime> _last_video_time;
AudioMerger _audio_merger;
+ DCPTime _last_audio_time;
boost::shared_ptr<AudioProcessor> _audio_processor;
_player->set_ignore_audio ();
_player->set_play_referenced ();
- _film_connection = _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));
+ _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));
- _player_connection = _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
+ _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
+ _player->Video.connect (boost::bind (&FilmViewer::video, this, _1));
calculate_sizes ();
refresh ();