Fix join for new caption stuff.
authorCarl Hetherington <cth@carlh.net>
Sat, 21 Jul 2018 21:09:29 +0000 (22:09 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 21 Jul 2018 21:09:29 +0000 (22:09 +0100)
src/lib/caption_content.cc
src/lib/ffmpeg_content.cc

index 0d13568e20ee3347999c64497e93b2539f958d0b..368d276d93abfbc893829206a82cba4d5cf46366 100644 (file)
@@ -231,49 +231,52 @@ CaptionContent::CaptionContent (Content* parent, cxml::ConstNodePtr node, int ve
 CaptionContent::CaptionContent (Content* parent, vector<shared_ptr<Content> > c)
        : ContentPart (parent)
 {
-       shared_ptr<CaptionContent> ref = c[0]->caption;
+       /* This constructor is for join which is only supported for content types
+          that have a single caption, so we can use only_caption() here.
+       */
+       shared_ptr<CaptionContent> ref = c[0]->only_caption();
        DCPOMATIC_ASSERT (ref);
        list<shared_ptr<Font> > ref_fonts = ref->fonts ();
 
        for (size_t i = 1; i < c.size(); ++i) {
 
-               if (c[i]->caption->use() != ref->use()) {
+               if (c[i]->only_caption()->use() != ref->use()) {
                        throw JoinError (_("Content to be joined must have the same 'use subtitles' setting."));
                }
 
-               if (c[i]->caption->burn() != ref->burn()) {
+               if (c[i]->only_caption()->burn() != ref->burn()) {
                        throw JoinError (_("Content to be joined must have the same 'burn subtitles' setting."));
                }
 
-               if (c[i]->caption->x_offset() != ref->x_offset()) {
+               if (c[i]->only_caption()->x_offset() != ref->x_offset()) {
                        throw JoinError (_("Content to be joined must have the same subtitle X offset."));
                }
 
-               if (c[i]->caption->y_offset() != ref->y_offset()) {
+               if (c[i]->only_caption()->y_offset() != ref->y_offset()) {
                        throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
                }
 
-               if (c[i]->caption->x_scale() != ref->x_scale()) {
+               if (c[i]->only_caption()->x_scale() != ref->x_scale()) {
                        throw JoinError (_("Content to be joined must have the same subtitle X scale."));
                }
 
-               if (c[i]->caption->y_scale() != ref->y_scale()) {
+               if (c[i]->only_caption()->y_scale() != ref->y_scale()) {
                        throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
                }
 
-               if (c[i]->caption->line_spacing() != ref->line_spacing()) {
+               if (c[i]->only_caption()->line_spacing() != ref->line_spacing()) {
                        throw JoinError (_("Content to be joined must have the same subtitle line spacing."));
                }
 
-               if ((c[i]->caption->fade_in() != ref->fade_in()) || (c[i]->caption->fade_out() != ref->fade_out())) {
+               if ((c[i]->only_caption()->fade_in() != ref->fade_in()) || (c[i]->only_caption()->fade_out() != ref->fade_out())) {
                        throw JoinError (_("Content to be joined must have the same subtitle fades."));
                }
 
-               if ((c[i]->caption->outline_width() != ref->outline_width())) {
+               if ((c[i]->only_caption()->outline_width() != ref->outline_width())) {
                        throw JoinError (_("Content to be joined must have the same outline width."));
                }
 
-               list<shared_ptr<Font> > fonts = c[i]->caption->fonts ();
+               list<shared_ptr<Font> > fonts = c[i]->only_caption()->fonts ();
                if (fonts.size() != ref_fonts.size()) {
                        throw JoinError (_("Content to be joined must use the same fonts."));
                }
index db999df204afba0b978d5181402551f675688f01..4300dc97071e4d4277ba09561bc9f8d74d1ade4d 100644 (file)
@@ -140,7 +140,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
        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);
+               need_caption = !(*i)->caption.empty();
        }
 
        while (i != c.end ()) {
@@ -150,7 +150,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
                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)) {
+               if (need_caption != !(*i)->caption.empty()) {
                        throw JoinError (_("Content to be joined must all have or not have captions"));
                }
                ++i;
@@ -163,7 +163,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
                audio.reset (new AudioContent (this, c));
        }
        if (need_caption) {
-               caption.reset (new CaptionContent (this, c));
+               caption.push_back (shared_ptr<CaptionContent> (new CaptionContent (this, c)));
        }
 
        shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
@@ -171,7 +171,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
 
        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())) {
+               if (fc->only_caption() && fc->only_caption()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
        }