summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-12 00:19:53 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-12 00:19:53 +0100
commiteb6efc4dbae63b90a7389f9818676279945cdafa (patch)
tree1d84bd7438558bed98b9e4cfa08275f4b03ad4b8 /src/lib
parent9b7df719c56b956e8a2aed336677550b64780c5a (diff)
Restore digests for content.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.h5
-rw-r--r--src/lib/film.cc9
-rw-r--r--src/lib/playlist.cc44
-rw-r--r--src/lib/playlist.h3
4 files changed, 54 insertions, 7 deletions
diff --git a/src/lib/content.h b/src/lib/content.h
index fc2672c95..c8aa6b0e0 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -51,6 +51,11 @@ public:
return _file;
}
+ std::string digest () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _digest;
+ }
+
boost::signals2::signal<void (boost::weak_ptr<Content>, int)> Changed;
protected:
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 5f1b89d0c..6ab6551da 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -192,15 +192,11 @@ Film::video_state_identifier () const
{
assert (format ());
- return "XXX";
-
-#if 0
-
pair<string, string> f = Filter::ffmpeg_strings (filters());
stringstream s;
s << format()->id()
- << "_" << content_digest()
+ << "_" << _playlist->video_digest()
<< "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
<< "_" << _dcp_frame_rate
<< "_" << f.first << "_" << f.second
@@ -214,7 +210,6 @@ Film::video_state_identifier () const
}
return s.str ();
-#endif
}
/** @return The path to the directory to write video frame info files to */
@@ -245,7 +240,7 @@ Film::audio_analysis_path () const
{
boost::filesystem::path p;
p /= "analysis";
- p /= "XXX";//content_digest();
+ p /= _playlist->audio_digest();
return file (p.string ());
}
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index f346cb6e0..58086d02b 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -18,6 +18,7 @@
*/
#include <boost/shared_ptr.hpp>
+#include <boost/lexical_cast.hpp>
#include "playlist.h"
#include "sndfile_content.h"
#include "sndfile_decoder.h"
@@ -32,9 +33,11 @@ using std::cout;
using std::vector;
using std::min;
using std::max;
+using std::string;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
+using boost::lexical_cast;
Playlist::Playlist ()
: _audio_from (AUDIO_FFMPEG)
@@ -251,3 +254,44 @@ Playlist::default_audio_mapping () const
return m;
}
+
+string
+Playlist::audio_digest () const
+{
+ string t;
+
+ switch (_audio_from) {
+ case AUDIO_FFMPEG:
+ for (list<shared_ptr<const VideoContent> >::const_iterator i = _video.begin(); i != _video.end(); ++i) {
+ shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
+ if (fc) {
+ t += (*i)->digest ();
+ t += lexical_cast<string> (fc->audio_stream()->id);
+ }
+ }
+ break;
+ case AUDIO_SNDFILE:
+ for (list<shared_ptr<const SndfileContent> >::const_iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
+ t += (*i)->digest ();
+ }
+ break;
+ }
+
+ return md5_digest (t.c_str(), t.length());
+}
+
+string
+Playlist::video_digest () const
+{
+ string t;
+
+ for (list<shared_ptr<const VideoContent> >::const_iterator i = _video.begin(); i != _video.end(); ++i) {
+ t += (*i)->digest ();
+ shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
+ if (fc) {
+ t += fc->subtitle_stream()->id;
+ }
+ }
+
+ return md5_digest (t.c_str(), t.length());
+}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 6384dce1c..d1f766d55 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -72,6 +72,9 @@ public:
return _sndfile;
}
+ std::string audio_digest () const;
+ std::string video_digest () const;
+
mutable boost::signals2::signal<void ()> Changed;
mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;