*/
Butler::Butler (
weak_ptr<const Film> film,
- shared_ptr<Player> player,
+ Player& player,
AudioMapping audio_mapping,
int audio_channels,
function<AVPixelFormat (AVPixelFormat)> pixel_format,
, _fast (fast)
, _prepare_only_proxy (prepare_only_proxy)
{
- _player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2));
- _player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1, _2, _3));
- _player_text_connection = _player->Text.connect (bind (&Butler::text, this, _1, _2, _3, _4));
+ _player_video_connection = _player.Video.connect(bind(&Butler::video, this, _1, _2));
+ _player_audio_connection = _player.Audio.connect(bind(&Butler::audio, this, _1, _2, _3));
+ _player_text_connection = _player.Text.connect(bind(&Butler::text, this, _1, _2, _3, _4));
/* The butler must hear about things first, otherwise it might not sort out suspensions in time for
get_video() to be called in response to this signal.
*/
- _player_change_connection = _player->Change.connect (bind (&Butler::player_change, this, _1, _2), boost::signals2::at_front);
+ _player_change_connection = _player.Change.connect(bind(&Butler::player_change, this, _1, _2), boost::signals2::at_front);
_thread = boost::thread (bind(&Butler::thread, this));
#ifdef DCPOMATIC_LINUX
pthread_setname_np (_thread.native_handle(), "butler");
/* Do any seek that has been requested */
if (_pending_seek_position) {
_finished = false;
- _player->seek (*_pending_seek_position, _pending_seek_accurate);
+ _player.seek(*_pending_seek_position, _pending_seek_accurate);
_pending_seek_position = optional<DCPTime> ();
}
*/
while (should_run() && !_pending_seek_position) {
lm.unlock ();
- bool const r = _player->pass ();
+ bool const r = _player.pass();
lm.lock ();
if (r) {
_finished = true;
if (type == ChangeType::DONE) {
auto film = _film.lock();
if (film) {
- _video.reset_metadata (film, _player->video_container_size());
+ _video.reset_metadata(film, _player.video_container_size());
}
}
return;
Butler (
std::weak_ptr<const Film> film,
- std::shared_ptr<Player> player,
+ Player& player,
AudioMapping map,
int audio_channels,
std::function<AVPixelFormat (AVPixelFormat)> pixel_format,
void seek_unlocked (dcpomatic::DCPTime position, bool accurate);
std::weak_ptr<const Film> _film;
- std::shared_ptr<Player> _player;
+ Player& _player;
boost::thread _thread;
VideoRingBuffers _video;
, _finishing (false)
, _non_burnt_subtitles (false)
{
- _player_video_connection = _player->Video.connect (bind (&DCPEncoder::video, this, _1, _2));
- _player_audio_connection = _player->Audio.connect (bind (&DCPEncoder::audio, this, _1, _2));
- _player_text_connection = _player->Text.connect (bind (&DCPEncoder::text, this, _1, _2, _3, _4));
- _player_atmos_connection = _player->Atmos.connect (bind (&DCPEncoder::atmos, this, _1, _2, _3));
+ _player_video_connection = _player.Video.connect(bind(&DCPEncoder::video, this, _1, _2));
+ _player_audio_connection = _player.Audio.connect(bind(&DCPEncoder::audio, this, _1, _2));
+ _player_text_connection = _player.Text.connect(bind(&DCPEncoder::text, this, _1, _2, _3, _4));
+ _player_atmos_connection = _player.Atmos.connect(bind(&DCPEncoder::atmos, this, _1, _2, _3));
for (auto c: film->content ()) {
for (auto i: c->text) {
}
if (_non_burnt_subtitles) {
- _writer.write(_player->get_subtitle_fonts());
+ _writer.write(_player.get_subtitle_fonts());
}
- while (!_player->pass ()) {}
+ while (!_player.pass()) {}
for (auto i: get_referenced_reel_assets(_film, _film->playlist())) {
_writer.write(i);
Encoder::Encoder (std::shared_ptr<const Film> film, std::weak_ptr<Job> job)
: _film (film)
, _job (job)
- , _player (new Player(film, Image::Alignment::PADDED))
+ , _player(film, Image::Alignment::PADDED)
{
}
#define DCPOMATIC_ENCODER_H
+#include "player.h"
#include "player_text.h"
#include "types.h"
#include <boost/signals2.hpp>
protected:
std::shared_ptr<const Film> _film;
std::weak_ptr<Job> _job;
- std::shared_ptr<Player> _player;
+ Player _player;
};
Butler::Audio::ENABLED
)
{
- _player->set_always_burn_open_subtitles ();
- _player->set_play_referenced ();
+ _player.set_always_burn_open_subtitles();
+ _player.set_play_referenced();
}
, _reel_index (0)
, _length (film->length())
{
- _player->set_play_referenced ();
- _player->set_ignore_video ();
- _player->set_ignore_audio ();
- _player->Text.connect (boost::bind(&SubtitleEncoder::text, this, _1, _2, _3, _4));
+ _player.set_play_referenced();
+ _player.set_ignore_video();
+ _player.set_ignore_audio();
+ _player.Text.connect(boost::bind(&SubtitleEncoder::text, this, _1, _2, _3, _4));
string const extension = film->interop() ? ".xml" : ".mxf";
_reel_index = 0;
- while (!_player->pass()) {}
+ while (!_player.pass()) {}
int reel = 0;
for (auto& i: _assets) {
}
if (!_film->interop() || _include_font) {
- for (auto j: _player->get_subtitle_fonts()) {
+ for (auto j: _player.get_subtitle_fonts()) {
i.first->add_font(j->id(), j->data().get_value_or(_default_font));
}
}
_closed_captions_dialog->clear ();
if (!_film) {
- _player.reset ();
+ _player = boost::none;
recreate_butler ();
_video_view->update ();
return;
}
try {
- _player = make_shared<Player>(_film, _optimise_for_j2k ? Image::Alignment::COMPACT : Image::Alignment::PADDED);
+ _player.emplace(_film, _optimise_for_j2k ? Image::Alignment::COMPACT : Image::Alignment::PADDED);
_player->set_fast ();
if (_dcp_decode_reduction) {
_player->set_dcp_decode_reduction (_dcp_decode_reduction);
auto const j2k_gl_optimised = false;
#endif
+ DCPOMATIC_ASSERT(_player);
+
_butler = std::make_shared<Butler>(
_film,
- _player,
+ *_player,
Config::instance()->audio_mapping(_audio_channels),
_audio_channels,
boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24),
void
FilmViewer::seek (shared_ptr<Content> content, ContentTime t, bool accurate)
{
+ DCPOMATIC_ASSERT(_player);
auto dt = _player->content_time_to_dcp (content, t);
if (dt) {
seek (*dt, accurate);
optional<ContentTime>
FilmViewer::position_in_content (shared_ptr<const Content> content) const
{
+ DCPOMATIC_ASSERT(_player);
return _player->dcp_to_content_time (content, position());
}
bool quick_refresh ();
std::shared_ptr<Film> _film;
- std::shared_ptr<Player> _player;
+ boost::optional<Player> _player;
std::shared_ptr<VideoView> _video_view;
bool _coalesce_player_changes = false;
map.set (i, i, 1);
}
+ Player player(film, Image::Alignment::COMPACT);
+
Butler butler (
film,
- make_shared<Player>(film, Image::Alignment::COMPACT),
+ player,
map,
6,
boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24),
map.set (i, i, 1);
}
+ Player player(film, Image::Alignment::COMPACT);
+
Butler butler (
film,
- make_shared<Player>(film, Image::Alignment::COMPACT),
+ player,
map,
6,
boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24),
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
+ Player player(film, Image::Alignment::PADDED);
+
auto butler = std::make_shared<Butler>(
film,
- make_shared<Player>(film, Image::Alignment::PADDED),
+ player,
AudioMapping(6, 6),
6,
boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24),
accumulated = std::make_shared<AudioBuffers>(film->audio_channels(), 0);
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->Audio.connect (bind (&accumulate, _1, _2));
- while (!player->pass ()) {}
+ Player player(film, Image::Alignment::COMPACT);
+ player.Audio.connect(bind(&accumulate, _1, _2));
+ while (!player.pass()) {}
BOOST_REQUIRE (accumulated->frames() >= 48000);
BOOST_CHECK_EQUAL (accumulated->channels(), film->audio_channels ());
/* 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));
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->setup_pieces ();
- BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1U);
- BOOST_CHECK (player->_black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
- BOOST_REQUIRE_EQUAL (player->_silent._periods.size(), 1U);
- BOOST_CHECK (player->_silent._periods.front() == DCPTimePeriod(DCPTime(289920), DCPTime::from_frames(3 * 24 + 1, 24)));
+ Player player(film, Image::Alignment::COMPACT);
+ player.setup_pieces();
+ BOOST_REQUIRE_EQUAL(player._black._periods.size(), 1U);
+ BOOST_CHECK(player._black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
+ BOOST_REQUIRE_EQUAL(player._silent._periods.size(), 1U);
+ BOOST_CHECK(player._silent._periods.front() == DCPTimePeriod(DCPTime(289920), DCPTime::from_frames(3 * 24 + 1, 24)));
}
film->examine_and_add_content (s);
BOOST_REQUIRE (!wait_for_jobs ());
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->Video.connect (bind (&video, _1, _2));
- player->Audio.connect (bind (&audio, _1, _2));
+ Player player(film, Image::Alignment::COMPACT);
+ player.Video.connect(bind(&video, _1, _2));
+ player.Audio.connect(bind(&audio, _1, _2));
video_frames = audio_frames = 0;
- while (!player->pass ()) {
+ while (!player.pass()) {
BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) <= 8);
}
}
BOOST_REQUIRE (!wait_for_jobs ());
dcp->only_text()->set_use (true);
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->set_fast ();
- player->set_always_burn_open_subtitles ();
- player->set_play_referenced ();
+ Player player(film, Image::Alignment::COMPACT);
+ player.set_fast();
+ player.set_always_burn_open_subtitles();
+ player.set_play_referenced();
auto butler = std::make_shared<Butler>(
film, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false, Butler::Audio::DISABLED
BOOST_REQUIRE (!wait_for_jobs ());
dcp->only_text()->set_use (true);
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->set_fast ();
- player->set_always_burn_open_subtitles ();
- player->set_play_referenced ();
+ Player player(film, Image::Alignment::COMPACT);
+ player.set_fast();
+ player.set_always_burn_open_subtitles();
+ player.set_play_referenced();
auto butler = std::make_shared<Butler>
(film, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false, Butler::Audio::DISABLED
text->only_text()->set_type (TextType::CLOSED_CAPTION);
text->only_text()->set_use (true);
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->set_ignore_video ();
- player->set_ignore_audio ();
+ Player player(film, Image::Alignment::COMPACT);
+ player.set_ignore_video();
+ player.set_ignore_audio();
list<Sub> out;
- player->Text.connect (bind (&store, &out, _1, _2, _3, _4));
- while (!player->pass ()) {}
+ player.Text.connect(bind (&store, &out, _1, _2, _3, _4));
+ while (!player.pass()) {}
BOOST_CHECK_EQUAL (out.size(), 6U);
}
film->examine_and_add_content (boon);
BOOST_REQUIRE (!wait_for_jobs());
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
- player->set_fast ();
+ Player player(film, Image::Alignment::COMPACT);
+ player.set_fast();
auto butler = std::make_shared<Butler>(
film, player, AudioMapping(), 6, bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true, false, Butler::Audio::ENABLED
);
auto content2 = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
auto film2 = new_test_film2 ("encrypted_dcp_with_no_kdm_gives_no_butler_error2", { content2 });
- auto player = std::make_shared<Player>(film2, Image::Alignment::COMPACT);
+ Player player(film, Image::Alignment::COMPACT);
Butler butler(film2, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false, Butler::Audio::ENABLED);
float buffer[2000 * 6];
subs1->set_position(film, DCPTime());
subs2->set_position(film, DCPTime());
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
+ Player player(film, Image::Alignment::COMPACT);
dcp::Time last;
- player->Text.connect([&last](PlayerText text, TextType, optional<DCPTextTrack>, dcpomatic::DCPTimePeriod) {
+ player.Text.connect([&last](PlayerText text, TextType, optional<DCPTextTrack>, dcpomatic::DCPTimePeriod) {
for (auto sub: text.string) {
BOOST_CHECK(sub.in() >= last);
last = sub.in();
}
});
- while (!player->pass()) {}
+ while (!player.pass()) {}
}
film->examine_and_add_content(B);
BOOST_REQUIRE (!wait_for_jobs());
- auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
+ Player player(film, Image::Alignment::COMPACT);
int const audio_channels = 2;
auto butler = std::make_shared<Butler>(
film, player, AudioMapping(), audio_channels, boost::bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false, Butler::Audio::ENABLED