More noncopyable.
[dcpomatic.git] / src / lib / imagemagick_content.cc
index 59fde40bb7d1059025bdaa91f941485c2204e2c5..ae3e1813790ccf409f7b6ff12467dd5dbc8320f6 100644 (file)
 
 #include <libcxml/cxml.h>
 #include "imagemagick_content.h"
-#include "imagemagick_decoder.h"
+#include "imagemagick_examiner.h"
+#include "config.h"
 #include "compose.hpp"
+#include "film.h"
 
 #include "i18n.h"
 
@@ -28,16 +30,16 @@ using std::string;
 using std::stringstream;
 using boost::shared_ptr;
 
-ImageMagickContent::ImageMagickContent (boost::filesystem::path f)
-       : Content (f)
-       , VideoContent (f)
+ImageMagickContent::ImageMagickContent (shared_ptr<const Film> f, boost::filesystem::path p)
+       : Content (f, p)
+       , VideoContent (f, p)
 {
-       
+
 }
 
-ImageMagickContent::ImageMagickContent (shared_ptr<const cxml::Node> node)
-       : Content (node)
-       , VideoContent (node)
+ImageMagickContent::ImageMagickContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
+       : Content (f, node)
+       , VideoContent (f, node)
 {
        
 }
@@ -65,35 +67,45 @@ ImageMagickContent::as_xml (xmlpp::Node* node) const
 }
 
 void
-ImageMagickContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
+ImageMagickContent::examine (shared_ptr<Job> job)
 {
-       Content::examine (film, job, quick);
-       shared_ptr<ImageMagickDecoder> decoder (new ImageMagickDecoder (film, shared_from_this()));
+       Content::examine (job);
 
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-               /* Initial length */
-               _video_length = 10 * 24;
-       }
-       
-       take_from_video_decoder (decoder);
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
        
-        signal_changed (VideoContentProperty::VIDEO_LENGTH);
-}
+       shared_ptr<ImageMagickExaminer> examiner (new ImageMagickExaminer (film, shared_from_this()));
 
-shared_ptr<Content>
-ImageMagickContent::clone () const
-{
-       return shared_ptr<Content> (new ImageMagickContent (*this));
+       set_video_length (Config::instance()->default_still_length() * 24);
+       take_from_video_examiner (examiner);
 }
 
 void
-ImageMagickContent::set_video_length (ContentVideoFrame len)
+ImageMagickContent::set_video_length (VideoContent::Frame len)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
                _video_length = len;
        }
 
-       signal_changed (VideoContentProperty::VIDEO_LENGTH);
+       signal_changed (ContentProperty::LENGTH);
+}
+
+Time
+ImageMagickContent::length () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       FrameRateConversion frc (24, film->dcp_video_frame_rate ());
+       return video_length() * frc.factor() * TIME_HZ / film->dcp_video_frame_rate ();
+}
+
+string
+ImageMagickContent::identifier () const
+{
+       stringstream s;
+       s << VideoContent::identifier ();
+       s << "_" << video_length();
+       return s.str ();
 }