summaryrefslogtreecommitdiff
path: root/src/sound_frame.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sound_frame.cc')
-rw-r--r--src/sound_frame.cc38
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;
+ }
}
}