Fiddle with some subtitle methods.
authorCarl Hetherington <cth@carlh.net>
Thu, 14 Apr 2016 02:56:25 +0000 (03:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 May 2016 10:50:29 +0000 (11:50 +0100)
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_subtitle_content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/ffmpeg_subtitle_stream.h

index d47c5227306b0587ac523e932e6f04962a0d3756..7a2d350de6b85e574953c0262d2cf55025b05cdc 100644 (file)
@@ -56,7 +56,6 @@ int const DCPContentProperty::REFERENCE_SUBTITLE = 603;
 
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
-       , _has_subtitles (false)
        , _encrypted (false)
        , _kdm_valid (false)
        , _reference_video (false)
@@ -65,7 +64,6 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
 {
        video.reset (new VideoContent (this, film));
        audio.reset (new AudioContent (this, film));
-       subtitle.reset (new SubtitleContent (this, film));
 
        read_directory (p);
        set_default_colour_conversion ();
@@ -75,16 +73,20 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
        : Content (film, node)
 {
        video.reset (new VideoContent (this, film, node, version));
+
        audio.reset (new AudioContent (this, film, node));
        audio->set_stream (
                AudioStreamPtr (
                        new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version))
                        )
                );
-       subtitle.reset (new SubtitleContent (this, film, node, version));
 
        _name = node->string_child ("Name");
-       _has_subtitles = node->bool_child ("HasSubtitles");
+
+       if (node->bool_child ("HasSubtitles")) {
+               subtitle.reset (new SubtitleContent (this, film, node, version));
+       }
+
        _encrypted = node->bool_child ("Encrypted");
        if (node->optional_node_child ("KDM")) {
                _kdm = dcp::EncryptedKDM (node->string_child ("KDM"));
@@ -134,7 +136,9 @@ DCPContent::examine (shared_ptr<Job> job)
        {
                boost::mutex::scoped_lock lm (_mutex);
                _name = examiner->name ();
-               _has_subtitles = examiner->has_subtitles ();
+               if (examiner->has_subtitles ()) {
+                       subtitle.reset (new SubtitleContent (this, film()));
+               }
                _encrypted = examiner->encrypted ();
                _kdm_valid = examiner->kdm_valid ();
        }
@@ -173,7 +177,7 @@ DCPContent::as_xml (xmlpp::Node* node) const
 
        boost::mutex::scoped_lock lm (_mutex);
        node->add_child("Name")->add_child_text (_name);
-       node->add_child("HasSubtitles")->add_child_text (_has_subtitles ? "1" : "0");
+       node->add_child("HasSubtitles")->add_child_text (subtitle ? "1" : "0");
        node->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0");
        if (_kdm) {
                node->add_child("KDM")->add_child_text (_kdm->as_xml ());
index b2bc90ebd76438fc777ee43224d3b45e962e7b87..269a0373cfa2f55a038c319d2d0b30b625403e59 100644 (file)
@@ -65,15 +65,6 @@ public:
        void set_default_colour_conversion ();
        std::list<DCPTime> reel_split_points () const;
 
-       bool has_text_subtitles () const {
-               boost::mutex::scoped_lock lm (_mutex);
-               return _has_subtitles;
-       }
-
-       bool has_image_subtitles () const {
-               return false;
-       }
-
        void changed (int property);
 
        boost::filesystem::path directory () const;
@@ -126,7 +117,6 @@ private:
        template <class T> bool can_reference (std::string overlapping, std::list<std::string>& why_not) const;
 
        std::string _name;
-       bool _has_subtitles;
        /** true if our DCP is encrypted */
        bool _encrypted;
        boost::optional<dcp::EncryptedKDM> _kdm;
index 2117657965f77aec45fc03972980021ce12aedbf..f454da9075d26f9bf01de098e6806971f8e50cc7 100644 (file)
@@ -26,23 +26,12 @@ public:
        DCPSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
        DCPSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
 
-       /* Content */
        void examine (boost::shared_ptr<Job>);
        std::string summary () const;
        std::string technical_summary () const;
        void as_xml (xmlpp::Node *) const;
        DCPTime full_length () const;
 
-       /* SubtitleContent */
-
-       bool has_text_subtitles () const {
-               return true;
-       }
-
-       bool has_image_subtitles () const {
-               return false;
-       }
-
 private:
        ContentTime _length;
 };
index dfeb2a0ad249ed91d67ecdcbda4e58eabe5331c6..463722778d1fafb867044b9fc2ac05e2cd4c6737 100644 (file)
@@ -355,30 +355,6 @@ FFmpegContent::text_subtitles_during (ContentTimePeriod period, bool starting) c
        return stream->text_subtitles_during (period, starting);
 }
 
-bool
-FFmpegContent::has_image_subtitles () const
-{
-       BOOST_FOREACH (shared_ptr<FFmpegSubtitleStream> i, subtitle_streams()) {
-               if (i->has_image_subtitles()) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-bool
-FFmpegContent::has_text_subtitles () const
-{
-       BOOST_FOREACH (shared_ptr<FFmpegSubtitleStream> i, subtitle_streams()) {
-               if (i->has_text_subtitles()) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
 void
 FFmpegContent::set_default_colour_conversion ()
 {
index de222b0dee4805d2a02e2c954089295aa5fde1b6..b11486bf11ef166da4c29a96989fce2fef5def06 100644 (file)
@@ -63,9 +63,6 @@ public:
 
        void set_default_colour_conversion ();
 
-       bool has_text_subtitles () const;
-       bool has_image_subtitles () const;
-
        void set_filters (std::vector<Filter const *> const &);
 
        void changed (int property);
index 175eeacef036eb26b75b34faf7596d1826a2d195..ce4faa0e42afb7c3b52a0ddfd8cf7fa4c3258932 100644 (file)
@@ -39,13 +39,6 @@ public:
        ContentTime find_subtitle_to (std::string id) const;
        void add_offset (ContentTime offset);
        void set_colour (RGBA from, RGBA to);
-
-       bool has_image_subtitles () const {
-               return !_image_subtitles.empty ();
-       }
-       bool has_text_subtitles () const {
-               return !_text_subtitles.empty ();
-       }
        std::map<RGBA, RGBA> colours () const;
 
 private: