diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-09-27 11:22:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-09-27 11:22:03 +0100 |
| commit | 8c7b705e318d888444e5156f627cdc48168d3ac7 (patch) | |
| tree | a2afbcce25fc53f6438a834dff856cb8172ff096 /src | |
| parent | 618962440a3474ab304772cda7b6aed08bb6a00a (diff) | |
Use a template as a basis for Frames.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame.h (renamed from src/sound_frame.cc) | 61 | ||||
| -rw-r--r-- | src/sound_asset.h | 2 | ||||
| -rw-r--r-- | src/sound_asset_reader.h | 2 | ||||
| -rw-r--r-- | src/sound_asset_writer.h | 2 | ||||
| -rw-r--r-- | src/sound_frame.h | 36 | ||||
| -rw-r--r-- | src/wscript | 1 |
6 files changed, 38 insertions, 66 deletions
diff --git a/src/sound_frame.cc b/src/frame.h index 132d25bd..54b74e55 100644 --- a/src/sound_frame.cc +++ b/src/frame.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,42 +31,45 @@ files in the program, then also delete it here. */ -/** @file src/sound_frame.cc - * @brief SoundFrame class. - */ - -#include "sound_frame.h" -#include "exceptions.h" #include "decryption_context.h" -#include <asdcp/AS_DCP.h> +#include "exceptions.h" #include <asdcp/KM_fileio.h> +#include <asdcp/AS_DCP.h> +#include <boost/noncopyable.hpp> -using namespace dcp; -using boost::shared_ptr; +namespace dcp { -SoundFrame::SoundFrame (ASDCP::PCM::MXFReader* reader, int n, shared_ptr<DecryptionContext> c) +template <class R, class B> +class Frame : public boost::noncopyable { - /* XXX: unfortunate guesswork on this buffer size */ - _buffer = new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte); +public: + Frame (R* reader, int n, boost::shared_ptr<const DecryptionContext> c) + { + /* XXX: unfortunate guesswork on this buffer size */ + _buffer = new B (Kumu::Megabyte); - if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->decryption()))) { - boost::throw_exception (DCPReadError ("could not read audio frame")); + if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->decryption()))) { + boost::throw_exception (DCPReadError ("could not read frame")); + } } -} -SoundFrame::~SoundFrame () -{ - delete _buffer; -} + ~Frame () + { + delete _buffer; + } -uint8_t const * -SoundFrame::data () const -{ - return _buffer->RoData(); -} + uint8_t const * data () const + { + return _buffer->RoData (); + } + + int size () const + { + return _buffer->Size (); + } + +private: + B* _buffer; +}; -int -SoundFrame::size () const -{ - return _buffer->Size (); } diff --git a/src/sound_asset.h b/src/sound_asset.h index a29eecd0..9278eeee 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -41,11 +41,11 @@ #include "mxf.h" #include "types.h" #include "metadata.h" +#include "sound_frame.h" namespace dcp { -class SoundFrame; class SoundAssetWriter; class SoundAssetReader; diff --git a/src/sound_asset_reader.h b/src/sound_asset_reader.h index 5a02322c..b2213b59 100644 --- a/src/sound_asset_reader.h +++ b/src/sound_asset_reader.h @@ -32,6 +32,7 @@ */ #include "asset_reader.h" +#include "sound_frame.h" #include <boost/shared_ptr.hpp> namespace ASDCP { @@ -42,7 +43,6 @@ namespace ASDCP { namespace dcp { -class SoundFrame; class SoundAsset; class SoundAssetReader : public AssetReader diff --git a/src/sound_asset_writer.h b/src/sound_asset_writer.h index 02639423..95d13855 100644 --- a/src/sound_asset_writer.h +++ b/src/sound_asset_writer.h @@ -37,12 +37,12 @@ #include "asset_writer.h" #include "types.h" +#include "sound_frame.h" #include <boost/shared_ptr.hpp> #include <boost/filesystem.hpp> namespace dcp { -class SoundFrame; class SoundAsset; /** @class SoundAssetWriter diff --git a/src/sound_frame.h b/src/sound_frame.h index 3cd3246b..2b78c8e1 100644 --- a/src/sound_frame.h +++ b/src/sound_frame.h @@ -38,42 +38,12 @@ #ifndef LIBDCP_SOUND_FRAME_H #define LIBDCP_SOUND_FRAME_H -#include <boost/noncopyable.hpp> -#include <boost/filesystem.hpp> -#include <stdint.h> -#include <string> - -namespace ASDCP { - namespace PCM { - class FrameBuffer; - class MXFReader; - } - class AESDecContext; -} +#include "frame.h" +#include <asdcp/AS_DCP.h> namespace dcp { -class DecryptionContext; - -/** @class SoundFrame - * @brief One ‘frame’ of sound data from a SoundAsset. - */ -class SoundFrame : public boost::noncopyable -{ -public: - ~SoundFrame (); - - uint8_t const * data () const; - int size () const; - -private: - friend class SoundAssetReader; - - SoundFrame (ASDCP::PCM::MXFReader* reader, int n, boost::shared_ptr<DecryptionContext>); - - /** a buffer to hold the frame */ - ASDCP::PCM::FrameBuffer* _buffer; -}; +typedef Frame<ASDCP::PCM::MXFReader, ASDCP::PCM::FrameBuffer> SoundFrame; } diff --git a/src/wscript b/src/wscript index 489d669e..dfb106be 100644 --- a/src/wscript +++ b/src/wscript @@ -90,7 +90,6 @@ def build(bld): sound_asset.cc sound_asset_reader.cc sound_asset_writer.cc - sound_frame.cc stereo_picture_asset.cc stereo_picture_asset_reader.cc stereo_picture_asset_writer.cc |
