From 6199e090dc1e32d3753ba7e7d7ea8c5f0d79f046 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Jul 2018 21:47:25 +0100 Subject: Revert "Remove join function; the code is long and I don't think anybody" It turns out Carsten uses it :) This reverts commit bd5e8b83a3a18787241982efdae809d4db21f65d. --- src/lib/content.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/lib/content.cc') diff --git a/src/lib/content.cc b/src/lib/content.cc index 13c5794fe..629672b73 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -104,6 +104,40 @@ Content::Content (shared_ptr film, cxml::ConstNodePtr node) _video_frame_rate = node->optional_number_child ("VideoFrameRate"); } +Content::Content (shared_ptr film, vector > c) + : _film (film) + , _position (c.front()->position ()) + , _trim_start (c.front()->trim_start ()) + , _trim_end (c.back()->trim_end ()) + , _video_frame_rate (c.front()->video_frame_rate()) + , _change_signals_frequent (false) +{ + for (size_t i = 0; i < c.size(); ++i) { + if (i > 0 && c[i]->trim_start() > ContentTime ()) { + throw JoinError (_("Only the first piece of content to be joined can have a start trim.")); + } + + if (i < (c.size() - 1) && c[i]->trim_end () > ContentTime ()) { + throw JoinError (_("Only the last piece of content to be joined can have an end trim.")); + } + + if ( + (_video_frame_rate && !c[i]->_video_frame_rate) || + (!_video_frame_rate && c[i]->_video_frame_rate) + ) { + throw JoinError (_("Content to be joined must have the same video frame rate")); + } + + if (_video_frame_rate && fabs (_video_frame_rate.get() - c[i]->_video_frame_rate.get()) > VIDEO_FRAME_RATE_EPSILON) { + throw JoinError (_("Content to be joined must have the same video frame rate")); + } + + for (size_t j = 0; j < c[i]->number_of_paths(); ++j) { + _paths.push_back (c[i]->path (j)); + } + } +} + void Content::as_xml (xmlpp::Node* node, bool with_paths) const { -- cgit v1.2.3