diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-09-27 11:35:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-09-27 11:35:53 +0100 |
| commit | f9474637db140eb3d9170185fc79437c8d9914b7 (patch) | |
| tree | 9f9e9eeaea1dd52c50f21869d8cb5e948787c4b7 /src/asset_reader.h | |
| parent | 8c7b705e318d888444e5156f627cdc48168d3ac7 (diff) | |
Use a template for AssetReader.
Diffstat (limited to 'src/asset_reader.h')
| -rw-r--r-- | src/asset_reader.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/asset_reader.h b/src/asset_reader.h index 09169a8e..1cfd9ea2 100644 --- a/src/asset_reader.h +++ b/src/asset_reader.h @@ -34,21 +34,43 @@ #ifndef LIBDCP_ASSET_READER_H #define LIBDCP_ASSET_READER_H +#include "dcp_assert.h" +#include "asset.h" +#include <asdcp/AS_DCP.h> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> namespace dcp { -class MXF; class DecryptionContext; +template <class R, class F> class AssetReader : public boost::noncopyable { public: - explicit AssetReader (MXF const * mxf); - virtual ~AssetReader () {} + explicit AssetReader (Asset const * asset) + { + _reader = new R (); + DCP_ASSERT (asset->file ()); + Kumu::Result_t 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 () + { + delete _reader; + } + + boost::shared_ptr<const F> get_frame (int n) const + { + return boost::shared_ptr<const F> (new F (_reader, n, _decryption_context)); + } protected: + R* _reader; boost::shared_ptr<DecryptionContext> _decryption_context; }; |
