44 #include "compose.hpp"
46 #include <asdcp/AS_DCP.h>
51 using std::shared_ptr;
55 struct AtmosAssetWriter::ASDCPState
57 ASDCP::ATMOS::MXFWriter mxf_writer;
58 ASDCP::DCData::FrameBuffer frame_buffer;
59 ASDCP::WriterInfo writer_info;
60 ASDCP::ATMOS::AtmosDescriptor desc;
64 AtmosAssetWriter::AtmosAssetWriter (
AtmosAsset* asset, boost::filesystem::path file)
69 _state->desc.EditRate = ASDCP::Rational (_asset->edit_rate().numerator, _asset->edit_rate().denominator);
70 _state->desc.FirstFrame = _asset->first_frame ();
71 _state->desc.MaxChannelCount = _asset->max_channel_count ();
72 _state->desc.MaxObjectCount = _asset->max_object_count ();
75 Kumu::hex2bin (_asset->atmos_id().c_str(), _state->desc.AtmosID, ASDCP::UUIDlen, &c);
76 DCP_ASSERT (c == ASDCP::UUIDlen);
78 _state->desc.AtmosVersion = _asset->atmos_version ();
80 _asset->fill_writer_info (&_state->writer_info, _asset->id());
85 AtmosAssetWriter::write (shared_ptr<const AtmosFrame> frame)
87 write (frame->data(), frame->size());
92 AtmosAssetWriter::write (uint8_t
const * data,
int size)
97 auto r = _state->mxf_writer.OpenWrite (
_file.string().c_str(), _state->writer_info, _state->desc);
98 if (ASDCP_FAILURE(r)) {
99 boost::throw_exception (
FileError (
"could not open atmos MXF for writing",
_file.string(), r));
106 _state->frame_buffer.Capacity (size);
107 _state->frame_buffer.Size (size);
108 memcpy (_state->frame_buffer.Data(), data, size);
110 auto const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
111 if (ASDCP_FAILURE(r)) {
112 boost::throw_exception (
MiscError(String::compose(
"could not write atmos MXF frame (%1)",
static_cast<int>(r))));
122 if (
_started && ASDCP_FAILURE(_state->mxf_writer.Finalize())) {
123 boost::throw_exception (
MiscError(
"could not finalise atmos MXF"));
Parent class for classes which can write MXF-based assets.
boost::filesystem::path _file
void set_file(boost::filesystem::path file) const
A helper class for writing to AtmosAssets.
An asset of Dolby ATMOS sound data.
An exception related to a file.
A miscellaneous exception.
Exceptions thrown by libdcp.
Namespace for everything in libdcp.