ASDCP::EssenceType_t type;
if (ASDCP::EssenceType (path.string().c_str(), type) != ASDCP::RESULT_OK) {
- throw DCPReadError ("Could not find essence type");
+ throw ReadError ("Could not find essence type");
}
switch (type) {
case ASDCP::ESS_UNKNOWN:
case ASDCP::ESS_MPEG2_VES:
- throw DCPReadError ("MPEG2 video essences are not supported");
+ throw ReadError ("MPEG2 video essences are not supported");
case ASDCP::ESS_JPEG_2000:
try {
return shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path));
case ASDCP::ESS_DCDATA_DOLBY_ATMOS:
return shared_ptr<AtmosAsset> (new AtmosAsset (path));
default:
- throw DCPReadError (String::compose ("Unknown MXF essence type %1 in %2", int(type), path.string()));
+ throw ReadError (String::compose ("Unknown MXF essence type %1 in %2", int(type), path.string()));
}
return shared_ptr<Asset>();
ASDCP::ATMOS::AtmosDescriptor desc;
if (ASDCP_FAILURE (reader.FillAtmosDescriptor (desc))) {
- boost::throw_exception (DCPReadError ("could not read Atmos MXF information"));
+ boost::throw_exception (ReadError ("could not read Atmos MXF information"));
}
_edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator);
} else if (boost::filesystem::exists (_directory / "ASSETMAP.xml")) {
_asset_map = _directory / "ASSETMAP.xml";
} else {
- boost::throw_exception (DCPReadError (String::compose ("could not find ASSETMAP nor ASSETMAP.xml in `%1'", _directory.string())));
+ boost::throw_exception (ReadError (String::compose ("could not find ASSETMAP nor ASSETMAP.xml in `%1'", _directory.string())));
}
cxml::Document asset_map ("AssetMap");
p->parse_file (path.string());
} catch (std::exception& e) {
delete p;
- throw DCPReadError(String::compose("XML error in %1", path.string()), e.what());
+ throw ReadError(String::compose("XML error in %1", path.string()), e.what());
}
string const root = p->get_document()->get_root_node()->get_name ();
} else if (*pkl_type == "image/png") {
/* It's an Interop PNG subtitle; let it go */
} else {
- throw DCPReadError (String::compose("Unknown asset type %1 in PKL", *pkl_type));
+ throw ReadError (String::compose("Unknown asset type %1 in PKL", *pkl_type));
}
}
class CertificateChain;
class DecryptedKDM;
class Asset;
-class DCPReadError;
+class ReadError;
/** @class DCP
* @brief A class to create or read a DCP.
split (b, time, is_any_of (":"));
if (b.size() < 3 || b[0].empty() || b[1].empty() || b[0].length() > 2 || b[1].length() > 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
}
if (!tcr_) {
vector<string> bs;
split (bs, b[2], is_any_of ("."));
if (bs.size() != 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
}
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (bs[0].empty() || bs[0].length() > 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[0])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[0])));
}
s = raw_convert<int> (bs[0]);
if (bs[1].empty() || bs[1].length() > 3) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[1])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[1])));
}
e = raw_convert<int> (bs[1]);
tcr = 1000;
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (b[2].empty() || b[2].length() > 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
}
s = raw_convert<int> (b[2]);
if (b[3].empty() || b[3].length() > 3) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
}
e = raw_convert<int> (b[3]);
tcr = 250;
} else {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
}
} else {
/* SMPTE: HH:MM:SS:EE */
split (b, time, is_any_of (":"));
if (b.size() != 4) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; does not have 4 parts", time)));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; does not have 4 parts", time)));
}
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (b[2].empty() || b[2].length() > 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
}
s = raw_convert<int> (b[2]);
if (b[3].empty() || b[3].length() > 2) {
- boost::throw_exception (DCPReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
+ boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
}
e = raw_convert<int> (b[3]);
tcr = tcr_.get();
}
BadContentKindError::BadContentKindError (string content_kind)
- : DCPReadError (String::compose("Bad content kind '%1'", content_kind))
+ : ReadError (String::compose("Bad content kind '%1'", content_kind))
{
}
}
-DCPReadError::DCPReadError (string message, string detail)
+ReadError::ReadError (string message, string detail)
: runtime_error(String::compose("%1 (%2)", message, detail))
, _message(message)
, _detail(detail)
{}
};
-/** @class DCPReadError
- * @brief A DCP read exception
+
+/** @class ReadError
+ * @brief Any error that occurs when reading data from a DCP.
*/
-class DCPReadError : public std::runtime_error
+class ReadError : public std::runtime_error
{
public:
- explicit DCPReadError (std::string message)
+ explicit ReadError (std::string message)
: std::runtime_error(message)
, _message(message)
{}
- DCPReadError (std::string message, std::string detail);
+ ReadError (std::string message, std::string detail);
- ~DCPReadError() throw () {}
+ ~ReadError() throw () {}
std::string message () const {
return _message;
boost::optional<std::string> _detail;
};
-class BadContentKindError : public DCPReadError
+
+class BadContentKindError : public ReadError
{
public:
BadContentKindError (std::string content_kind);
_buffer = new B (Kumu::Megabyte);
if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) {
- boost::throw_exception (DCPReadError ("could not read frame"));
+ boost::throw_exception (ReadError ("could not read frame"));
}
}
opj_codec_t* decoder = opj_create_decompress (format);
if (!decoder) {
- boost::throw_exception (DCPReadError ("could not create JPEG2000 decompresser"));
+ boost::throw_exception (ReadError ("could not create JPEG2000 decompresser"));
}
opj_dparameters_t parameters;
opj_set_default_decoder_parameters (¶meters);
opj_destroy_codec (decoder);
opj_stream_destroy (stream);
if (format == OPJ_CODEC_J2K) {
- boost::throw_exception (DCPReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
+ boost::throw_exception (ReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
} else {
- boost::throw_exception (DCPReadError (String::compose ("could not decode JP2 file of %1 bytes.", size)));
+ boost::throw_exception (ReadError (String::compose ("could not decode JP2 file of %1 bytes.", size)));
}
}
if (!image) {
opj_destroy_decompress (decoder);
opj_cio_close (cio);
- boost::throw_exception (DCPReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
+ boost::throw_exception (ReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
}
opj_destroy_decompress (decoder);
ASDCP::JP2K::PictureDescriptor desc;
if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
read_picture_descriptor (desc);
ASDCP::WriterInfo info;
if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
_id = read_writer_info (info);
ASDCP::JP2K::PictureDescriptor desc_A;
if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
ASDCP::JP2K::PictureDescriptor desc_B;
if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
if (!descriptor_equals (desc_A, desc_B, note)) {
ASDCP::Result_t const r = reader->ReadFrame (n, *_buffer, c->context(), c->hmac());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
+ boost::throw_exception (ReadError (String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
}
}
_standard = SMPTE;
break;
default:
- throw DCPReadError ("Unrecognised label set type in MXF");
+ throw ReadError ("Unrecognised label set type in MXF");
}
_metadata.read (info);
_id = _xml_id = remove_urn_uuid (xml->string_child ("Id"));
} catch (cxml::Error& e) {
boost::throw_exception (
- DCPReadError (
+ ReadError (
String::compose (
"Failed to read subtitle file %1; MXF failed with %2, XML failed with %3",
file, static_cast<int> (r), e.what ()
Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (
- DCPReadError (
+ ReadError (
String::compose ("Could not read encrypted subtitle MXF (%1)", static_cast<int> (r))
)
);
ASDCP::PCM::AudioDescriptor desc;
if (ASDCP_FAILURE (reader.FillAudioDescriptor (desc))) {
- boost::throw_exception (DCPReadError ("could not read audio MXF information"));
+ boost::throw_exception (ReadError ("could not read audio MXF information"));
}
_sampling_rate = desc.AudioSamplingRate.Numerator / desc.AudioSamplingRate.Denominator;
ASDCP::WriterInfo info;
if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
- boost::throw_exception (DCPReadError ("could not read audio MXF information"));
+ boost::throw_exception (ReadError ("could not read audio MXF information"));
}
_id = read_writer_info (info);
ASDCP::PCM::AudioDescriptor desc_A;
if (ASDCP_FAILURE (reader_A.FillAudioDescriptor (desc_A))) {
- boost::throw_exception (DCPReadError ("could not read audio MXF information"));
+ boost::throw_exception (ReadError ("could not read audio MXF information"));
}
ASDCP::PCM::AudioDescriptor desc_B;
if (ASDCP_FAILURE (reader_B.FillAudioDescriptor (desc_B))) {
- boost::throw_exception (DCPReadError ("could not read audio MXF information"));
+ boost::throw_exception (ReadError ("could not read audio MXF information"));
}
if (desc_A.EditRate != desc_B.EditRate) {
ASDCP::JP2K::PictureDescriptor desc;
if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
read_picture_descriptor (desc);
ASDCP::WriterInfo info;
if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
_id = read_writer_info (info);
ASDCP::JP2K::PictureDescriptor desc_A;
if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
ASDCP::JP2K::PictureDescriptor desc_B;
if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
- boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError ("could not read video MXF information"));
}
if (!descriptor_equals (desc_A, desc_B, note)) {
try {
frame_A = reader->get_frame (i);
frame_B = other_reader->get_frame (i);
- } catch (DCPReadError& e) {
+ } catch (ReadError& e) {
/* If there was a problem reading the frame data we'll just assume
the two frames are not equal.
*/
_buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte);
if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) {
- boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 of %2", n)));
+ boost::throw_exception (ReadError (String::compose ("could not read video frame %1 of %2", n)));
}
}
return SHADOW;
}
- boost::throw_exception (DCPReadError ("unknown subtitle effect type"));
+ boost::throw_exception (ReadError ("unknown subtitle effect type"));
}
string
return HALIGN_RIGHT;
}
- boost::throw_exception (DCPReadError ("unknown subtitle halign type"));
+ boost::throw_exception (ReadError ("unknown subtitle halign type"));
}
string
return VALIGN_BOTTOM;
}
- boost::throw_exception (DCPReadError ("unknown subtitle valign type"));
+ boost::throw_exception (ReadError ("unknown subtitle valign type"));
}
string
return DIRECTION_BTT;
}
- boost::throw_exception (DCPReadError ("unknown subtitle direction type"));
+ boost::throw_exception (ReadError ("unknown subtitle direction type"));
}
/** Convert a content kind to a string which can be used in a
stage ("Checking DCP", dcp->directory());
try {
dcp->read (¬es);
- } catch (DCPReadError& e) {
+ } catch (ReadError& e) {
notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::GENERAL_READ, string(e.what())));
} catch (XMLError& e) {
notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::GENERAL_READ, string(e.what())));
BOOST_CHECK_EQUAL (a, dcp::Time (1, 23, 45, 12, 250));
/* Check some disallowed constructions from string */
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:1234", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:1234:66", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23::123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01::45:123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time (":23:45:123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45.1234", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45.1234.66", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45.", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:.123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01::45.123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time (":23:45.123", optional<int>()), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:123", 250), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:123:66", 250), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23:45:", 250), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01:23::123", 250), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time ("01::45:123", 250), dcp::DCPReadError);
- BOOST_CHECK_THROW (dcp::Time (":23:45:123", 250), dcp::DCPReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:1234", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:1234:66", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23::123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01::45:123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time (":23:45:123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45.1234", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45.1234.66", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45.", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:.123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01::45.123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time (":23:45.123", optional<int>()), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:123", 250), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:123:66", 250), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23:45:", 250), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01:23::123", 250), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time ("01::45:123", 250), dcp::ReadError);
+ BOOST_CHECK_THROW (dcp::Time (":23:45:123", 250), dcp::ReadError);
/* Check operator< and operator> */
BOOST_CHECK (dcp::Time (3, 2, 3, 4, 24) < dcp::Time (3, 2, 3, 5, 24));
BOOST_CHECK_EQUAL (dcp::string_to_effect ("none"), dcp::NONE);
BOOST_CHECK_EQUAL (dcp::string_to_effect ("border"), dcp::BORDER);
BOOST_CHECK_EQUAL (dcp::string_to_effect ("shadow"), dcp::SHADOW);
- BOOST_CHECK_THROW (dcp::string_to_effect ("fish"), dcp::DCPReadError);
+ BOOST_CHECK_THROW (dcp::string_to_effect ("fish"), dcp::ReadError);
}
cerr << e.what() << " (" << e.filename() << ") when reading " << argv[1] << "\n";
exit (EXIT_FAILURE);
}
- catch (DCPReadError& e)
+ catch (ReadError& e)
{
cerr << e.what() << " when reading " << argv[1] << "\n";
exit (EXIT_FAILURE);
"TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf"
);
- BOOST_CHECK_THROW (asset.start_read()->get_frame (99999999), dcp::DCPReadError);
+ BOOST_CHECK_THROW (asset.start_read()->get_frame (99999999), dcp::ReadError);
}
shared_ptr<const dcp::AtmosFrame> f = reader->get_frame (i);
writer->write (f->data(), f->size());
}
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
cerr << "Unknown MXF format.\n";
return EXIT_FAILURE;
}
} catch (FileError& e) {
cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
exit (EXIT_FAILURE);
- } catch (DCPReadError& e) {
+ } catch (ReadError& e) {
cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
exit (EXIT_FAILURE);
} catch (KDMDecryptionError& e) {
list<dcp::VerificationNote> notes;
try {
dcp.read (¬es, true);
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
cout << "Error:" << e.what() << "\n";
}
if (i->path().extension() == ".xml") {
try {
cpl.reset(new dcp::CPL(i->path()));
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
cout << "Error: " << e.what() << "\n";
} catch (xmlpp::parse_error& e) {
cout << "Error: " << e.what() << "\n";
asset->hash (&progress);
cout << "100% \n";
assets.push_back (asset);
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
cout << "Error: " << e.what() << "\n";
}
}