Prevent erroneous creation of subtitle MXF where there are no subtitles.
[dcpomatic.git] / src / lib / video_content.cc
index f52a75e706c5105067117c66cf6921556afe5a55..a2a4e6c6b3b46c452290975d5eccb2952fbaab89 100644 (file)
 #include "film.h"
 #include "exceptions.h"
 #include "frame_rate_change.h"
+#include "log.h"
 
 #include "i18n.h"
 
+#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
+
 int const VideoContentProperty::VIDEO_SIZE       = 0;
 int const VideoContentProperty::VIDEO_FRAME_RATE  = 1;
 int const VideoContentProperty::VIDEO_FRAME_TYPE  = 2;
@@ -96,7 +99,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, i
                /* DCP-o-matic 1.0 branch */
                _video_length = ContentTime::from_frames (node->number_child<int64_t> ("VideoLength"), _video_frame_rate);
        } else {
-               _video_length = ContentTime (node->number_child<int64_t> ("VideoLength"));
+               _video_length = ContentTime (node->number_child<ContentTime::Type> ("VideoLength"));
        }
        
        _video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));
@@ -188,15 +191,22 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
        /* These examiner calls could call other content methods which take a lock on the mutex */
        dcp::Size const vs = d->video_size ();
        float const vfr = d->video_frame_rate ();
+       ContentTime vl = d->video_length ();
        
        {
                boost::mutex::scoped_lock lm (_mutex);
                _video_size = vs;
                _video_frame_rate = vfr;
+               _video_length = vl;
        }
+
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length.frames (_video_frame_rate));
        
        signal_changed (VideoContentProperty::VIDEO_SIZE);
        signal_changed (VideoContentProperty::VIDEO_FRAME_RATE);
+       signal_changed (ContentProperty::LENGTH);
 }