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 | |
| parent | d406283ff669a33973b43839da6200d972d25f2a (diff) | |
Tweaks to dcpinfo.
| -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 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 21 |
5 files changed, 70 insertions, 54 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; diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 66813d95..ba1fed0a 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -5,6 +5,9 @@ #include "dcp.h" #include "exceptions.h" #include "reel.h" +#include "sound_asset.h" +#include "picture_asset.h" +#include "subtitle_asset.h" using namespace std; using namespace boost; @@ -53,8 +56,6 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } - list<string> missing_mxfs; - DCP* dcp = 0; try { dcp = new DCP (argv[optind], false); @@ -67,30 +68,20 @@ main (int argc, char* argv[]) << "\tLength: " << dcp->length() << "\n" << "\tFrames per second: " << dcp->frames_per_second() << "\n"; - if (!missing_mxfs.empty ()) { - cout << "\tmissing MXFs: "; - for (list<string>::const_iterator i = missing_mxfs.begin(); i != missing_mxfs.end(); ++i) { - cout << *i << " " ; - } - cout << "\n"; - } - list<shared_ptr<const Reel> > reels = dcp->reels (); int R = 1; for (list<shared_ptr<const Reel> >::const_iterator i = reels.begin(); i != reels.end(); ++i) { cout << "Reel " << R << "\n"; - cout << "\tContains: "; if ((*i)->main_picture()) { - cout << "picture "; + cout << "\tPicture: " << (*i)->main_picture()->width() << "x" << (*i)->main_picture()->height() << "\n"; } if ((*i)->main_sound()) { - cout << "sound "; + cout << "\tSound: " << (*i)->main_sound()->channels() << " channels at " << (*i)->main_sound()->sampling_rate() << "Hz\n"; } if ((*i)->main_subtitle()) { - cout << "subtitle "; + cout << "\tSubtitle: " << (*i)->main_subtitle()->subtitles().size() << " subtitles in " << (*i)->main_subtitle()->language() << "\n"; } - cout << "\n"; ++R; } |
