45 #include <asdcp/AS_DCP.h>
46 #include <asdcp/KM_fileio.h>
53 using std::shared_ptr;
57 struct StereoPictureAssetWriter::ASDCPState :
public ASDCPStateBase
59 ASDCP::JP2K::MXFSWriter mxf_writer;
63 StereoPictureAssetWriter::StereoPictureAssetWriter (
PictureAsset* mxf, boost::filesystem::path file,
bool overwrite)
72 StereoPictureAssetWriter::start (uint8_t
const * data,
int size)
74 dcp::start (
this, _state, _picture_asset, data, size);
75 _picture_asset->set_frame_rate (
Fraction (_picture_asset->edit_rate().numerator * 2, _picture_asset->edit_rate().denominator));
88 if (ASDCP_FAILURE (_state->j2k_parser.OpenReadFrame (data, size, _state->frame_buffer))) {
89 boost::throw_exception (
MiscError (
"could not parse J2K frame"));
92 uint64_t
const before_offset = _state->mxf_writer.Tell ();
95 auto r = _state->mxf_writer.WriteFrame (
97 _next_eye == Eye::LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT,
98 _crypto_context->context(),
99 _crypto_context->hmac(),
103 if (ASDCP_FAILURE (r)) {
104 boost::throw_exception (
MXFFileError (
"error in writing video MXF",
_file.string(), r));
107 _next_eye = _next_eye == Eye::LEFT ? Eye::RIGHT : Eye::LEFT;
109 if (_next_eye == Eye::LEFT) {
113 return FrameInfo (before_offset, _state->mxf_writer.Tell() - before_offset, hash);
118 StereoPictureAssetWriter::fake_write (
int size)
123 auto r = _state->mxf_writer.FakeWriteFrame (size, _next_eye == Eye::LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT);
124 if (ASDCP_FAILURE(r)) {
125 boost::throw_exception (
MXFFileError(
"error in writing video MXF",
_file.string(), r));
128 _next_eye = _next_eye == Eye::LEFT ? Eye::RIGHT : Eye::LEFT;
129 if (_next_eye == Eye::LEFT) {
139 auto r = _state->mxf_writer.Finalize();
140 if (ASDCP_FAILURE(r)) {
141 boost::throw_exception (
MXFFileError(
"error in finalizing video MXF",
_file.string(), r));
boost::filesystem::path _file
A fraction (i.e. a thing with an integer numerator and an integer denominator).
An exception related to an MXF file.
A miscellaneous exception.
Parent class for classes which write picture assets.
An asset made up of JPEG2000 data.
int64_t _intrinsic_duration
A helper class for writing to StereoPictureAssets.
FrameInfo write(uint8_t const *data, int size) override
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
Common parts of PictureAssetWriter.
StereoPictureAssetWriter class.
Information about a single frame (either a monoscopic frame or a left or right eye stereoscopic frame...