Quell config-save warning when we're only trying to save history.
[dcpomatic.git] / src / lib / video_content.cc
index 0dba555251465b1b77ed5af9326f3b0246c52a5e..8cb30546371a7c43a19a3afd1529c7941ffbb0c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -154,6 +154,56 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
        }
 }
 
+VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
+       : ContentPart (parent)
+       , _length (0)
+       , _yuv (false)
+{
+       shared_ptr<VideoContent> ref = c[0]->video;
+       DCPOMATIC_ASSERT (ref);
+
+       for (size_t i = 1; i < c.size(); ++i) {
+
+               if (c[i]->video->size() != ref->size()) {
+                       throw JoinError (_("Content to be joined must have the same picture size."));
+               }
+
+               if (c[i]->video->frame_type() != ref->frame_type()) {
+                       throw JoinError (_("Content to be joined must have the same video frame type."));
+               }
+
+               if (c[i]->video->crop() != ref->crop()) {
+                       throw JoinError (_("Content to be joined must have the same crop."));
+               }
+
+               if (c[i]->video->scale() != ref->scale()) {
+                       throw JoinError (_("Content to be joined must have the same scale setting."));
+               }
+
+               if (c[i]->video->colour_conversion() != ref->colour_conversion()) {
+                       throw JoinError (_("Content to be joined must have the same colour conversion."));
+               }
+
+               if (c[i]->video->fade_in() != ref->fade_in() || c[i]->video->fade_out() != ref->fade_out()) {
+                       throw JoinError (_("Content to be joined must have the same fades."));
+               }
+
+               _length += c[i]->video->length ();
+
+               if (c[i]->video->yuv ()) {
+                       _yuv = true;
+               }
+       }
+
+       _size = ref->size ();
+       _frame_type = ref->frame_type ();
+       _crop = ref->crop ();
+       _scale = ref->scale ();
+       _colour_conversion = ref->colour_conversion ();
+       _fade_in = ref->fade_in ();
+       _fade_out = ref->fade_out ();
+}
+
 void
 VideoContent::as_xml (xmlpp::Node* node) const
 {
@@ -184,6 +234,10 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
        optional<double> const ar = d->sample_aspect_ratio ();
        bool const yuv = d->yuv ();
 
+       ChangeSignaller<Content> cc1 (_parent, VideoContentProperty::SIZE);
+       ChangeSignaller<Content> cc2 (_parent, VideoContentProperty::SCALE);
+       ChangeSignaller<Content> cc3 (_parent, ContentProperty::LENGTH);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _size = vs;
@@ -206,10 +260,6 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
        if (d->video_frame_rate()) {
                _parent->set_video_frame_rate (d->video_frame_rate().get());
        }
-
-       _parent->signal_changed (VideoContentProperty::SIZE);
-       _parent->signal_changed (VideoContentProperty::SCALE);
-       _parent->signal_changed (ContentProperty::LENGTH);
 }
 
 /** @return string which includes everything about how this content looks */