diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-07 17:28:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-07 17:28:30 +0100 |
| commit | a680f27bddf78d7dcbe52ddb4f8e3e9194d85fd5 (patch) | |
| tree | 6a39e47781577278dca9c6e44bdfc236c2d65e26 /src | |
| parent | d406283ff669a33973b43839da6200d972d25f2a (diff) | |
Tweaks to dcpinfo.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dcp.cc | 78 | ||||
| -rw-r--r-- | src/exceptions.h | 9 | ||||
| -rw-r--r-- | src/picture_asset.cc | 10 | ||||
| -rw-r--r-- | src/sound_asset.cc | 6 |
4 files changed, 64 insertions, 39 deletions
@@ -214,7 +214,7 @@ DCP::write_assetmap (string cpl_uuid, int cpl_length, string pkl_uuid, int pkl_l } -DCP::DCP (string directory, bool read_mxfs) +DCP::DCP (string directory, bool require_mxfs) : _directory (directory) { Files files; @@ -329,56 +329,74 @@ DCP::DCP (string directory, bool read_mxfs) shared_ptr<PictureAsset> picture; shared_ptr<SoundAsset> sound; shared_ptr<SubtitleAsset> subtitle; - - if (read_mxfs && (*i)->asset_list->main_picture) { + + if ((*i)->asset_list->main_picture) { string n = pkl->asset_from_id (p->id)->original_file_name; if (n.empty ()) { n = p->annotation_text; } - - picture.reset (new MonoPictureAsset ( - _directory, - n, - _fps, - (*i)->asset_list->main_picture->entry_point, - (*i)->asset_list->main_picture->duration - ) - ); + + try { + picture.reset (new MonoPictureAsset ( + _directory, + n, + _fps, + (*i)->asset_list->main_picture->entry_point, + (*i)->asset_list->main_picture->duration + ) + ); + } catch (MXFFileError) { + if (require_mxfs) { + throw; + } + } - } else if (read_mxfs && (*i)->asset_list->main_stereoscopic_picture) { + } else if ((*i)->asset_list->main_stereoscopic_picture) { string n = pkl->asset_from_id (p->id)->original_file_name; if (n.empty ()) { n = p->annotation_text; } - picture.reset (new StereoPictureAsset ( - _directory, - n, - _fps, - (*i)->asset_list->main_stereoscopic_picture->entry_point, - (*i)->asset_list->main_stereoscopic_picture->duration - ) - ); + try { + picture.reset (new StereoPictureAsset ( + _directory, + n, + _fps, + (*i)->asset_list->main_stereoscopic_picture->entry_point, + (*i)->asset_list->main_stereoscopic_picture->duration + ) + ); + } catch (MXFFileError) { + if (require_mxfs) { + throw; + } + } } - if (read_mxfs && (*i)->asset_list->main_sound) { + if ((*i)->asset_list->main_sound) { string n = pkl->asset_from_id ((*i)->asset_list->main_sound->id)->original_file_name; if (n.empty ()) { n = (*i)->asset_list->main_sound->annotation_text; } - sound.reset (new SoundAsset ( - _directory, - n, - _fps, - (*i)->asset_list->main_sound->entry_point, - (*i)->asset_list->main_sound->duration - ) - ); + try { + sound.reset (new SoundAsset ( + _directory, + n, + _fps, + (*i)->asset_list->main_sound->entry_point, + (*i)->asset_list->main_sound->duration + ) + ); + } catch (MXFFileError) { + if (require_mxfs) { + throw; + } + } } if ((*i)->asset_list->main_subtitle) { diff --git a/src/exceptions.h b/src/exceptions.h index cd3c5cdb..25e51c9e 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -55,7 +55,14 @@ private: std::string _filename; }; - +class MXFFileError : public FileError +{ +public: + MXFFileError (std::string const & message, std::string const & filename) + : FileError (message, filename) + {} +}; + /** @brief A miscellaneous exception */ class MiscError : public std::exception { diff --git a/src/picture_asset.cc b/src/picture_asset.cc index 4c66bd02..142bc8fc 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -72,12 +72,12 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const if (opt.flags & MXF_INSPECT) { ASDCP::JP2K::MXFReader reader_A; if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::JP2K::MXFReader reader_B; if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::JP2K::PictureDescriptor desc_A; @@ -244,7 +244,7 @@ MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, { ASDCP::JP2K::MXFReader reader; if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::JP2K::PictureDescriptor desc; @@ -274,7 +274,7 @@ MonoPictureAsset::construct (sigc::slot<string, int> get_path) ASDCP::JP2K::MXFWriter mxf_writer; if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc))) { - throw FileError ("could not open MXF file for writing", path().string()); + throw MXFFileError ("could not open MXF file for writing", path().string()); } for (int i = 0; i < _length; ++i) { @@ -317,7 +317,7 @@ StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int f { ASDCP::JP2K::MXFSReader reader; if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::JP2K::PictureDescriptor desc; diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 732bb610..a41e5b67 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -62,7 +62,7 @@ SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int entry_po { ASDCP::PCM::MXFReader reader; if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } @@ -202,13 +202,13 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const ASDCP::PCM::MXFReader reader_A; if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { cout << "failed " << path() << "\n"; - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::PCM::MXFReader reader_B; if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { cout << "failed " << other->path() << "\n"; - throw FileError ("could not open MXF file for reading", path().string()); + throw MXFFileError ("could not open MXF file for reading", path().string()); } ASDCP::PCM::AudioDescriptor desc_A; |
