void
AnalyseAudioJob::run ()
{
- shared_ptr<Player> player (new Player(_film, _playlist, _playlist->length(_film)));
+ shared_ptr<Player> player (new Player(_film, _playlist));
player->set_ignore_video ();
player->set_ignore_text ();
player->set_fast ();
Encoder::Encoder (shared_ptr<const Film> film, weak_ptr<Job> job)
: _film (film)
, _job (job)
- , _player (new Player(film, film->playlist(), film->length()))
+ , _player (new Player(film))
{
}
emit (bind(boost::ref(Progress), _("Examining closed captions")));
- shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+ shared_ptr<Player> player (new Player(film));
player->set_ignore_video ();
player->set_ignore_audio ();
player->Text.connect (bind(&Hints::text, this, _1, _2, _4));
int const PlayerProperty::DCP_DECODE_REDUCTION = 704;
int const PlayerProperty::PLAYBACK_LENGTH = 705;
-Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist_, DCPTime playback_length)
+Player::Player (shared_ptr<const Film> film)
+ : _film (film)
+ , _suspended (0)
+ , _ignore_video (false)
+ , _ignore_audio (false)
+ , _ignore_text (false)
+ , _always_burn_open_subtitles (false)
+ , _fast (false)
+ , _tolerant (film->tolerant())
+ , _play_referenced (false)
+ , _audio_merger (_film->audio_frame_rate())
+ , _shuffler (0)
+{
+ construct ();
+}
+
+Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist_)
: _film (film)
, _playlist (playlist_)
, _suspended (0)
, _play_referenced (false)
, _audio_merger (_film->audio_frame_rate())
, _shuffler (0)
- , _playback_length (playback_length)
+{
+ construct ();
+}
+
+void
+Player::construct ()
{
_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
}
-void
-Player::set_playback_length (DCPTime len)
-{
- Change (CHANGE_TYPE_PENDING, PlayerProperty::PLAYBACK_LENGTH, false);
- _playback_length = len;
- Change (CHANGE_TYPE_DONE, PlayerProperty::PLAYBACK_LENGTH, false);
- setup_pieces ();
-}
-
bool
have_video (shared_ptr<const Content> content)
{
void
Player::setup_pieces_unlocked ()
{
+ _playback_length = _playlist ? _playlist->length(_film) : _film->length();
+
list<shared_ptr<Piece> > old_pieces = _pieces;
_pieces.clear ();
shared_ptr<const Playlist>
Player::playlist () const
{
- return _playlist;
+ return _playlist ? _playlist : _film->playlist();
}
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, dcpomatic::DCPTime playback_length);
+ Player (boost::shared_ptr<const Film>);
+ Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist> playlist);
~Player ();
bool pass ();
return _video_container_size;
}
- void set_playback_length (dcpomatic::DCPTime len);
void set_video_container_size (dcp::Size);
void set_ignore_video ();
void set_ignore_audio ();
friend struct empty_test2;
friend struct check_reuse_old_data_test;
+ void construct ();
void setup_pieces ();
void setup_pieces_unlocked ();
void flush ();
mutable boost::mutex _mutex;
boost::shared_ptr<const Film> _film;
+ /** Playlist, or 0 if we are using the one from the _film */
boost::shared_ptr<const Playlist> _playlist;
/** > 0 if we are suspended (i.e. pass() and seek() do nothing) */
film.reset (new Film (film_dir));
film->read_metadata ();
- shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+ shared_ptr<Player> player (new Player(film));
player->Video.connect (bind (&process_video, _1));
while (!player->pass ()) {}
} catch (std::exception& e) {
}
try {
- _player.reset (new Player(_film, _film->playlist(), _film->length()));
+ _player.reset (new Player(_film));
_player->set_fast ();
if (_dcp_decode_reduction) {
_player->set_dcp_decode_reduction (_dcp_decode_reduction);
FilmViewer::film_length_change ()
{
_video_view->set_length (_film->length());
- _player->set_playback_length (_film->length());
}
/** Re-get the current frame slowly by seeking */
map.set (i, i, 1);
}
- Butler butler (shared_ptr<Player>(new Player(film, film->playlist(), film->length())), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, false);
+ Butler butler (shared_ptr<Player>(new Player(film)), 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(), test->length()));
+ shared_ptr<Player> player (new Player(test));
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(), test->length()));
+ player.reset (new Player(test));
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(), test->length()));
+ player.reset (new Player(test));
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(), film->length())),
+ shared_ptr<Player>(new Player(film)),
AudioMapping(6, 6),
6,
bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
ref_buffer_size = info.samplerate * info.channels;
ref_buffer = new float[ref_buffer_size];
- shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
while (!player->pass ()) {}
}
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs ());
- shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
/* 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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
/* 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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
/* 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(), film->length()));
+ shared_ptr<Player> player (new Player(film));
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(), vf->length()));
+ shared_ptr<Player> player (new Player(vf));
list<ReferencedReelAsset> a = player->get_reel_assets();
BOOST_REQUIRE_EQUAL (a.size(), 4);
list<ReferencedReelAsset>::const_iterator i = a.begin();