X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=b112760ef412a024fa581c9779ca5be4b1c65138;hb=93439dbc6d93dafd88e80d51d6473c8d97aa02c7;hp=8f6a8bb355bdc447504e261c69a3beaa68114f71;hpb=db67e0d5c855127862bb8dd579d41e4a11f84798;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 8f6a8bb35..b112760ef 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,20 +22,22 @@ #include "film.h" #include "ffmpeg_decoder.h" #include "ffmpeg_content.h" -#include "still_image_decoder.h" -#include "still_image_content.h" -#include "moving_image_decoder.h" -#include "moving_image_content.h" +#include "image_decoder.h" +#include "image_content.h" #include "sndfile_decoder.h" #include "sndfile_content.h" #include "subtitle_content.h" #include "playlist.h" #include "job.h" #include "image.h" +#include "image_proxy.h" #include "ratio.h" #include "resampler.h" #include "log.h" #include "scaler.h" +#include "player_video_frame.h" + +#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); using std::list; using std::cout; @@ -48,28 +50,6 @@ using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; -class Piece -{ -public: - Piece (shared_ptr c) - : content (c) - , video_position (c->position ()) - , audio_position (c->position ()) - {} - - Piece (shared_ptr c, shared_ptr d) - : content (c) - , decoder (d) - , video_position (c->position ()) - , audio_position (c->position ()) - {} - - shared_ptr content; - shared_ptr decoder; - Time video_position; - Time audio_position; -}; - Player::Player (shared_ptr f, shared_ptr p) : _film (f) , _playlist (p) @@ -84,7 +64,7 @@ Player::Player (shared_ptr f, shared_ptr p) _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3)); _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1)); - set_video_container_size (fit_ratio_within (_film->container()->ratio (), _film->full_frame ())); + set_video_container_size (_film->frame_size ()); } void @@ -104,7 +84,6 @@ Player::pass () { if (!_have_valid_pieces) { setup_pieces (); - _have_valid_pieces = true; } Time earliest_t = TIME_MAX; @@ -119,7 +98,10 @@ Player::pass () continue; } - if (_video && dynamic_pointer_cast ((*i)->decoder)) { + shared_ptr vd = dynamic_pointer_cast ((*i)->decoder); + shared_ptr ad = dynamic_pointer_cast ((*i)->decoder); + + if (_video && vd) { if ((*i)->video_position < earliest_t) { earliest_t = (*i)->video_position; earliest = *i; @@ -127,7 +109,7 @@ Player::pass () } } - if (_audio && dynamic_pointer_cast ((*i)->decoder)) { + if (_audio && ad && ad->has_audio ()) { if ((*i)->audio_position < earliest_t) { earliest_t = (*i)->audio_position; earliest = *i; @@ -146,7 +128,11 @@ Player::pass () if (earliest_t > _video_position) { emit_black (); } else { - earliest->decoder->pass (); + if (earliest->repeating ()) { + earliest->repeat (this); + } else { + earliest->decoder->pass (); + } } break; @@ -172,30 +158,40 @@ Player::pass () } if (_audio) { - Time audio_done_up_to = TIME_MAX; + boost::optional