projects
/
libdcp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unpick MXF from the class hierarchy.
[libdcp.git]
/
src
/
sound_mxf.cc
diff --git
a/src/sound_mxf.cc
b/src/sound_mxf.cc
index 5ce72b1da719f5d89d39cb3f6b3ded48318f8422..19a30bff9287eb7784fb55f2554ec2bbc3ac5796 100644
(file)
--- a/
src/sound_mxf.cc
+++ b/
src/sound_mxf.cc
@@
-17,8
+17,8
@@
*/
*/
-/** @file src/sound_
asset
.cc
- * @brief
An asset made up of WAV files
+/** @file src/sound_
mxf
.cc
+ * @brief
SoundMXF class.
*/
#include "sound_mxf.h"
*/
#include "sound_mxf.h"
@@
-26,11
+26,12
@@
#include "exceptions.h"
#include "sound_frame.h"
#include "sound_mxf_writer.h"
#include "exceptions.h"
#include "sound_frame.h"
#include "sound_mxf_writer.h"
+#include "compose.hpp"
#include "KM_fileio.h"
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "AS_DCP.h"
+#include "dcp_assert.h"
#include <libxml++/nodes/element.h>
#include <boost/filesystem.hpp>
#include <libxml++/nodes/element.h>
#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
#include <iostream>
#include <stdexcept>
#include <iostream>
#include <stdexcept>
@@
-40,11
+41,11
@@
using std::ostream;
using std::vector;
using std::list;
using boost::shared_ptr;
using std::vector;
using std::list;
using boost::shared_ptr;
-using boost::lexical_cast;
using namespace dcp;
SoundMXF::SoundMXF (boost::filesystem::path file)
using namespace dcp;
SoundMXF::SoundMXF (boost::filesystem::path file)
- : MXF (file)
+ : Asset (file)
+ , _intrinsic_duration (0)
, _channels (0)
, _sampling_rate (0)
{
, _channels (0)
, _sampling_rate (0)
{
@@
-64,10
+65,18
@@
SoundMXF::SoundMXF (boost::filesystem::path file)
_edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator);
_intrinsic_duration = desc.ContainerDuration;
_edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator);
_intrinsic_duration = desc.ContainerDuration;
+
+ ASDCP::WriterInfo info;
+ if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
+ boost::throw_exception (DCPReadError ("could not read audio MXF information"));
+ }
+
+ _id = read_writer_info (info);
}
SoundMXF::SoundMXF (Fraction edit_rate, int sampling_rate, int channels)
}
SoundMXF::SoundMXF (Fraction edit_rate, int sampling_rate, int channels)
- : MXF (edit_rate)
+ : _edit_rate (edit_rate)
+ , _intrinsic_duration (0)
, _channels (channels)
, _sampling_rate (sampling_rate)
{
, _channels (channels)
, _sampling_rate (sampling_rate)
{
@@
-75,12
+84,8
@@
SoundMXF::SoundMXF (Fraction edit_rate, int sampling_rate, int channels)
}
bool
}
bool
-SoundMXF::equals (shared_ptr<const
Content> other, EqualityOptions opt, boost::function<void (NoteType, string)>
note) const
+SoundMXF::equals (shared_ptr<const
Asset> other, EqualityOptions opt, NoteHandler
note) const
{
{
- if (!MXF::equals (other, opt, note)) {
- return false;
- }
-
ASDCP::PCM::MXFReader reader_A;
Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
ASDCP::PCM::MXFReader reader_A;
Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
@@
-115,7
+120,7
@@
SoundMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::f
// desc_A.ChannelFormat != desc_B.ChannelFormat ||
) {
// desc_A.ChannelFormat != desc_B.ChannelFormat ||
) {
- note (ERROR, "audio MXF picture descriptors differ");
+ note (
DCP_
ERROR, "audio MXF picture descriptors differ");
return false;
}
return false;
}
@@
-132,7
+137,7
@@
SoundMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::f
}
if (buffer_A.Size() != buffer_B.Size()) {
}
if (buffer_A.Size() != buffer_B.Size()) {
- note (
ERROR, "sizes of audio data for frame " + lexical_cast<string>(i) + " differ"
);
+ note (
DCP_ERROR, String::compose ("sizes of audio data for frame %1 differ", i)
);
return false;
}
return false;
}
@@
-140,7
+145,7
@@
SoundMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::f
for (uint32_t i = 0; i < buffer_A.Size(); ++i) {
int const d = abs (buffer_A.RoData()[i] - buffer_B.RoData()[i]);
if (d > opt.max_audio_sample_error) {
for (uint32_t i = 0; i < buffer_A.Size(); ++i) {
int const d = abs (buffer_A.RoData()[i] - buffer_B.RoData()[i]);
if (d > opt.max_audio_sample_error) {
- note (
ERROR, "PCM data difference of " + lexical_cast<string> (
d));
+ note (
DCP_ERROR, String::compose ("PCM data difference of %1",
d));
return false;
}
}
return false;
}
}
@@
-154,7
+159,7
@@
shared_ptr<const SoundFrame>
SoundMXF::get_frame (int n) const
{
/* XXX: should add on entry point here? */
SoundMXF::get_frame (int n) const
{
/* XXX: should add on entry point here? */
- return shared_ptr<const SoundFrame> (new SoundFrame (file()
.string()
, n, _decryption_context));
+ return shared_ptr<const SoundFrame> (new SoundFrame (file(), n, _decryption_context));
}
shared_ptr<SoundMXFWriter>
}
shared_ptr<SoundMXFWriter>
@@
-165,7
+170,14
@@
SoundMXF::start_write (boost::filesystem::path file, Standard standard)
}
string
}
string
-SoundMXF::
key_type (
) const
+SoundMXF::
pkl_type (Standard standard
) const
{
{
- return "MDAK";
+ switch (standard) {
+ case INTEROP:
+ return "application/x-smpte-mxf;asdcpKind=Sound";
+ case SMPTE:
+ return "application/mxf";
+ default:
+ DCP_ASSERT (false);
+ }
}
}