summaryrefslogtreecommitdiff
path: root/src/asset_reader.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-09-28 19:15:03 +0100
committerCarl Hetherington <cth@carlh.net>2016-09-28 19:15:03 +0100
commiteb772d227c378e17c99b5d609b81d0cc4b664d2c (patch)
treeccc3b4c75316d76fd441767e29ed1e0d8d3908a6 /src/asset_reader.h
parentfba372ef15a9dd9c6f840e5c03bdb85146657955 (diff)
parent5aba207171b7f1da91968bf2197c5668e8aacb4e (diff)
Merge branch '1.0' of ssh://main.carlh.net/home/carl/git/libdcp into 1.0
Diffstat (limited to 'src/asset_reader.h')
-rw-r--r--src/asset_reader.h30
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;
};