summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-07-21 21:47:25 +0100
committerCarl Hetherington <cth@carlh.net>2018-07-21 21:47:25 +0100
commit6199e090dc1e32d3753ba7e7d7ea8c5f0d79f046 (patch)
treeb09d9b6b19dadb694590981775a61f829b6f3622 /src/lib/ffmpeg_content.cc
parentcbd4450197a083bf58bda510e626f73ba583cb66 (diff)
Revert "Remove join function; the code is long and I don't think anybody"
It turns out Carsten uses it :) This reverts commit bd5e8b83a3a18787241982efdae809d4db21f65d.
Diffstat (limited to 'src/lib/ffmpeg_content.cc')
-rw-r--r--src/lib/ffmpeg_content.cc61
1 files changed, 61 insertions, 0 deletions
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<const Film> film, cxml::ConstNodePtr no
}
+FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
+ : Content (film, c)
+{
+ vector<shared_ptr<Content> >::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<bool> ((*i)->video);
+ need_audio = static_cast<bool> ((*i)->audio);
+ need_caption = static_cast<bool> ((*i)->caption);
+ }
+
+ while (i != c.end ()) {
+ if (need_video != static_cast<bool> ((*i)->video)) {
+ throw JoinError (_("Content to be joined must all have or not have video"));
+ }
+ if (need_audio != static_cast<bool> ((*i)->audio)) {
+ throw JoinError (_("Content to be joined must all have or not have audio"));
+ }
+ if (need_caption != static_cast<bool> ((*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<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
+ DCPOMATIC_ASSERT (ref);
+
+ for (size_t i = 0; i < c.size(); ++i) {
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (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
{