Still more licence fixups.
[libdcp.git] / src / stereo_picture_asset_reader.cc
1 /*
2     Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "stereo_picture_asset_reader.h"
21 #include "stereo_picture_asset.h"
22 #include "stereo_picture_frame.h"
23 #include "exceptions.h"
24 #include "AS_DCP.h"
25
26 using namespace dcp;
27 using boost::shared_ptr;
28
29 StereoPictureAssetReader::StereoPictureAssetReader (StereoPictureAsset const * asset)
30         : AssetReader (asset)
31 {
32         _reader = new ASDCP::JP2K::MXFSReader ();
33         Kumu::Result_t const r = _reader->OpenRead (asset->file().string().c_str());
34         if (ASDCP_FAILURE (r)) {
35                 delete _reader;
36                 boost::throw_exception (FileError ("could not open MXF file for reading", asset->file(), r));
37         }
38 }
39
40 StereoPictureAssetReader::~StereoPictureAssetReader ()
41 {
42         delete _reader;
43 }
44
45 shared_ptr<const StereoPictureFrame>
46 StereoPictureAssetReader::get_frame (int n) const
47 {
48         return shared_ptr<const StereoPictureFrame> (new StereoPictureFrame (_reader, n, _decryption_context));
49 }