return _digest;
}
-
-
-
+int
+Asset::length () const
+{
+ return _length;
+}
+
+
#define LIBDCP_ASSET_H
#include <string>
+#include <boost/filesystem.hpp>
#include <sigc++/sigc++.h>
#include "types.h"
virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
+ int length () const;
+
protected:
friend class PictureAsset;
friend class SoundAsset;
return notes;
}
+
+shared_ptr<const PictureAsset>
+DCP::picture_asset () const
+{
+ for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
+ shared_ptr<PictureAsset> p = dynamic_pointer_cast<PictureAsset> (*i);
+ if (p) {
+ return p;
+ }
+ }
+
+ return shared_ptr<const PictureAsset> ();
+}
{
class Asset;
+class PictureAsset;
/** @class DCP dcp.h libdcp/dcp.h
* @brief A class to create or read a DCP.
return _length;
}
+ boost::shared_ptr<const PictureAsset> picture_asset () const;
+
std::list<std::string> equals (DCP const & other, EqualityOptions options) const;
/** Emitted with a parameter between 0 and 1 to indicate progress
#include "picture_asset.h"
#include "util.h"
#include "exceptions.h"
+#include "picture_frame.h"
using namespace std;
using namespace boost;
opj_cio_close (cio);
return image;
}
+
+shared_ptr<const PictureFrame>
+PictureAsset::get_frame (int n) const
+{
+ return shared_ptr<const PictureFrame> (new PictureFrame (mxf_path().string(), n));
+}
namespace libdcp
{
+class PictureFrame;
+
/** @brief An asset made up of JPEG2000 files */
class PictureAsset : public Asset
{
void write_to_cpl (std::ostream& s) const;
std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
+
+ boost::shared_ptr<const PictureFrame> get_frame (int n) const;
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
--- /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 "picture_frame.h"
+#include "exceptions.h"
+
+using namespace std;
+using namespace libdcp;
+
+PictureFrame::PictureFrame (string mxf_path, int n)
+{
+ ASDCP::JP2K::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::JP2K::FrameBuffer (4 * Kumu::Megabyte);
+
+ if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer))) {
+ throw DCPReadError ("could not read video frame");
+ }
+}
+
+PictureFrame::~PictureFrame ()
+{
+ delete _buffer;
+}
+
+uint8_t const *
+PictureFrame::data () const
+{
+ return _buffer->RoData();
+}
+
+int
+PictureFrame::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 libdcp {
+
+class PictureFrame
+{
+public:
+ PictureFrame (std::string mxf_path, int n);
+ ~PictureFrame ();
+
+ uint8_t const * data () const;
+ int size () const;
+
+private:
+ ASDCP::JP2K::FrameBuffer* _buffer;
+};
+
+}
dcp.cc
sound_asset.cc
picture_asset.cc
+ picture_frame.cc
pkl.cc
util.cc
metadata.cc
exceptions.h
test_mode.h
version.h
+ picture_asset.h
+ asset.h
"""
bld.install_files('${PREFIX}/include/libdcp', headers)