46 #include <asdcp/AS_DCP.h>
52 using std::shared_ptr;
53 using std::dynamic_pointer_cast;
57 StereoPictureAsset::StereoPictureAsset (boost::filesystem::path file)
60 ASDCP::JP2K::MXFSReader reader;
61 auto r = reader.OpenRead (file.string().c_str());
62 if (ASDCP_FAILURE(r)) {
63 boost::throw_exception (
MXFFileError(
"could not open MXF file for reading", file.string(), r));
66 ASDCP::JP2K::PictureDescriptor desc;
67 if (ASDCP_FAILURE (reader.FillPictureDescriptor(desc))) {
68 boost::throw_exception (
ReadError(
"could not read video MXF information"));
71 read_picture_descriptor (desc);
73 ASDCP::WriterInfo info;
74 if (ASDCP_FAILURE (reader.FillWriterInfo(info))) {
75 boost::throw_exception (
ReadError(
"could not read video MXF information"));
78 _id = read_writer_info (info);
82 StereoPictureAsset::StereoPictureAsset (
Fraction edit_rate, Standard standard)
89 shared_ptr<PictureAssetWriter>
90 StereoPictureAsset::start_write (boost::filesystem::path file,
bool overwrite)
96 shared_ptr<StereoPictureAssetReader>
97 StereoPictureAsset::start_read ()
const
104 StereoPictureAsset::equals (shared_ptr<const Asset> other,
EqualityOptions opt, NoteHandler note)
const
106 ASDCP::JP2K::MXFSReader reader_A;
108 auto r = reader_A.OpenRead (
file()->
string().c_str());
109 if (ASDCP_FAILURE (r)) {
110 boost::throw_exception (
MXFFileError (
"could not open MXF file for reading",
file()->
string(), r));
113 ASDCP::JP2K::MXFSReader reader_B;
114 DCP_ASSERT (other->file());
115 r = reader_B.OpenRead (other->file()->string().c_str());
116 if (ASDCP_FAILURE (r)) {
117 boost::throw_exception (
MXFFileError (
"could not open MXF file for reading", other->file()->string(), r));
120 ASDCP::JP2K::PictureDescriptor desc_A;
121 if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
122 boost::throw_exception (
ReadError (
"could not read video MXF information"));
124 ASDCP::JP2K::PictureDescriptor desc_B;
125 if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
126 boost::throw_exception (
ReadError (
"could not read video MXF information"));
129 if (!descriptor_equals (desc_A, desc_B, note)) {
133 auto other_picture = dynamic_pointer_cast<const StereoPictureAsset> (other);
134 DCP_ASSERT (other_picture);
136 auto reader = start_read ();
137 auto other_reader = other_picture->start_read ();
142 shared_ptr<const StereoPictureFrame> frame_A;
143 shared_ptr<const StereoPictureFrame> frame_B;
145 frame_A = reader->get_frame (i);
146 frame_B = other_reader->get_frame (i);
151 note (NoteType::ERROR, e.what ());
155 if (!frame_buffer_equals (
157 frame_A->left()->data(), frame_A->left()->size(),
158 frame_B->left()->data(), frame_B->left()->size()
161 if (!opt.keep_going) {
166 if (!frame_buffer_equals (
168 frame_A->right()->data(), frame_A->right()->size(),
169 frame_B->right()->data(), frame_B->right()->size()
172 if (!opt.keep_going) {
boost::optional< boost::filesystem::path > file() const
A fraction (i.e. a thing with an integer numerator and an integer denominator).
An exception related to an MXF file.
boost::optional< Key > key() const
An asset made up of JPEG2000 data.
int64_t _intrinsic_duration
Any error that occurs when reading data from a DCP.
A helper class for writing to StereoPictureAssets.
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
StereoPictureAsset class.
StereoPictureAssetReader typedef.
StereoPictureAssetWriter class.
StereoPictureFrame class.
A class to describe what "equality" means for a particular test.