+SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Content> > c)
+ : Content (f, c)
+{
+ shared_ptr<SubtitleContent> ref = dynamic_pointer_cast<SubtitleContent> (c[0]);
+ DCPOMATIC_ASSERT (ref);
+ list<shared_ptr<Font> > ref_fonts = ref->fonts ();
+
+ for (size_t i = 0; i < c.size(); ++i) {
+ shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]);
+
+ if (sc->use_subtitles() != ref->use_subtitles()) {
+ throw JoinError (_("Content to be joined must have the same 'use subtitles' setting."));
+ }
+
+ if (sc->subtitle_x_offset() != ref->subtitle_x_offset()) {
+ throw JoinError (_("Content to be joined must have the same subtitle X offset."));
+ }
+
+ if (sc->subtitle_y_offset() != ref->subtitle_y_offset()) {
+ throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
+ }
+
+ if (sc->subtitle_x_scale() != ref->subtitle_x_scale()) {
+ throw JoinError (_("Content to be joined must have the same subtitle X scale."));
+ }
+
+ if (sc->subtitle_y_scale() != ref->subtitle_y_scale()) {
+ throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
+ }
+
+ list<shared_ptr<Font> > fonts = sc->fonts ();
+ if (fonts.size() != ref_fonts.size()) {
+ throw JoinError (_("Content to be joined must use the same fonts."));
+ }
+
+ list<shared_ptr<Font> >::const_iterator j = ref_fonts.begin ();
+ list<shared_ptr<Font> >::const_iterator k = fonts.begin ();
+
+ while (j != ref_fonts.end ()) {
+ if (**j != **k) {
+ throw JoinError (_("Content to be joined must use the same fonts."));
+ }
+ ++j;
+ ++k;
+ }
+ }
+
+ _use_subtitles = ref->use_subtitles ();
+ _subtitle_x_offset = ref->subtitle_x_offset ();
+ _subtitle_y_offset = ref->subtitle_y_offset ();
+ _subtitle_x_scale = ref->subtitle_x_scale ();
+ _subtitle_y_scale = ref->subtitle_y_scale ();
+ _subtitle_language = ref->subtitle_language ();
+ _fonts = ref_fonts;
+}
+
+/** _mutex must not be held on entry */