- DCP_ASSERT (!parse_state.text_nodes.empty ());
- DCP_ASSERT (!parse_state.subtitle_nodes.empty ());
-
- dcp::FontNode effective_font (parse_state.font_nodes);
- dcp::TextNode effective_text (*parse_state.text_nodes.back ());
- dcp::SubtitleNode effective_subtitle (*parse_state.subtitle_nodes.back ());
-
- _subtitles.push_back (
- SubtitleString (
- effective_font.id,
- effective_font.italic.get_value_or (false),
- effective_font.colour.get_value_or (dcp::Colour (255, 255, 255)),
- effective_font.size,
- effective_font.aspect_adjust.get_value_or (1.0),
- effective_subtitle.in,
- effective_subtitle.out,
- effective_text.h_position,
- effective_text.h_align,
- effective_text.v_position,
- effective_text.v_align,
- text,
- effective_font.effect.get_value_or (NONE),
- effective_font.effect_colour.get_value_or (dcp::Colour (0, 0, 0)),
- effective_subtitle.fade_up_time,
- effective_subtitle.fade_down_time
- )
- );
+ DCP_ASSERT (ps.type);
+
+ switch (ps.type.get()) {
+ case ParseState::Type::TEXT:
+ _subtitles.push_back (
+ make_shared<SubtitleString>(
+ ps.font_id,
+ ps.italic.get_value_or (false),
+ ps.bold.get_value_or (false),
+ ps.underline.get_value_or (false),
+ ps.colour.get_value_or (dcp::Colour (255, 255, 255)),
+ ps.size.get_value_or (42),
+ ps.aspect_adjust.get_value_or (1.0),
+ ps.in.get(),
+ ps.out.get(),
+ ps.h_position.get_value_or(0),
+ ps.h_align.get_value_or(HAlign::CENTER),
+ ps.v_position.get_value_or(0),
+ ps.v_align.get_value_or(VAlign::CENTER),
+ ps.z_position.get_value_or(0),
+ ps.direction.get_value_or (Direction::LTR),
+ text,
+ ps.effect.get_value_or (Effect::NONE),
+ ps.effect_colour.get_value_or (dcp::Colour (0, 0, 0)),
+ ps.fade_up_time.get_value_or(Time()),
+ ps.fade_down_time.get_value_or(Time()),
+ space_before
+ )
+ );
+ break;
+ case ParseState::Type::IMAGE:
+ {
+ switch (standard) {
+ case Standard::INTEROP:
+ if (text.size() >= 4) {
+ /* Remove file extension */
+ text = text.substr(0, text.size() - 4);
+ }
+ break;
+ case Standard::SMPTE:
+ /* It looks like this urn:uuid: is required, but DoM wasn't expecting it (and not writing it)
+ * until around 2.15.140 so I guess either:
+ * a) it is not (always) used in the field, or
+ * b) nobody noticed / complained.
+ */
+ if (text.substr(0, 9) == "urn:uuid:") {
+ text = text.substr(9);
+ }
+ break;
+ }
+
+ /* Add a subtitle with no image data and we'll fill that in later */
+ _subtitles.push_back (
+ make_shared<SubtitleImage>(
+ ArrayData(),
+ text,
+ ps.in.get(),
+ ps.out.get(),
+ ps.h_position.get_value_or(0),
+ ps.h_align.get_value_or(HAlign::CENTER),
+ ps.v_position.get_value_or(0),
+ ps.v_align.get_value_or(VAlign::CENTER),
+ ps.z_position.get_value_or(0),
+ ps.fade_up_time.get_value_or(Time()),
+ ps.fade_down_time.get_value_or(Time())
+ )
+ );
+ break;
+ }
+ }
+}
+
+
+vector<shared_ptr<const Subtitle>>
+SubtitleAsset::subtitles () const
+{
+ vector<shared_ptr<const Subtitle>> s;
+ for (auto i: _subtitles) {
+ s.push_back (i);
+ }
+ return s;