}
-DCP::DCP (string directory, bool read_mxfs)
+DCP::DCP (string directory, bool require_mxfs)
: _directory (directory)
{
Files files;
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) {
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
{
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;
{
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;
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) {
{
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;
{
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());
}
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;
#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;
exit (EXIT_FAILURE);
}
- list<string> missing_mxfs;
-
DCP* dcp = 0;
try {
dcp = new DCP (argv[optind], false);
<< "\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;
}