Factor out decoder creation to a factory method.
[dcpomatic.git] / src / wx / subtitle_panel.cc
index 52b23f5a20069eab46138bbd436be696f45ef319..31ee2c4777686f9a172c6d676516824510595716 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/dcp_subtitle_decoder.h"
 #include "lib/dcp_content.h"
 #include "lib/subtitle_content.h"
+#include "lib/decoder_factory.h"
 #include <wx/spinctrl.h>
 #include <boost/foreach.hpp>
 
@@ -384,17 +385,8 @@ SubtitlePanel::subtitle_view_clicked ()
        ContentList c = _parent->selected_subtitle ();
        DCPOMATIC_ASSERT (c.size() == 1);
 
-       shared_ptr<Decoder> decoder;
-
-       shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
-       if (sr) {
-               decoder.reset (new TextSubtitleDecoder (sr));
-       }
-
-       shared_ptr<DCPSubtitleContent> dc = dynamic_pointer_cast<DCPSubtitleContent> (c.front ());
-       if (dc) {
-               decoder.reset (new DCPSubtitleDecoder (dc));
-       }
+       list<shared_ptr<ImageDecoder> > image_decoders;
+       shared_ptr<Decoder> decoder = decoder_factory (c.front(), image_decoders, _parent->film()->log(), false);
 
        if (decoder) {
                _subtitle_view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ());