void
AnalyseAudioJob::run ()
{
- shared_ptr<Player> player (new Player (_film, _playlist));
+ shared_ptr<Player> player (new Player(_film, _playlist, _playlist->length(_film)));
player->set_ignore_video ();
player->set_ignore_text ();
player->set_fast ();
using boost::function;
using namespace dcpomatic;
-Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part)
+Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part, DCPTime length)
{
list<DCPTimePeriod> full;
BOOST_FOREACH (shared_ptr<Content> i, playlist->content()) {
}
}
- _periods = subtract (DCPTimePeriod(DCPTime(), playlist->length(film)), coalesce(full));
+ _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
if (!_periods.empty ()) {
_position = _periods.front().from;
{
public:
Empty () {}
- Empty (boost::shared_ptr<const Film> film, boost::shared_ptr<const Playlist> playlist, boost::function<bool (boost::shared_ptr<const Content>)> part);
+ Empty (boost::shared_ptr<const Film> film, boost::shared_ptr<const Playlist> playlist, boost::function<bool (boost::shared_ptr<const Content>)> part, dcpomatic::DCPTime length);
dcpomatic::DCPTime position () const {
return _position;
Encoder::Encoder (shared_ptr<const Film> film, weak_ptr<Job> job)
: _film (film)
, _job (job)
- , _player (new Player (film, film->playlist ()))
+ , _player (new Player(film, film->playlist(), film->length()))
{
}
emit (bind(boost::ref(Progress), _("Examining closed captions")));
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_ignore_video ();
player->set_ignore_audio ();
player->Text.connect (bind(&Hints::text, this, _1, _2, _4));
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)
+Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, DCPTime playback_length)
: _film (film)
, _playlist (playlist)
, _suspended (0)
, _play_referenced (false)
, _audio_merger (_film->audio_frame_rate())
, _shuffler (0)
+ , _playback_length (playback_length)
{
_film_changed_connection = _film->Change.connect (bind (&Player::film_change, this, _1, _2));
/* The butler must hear about this first, so since we are proxying this through to the butler we must
}
}
- _black = Empty (_film, _playlist, bind(&have_video, _1));
- _silent = Empty (_film, _playlist, bind(&have_audio, _1));
+ _black = Empty (_film, _playlist, bind(&have_video, _1), _playback_length);
+ _silent = Empty (_film, _playlist, bind(&have_audio, _1), _playback_length);
_last_video_time = DCPTime ();
_last_video_eyes = EYES_BOTH;
_last_audio_time = DCPTime ();
-
- /* Cached value to save recalculating it on every ::pass */
- _film_length = _film->length ();
}
void
Player::pass ()
{
boost::mutex::scoped_lock lm (_mutex);
- DCPOMATIC_ASSERT (_film_length);
if (_suspended) {
/* We can't pass in this state */
return false;
}
- if (*_film_length == DCPTime()) {
- /* Special case of an empty Film; just give one black frame */
+ if (_playback_length == DCPTime()) {
+ /* Special; just give one black frame */
emit_video (black_player_video_frame(EYES_BOTH), DCPTime());
return true;
}
/* Work out the time before which the audio is definitely all here. This is the earliest last_push_end of one
of our streams, or the position of the _silent.
*/
- DCPTime pull_to = *_film_length;
+ DCPTime pull_to = _playback_length;
for (map<AudioStreamPtr, StreamState>::const_iterator i = _stream_states.begin(); i != _stream_states.end(); ++i) {
if (!i->second.piece->done && i->second.last_push_end < pull_to) {
pull_to = i->second.last_push_end;
class Player : public boost::enable_shared_from_this<Player>, public boost::noncopyable
{
public:
- Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist> playlist);
+ Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime playback_length);
~Player ();
bool pass ();
ActiveText _active_texts[TEXT_COUNT];
boost::shared_ptr<AudioProcessor> _audio_processor;
- /* Cached stuff */
- boost::optional<dcpomatic::DCPTime> _film_length;
+ dcpomatic::DCPTime _playback_length;
boost::signals2::scoped_connection _film_changed_connection;
boost::signals2::scoped_connection _playlist_change_connection;
film.reset (new Film (film_dir));
film->read_metadata ();
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->Video.connect (bind (&process_video, _1));
while (!player->pass ()) {}
} catch (std::exception& e) {
}
try {
- _player.reset (new Player (_film, _film->playlist ()));
+ _player.reset (new Player(_film, _film->playlist(), _film->length()));
_player->set_fast ();
if (_dcp_decode_reduction) {
_player->set_dcp_decode_reduction (_dcp_decode_reduction);
map.set (i, i, 1);
}
- Butler butler (shared_ptr<Player>(new Player(film, film->playlist())), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, false);
+ Butler butler (shared_ptr<Player>(new Player(film, film->playlist(), film->length())), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, false);
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
ov_content.reset (new DCPContent(ov->dir(ov->dcp_name(false))));
test->examine_and_add_content (ov_content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Player> player (new Player(test, test->playlist()));
+ shared_ptr<Player> player (new Player(test, test->playlist(), test->length()));
shared_ptr<DCPDecoder> decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
BOOST_REQUIRE (decoder);
shared_ptr<DCPContent> vf_content (new DCPContent(vf->dir(vf->dcp_name(false))));
test->examine_and_add_content (vf_content);
BOOST_REQUIRE (!wait_for_jobs());
- player.reset (new Player(test, test->playlist()));
+ player.reset (new Player(test, test->playlist(), test->length()));
decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
BOOST_REQUIRE (decoder);
shared_ptr<DCPContent> encrypted_content (new DCPContent(encrypted->dir(encrypted->dcp_name(false))));
test->examine_and_add_content (encrypted_content);
BOOST_REQUIRE (!wait_for_jobs());
- player.reset (new Player(test, test->playlist()));
+ player.reset (new Player(test, test->playlist(), test->length()));
decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
BOOST_REQUIRE (decoder);
shared_ptr<Butler> butler (
new Butler(
- shared_ptr<Player>(new Player(film, film->playlist())),
+ shared_ptr<Player>(new Player(film, film->playlist(), film->length())),
AudioMapping(6, 6),
6,
bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
contentB->video->set_length (1);
contentB->set_position (film, DCPTime::from_frames (7, vfr));
- Empty black (film, film->playlist(), bind(&has_video, _1));
+ Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 2);
list<dcpomatic::DCPTimePeriod>::const_iterator i = black._periods.begin();
BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr));
contentB->video->set_length (1);
contentB->set_position (film, DCPTime::from_frames(7, vfr));
- Empty black (film, film->playlist(), bind(&has_video, _1));
+ Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 1);
BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(3, vfr));
BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));
shared_ptr<Playlist> playlist (new Playlist);
playlist->add (film, contentB);
- Empty black (film, playlist, bind(&has_video, _1));
+ Empty black (film, playlist, bind(&has_video, _1), playlist->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 1);
BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(0, vfr));
BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));
ref_buffer_size = info.samplerate * info.channels;
ref_buffer = new float[ref_buffer_size];
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->Audio.connect (bind (&audio, _1, info.channels));
while (!player->pass ()) {}
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs ());
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
while (!player->pass ()) {}
}
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs ());
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_fast ();
while (!player->pass ()) {}
}
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
film->write_metadata ();
- shared_ptr<Player> player (new Player (film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
BOOST_REQUIRE (content->video_frame_rate());
BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
accumulated.reset (new AudioBuffers (film->audio_channels(), 0));
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->Audio.connect (bind (&accumulate, _1, _2));
while (!player->pass ()) {}
BOOST_REQUIRE (accumulated->frames() >= 48000);
/* Length should be rounded up from B's length to the next video frame */
BOOST_CHECK (film->length() == DCPTime::from_frames(3 * 24 + 1, 24));
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1);
BOOST_CHECK (player->_black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
film->examine_and_add_content (s);
BOOST_REQUIRE (!wait_for_jobs ());
- shared_ptr<Player> player (new Player(film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->Video.connect (bind (&video, _1, _2));
player->Audio.connect (bind (&audio, _1, _2));
video_frames = audio_frames = 0;
BOOST_REQUIRE (!wait_for_jobs ());
dcp->only_text()->set_use (true);
- shared_ptr<Player> player (new Player (film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_fast ();
player->set_always_burn_open_subtitles ();
player->set_play_referenced ();
BOOST_REQUIRE (!wait_for_jobs ());
dcp->only_text()->set_use (true);
- shared_ptr<Player> player (new Player (film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_fast ();
player->set_always_burn_open_subtitles ();
player->set_play_referenced ();
text->only_text()->set_type (TEXT_CLOSED_CAPTION);
text->only_text()->set_use (true);
- shared_ptr<Player> player (new Player(film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_ignore_video ();
player->set_ignore_audio ();
film->examine_and_add_content (boon);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Player> player (new Player(film, film->playlist()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->set_fast ();
shared_ptr<Butler> butler (new Butler(player, AudioMapping(), 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true));
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
/* Position 0, no trim, video/audio content rate = video/audio DCP rate */
content->set_position (film, DCPTime());
Ls = sf_open ("build/test/upmixer_a_test/Ls.wav", SFM_WRITE, &info);
Rs = sf_open ("build/test/upmixer_a_test/Rs.wav", SFM_WRITE, &info);
- shared_ptr<Player> player (new Player (film, film->playlist ()));
+ shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
player->Audio.connect (bind (&write, _1, _2));
while (!player->pass()) {}
BOOST_REQUIRE (!wait_for_jobs());
/* Check that the selected reel assets are right */
- shared_ptr<Player> player (new Player(vf, vf->playlist()));
+ shared_ptr<Player> player (new Player(vf, vf->playlist(), vf->length()));
list<ReferencedReelAsset> a = player->get_reel_assets();
BOOST_REQUIRE_EQUAL (a.size(), 4);
list<ReferencedReelAsset>::const_iterator i = a.begin();