while (j != decoder->text.end()) {
(*j)->BitmapStart.connect (
- bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
);
(*j)->PlainStart.connect (
- bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
);
(*j)->Stop.connect (
- bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
);
++j;
}
+optional<DCPTime>
+Player::content_time_to_dcp (shared_ptr<Content> content, ContentTime t)
+{
+ boost::mutex::scoped_lock lm (_mutex);
+
+ for (auto i: _pieces) {
+ auto dcp = i->content_time_to_dcp(content, t);
+ if (dcp) {
+ return *dcp;
+ }
+ }
+
+ /* We couldn't find this content; perhaps things are being changed over */
+ return {};
+}
+
+
void
Player::playlist_content_change (ChangeType type, int property, bool frequent)
{
void
-Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, ContentBitmapText subtitle)
+Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentBitmapText subtitle)
{
auto piece = wp.lock ();
- auto text = wc.lock ();
- if (!piece || !text) {
+ auto content = wc.lock ();
+ auto text = wt.lock ();
+ if (!piece || !content || !text) {
return;
}
dcp::Size scaled_size (width, height);
ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), true, _fast), subtitle.sub.rectangle));
- DCPTime from (piece->content_time_to_dcp(subtitle.from()));
+ auto from = piece->content_time_to_dcp(content, subtitle.from());
+ DCPOMATIC_ASSERT (from);
- _active_texts[static_cast<int>(text->type())].add_from (wc, ps, from);
+ _active_texts[static_cast<int>(text->type())].add_from (wt, ps, *from);
}
void
-Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, ContentStringText subtitle)
+Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentStringText subtitle)
{
auto piece = wp.lock ();
- auto text = wc.lock ();
- if (!piece || !text) {
+ auto content = wc.lock ();
+ auto text = wt.lock ();
+ if (!piece || !content || !text) {
return;
}
PlayerText ps;
- DCPTime const from (piece->content_time_to_dcp(subtitle.from()));
+ auto const from = piece->content_time_to_dcp(content, subtitle.from());
+ DCPOMATIC_ASSERT (from);
if (from > piece->end(_film)) {
return;
s.set_aspect_adjust (xs / ys);
}
- s.set_in (dcp::Time(from.seconds(), 1000));
+ s.set_in (dcp::Time(from->seconds(), 1000));
ps.string.push_back (StringText (s, text->outline_width()));
ps.add_fonts (text->fonts ());
}
- _active_texts[static_cast<int>(text->type())].add_from (wc, ps, from);
+ _active_texts[static_cast<int>(text->type())].add_from (wt, ps, *from);
}
void
-Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, ContentTime to)
+Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentTime to)
{
- auto text = wc.lock ();
+ auto content = wc.lock ();
+ auto text = wt.lock ();
if (!text) {
return;
}
- if (!_active_texts[static_cast<int>(text->type())].have(wc)) {
+ if (!_active_texts[static_cast<int>(text->type())].have(wt)) {
return;
}
return;
}
- auto const dcp_to = piece->content_time_to_dcp(to);
+ auto const dcp_to = piece->content_time_to_dcp(content, to);
+ DCPOMATIC_ASSERT (dcp_to);
- if (dcp_to > piece->end(_film)) {
+ if (*dcp_to > piece->end(_film)) {
return;
}
- auto from = _active_texts[static_cast<int>(text->type())].add_to (wc, dcp_to);
+ auto from = _active_texts[static_cast<int>(text->type())].add_to(wt, *dcp_to);
bool const always = (text->type() == TextType::OPEN_SUBTITLE && _always_burn_open_subtitles);
if (text->use() && !always && !text->burn()) {
- Text (from.first, text->type(), text->dcp_track().get_value_or(DCPTextTrack()), DCPTimePeriod (from.second, dcp_to));
+ Text (from.first, text->type(), text->dcp_track().get_value_or(DCPTextTrack()), DCPTimePeriod (from.second, *dcp_to));
}
}
}
-optional<DCPTime>
-Player::content_time_to_dcp (shared_ptr<Content> content, ContentTime t)
-{
- boost::mutex::scoped_lock lm (_mutex);
-
- for (auto i: _pieces) {
- if (i->content == content) {
- return i->content_time_to_dcp(t);
- }
- }
-
- /* We couldn't find this content; perhaps things are being changed over */
- return {};
-}
-
-
shared_ptr<const Playlist>
Player::playlist () const
{
void video (std::weak_ptr<Piece>, ContentVideo);
void audio (std::weak_ptr<Piece>, AudioStreamPtr, ContentAudio);
- void bitmap_text_start (std::weak_ptr<Piece>, std::weak_ptr<const TextContent>, ContentBitmapText);
- void plain_text_start (std::weak_ptr<Piece>, std::weak_ptr<const TextContent>, ContentStringText);
- void subtitle_stop (std::weak_ptr<Piece>, std::weak_ptr<const TextContent>, dcpomatic::ContentTime);
+ void bitmap_text_start (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, ContentBitmapText);
+ void plain_text_start (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, ContentStringText);
+ void subtitle_stop (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, dcpomatic::ContentTime);
void atmos (std::weak_ptr<Piece>, ContentAtmos);
dcpomatic::DCPTime one_video_frame () const;
/** > 0 if we are suspended (i.e. pass() and seek() do nothing) */
boost::atomic<int> _suspended;
- std::list<std::shared_ptr<Piece> > _pieces;
+ std::list<std::shared_ptr<Piece>> _pieces;
/** Size of the image we are rendering to; this may be the DCP frame size, or
* the size of preview in a window.