Rearrange subtitle font management.
[dcpomatic.git] / src / lib / dcp_decoder.cc
index 85c5d3297d0d6a8acb704f523bf70d01524446e4..636cc8ed2b3f1f8d937d65943083e322e600bf9e 100644 (file)
@@ -44,6 +44,7 @@
 #include <dcp/reel_picture_asset.h>
 #include <dcp/reel_sound_asset.h>
 #include <dcp/reel_subtitle_asset.h>
+#include <dcp/search.h>
 #include <dcp/sound_asset_reader.h>
 #include <dcp/sound_frame.h>
 #include <dcp/stereo_picture_asset.h>
@@ -68,8 +69,8 @@ using namespace dcpomatic;
 
 
 DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent> content, bool fast, bool tolerant, shared_ptr<DCPDecoder> old)
-       : DCP (content, tolerant)
-       , Decoder (film)
+       : Decoder (film)
+       , _dcp_content (content)
 {
        if (content->can_be_played()) {
                if (content->video) {
@@ -101,7 +102,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
                _reels = old->_reels;
        } else {
 
-               auto cpl_list = cpls ();
+               auto cpl_list = dcp::find_and_resolve_cpls(content->directories(), tolerant);
 
                if (cpl_list.empty()) {
                        throw DCPError (_("No CPLs found in DCP."));
@@ -118,7 +119,11 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
                        /* No CPL found; probably an old file that doesn't specify it;
                           just use the first one.
                        */
-                       cpl = cpls().front ();
+                       cpl = cpl_list.front();
+               }
+
+               if (content->kdm()) {
+                       cpl->add (decrypt_kdm_with_helpful_error(content->kdm().get()));
                }
 
                _reels = cpl->reels ();
@@ -283,7 +288,7 @@ DCPDecoder::pass_texts (
                        true
                        );
 
-               list<dcp::SubtitleString> strings;
+               vector<dcp::SubtitleString> strings;
 
                for (auto i: subs) {
                        auto is = dynamic_pointer_cast<const dcp::SubtitleString>(i);
@@ -497,18 +502,3 @@ DCPDecoder::position () const
        return ContentTime::from_frames(_offset, _dcp_content->active_video_frame_rate(film())) + _next;
 }
 
-
-vector<FontData>
-DCPDecoder::fonts () const
-{
-       vector<FontData> data;
-       for (auto i: _reels) {
-               if (i->main_subtitle() && i->main_subtitle()->asset()) {
-                       for (auto const& j: i->main_subtitle()->asset()->font_data()) {
-                               data.push_back (FontData(j.first, j.second));
-                       }
-               }
-       }
-       return data;
-}
-