#include "dcp_assert.h"
#include "equality_options.h"
#include "exceptions.h"
+#include "filesystem.h"
#include "raw_convert.h"
#include "smpte_load_font_node.h"
#include "smpte_subtitle_asset.h"
auto r = Kumu::RESULT_OK;
{
ASDCPErrorSuspender sus;
- r = reader->OpenRead (_file->string().c_str ());
+ r = reader->OpenRead(dcp::filesystem::fix_long_path(*_file).string().c_str());
}
if (!ASDCP_FAILURE(r)) {
/* MXF-wrapped */
try {
_raw_xml = dcp::file_to_string (file);
xml = make_shared<cxml::Document>("SubtitleReel");
- xml->read_file (file);
+ xml->read_file(dcp::filesystem::fix_long_path(file));
parse_xml (xml);
} catch (cxml::Error& e) {
boost::throw_exception (
if (im && im->png_image().size() == 0) {
/* Even more dubious; allow <id>.png or urn:uuid:<id>.png */
auto p = file.parent_path() / String::compose("%1.png", im->id());
- if (boost::filesystem::is_regular_file(p)) {
+ if (filesystem::is_regular_file(p)) {
im->read_png_file (p);
} else if (starts_with (im->id(), "urn:uuid:")) {
p = file.parent_path() / String::compose("%1.png", remove_urn_uuid(im->id()));
- if (boost::filesystem::is_regular_file(p)) {
+ if (filesystem::is_regular_file(p)) {
im->read_png_file (p);
}
}
++i) {
ASDCP::TimedText::FrameBuffer buffer;
- buffer.Capacity (10 * 1024 * 1024);
- reader->ReadAncillaryResource (i->ResourceID, buffer, dec->context(), dec->hmac());
+ buffer.Capacity(32 * 1024 * 1024);
+ auto const result = reader->ReadAncillaryResource(i->ResourceID, buffer, dec->context(), dec->hmac());
+ if (ASDCP_FAILURE(result)) {
+ switch (i->Type) {
+ case ASDCP::TimedText::MT_OPENTYPE:
+ throw ReadError(String::compose("Could not read font from MXF file (%1)", static_cast<int>(result)));
+ case ASDCP::TimedText::MT_PNG:
+ throw ReadError(String::compose("Could not read subtitle image from MXF file (%1)", static_cast<int>(result)));
+ default:
+ throw ReadError(String::compose("Could not read resource from MXF file (%1)", static_cast<int>(result)));
+ }
+ }
char id[64];
Kumu::bin2UUIDhex (i->ResourceID, ASDCP::UUIDlen, id, sizeof(id));
have read that file.
*/
auto const had_key = static_cast<bool>(_key);
+ auto const had_key_id = static_cast<bool>(_key_id);
MXF::set_key (key);
- if (!_key_id || !_file || had_key) {
+ if (!had_key_id || !_file || had_key) {
/* Either we don't have any data to read, it wasn't
encrypted, or we've already read it, so we don't
need to do anything else.
/* Our data was encrypted; now we can decrypt it */
auto reader = make_shared<ASDCP::TimedText::MXFReader>();
- auto r = reader->OpenRead (_file->string().c_str ());
+ auto r = reader->OpenRead(dcp::filesystem::fix_long_path(*_file).string().c_str());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (
ReadError (
auto xml = make_shared<cxml::Document>("SubtitleReel");
xml->read_string (xml_string);
parse_xml (xml);
+ read_mxf_descriptor(reader);
read_mxf_resources (reader, dec);
}
{
ASDCP::TimedText::MXFReader reader;
Kumu::DefaultLogSink().UnsetFilterFlag(Kumu::LOG_ALLOW_ALL);
- auto r = reader.OpenRead (file.string().c_str ());
+ auto r = reader.OpenRead(dcp::filesystem::fix_long_path(file).string().c_str());
Kumu::DefaultLogSink().SetFilterFlag(Kumu::LOG_ALLOW_ALL);
return !ASDCP_FAILURE (r);
}
/* This header size is a guess. Empirically it seems that each subtitle reference is 90 bytes, and we need some extra.
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);
+ ASDCP::Result_t r = writer.OpenWrite(dcp::filesystem::fix_long_path(p).string().c_str(), writer_info, descriptor, _subtitles.size() * 90 + 16384);
if (ASDCP_FAILURE (r)) {
boost::throw_exception (FileError ("could not open subtitle MXF for writing", p.string(), r));
}
DCP_ASSERT(false);
}
-