Tidy up video state identifer code slightly.
authorCarl Hetherington <cth@carlh.net>
Fri, 12 Jul 2013 14:17:45 +0000 (15:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 12 Jul 2013 14:17:45 +0000 (15:17 +0100)
src/lib/content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/film.cc
src/lib/film.h
src/lib/imagemagick_content.cc
src/lib/imagemagick_content.h
src/lib/playlist.cc
src/lib/playlist.h
src/lib/video_content.cc
src/lib/video_content.h

index 5dcf275979cbd4ad48b31b676f3216107216e252..a190a393fbe1ad52fadbc9a4bae6b7e0bb618db9 100644 (file)
@@ -62,6 +62,7 @@ public:
                return _file;
        }
 
+       /** @return MD5 digest of the content's file */
        std::string digest () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _digest;
index 35f9f71f2fc98806c4d13089db93c34cb090b2dc..b4c1ecbfacd5abc19c13e2cafecb4e5e66b896a8 100644 (file)
@@ -378,3 +378,23 @@ FFmpegContent::set_audio_mapping (AudioMapping m)
        audio_stream()->mapping = m;
        signal_changed (AudioContentProperty::AUDIO_MAPPING);
 }
+
+string
+FFmpegContent::identifier () const
+{
+       stringstream s;
+
+       s << VideoContent::identifier();
+
+       boost::mutex::scoped_lock lm (_mutex);
+
+       if (_subtitle_stream) {
+               s << "_" << _subtitle_stream->id;
+       }
+
+       for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
+               s << "_" << (*i)->id ();
+       }
+
+       return s.str ();
+}
index 5b9f1f5792b240a604fc78719c09d1ed17698eb8..2d8a043f773323c2b5e20a3d8de3d63d6e5257cb 100644 (file)
@@ -98,6 +98,8 @@ public:
        boost::shared_ptr<Content> clone () const;
        Time length () const;
 
+       std::string identifier () const;
+       
         /* AudioContent */
         int audio_channels () const;
         AudioContent::Frame audio_length () const;
index 16b34110c932b5dbef96b03f7118f0ecda286309..a49e549a7b1837a3b3b1c0dadf895757297c2d5b 100644 (file)
@@ -151,14 +151,14 @@ Film::Film (Film const & o)
 }
 
 string
-Film::video_state_identifier () const
+Film::video_identifier () const
 {
        assert (container ());
        LocaleGuard lg;
 
        stringstream s;
        s << container()->id()
-         << "_" << _playlist->video_digest()
+         << "_" << _playlist->video_identifier()
          << "_" << _dcp_video_frame_rate
          << "_" << scaler()->id()
          << "_" << j2k_bandwidth()
@@ -173,7 +173,7 @@ Film::info_dir () const
 {
        boost::filesystem::path p;
        p /= "info";
-       p /= video_state_identifier ();
+       p /= video_identifier ();
        return dir (p.string());
 }
 
@@ -186,7 +186,7 @@ Film::internal_video_mxf_dir () const
 string
 Film::internal_video_mxf_filename () const
 {
-       return video_state_identifier() + ".mxf";
+       return video_identifier() + ".mxf";
 }
 
 string
@@ -685,7 +685,7 @@ Film::j2c_path (int f, bool t) const
 {
        boost::filesystem::path p;
        p /= "j2c";
-       p /= video_state_identifier ();
+       p /= video_identifier ();
 
        stringstream s;
        s.width (8);
index 2bf1a0e901b6bc15cc150eeffdec81b1815f86ce..c107541a015961abbf4f448f39691f291cf5f3ac 100644 (file)
@@ -237,7 +237,7 @@ public:
 private:
        
        void signal_changed (Property);
-       std::string video_state_identifier () const;
+       std::string video_identifier () const;
        void playlist_changed ();
        void playlist_content_changed (boost::weak_ptr<Content>, int);
        std::string filename_safe_name () const;
index 2fd65ffa0d403d607fd7b2a835d9b71710516746..42e3776f55452ccb8afdf629b36dc06528ae2d17 100644 (file)
@@ -107,3 +107,10 @@ ImageMagickContent::length () const
        return video_length() * frc.factor() * TIME_HZ / film->dcp_video_frame_rate ();
 }
 
+string
+ImageMagickContent::identifier () const
+{
+       stringstream s;
+       s << VideoContent::identifier ();
+       s << "_" << video_length();
+}
index 04425af080111aebb54cb0a81bb6b8a906d63ddc..dab3158e306056909f6c6a23cef2ee0a368f657a 100644 (file)
@@ -43,6 +43,8 @@ public:
        boost::shared_ptr<Content> clone () const;
        Time length () const;
 
+       std::string identifier () const;
+       
        void set_video_length (VideoContent::Frame);
 
        static bool valid_file (boost::filesystem::path);
index 995067b66ee7bf7133f6d0b025c70f381869dd1e..9e7f7f5f50f7770503e47b635c550093558a630b 100644 (file)
@@ -94,19 +94,14 @@ Playlist::content_changed (weak_ptr<Content> c, int p)
 }
 
 string
-Playlist::video_digest () const
+Playlist::video_identifier () const
 {
        string t;
        
        for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
-               if (!dynamic_pointer_cast<const VideoContent> (*i)) {
-                       continue;
-               }
-               
-               t += (*i)->digest ();
-               shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
-               if (fc && fc->subtitle_stream()) {
-                       t += fc->subtitle_stream()->id;
+               shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
+               if (vc) {
+                       t += vc->identifier ();
                }
        }
 
index 2d243fe8f0e84060b0ffa20b93a96d08fbf7af31..cf0f09b31bc0d2d88da6776149941759fcdb49be 100644 (file)
@@ -73,7 +73,7 @@ public:
                return _content;
        }
 
-       std::string video_digest () const;
+       std::string video_identifier () const;
 
        int loop () const {
                return _loop;
index 3818fa7920fb4b86d6cbf990858a192473428a1b..c1f4d0089d8fab807b74d1fae14c8125ac6426f0 100644 (file)
@@ -222,3 +222,21 @@ VideoContent::set_ratio (Ratio const * r)
 
        signal_changed (VideoContentProperty::VIDEO_RATIO);
 }
+
+/** @return string which includes everything about how this content looks */
+string
+VideoContent::identifier () const
+{
+       stringstream s;
+       s << Content::digest()
+         << "_" << crop().left
+         << "_" << crop().right
+         << "_" << crop().top
+         << "_" << crop().bottom;
+
+       if (ratio()) {
+               s << "_" << ratio()->id ();
+       }
+
+       return s.str ();
+}
index 372cab3bd3c48ab5874188800cf7b41e541ebea0..e7bbad9e15c67c5b99a3b9d494819a53c9c48bbd 100644 (file)
@@ -46,6 +46,7 @@ public:
 
        void as_xml (xmlpp::Node *) const;
        virtual std::string information () const;
+       virtual std::string identifier () const;
 
        VideoContent::Frame video_length () const {
                boost::mutex::scoped_lock lm (_mutex);