From ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 24 Jan 2021 04:15:26 +0100 Subject: Tidying. --- src/asset_reader.h | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'src/asset_reader.h') diff --git a/src/asset_reader.h b/src/asset_reader.h index 859c88f3..2da67bd8 100644 --- a/src/asset_reader.h +++ b/src/asset_reader.h @@ -32,6 +32,11 @@ */ +/** @file src/asset_reader.h + * @brief AssetReader class + */ + + #ifndef LIBDCP_ASSET_READER_H #define LIBDCP_ASSET_READER_H @@ -46,22 +51,16 @@ namespace dcp { +class AtmosAsset; +class MonoPictureAsset; +class SoundAsset; +class StereoPictureAsset; + + template class AssetReader { public: - explicit AssetReader (Asset const * asset, boost::optional key, Standard standard) - : _crypto_context (new DecryptionContext(key, standard)) - { - _reader = new R (); - DCP_ASSERT (asset->file()); - auto const r = _reader->OpenRead (asset->file()->string().c_str()); - if (ASDCP_FAILURE(r)) { - delete _reader; - boost::throw_exception (FileError("could not open MXF file for reading", asset->file().get(), r)); - } - } - AssetReader (AssetReader const&) = delete; AssetReader& operator== (AssetReader const&) = delete; @@ -72,6 +71,7 @@ public: std::shared_ptr get_frame (int n) const { + /* Can't use make_shared here as the constructor is private */ return std::shared_ptr (new F(_reader, n, _crypto_context)); } @@ -82,6 +82,24 @@ public: protected: R* _reader = nullptr; std::shared_ptr _crypto_context; + +private: + friend class AtmosAsset; + friend class MonoPictureAsset; + friend class SoundAsset; + friend class StereoPictureAsset; + + explicit AssetReader (Asset const * asset, boost::optional key, Standard standard) + : _crypto_context (new DecryptionContext(key, standard)) + { + _reader = new R (); + DCP_ASSERT (asset->file()); + auto const r = _reader->OpenRead (asset->file()->string().c_str()); + if (ASDCP_FAILURE(r)) { + delete _reader; + boost::throw_exception (FileError("could not open MXF file for reading", asset->file().get(), r)); + } + } }; -- cgit v1.2.3