diff options
Diffstat (limited to 'src/asset_reader.h')
| -rw-r--r-- | src/asset_reader.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/asset_reader.h b/src/asset_reader.h index 09169a8e..eaf2721a 100644 --- a/src/asset_reader.h +++ b/src/asset_reader.h @@ -34,21 +34,45 @@ #ifndef LIBDCP_ASSET_READER_H #define LIBDCP_ASSET_READER_H +#include "dcp_assert.h" +#include "asset.h" +#include "decryption_context.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, boost::optional<Key> key) + : _decryption_context (new DecryptionContext (key)) + { + _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; }; |
