}
};
+/** @param standard Standard (INTEROP or SMPTE); this is used rather than putting things in the child
+ * class because the differences between the two are fairly subtle.
+ */
void
-SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, string xmlns) const
+SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Standard standard) const
{
list<SubtitleString> sorted = _subtitles;
sorted.sort (SubtitleSorter ());
+ string const xmlns = standard == SMPTE ? "dcst" : "";
+
/* XXX: script, underlined, weight not supported */
optional<string> font;
if (!font_element || font_changed) {
font_element = root->add_child ("Font", xmlns);
if (font) {
- font_element->set_attribute ("Id", font.get ());
+ if (standard == SMPTE) {
+ font_element->set_attribute ("ID", font.get ());
+ } else {
+ font_element->set_attribute ("Id", font.get ());
+ }
}
font_element->set_attribute ("Italic", italic ? "yes" : "no");
font_element->set_attribute ("Color", colour.to_argb_string());
font_element->set_attribute ("Effect", effect_to_string (effect));
font_element->set_attribute ("EffectColor", effect_colour.to_argb_string());
font_element->set_attribute ("Script", "normal");
- font_element->set_attribute ("Underlined", "no");
+ if (standard == SMPTE) {
+ font_element->set_attribute ("Underline", "no");
+ } else {
+ font_element->set_attribute ("Underlined", "no");
+ }
font_element->set_attribute ("Weight", "normal");
}
subtitle_element = font_element->add_child ("Subtitle", xmlns);
subtitle_element->set_attribute ("SpotNumber", raw_convert<string> (spot_number++));
- subtitle_element->set_attribute ("TimeIn", i->in().rebase(time_code_rate).as_string());
- subtitle_element->set_attribute ("TimeOut", i->out().rebase(time_code_rate).as_string());
- subtitle_element->set_attribute ("FadeUpTime", raw_convert<string> (i->fade_up_time().as_editable_units(time_code_rate)));
- subtitle_element->set_attribute ("FadeDownTime", raw_convert<string> (i->fade_down_time().as_editable_units(time_code_rate)));
+ subtitle_element->set_attribute ("TimeIn", i->in().rebase(time_code_rate).as_string(standard));
+ subtitle_element->set_attribute ("TimeOut", i->out().rebase(time_code_rate).as_string(standard));
+ if (standard == SMPTE) {
+ subtitle_element->set_attribute ("FadeUpTime", i->fade_up_time().rebase(time_code_rate).as_string(standard));
+ subtitle_element->set_attribute ("FadeDownTime", i->fade_down_time().rebase(time_code_rate).as_string(standard));
+ } else {
+ subtitle_element->set_attribute ("FadeUpTime", raw_convert<string> (i->fade_up_time().as_editable_units(time_code_rate)));
+ subtitle_element->set_attribute ("FadeDownTime", raw_convert<string> (i->fade_down_time().as_editable_units(time_code_rate)));
+ }
last_in = i->in ();
last_out = i->out ();
xmlpp::Element* text = subtitle_element->add_child ("Text", xmlns);
if (i->h_align() != HALIGN_CENTER) {
- text->set_attribute ("HAlign", halign_to_string (i->h_align ()));
+ if (standard == SMPTE) {
+ text->set_attribute ("Halign", halign_to_string (i->h_align ()));
+ } else {
+ text->set_attribute ("HAlign", halign_to_string (i->h_align ()));
+ }
}
if (i->h_position() > ALIGN_EPSILON) {
- text->set_attribute ("HPosition", raw_convert<string> (i->h_position() * 100, 6));
+ if (standard == SMPTE) {
+ text->set_attribute ("Hposition", raw_convert<string> (i->h_position() * 100, 6));
+ } else {
+ text->set_attribute ("HPosition", raw_convert<string> (i->h_position() * 100, 6));
+ }
+ }
+ if (standard == SMPTE) {
+ text->set_attribute ("Valign", valign_to_string (i->v_align()));
+ } else {
+ text->set_attribute ("VAlign", valign_to_string (i->v_align()));
}
- text->set_attribute ("VAlign", valign_to_string (i->v_align()));
if (i->v_position() > ALIGN_EPSILON) {
- text->set_attribute ("VPosition", raw_convert<string> (i->v_position() * 100, 6));
+ if (standard == SMPTE) {
+ text->set_attribute ("Vposition", raw_convert<string> (i->v_position() * 100, 6));
+ } else {
+ text->set_attribute ("VPosition", raw_convert<string> (i->v_position() * 100, 6));
+ }
} else {
- text->set_attribute ("VPosition", "0");
+ if (standard == SMPTE) {
+ text->set_attribute ("Vposition", "0");
+ } else {
+ text->set_attribute ("VPosition", "0");
+ }
}
text->add_child_text (i->text());
}
BOOST_CHECK_EQUAL (t.s, 34);
BOOST_CHECK_EQUAL (t.m, 18);
BOOST_CHECK_EQUAL (t.h, 11);
- BOOST_CHECK_EQUAL (t.as_string(), "11:18:34:073");
+ BOOST_CHECK_EQUAL (t.as_string(dcp::INTEROP), "11:18:34:073");
/* Use a tcr of 24 so that the editable event is a frame */
dcp::Time a (3, 2, 3, 4, 24);
BOOST_CHECK_EQUAL (r.m, 58);
BOOST_CHECK_EQUAL (r.s, 58);
BOOST_CHECK_EQUAL (r.e, 23);
- BOOST_CHECK_EQUAL (r.as_string(), "00:58:58:023");
+ BOOST_CHECK_EQUAL (r.as_string(dcp::INTEROP), "00:58:58:023");
/* Different tcr (25) */
a = dcp::Time (1, 58, 56, 2, 25);
BOOST_CHECK_EQUAL (r.m, 6);
BOOST_CHECK_EQUAL (r.s, 8);
BOOST_CHECK_EQUAL (r.e, 3);
- BOOST_CHECK_EQUAL (r.as_string(), "03:06:08:003");
+ BOOST_CHECK_EQUAL (r.as_string(dcp::INTEROP), "03:06:08:003");
/* Another arbitrary tcr (30) */
a = dcp::Time (24, 12, 6, 3, 30);