46 LIBDCP_DISABLE_WARNINGS
47 #include <asdcp/AS_DCP.h>
48 #include <asdcp/KM_fileio.h>
49 LIBDCP_ENABLE_WARNINGS
56 using std::shared_ptr;
62 ASDCP::JP2K::MXFWriter mxf_writer;
77 MonoJ2KPictureAssetWriter::~MonoJ2KPictureAssetWriter()
82 _state->mxf_writer.Finalize();
89 MonoJ2KPictureAssetWriter::start (uint8_t
const * data,
int size)
91 dcp::start (
this, _state, _picture_asset, data, size);
92 _picture_asset->set_frame_rate (_picture_asset->edit_rate());
97 MonoJ2KPictureAssetWriter::write (uint8_t
const * data,
int size)
105 if (ASDCP_FAILURE (_state->j2k_parser.OpenReadFrame(data, size, _state->frame_buffer))) {
106 boost::throw_exception (
MiscError (
"could not parse J2K frame"));
109 _state->frame_buffer.PlaintextOffset(0);
111 uint64_t
const before_offset = _state->mxf_writer.Tell ();
114 auto const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac(), &hash);
115 if (ASDCP_FAILURE(r)) {
116 boost::throw_exception (
MXFFileError (
"error in writing video MXF",
_file.string(), r));
120 return J2KFrameInfo(before_offset, _state->mxf_writer.Tell() - before_offset, hash);
125 MonoJ2KPictureAssetWriter::fake_write(
J2KFrameInfo const& info)
130 auto r = _state->mxf_writer.FakeWriteFrame(info.size);
131 if (ASDCP_FAILURE(r)) {
132 boost::throw_exception (
MXFFileError(
"error in writing video MXF",
_file.string(), r));
143 auto r = _state->mxf_writer.Finalize();
144 if (ASDCP_FAILURE(r)) {
145 boost::throw_exception (
MXFFileError(
"error in finalizing video MXF",
_file.string(), r));
boost::filesystem::path _file
Parent class for classes which write picture assets.
An asset made up of JPEG2000 data.
An exception related to an MXF file.
A miscellaneous exception.
A helper class for writing to MonoJ2KPictureAssets.
MonoJ2KPictureAssetWriter(J2KPictureAsset *a, boost::filesystem::path file, bool)
int64_t _intrinsic_duration
Exceptions thrown by libdcp.
Common parts of J2KPictureAssetWriter.
MonoJ2KPictureAssetWriter class.
Namespace for everything in libdcp.