summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-12 15:17:45 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-12 15:17:45 +0100
commitc2b6ca1193107581b433d294aa2327a936f77383 (patch)
tree08d26653c408f8af7e070a60f62e6feac1509e58 /src/lib
parent4b971f28170354c415f74fd99cbcc3a328325337 (diff)
Tidy up video state identifer code slightly.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.h1
-rw-r--r--src/lib/ffmpeg_content.cc20
-rw-r--r--src/lib/ffmpeg_content.h2
-rw-r--r--src/lib/film.cc10
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/imagemagick_content.cc7
-rw-r--r--src/lib/imagemagick_content.h2
-rw-r--r--src/lib/playlist.cc13
-rw-r--r--src/lib/playlist.h2
-rw-r--r--src/lib/video_content.cc18
-rw-r--r--src/lib/video_content.h1
11 files changed, 62 insertions, 16 deletions
diff --git a/src/lib/content.h b/src/lib/content.h
index 5dcf27597..a190a393f 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -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;
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index 35f9f71f2..b4c1ecbfa 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -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 ();
+}
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index 5b9f1f579..2d8a043f7 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -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;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 16b34110c..a49e549a7 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -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);
diff --git a/src/lib/film.h b/src/lib/film.h
index 2bf1a0e90..c107541a0 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -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;
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc
index 2fd65ffa0..42e3776f5 100644
--- a/src/lib/imagemagick_content.cc
+++ b/src/lib/imagemagick_content.cc
@@ -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();
+}
diff --git a/src/lib/imagemagick_content.h b/src/lib/imagemagick_content.h
index 04425af08..dab3158e3 100644
--- a/src/lib/imagemagick_content.h
+++ b/src/lib/imagemagick_content.h
@@ -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);
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 995067b66..9e7f7f5f5 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -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 ();
}
}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 2d243fe8f..cf0f09b31 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -73,7 +73,7 @@ public:
return _content;
}
- std::string video_digest () const;
+ std::string video_identifier () const;
int loop () const {
return _loop;
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 3818fa792..c1f4d0089 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -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 ();
+}
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index 372cab3bd..e7bbad9e1 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -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);