X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsound_asset.cc;h=a8b6372748c83069221fc95790bc5b8b36f6215e;hb=bc09fbc79580f56c93e35de25230af18b30e0e1e;hp=71d1d9ff0a29e0f5185a98ea818e1c677da7cfb3;hpb=8d94e57248b7957d62350083a93aa479457f9385;p=libdcp.git diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 71d1d9ff..a8b63727 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -232,7 +232,7 @@ SoundAsset::equals (shared_ptr other, EqualityOptions opt) const } if (buffer_A.Size() != buffer_B.Size()) { - notes.push_back ("sizes of video data for frame " + lexical_cast(i) + " differ"); + notes.push_back ("sizes of audio data for frame " + lexical_cast(i) + " differ"); continue; } @@ -245,3 +245,22 @@ SoundAsset::equals (shared_ptr other, EqualityOptions opt) const return notes; } + + +int +SoundAsset::sampling_rate () const +{ + ASDCP::PCM::MXFReader reader; + if (ASDCP_FAILURE (reader.OpenRead (mxf_path().string().c_str()))) { + throw FileError ("could not open MXF file for reading", mxf_path().string()); + } + + + ASDCP::PCM::AudioDescriptor desc; + if (ASDCP_FAILURE (reader.FillAudioDescriptor (desc))) { + throw DCPReadError ("could not read audio MXF information"); + } + + return desc.AudioSamplingRate.Numerator / desc.AudioSamplingRate.Denominator; +} +