diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-05 01:24:19 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-05 01:24:19 +0000 |
| commit | 5ee3348142f4cfafdbcf2c9c833843d717affc11 (patch) | |
| tree | 1c97c80eeccc6b5f515a611e35dee35b21d3b09b /src/sound_frame.cc | |
| parent | 740938890d95e853cf13d4780a5d674c3d6c7f6f (diff) | |
Various IMF hacks.imf
Diffstat (limited to 'src/sound_frame.cc')
| -rw-r--r-- | src/sound_frame.cc | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/sound_frame.cc b/src/sound_frame.cc index 42c5ee17..c51491a7 100644 --- a/src/sound_frame.cc +++ b/src/sound_frame.cc @@ -24,24 +24,44 @@ #include "sound_frame.h" #include "exceptions.h" #include "AS_DCP.h" +#include "AS_02.h" #include "KM_fileio.h" using namespace std; using namespace dcp; -SoundFrame::SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c) +SoundFrame::SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c, AssetType type, Fraction edit_rate) + /* XXX: unfortunate guesswork on this buffer size */ + : _buffer (new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte)) { - ASDCP::PCM::MXFReader reader; - Kumu::Result_t r = reader.OpenRead (path.string().c_str()); - if (ASDCP_FAILURE (r)) { - boost::throw_exception (FileError ("could not open MXF file for reading", path, r)); + switch (type) { + case ASSET_DCP: + { + ASDCP::PCM::MXFReader reader; + Kumu::Result_t r = reader.OpenRead (path.string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open MXF file for reading", path, r)); + } + + if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) { + boost::throw_exception (PackageReadError ("could not read audio frame")); + } + break; } - /* XXX: unfortunate guesswork on this buffer size */ - _buffer = new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte); + case ASSET_IMP: + { + AS_02::PCM::MXFReader reader; + Kumu::Result_t r = reader.OpenRead (path.string().c_str(), ASDCP::Rational (edit_rate.numerator, edit_rate.denominator)); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open MXF file for reading", path, r)); + } - if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) { - boost::throw_exception (PackageReadError ("could not read audio frame")); + if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) { + boost::throw_exception (PackageReadError ("could not read audio frame")); + } + break; + } } } |
