#include <dcp/reel_sound_asset.h>
#include <dcp/reel_subtitle_asset.h>
#include <dcp/reel_picture_asset.h>
+#include <dcp/reel_closed_caption_asset.h>
#include <boost/foreach.hpp>
#include <stdint.h>
#include <algorithm>
, _playlist (playlist)
, _have_valid_pieces (false)
, _ignore_video (false)
- , _ignore_subtitle (false)
+ , _ignore_caption (false)
, _fast (false)
, _play_referenced (false)
, _audio_merger (_film->audio_frame_rate())
decoder->video->set_ignore (true);
}
- if (decoder->caption && _ignore_subtitle) {
- decoder->caption->set_ignore (true);
+ if (_ignore_caption) {
+ BOOST_FOREACH (shared_ptr<CaptionDecoder> i, decoder->caption) {
+ i->set_ignore (true);
+ }
}
shared_ptr<DCPDecoder> dcp = dynamic_pointer_cast<DCPDecoder> (decoder);
decoder->audio->Data.connect (bind (&Player::audio, this, weak_ptr<Piece> (piece), _1, _2));
}
- if (decoder->caption) {
- decoder->caption->BitmapStart.connect (
- bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), weak_ptr<CaptionContent>(piece->content->caption), _1)
+ list<shared_ptr<CaptionDecoder> >::const_iterator j = decoder->caption.begin();
+
+ while (j != decoder->caption.end()) {
+ (*j)->BitmapStart.connect (
+ bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const CaptionContent>((*j)->content()), _1)
);
- decoder->caption->PlainStart.connect (
- bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<CaptionContent>(piece->content->caption), _1)
+ (*j)->PlainStart.connect (
+ bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const CaptionContent>((*j)->content()), _1)
);
- decoder->caption->Stop.connect (
- bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<CaptionContent>(piece->content->caption), _1, _2)
+ (*j)->Stop.connect (
+ bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const CaptionContent>((*j)->content()), _1, _2)
);
+
+ ++j;
}
}
}
list<shared_ptr<Font> > fonts;
- BOOST_FOREACH (shared_ptr<Piece>& p, _pieces) {
- if (p->content->caption) {
+ BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
+ BOOST_FOREACH (shared_ptr<CaptionContent> j, i->content->caption) {
/* XXX: things may go wrong if there are duplicate font IDs
with different font files.
*/
- list<shared_ptr<Font> > f = p->content->caption->fonts ();
+ list<shared_ptr<Font> > f = j->fonts ();
copy (f.begin(), f.end(), back_inserter (fonts));
}
}
}
void
-Player::set_ignore_subtitle ()
+Player::set_ignore_caption ()
{
- _ignore_subtitle = true;
+ _ignore_caption = true;
}
/** Set a type of caption that this player should always burn into the image,
);
}
- if (j->reference_subtitle ()) {
+ if (j->reference_caption (CAPTION_OPEN)) {
shared_ptr<dcp::ReelAsset> ra = k->main_subtitle ();
DCPOMATIC_ASSERT (ra);
ra->set_entry_point (ra->entry_point() + trim_start);
);
}
+ if (j->reference_caption (CAPTION_CLOSED)) {
+ shared_ptr<dcp::ReelAsset> ra = k->closed_caption ();
+ DCPOMATIC_ASSERT (ra);
+ ra->set_entry_point (ra->entry_point() + trim_start);
+ ra->set_duration (ra->duration() - trim_start - trim_end);
+ a.push_back (
+ ReferencedReelAsset (ra, DCPTimePeriod (from, from + DCPTime::from_frames (ra->duration(), ffr)))
+ );
+ }
+
/* Assume that main picture duration is the length of the reel */
offset += k->main_picture()->duration ();
}
i->done = true;
} else {
- /* Given two choices at the same time, pick the one with a subtitle so we see it before
+ /* Given two choices at the same time, pick the one with captions so we see it before
the video.
*/
- if (!earliest_time || t < *earliest_time || (t == *earliest_time && i->decoder->caption)) {
+ if (!earliest_time || t < *earliest_time || (t == *earliest_time && !i->decoder->caption.empty())) {
earliest_time = t;
earliest_content = i;
}
}
void
-Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<CaptionContent> wc, ContentBitmapCaption subtitle)
+Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const CaptionContent> wc, ContentBitmapCaption subtitle)
{
shared_ptr<Piece> piece = wp.lock ();
- shared_ptr<CaptionContent> caption = wc.lock ();
+ shared_ptr<const CaptionContent> caption = wc.lock ();
if (!piece || !caption) {
return;
}
}
void
-Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<CaptionContent> wc, ContentTextCaption subtitle)
+Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const CaptionContent> wc, ContentTextCaption subtitle)
{
shared_ptr<Piece> piece = wp.lock ();
- shared_ptr<CaptionContent> caption = wc.lock ();
+ shared_ptr<const CaptionContent> caption = wc.lock ();
if (!piece || !caption) {
return;
}
}
void
-Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<CaptionContent> wc, ContentTime to, CaptionType type)
+Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const CaptionContent> wc, ContentTime to, CaptionType type)
{
if (!_active_captions[type].have (wc)) {
return;
}
shared_ptr<Piece> piece = wp.lock ();
- shared_ptr<CaptionContent> caption = wc.lock ();
+ shared_ptr<const CaptionContent> caption = wc.lock ();
if (!piece || !caption) {
return;
}