summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-21 21:01:59 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-21 21:01:59 +0000
commitc21da9cdd8284e8d36a08bc7976744a3cd74bede (patch)
tree7d4f8a67e29e7f416eb8a498a0e2c76be9fe1a10 /src
parenta2c5f0ee3dca60fa3c593a55f9bf7f42f3aa88d4 (diff)
Try to remove need for asdcplib includes in libdcp headers.
Diffstat (limited to 'src')
-rw-r--r--src/picture_asset.cc30
-rw-r--r--src/picture_asset.h19
-rw-r--r--src/sound_asset.cc51
-rw-r--r--src/sound_asset.h17
4 files changed, 76 insertions, 41 deletions
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index a2f6b584..564ada79 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -400,11 +400,25 @@ MonoPictureAsset::start_write ()
return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this));
}
+struct MonoPictureAssetWriter::ASDCPState
+{
+ ASDCPState()
+ : frame_buffer (4 * Kumu::Megabyte)
+ {}
+
+ ASDCP::JP2K::CodestreamParser j2k_parser;
+ ASDCP::JP2K::FrameBuffer frame_buffer;
+ ASDCP::JP2K::MXFWriter mxf_writer;
+ ASDCP::WriterInfo writer_info;
+ ASDCP::JP2K::PictureDescriptor picture_descriptor;
+};
+
+
/** @param a Asset to write to. `a' must not be deleted while
* this writer class still exists, or bad things will happen.
*/
MonoPictureAssetWriter::MonoPictureAssetWriter (MonoPictureAsset* a)
- : _frame_buffer (4 * Kumu::Megabyte)
+ : _state (new MonoPictureAssetWriter::ASDCPState)
, _asset (a)
, _frames_written (0)
, _finalized (false)
@@ -417,24 +431,24 @@ MonoPictureAssetWriter::write (uint8_t* data, int size)
{
assert (!_finalized);
- if (ASDCP_FAILURE (_j2k_parser.OpenReadFrame (data, size, _frame_buffer))) {
+ if (ASDCP_FAILURE (_state->j2k_parser.OpenReadFrame (data, size, _state->frame_buffer))) {
throw MiscError ("could not parse J2K frame");
}
if (_frames_written == 0) {
/* This is our first frame; set up the writer */
- _j2k_parser.FillPictureDescriptor (_picture_descriptor);
- _picture_descriptor.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
+ _state->j2k_parser.FillPictureDescriptor (_state->picture_descriptor);
+ _state->picture_descriptor.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
- MXFAsset::fill_writer_info (&_writer_info, _asset->uuid());
+ MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid());
- if (ASDCP_FAILURE (_mxf_writer.OpenWrite (_asset->path().c_str(), _writer_info, _picture_descriptor))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.OpenWrite (_asset->path().c_str(), _state->writer_info, _state->picture_descriptor))) {
throw MXFFileError ("could not open MXF file for writing", _asset->path().string());
}
}
- if (ASDCP_FAILURE (_mxf_writer.WriteFrame (_frame_buffer, 0, 0))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0))) {
throw MiscError ("error in writing video MXF");
}
@@ -444,7 +458,7 @@ MonoPictureAssetWriter::write (uint8_t* data, int size)
void
MonoPictureAssetWriter::finalize ()
{
- if (ASDCP_FAILURE (_mxf_writer.Finalize())) {
+ if (ASDCP_FAILURE (_state->mxf_writer.Finalize())) {
throw MiscError ("error in finalizing video MXF");
}
diff --git a/src/picture_asset.h b/src/picture_asset.h
index ea558e7d..71900200 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -22,7 +22,6 @@
*/
#include <openjpeg.h>
-#include "AS_DCP.h"
#include "mxf_asset.h"
#include "util.h"
@@ -100,14 +99,20 @@ public:
private:
friend class MonoPictureAsset;
-
+
MonoPictureAssetWriter (MonoPictureAsset *);
- ASDCP::JP2K::CodestreamParser _j2k_parser;
- ASDCP::JP2K::FrameBuffer _frame_buffer;
- ASDCP::JP2K::MXFWriter _mxf_writer;
- ASDCP::WriterInfo _writer_info;
- ASDCP::JP2K::PictureDescriptor _picture_descriptor;
+ /* no copy construction */
+ MonoPictureAssetWriter (MonoPictureAssetWriter const &);
+ MonoPictureAssetWriter& operator= (MonoPictureAssetWriter const &);
+
+ /* do this with an opaque pointer so we don't have to include
+ ASDCP headers
+ */
+
+ struct ASDCPState;
+ boost::shared_ptr<ASDCPState> _state;
+
MonoPictureAsset* _asset;
/** Number of picture frames written to the asset so far */
int _frames_written;
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 2ed18312..08ca71e5 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -321,30 +321,39 @@ SoundAsset::start_write ()
return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this));
}
+struct SoundAssetWriter::ASDCPState
+{
+ ASDCP::PCM::MXFWriter mxf_writer;
+ ASDCP::PCM::FrameBuffer frame_buffer;
+ ASDCP::WriterInfo writer_info;
+ ASDCP::PCM::AudioDescriptor audio_desc;
+};
+
SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
- : _asset (a)
+ : _state (new SoundAssetWriter::ASDCPState)
+ , _asset (a)
, _finalized (false)
, _frames_written (0)
, _frame_buffer_offset (0)
{
/* Derived from ASDCP::Wav::SimpleWaveHeader::FillADesc */
- _audio_desc.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
- _audio_desc.AudioSamplingRate = ASDCP::Rational (_asset->sampling_rate(), 1);
- _audio_desc.Locked = 0;
- _audio_desc.ChannelCount = _asset->channels ();
- _audio_desc.QuantizationBits = 24;
- _audio_desc.BlockAlign = 3 * _asset->channels();
- _audio_desc.AvgBps = _asset->sampling_rate() * _audio_desc.BlockAlign;
- _audio_desc.LinkedTrackID = 0;
- _audio_desc.ChannelFormat = ASDCP::PCM::CF_NONE;
+ _state->audio_desc.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
+ _state->audio_desc.AudioSamplingRate = ASDCP::Rational (_asset->sampling_rate(), 1);
+ _state->audio_desc.Locked = 0;
+ _state->audio_desc.ChannelCount = _asset->channels ();
+ _state->audio_desc.QuantizationBits = 24;
+ _state->audio_desc.BlockAlign = 3 * _asset->channels();
+ _state->audio_desc.AvgBps = _asset->sampling_rate() * _state->audio_desc.BlockAlign;
+ _state->audio_desc.LinkedTrackID = 0;
+ _state->audio_desc.ChannelFormat = ASDCP::PCM::CF_NONE;
- _frame_buffer.Capacity (ASDCP::PCM::CalcFrameBufferSize (_audio_desc));
- _frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (_audio_desc));
- memset (_frame_buffer.Data(), 0, _frame_buffer.Capacity());
+ _state->frame_buffer.Capacity (ASDCP::PCM::CalcFrameBufferSize (_state->audio_desc));
+ _state->frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (_state->audio_desc));
+ memset (_state->frame_buffer.Data(), 0, _state->frame_buffer.Capacity());
- MXFAsset::fill_writer_info (&_writer_info, _asset->uuid ());
+ MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid ());
- if (ASDCP_FAILURE (_mxf_writer.OpenWrite (_asset->path().c_str(), _writer_info, _audio_desc))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.OpenWrite (_asset->path().c_str(), _state->writer_info, _state->audio_desc))) {
throw FileError ("could not open audio MXF for writing", _asset->path().string());
}
}
@@ -354,7 +363,7 @@ SoundAssetWriter::write (float const * const * data, int frames)
{
for (int i = 0; i < frames; ++i) {
- byte_t* out = _frame_buffer.Data() + _frame_buffer_offset;
+ byte_t* out = _state->frame_buffer.Data() + _frame_buffer_offset;
/* Write one sample per channel */
for (int j = 0; j < _asset->channels(); ++j) {
@@ -365,13 +374,13 @@ SoundAssetWriter::write (float const * const * data, int frames)
}
_frame_buffer_offset += 3 * _asset->channels();
- assert (_frame_buffer_offset <= int (_frame_buffer.Capacity()));
+ assert (_frame_buffer_offset <= int (_state->frame_buffer.Capacity()));
/* Finish the MXF frame if required */
- if (_frame_buffer_offset == int (_frame_buffer.Capacity())) {
+ if (_frame_buffer_offset == int (_state->frame_buffer.Capacity())) {
write_current_frame ();
_frame_buffer_offset = 0;
- memset (_frame_buffer.Data(), 0, _frame_buffer.Capacity());
+ memset (_state->frame_buffer.Data(), 0, _state->frame_buffer.Capacity());
}
}
}
@@ -379,7 +388,7 @@ SoundAssetWriter::write (float const * const * data, int frames)
void
SoundAssetWriter::write_current_frame ()
{
- if (ASDCP_FAILURE (_mxf_writer.WriteFrame (_frame_buffer, 0, 0))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0))) {
throw MiscError ("could not write audio MXF frame");
}
@@ -393,7 +402,7 @@ SoundAssetWriter::finalize ()
write_current_frame ();
}
- if (ASDCP_FAILURE (_mxf_writer.Finalize())) {
+ if (ASDCP_FAILURE (_state->mxf_writer.Finalize())) {
throw MiscError ("could not finalise audio MXF");
}
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 17767b3a..e13c5028 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -24,7 +24,6 @@
* @brief An asset made up of PCM audio data files
*/
-#include "AS_DCP.h"
#include "mxf_asset.h"
#include "types.h"
@@ -47,16 +46,24 @@ private:
friend class SoundAsset;
SoundAssetWriter (SoundAsset *);
+
+ /* no copy construction */
+ SoundAssetWriter (SoundAssetWriter const &);
+ SoundAssetWriter& operator= (SoundAssetWriter const &);
+
void write_current_frame ();
+ /* do this with an opaque pointer so we don't have to include
+ ASDCP headers
+ */
+
+ struct ASDCPState;
+ boost::shared_ptr<ASDCPState> _state;
+
SoundAsset* _asset;
bool _finalized;
int _frames_written;
int _frame_buffer_offset;
- ASDCP::PCM::MXFWriter _mxf_writer;
- ASDCP::PCM::FrameBuffer _frame_buffer;
- ASDCP::WriterInfo _writer_info;
- ASDCP::PCM::AudioDescriptor _audio_desc;
};
/** @brief An asset made up of WAV files */