Add trim type property to Content; by content or by playlist.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Aug 2020 07:59:25 +0000 (09:59 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Aug 2020 07:59:25 +0000 (09:59 +0200)
src/lib/content.cc
src/lib/content.h

index 4242477d483a06fbfb877d90e8fa74c4f0f5db3c..3ac2bc05183b1228809323c2ffb03319df24b92f 100644 (file)
@@ -59,12 +59,14 @@ int const ContentProperty::POSITION = 401;
 int const ContentProperty::LENGTH = 402;
 int const ContentProperty::TRIM_START = 403;
 int const ContentProperty::TRIM_END = 404;
-int const ContentProperty::VIDEO_FRAME_RATE = 405;
+int const ContentProperty::TRIM_BEHAVIOUR = 405;
+int const ContentProperty::VIDEO_FRAME_RATE = 406;
 
 Content::Content ()
        : _position (0)
        , _trim_start (0)
        , _trim_end (0)
+       , _trim_behaviour (TRIM_CONTENT)
        , _change_signals_frequent (false)
 {
 
@@ -74,6 +76,7 @@ Content::Content (DCPTime p)
        : _position (p)
        , _trim_start (0)
        , _trim_end (0)
+       , _trim_behaviour (TRIM_CONTENT)
        , _change_signals_frequent (false)
 {
 
@@ -83,6 +86,7 @@ Content::Content (boost::filesystem::path p)
        : _position (0)
        , _trim_start (0)
        , _trim_end (0)
+       , _trim_behaviour (TRIM_CONTENT)
        , _change_signals_frequent (false)
 {
        add_path (p);
@@ -107,6 +111,7 @@ Content::Content (cxml::ConstNodePtr node)
        _position = DCPTime (node->number_child<DCPTime::Type> ("Position"));
        _trim_start = ContentTime (node->number_child<ContentTime::Type> ("TrimStart"));
        _trim_end = ContentTime (node->number_child<ContentTime::Type> ("TrimEnd"));
+       _trim_behaviour = node->optional_string_child("TrimBehaviour").get_value_or("content") == "content" ? TRIM_CONTENT : TRIM_PLAYLIST;
        _video_frame_rate = node->optional_number_child<double> ("VideoFrameRate");
 }
 
@@ -126,6 +131,10 @@ Content::Content (vector<shared_ptr<Content> > c)
                        throw JoinError (_("Only the last piece of content to be joined can have an end trim."));
                }
 
+               if (_trim_behaviour != c[i]->_trim_behaviour) {
+                       throw JoinError (_("Content to be joined must ahve the same trim behaviour setting"));
+               }
+
                if (
                        (_video_frame_rate && !c[i]->_video_frame_rate) ||
                        (!_video_frame_rate && c[i]->_video_frame_rate)
@@ -160,6 +169,7 @@ Content::as_xml (xmlpp::Node* node, bool with_paths) const
        node->add_child("Position")->add_child_text (raw_convert<string> (_position.get ()));
        node->add_child("TrimStart")->add_child_text (raw_convert<string> (_trim_start.get ()));
        node->add_child("TrimEnd")->add_child_text (raw_convert<string> (_trim_end.get ()));
+       node->add_child("TrimBehaviour")->add_child_text (_trim_behaviour == TRIM_CONTENT ? N_("content") : N_("playlist"));
        if (_video_frame_rate) {
                node->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate.get()));
        }
@@ -277,6 +287,18 @@ Content::set_trim_end (ContentTime t)
 }
 
 
+void
+Content::set_trim_behaviour (TrimBehaviour t)
+{
+       ChangeSignaller<Content> cc (this, ContentProperty::TRIM_BEHAVIOUR);
+
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _trim_behaviour = t;
+       }
+}
+
+
 shared_ptr<Content>
 Content::clone () const
 {
index 5f8e9f53d3a8a0a25c79315635f4bd7653a01f0f..440d42a79021922ee2cd6eda395cf0b2b3096f14 100644 (file)
@@ -56,6 +56,7 @@ public:
        static int const LENGTH;
        static int const TRIM_START;
        static int const TRIM_END;
+       static int const TRIM_BEHAVIOUR;
        static int const VIDEO_FRAME_RATE;
 };
 
@@ -160,6 +161,19 @@ public:
                return _trim_end;
        }
 
+       enum TrimBehaviour
+       {
+               TRIM_CONTENT,
+               TRIM_PLAYLIST
+       };
+
+       void set_trim_behaviour (TrimBehaviour b);
+
+       TrimBehaviour trim_behaviour () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _trim_behaviour;
+       }
+
        /** @return Time immediately after the last thing in this content */
        dcpomatic::DCPTime end (boost::shared_ptr<const Film> film) const {
                return position() + length_after_trim(film);
@@ -224,6 +238,7 @@ private:
        dcpomatic::DCPTime _position;
        dcpomatic::ContentTime _trim_start;
        dcpomatic::ContentTime _trim_end;
+       TrimBehaviour _trim_behaviour;
        /** The video frame rate that this content is or was prepared to be used with,
         *  or empty if the effective rate of this content should be dictated by something
         *  else (either some video happening at the same time, or the rate of the DCP).