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/ffmpeg_content.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/lib/ffmpeg_content.cc') diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index ddf4548b4..db999df20 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -128,6 +128,67 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no } +FFmpegContent::FFmpegContent (shared_ptr film, vector > c) + : Content (film, c) +{ + vector >::const_iterator i = c.begin (); + + bool need_video = false; + bool need_audio = false; + bool need_caption = false; + + if (i != c.end ()) { + need_video = static_cast ((*i)->video); + need_audio = static_cast ((*i)->audio); + need_caption = static_cast ((*i)->caption); + } + + while (i != c.end ()) { + if (need_video != static_cast ((*i)->video)) { + throw JoinError (_("Content to be joined must all have or not have video")); + } + if (need_audio != static_cast ((*i)->audio)) { + throw JoinError (_("Content to be joined must all have or not have audio")); + } + if (need_caption != static_cast ((*i)->caption)) { + throw JoinError (_("Content to be joined must all have or not have captions")); + } + ++i; + } + + if (need_video) { + video.reset (new VideoContent (this, c)); + } + if (need_audio) { + audio.reset (new AudioContent (this, c)); + } + if (need_caption) { + caption.reset (new CaptionContent (this, c)); + } + + shared_ptr ref = dynamic_pointer_cast (c[0]); + DCPOMATIC_ASSERT (ref); + + for (size_t i = 0; i < c.size(); ++i) { + shared_ptr fc = dynamic_pointer_cast (c[i]); + if (fc->caption && fc->caption->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { + throw JoinError (_("Content to be joined must use the same subtitle stream.")); + } + } + + /* XXX: should probably check that more of the stuff below is the same in *this and ref */ + + _subtitle_streams = ref->subtitle_streams (); + _subtitle_stream = ref->subtitle_stream (); + _first_video = ref->_first_video; + _filters = ref->_filters; + _color_range = ref->_color_range; + _color_primaries = ref->_color_primaries; + _color_trc = ref->_color_trc; + _colorspace = ref->_colorspace; + _bits_per_pixel = ref->_bits_per_pixel; +} + void FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const { -- cgit v1.2.3