/*
- Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
files in the program, then also delete it here.
*/
+
#include "atmos_asset_writer.h"
#include "atmos_asset.h"
#include "exceptions.h"
#include "crypto_context.h"
#include <asdcp/AS_DCP.h>
+
using std::min;
using std::max;
using std::shared_ptr;
using namespace dcp;
+
struct AtmosAssetWriter::ASDCPState
{
ASDCP::ATMOS::MXFWriter mxf_writer;
ASDCP::ATMOS::AtmosDescriptor desc;
};
+
AtmosAssetWriter::AtmosAssetWriter (AtmosAsset* asset, boost::filesystem::path file)
: AssetWriter (asset, file)
, _state (new AtmosAssetWriter::ASDCPState)
DCP_ASSERT (!_finalized);
if (!_started) {
- Kumu::Result_t r = _state->mxf_writer.OpenWrite (_file.string().c_str(), _state->writer_info, _state->desc);
- if (ASDCP_FAILURE (r)) {
+ auto r = _state->mxf_writer.OpenWrite (_file.string().c_str(), _state->writer_info, _state->desc);
+ if (ASDCP_FAILURE(r)) {
boost::throw_exception (FileError ("could not open atmos MXF for writing", _file.string(), r));
}
_state->frame_buffer.Size (size);
memcpy (_state->frame_buffer.Data(), data, size);
- ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MiscError (String::compose ("could not write atmos MXF frame (%1)", int (r))));
+ auto const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
+ if (ASDCP_FAILURE(r)) {
+ boost::throw_exception (MiscError(String::compose("could not write atmos MXF frame (%1)", static_cast<int>(r))));
}
++_frames_written;
bool
AtmosAssetWriter::finalize ()
{
- if (_started && ASDCP_FAILURE (_state->mxf_writer.Finalize())) {
- boost::throw_exception (MiscError ("could not finalise atmos MXF"));
+ if (_started && ASDCP_FAILURE(_state->mxf_writer.Finalize())) {
+ boost::throw_exception (MiscError("could not finalise atmos MXF"));
}
_asset->_intrinsic_duration = _frames_written;