_directory,
n,
_fps,
- _length,
- cpl_assets->main_picture->screen_aspect_ratio.numerator,
- cpl_assets->main_picture->screen_aspect_ratio.denominator
+ _length
)
));
- n = cpl_assets->main_sound->annotation_text;
- if (n.empty ()) {
- n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name;
- }
-
if (cpl_assets->main_sound) {
+
+ n = cpl_assets->main_sound->annotation_text;
+ if (n.empty ()) {
+ n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name;
+ }
+
_assets.push_back (shared_ptr<SoundAsset> (
new SoundAsset (
_directory,
construct (sigc::bind (sigc::mem_fun (*this, &PictureAsset::path_from_list), files));
}
-PictureAsset::PictureAsset (string directory, string mxf_name, int fps, int length, int width, int height)
+PictureAsset::PictureAsset (string directory, string mxf_name, int fps, int length)
: Asset (directory, mxf_name, 0, fps, length)
- , _width (width)
- , _height (height)
{
+ ASDCP::JP2K::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::JP2K::PictureDescriptor desc;
+ if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
+ throw DCPReadError ("could not read video MXF information");
+ }
+
+ _width = desc.StoredWidth;
+ _height = desc.StoredHeight;
}
int height
);
- PictureAsset (std::string directory, std::string mxf_name, int fps, int length, int width, int height);
+ PictureAsset (std::string directory, std::string mxf_name, int fps, int length);
/** Write details of this asset to a CPL stream.
* @param s Stream.
#include "sound_asset.h"
#include "util.h"
#include "exceptions.h"
+#include "sound_frame.h"
using namespace std;
using namespace boost;
)
: Asset (directory, mxf_name, progress, fps, length)
, _channels (files.size ())
+ , _sampling_rate (0)
{
construct (sigc::bind (sigc::mem_fun (*this, &SoundAsset::path_from_channel), files));
}
)
: Asset (directory, mxf_name, progress, fps, length)
, _channels (channels)
+ , _sampling_rate (0)
{
construct (get_path);
}
: Asset (directory, mxf_name, 0, fps, length)
, _channels (0)
{
+ 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");
+ }
+ _sampling_rate = desc.AudioSamplingRate.Numerator / desc.AudioSamplingRate.Denominator;
+ _channels = desc.ChannelCount;
}
string
return notes;
}
-
-int
-SoundAsset::sampling_rate () const
+shared_ptr<const SoundFrame>
+SoundAsset::get_frame (int n) 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;
+ return shared_ptr<const SoundFrame> (new SoundFrame (mxf_path().string(), n));
}
-
namespace libdcp
{
+class SoundFrame;
+
/** @brief An asset made up of WAV files */
class SoundAsset : public Asset
{
std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
+ boost::shared_ptr<const SoundFrame> get_frame (int n) const;
+
int channels () const {
return _channels;
}
- int sampling_rate () const;
+ int sampling_rate () const {
+ return _sampling_rate;
+ }
private:
void construct (sigc::slot<std::string, Channel> get_path);
/** Number of channels in the asset */
int _channels;
+ int _sampling_rate;
};
}
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "AS_DCP.h"
+#include "KM_fileio.h"
+#include "sound_frame.h"
+#include "exceptions.h"
+
+using namespace std;
+using namespace libdcp;
+
+SoundFrame::SoundFrame (string mxf_path, int n)
+{
+ ASDCP::PCM::MXFReader reader;
+ if (ASDCP_FAILURE (reader.OpenRead (mxf_path.c_str()))) {
+ throw FileError ("could not open MXF file for reading", mxf_path);
+ }
+
+ /* XXX: unfortunate guesswork on this buffer size */
+ _buffer = new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte);
+
+ if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer))) {
+ throw DCPReadError ("could not read audio frame");
+ }
+}
+
+SoundFrame::~SoundFrame ()
+{
+ delete _buffer;
+}
+
+uint8_t const *
+SoundFrame::data () const
+{
+ return _buffer->RoData();
+}
+
+int
+SoundFrame::size () const
+{
+ return _buffer->Size ();
+}
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <string>
+#include <stdint.h>
+
+namespace ASDCP {
+ namespace PCM {
+ class FrameBuffer;
+ }
+}
+
+namespace libdcp {
+
+class SoundFrame
+{
+public:
+ SoundFrame (std::string mxf_path, int n);
+ ~SoundFrame ();
+
+ uint8_t const * data () const;
+ int size () const;
+
+private:
+ ASDCP::PCM::FrameBuffer* _buffer;
+};
+
+}
test_mode.cc
types.cc
xml.cc
+ sound_frame.cc
"""
headers = """
sound_asset.h
asset.h
picture_frame.h
+ sound_frame.h
"""
bld.install_files('${PREFIX}/include/libdcp', headers)