summaryrefslogtreecommitdiff
path: root/src/atmos_asset_writer.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-23 09:48:00 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-23 09:48:00 +0100
commita65c9be7a5c455111b44b24690fe162413268b9f (patch)
treee6ffc7792fe6040f3691695688ee5ce24b330458 /src/atmos_asset_writer.cc
parent302a059052e2e55345e91b5300e2389b87bd7f0a (diff)
Small bits of pre-release tidying.
Diffstat (limited to 'src/atmos_asset_writer.cc')
-rw-r--r--src/atmos_asset_writer.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/atmos_asset_writer.cc b/src/atmos_asset_writer.cc
index 8431086d..891a8c01 100644
--- a/src/atmos_asset_writer.cc
+++ b/src/atmos_asset_writer.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -31,6 +31,7 @@
files in the program, then also delete it here.
*/
+
#include "atmos_asset_writer.h"
#include "atmos_asset.h"
#include "exceptions.h"
@@ -39,11 +40,13 @@
#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;
@@ -52,6 +55,7 @@ struct AtmosAssetWriter::ASDCPState
ASDCP::ATMOS::AtmosDescriptor desc;
};
+
AtmosAssetWriter::AtmosAssetWriter (AtmosAsset* asset, boost::filesystem::path file)
: AssetWriter (asset, file)
, _state (new AtmosAssetWriter::ASDCPState)
@@ -85,8 +89,8 @@ AtmosAssetWriter::write (uint8_t const * data, int size)
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));
}
@@ -98,9 +102,9 @@ AtmosAssetWriter::write (uint8_t const * data, int size)
_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;
@@ -109,8 +113,8 @@ AtmosAssetWriter::write (uint8_t const * data, int size)
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;