diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
| commit | ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 (patch) | |
| tree | c55e4b85ee30138ce83263045d77d01631378b2e /src/asset_reader.h | |
| parent | 6c37cc1979b2a01205a888c4c98f3334685ee8dd (diff) | |
Tidying.
Diffstat (limited to 'src/asset_reader.h')
| -rw-r--r-- | src/asset_reader.h | 42 |
1 files changed, 30 insertions, 12 deletions
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 R, class F> class AssetReader { public: - explicit AssetReader (Asset const * asset, boost::optional<Key> 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<const F> get_frame (int n) const { + /* Can't use make_shared here as the constructor is private */ return std::shared_ptr<const F> (new F(_reader, n, _crypto_context)); } @@ -82,6 +82,24 @@ public: protected: R* _reader = nullptr; std::shared_ptr<DecryptionContext> _crypto_context; + +private: + friend class AtmosAsset; + friend class MonoPictureAsset; + friend class SoundAsset; + friend class StereoPictureAsset; + + explicit AssetReader (Asset const * asset, boost::optional<Key> 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)); + } + } }; |
