using std::list;
using std::vector;
using std::map;
-using boost::shared_ptr;
+using std::shared_ptr;
using boost::split;
using boost::is_any_of;
using boost::shared_array;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
using boost::optional;
using boost::starts_with;
using namespace dcp;
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
shared_ptr<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
- Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
+ Kumu::Result_t r = Kumu::RESULT_OK;
+ {
+ ASDCPErrorSuspender sus;
+ r = reader->OpenRead (_file->string().c_str ());
+ }
if (!ASDCP_FAILURE (r)) {
/* MXF-wrapped */
ASDCP::WriterInfo info;
}
}
}
+ _standard = dcp::SMPTE;
}
/* Check that all required image data have been found */
/* Now we need to drop down to xmlpp */
- list<ParseState> ps;
+ vector<ParseState> ps;
xmlpp::Node::NodeList c = xml->node()->get_children ();
for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
switch (i->Type) {
case ASDCP::TimedText::MT_OPENTYPE:
{
- list<shared_ptr<SMPTELoadFontNode> >::const_iterator j = _load_font_nodes.begin ();
+ auto j = _load_font_nodes.begin();
while (j != _load_font_nodes.end() && (*j)->urn != id) {
++j;
}
if (j != _load_font_nodes.end ()) {
- _fonts.push_back (Font ((*j)->id, (*j)->urn, Data (data, buffer.Size ())));
+ _fonts.push_back (Font ((*j)->id, (*j)->urn, ArrayData (data, buffer.Size ())));
}
break;
}
case ASDCP::TimedText::MT_PNG:
{
- list<shared_ptr<Subtitle> >::const_iterator j = _subtitles.begin ();
+ auto j = _subtitles.begin();
while (j != _subtitles.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) {
++j;
}
if (j != _subtitles.end()) {
- dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (Data(data, buffer.Size()));
+ dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (ArrayData(data, buffer.Size()));
}
break;
}
read_mxf_descriptor (reader, dec);
}
-list<shared_ptr<LoadFontNode> >
+vector<shared_ptr<LoadFontNode>>
SMPTESubtitleAsset::load_font_nodes () const
{
- list<shared_ptr<LoadFontNode> > lf;
+ vector<shared_ptr<LoadFontNode>> lf;
copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter (lf));
return lf;
}
/* Font references */
BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
- list<Font>::const_iterator j = _fonts.begin ();
+ auto j = _fonts.begin();
while (j != _fonts.end() && j->load_id != i->id) {
++j;
}
ASDCP::TimedText::MXFWriter writer;
/* This header size is a guess. Empirically it seems that each subtitle reference is 90 bytes, and we need some extra.
- The defualt size is not enough for some feature-length PNG sub projects (see DCP-o-matic #1561).
+ The default size is not enough for some feature-length PNG sub projects (see DCP-o-matic #1561).
*/
ASDCP::Result_t r = writer.OpenWrite (p.string().c_str(), writer_info, descriptor, _subtitles.size() * 90 + 16384);
if (ASDCP_FAILURE (r)) {
/* Font payload */
BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
- list<Font>::const_iterator j = _fonts.begin ();
+ auto j = _fonts.begin();
while (j != _fonts.end() && j->load_id != i->id) {
++j;
}
if (j != _fonts.end ()) {
ASDCP::TimedText::FrameBuffer buffer;
- buffer.SetData (j->data.data().get(), j->data.size());
+ ArrayData data_copy(j->data);
+ buffer.SetData (data_copy.data(), data_copy.size());
buffer.Size (j->data.size());
r = writer.WriteAncillaryResource (buffer, enc.context(), enc.hmac());
if (ASDCP_FAILURE (r)) {
shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
if (si) {
ASDCP::TimedText::FrameBuffer buffer;
- buffer.SetData (si->png_image().data().get(), si->png_image().size());
+ buffer.SetData (si->png_image().data(), si->png_image().size());
buffer.Size (si->png_image().size());
r = writer.WriteAncillaryResource (buffer, enc.context(), enc.hmac());
if (ASDCP_FAILURE(r)) {
return false;
}
- list<shared_ptr<SMPTELoadFontNode> >::const_iterator i = _load_font_nodes.begin ();
- list<shared_ptr<SMPTELoadFontNode> >::const_iterator j = other->_load_font_nodes.begin ();
+ auto i = _load_font_nodes.begin();
+ auto j = other->_load_font_nodes.begin();
while (i != _load_font_nodes.end ()) {
if (j == other->_load_font_nodes.end ()) {
}
if (_language != other->_language) {
- note (DCP_ERROR, "Subtitle languages differ");
+ note (DCP_ERROR, String::compose("Subtitle languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]")));
return false;
}
}
void
-SMPTESubtitleAsset::add_font (string load_id, boost::filesystem::path file)
+SMPTESubtitleAsset::add_font (string load_id, dcp::ArrayData data)
{
string const uuid = make_uuid ();
- _fonts.push_back (Font (load_id, uuid, file));
+ _fonts.push_back (Font(load_id, uuid, data));
_load_font_nodes.push_back (shared_ptr<SMPTELoadFontNode> (new SMPTELoadFontNode (load_id, uuid)));
}