Basics of multiple captions per content so that DCPContent can
[dcpomatic.git] / src / wx / caption_view.cc
index c57f9161e5cce2e4b16a38635403644a3983e9a6..e6e63efffdcf862be274b590ed6b4100ee715612 100644 (file)
@@ -35,7 +35,7 @@ using boost::shared_ptr;
 using boost::bind;
 using boost::dynamic_pointer_cast;
 
-CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<Decoder> decoder, FilmViewer* viewer)
+CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<CaptionContent> caption, shared_ptr<Decoder> decoder, FilmViewer* viewer)
        : wxDialog (parent, wxID_ANY, _("Captions"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
        , _content (content)
        , _film_viewer (viewer)
@@ -85,8 +85,14 @@ CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Co
 
        _subs = 0;
        _frc = film->active_frame_rate_change (content->position());
-       decoder->caption->PlainStart.connect (bind (&CaptionView::data_start, this, _1));
-       decoder->caption->Stop.connect (bind (&CaptionView::data_stop, this, _1));
+
+       /* Find the decoder that is being used for our CaptionContent and attach to it */
+       BOOST_FOREACH (shared_ptr<CaptionDecoder> i, decoder->caption) {
+               if (i->content() == caption) {
+                       i->PlainStart.connect (bind (&CaptionView::data_start, this, _1));
+                       i->Stop.connect (bind (&CaptionView::data_stop, this, _1));
+               }
+       }
        while (!decoder->pass ()) {}
        SetSizerAndFit (sizer);
 }