# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES
-EXTRACT_ALL = YES
+EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
-EXTRACT_PRIVATE = NO
+EXTRACT_PRIVATE = YES
# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
# scope will be included in the documentation.
# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
# directory containing the font.
-DOT_FONTNAME = FreeSans.ttf
+DOT_FONTNAME =
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
@mainpage libdcp
-libdcp is a library to create Digital Cinema Packages (DCPs) from JPEG2000 and WAV files, and also to
-read and process existing DCPs.
+libdcp is a library to create Digital Cinema Packages (DCPs) from
+video, audio and subtitle data, and also to read and process existing
+DCPs.
-Most of the hard work is done by a (slightly patched) version of asdcplib (http://www.cinecert.com/asdcplib/)
-which is included in the source distribution for libdcp.
+Most of the hard work is done by a (slightly patched) version of
+asdcplib (http://www.cinecert.com/asdcplib/) which is included in the
+source distribution for libdcp.
libdcp is distributed under the GNU GPL.
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 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
*/
/** @file examples/make_dcp.cc
- * @brief Shows how to make a DCP from some JPEG2000 and WAV files.
+ * @brief Shows how to make a DCP from some JPEG2000 and audio data.
*/
#include <vector>
--- /dev/null
+/*
+ Copyright (C) 2012-2014 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.
+
+*/
+
+/* If you are using an installed libdcp, these #includes would need to be changed to
+#include <libdcp/dcp.h>
+#include <libdcp/cpl.h>
+#include <libdcp/mono_picture_asset.h>
+... etc. ...
+*/
+
+#include "dcp.h"
+
+/** @file examples/read_dcp.cc
+ * @brief Shows how to read a DCP.
+ */
+
+int
+main ()
+{
+ /* Create a DCP, specifying where our existing data is */
+ dcp::DCP dcp ("/home/carl/diagonal.com/APPASSIONATA_TLR_F_UK-DEFR_CH_51_2K_LOK_20121115_DGL_OV");
+ /* Read the DCP to find out about it */
+ dcp.read ();
+
+ if (dcp.encrypted ()) {
+ std::cout << "DCP is encrypted.\n";
+ } else {
+ std::cout << "DCP is not encrypted.\n";
+ }
+
+ std::cout << "DCP has " << dcp.cpls().size() << " CPLs.\n";
+ std::cout << "DCP has " << dcp.assets().size() << " assets.\n";
+
+ return 0;
+}
def build(bld):
obj = bld(features = 'cxx cxxprogram')
- obj.name = 'examples'
+ obj.name = 'make_dcp'
obj.use = 'libdcp'
obj.uselib = 'OPENJPEG CXML'
obj.source = 'make_dcp.cc'
obj.target = 'make_dcp'
obj.install_path = ''
+
+ obj = bld(features = 'cxx cxxprogram')
+ obj.name = 'read_dcp'
+ obj.use = 'libdcp'
+ obj.uselib = 'OPENJPEG CXML'
+ obj.source = 'read_dcp.cc'
+ obj.target = 'read_dcp'
+ obj.install_path = ''
--- /dev/null
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src
+if [ "$1" == "--debug" ]; then
+ shift
+ gdb --args build/examples/read_dcp "$@"
+elif [ "$1" == "--valgrind" ]; then
+ shift
+ valgrind --tool="memcheck" --leak-check=full --show-reachable=yes build/examples/read_dcp "$@"
+else
+ build/examples/read_dcp "$@"
+fi
}
+/** Create an Asset from a given file. The ID will
+ * be extracted from the file.
+ * @param file File name.
+ */
Asset::Asset (boost::filesystem::path file)
: _file (file)
{
void
Asset::write_to_pkl (xmlpp::Node* node) const
{
+ assert (!_file.empty ());
+
xmlpp::Node* asset = node->add_child ("Asset");
asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
asset->add_child("AnnotationText")->add_child_text (_id);
void
Asset::write_to_assetmap (xmlpp::Node* node) const
{
+ assert (!_file.empty ());
+
xmlpp::Node* asset = node->add_child ("Asset");
asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
string
Asset::hash () const
{
+ assert (!_file.empty ());
+
if (!_hash.empty ()) {
_hash = make_digest (_file, 0);
}
/** @class Asset
* @brief Parent class for DCP assets, i.e. picture/sound/subtitles and CPLs.
*
- * Note that this class is not used for ReelAssets; they are just for the metadata
+ * Note that this class is not used for ReelAssets; those are just for the metadata
* that gets put into <Reel>s.
*/
class Asset : public Object
Asset (std::string id);
virtual std::string pkl_type () const = 0;
- virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
-
+ virtual bool equals (
+ boost::shared_ptr<const Asset> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
+
+ /** Write details of the asset to a ASSETMAP.
+ * @param node Parent node.
+ */
+ void write_to_assetmap (xmlpp::Node* node) const;
+
/** Write details of the asset to a PKL AssetList node.
* @param node Parent node.
*/
void write_to_pkl (xmlpp::Node* node) const;
- void write_to_assetmap (xmlpp::Node* node) const;
boost::filesystem::path file () const {
return _file;
}
- void set_file (boost::filesystem::path file) {
+ void set_file (boost::filesystem::path file) const {
_file = file;
+ _hash.clear ();
}
+ /** @return the hash of this asset's file. It will be
+ * computed by this call if necessary.
+ */
std::string hash () const;
protected:
- friend class MXFWriter;
-
- boost::filesystem::path _file;
+ /** The disk file that represents this asset, if one exists */
+ mutable boost::filesystem::path _file;
+ /** Hash of _file, or empty if the hash has not yet been computed */
mutable std::string _hash;
};
public:
Content (boost::filesystem::path file);
Content (Fraction edit_rate);
-
virtual ~Content () {}
+ bool equals (
+ boost::shared_ptr<const Content> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)>
+ ) const;
+
Fraction edit_rate () const {
return _edit_rate;
}
return _intrinsic_duration;
}
- virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
-
protected:
friend class MXFWriter;
CPL::CPL (string annotation_text, ContentKind content_kind)
: _annotation_text (annotation_text)
, _content_kind (content_kind)
- , _length (0)
{
}
/** Construct a CPL object from a XML file */
CPL::CPL (boost::filesystem::path file)
: _content_kind (FEATURE)
- , _length (0)
{
cxml::Document f ("CompositionPlaylist");
f.read_file (file);
* @param reel Reel to add.
*/
void
-CPL::add (shared_ptr<Reel> reel)
+CPL::add (boost::shared_ptr<Reel> reel)
{
_reels.push_back (reel);
}
/* This must not be the _formatted version otherwise signature digests will be wrong */
doc.write_to_file (file.string (), "UTF-8");
- _digest = make_digest (file.string (), 0);
- _length = boost::filesystem::file_size (file.string ());
+ set_file (file);
}
list<shared_ptr<const Content> >
return a;
}
-
-void
-CPL::write_to_assetmap (xmlpp::Node* node) const
-{
- xmlpp::Node* asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
- xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
- xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
- chunk->add_child("Path")->add_child_text (_id + "_cpl.xml");
- chunk->add_child("VolumeIndex")->add_child_text ("1");
- chunk->add_child("Offset")->add_child_text("0");
- chunk->add_child("Length")->add_child_text(lexical_cast<string> (_length));
-}
bool
CPL::equals (CPL const & other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
}
}
+/** Set a private key for every MXF referenced by this CPL. This will allow the data
+ * to be decrypted or encrypted.
+ * @param key Key to use.
+ */
void
CPL::set_mxf_keys (Key key)
{
return "text/xml";
}
- void add (boost::shared_ptr<Reel> reel);
+ bool equals (
+ CPL const & other,
+ EqualityOptions options,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
+ void add (boost::shared_ptr<Reel> reel);
+ void add (KDM const &);
+
std::string annotation_text () const {
return _annotation_text;
}
void set_mxf_keys (Key);
- bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
-
- void write_xml (boost::filesystem::path file, Standard standard, XMLMetadata, boost::shared_ptr<const Signer>) const;
- void write_to_assetmap (xmlpp::Node *) const;
-
- void add (KDM const &);
+ void write_xml (
+ boost::filesystem::path file,
+ Standard standard,
+ XMLMetadata,
+ boost::shared_ptr<const Signer>
+ ) const;
private:
-
- std::string _annotation_text;
- std::string _issue_date;
- std::string _creator;
- std::string _content_title_text;
- ContentKind _content_kind;
- std::string _content_version_id;
- std::string _content_version_label_text;
- /** reels */
+ std::string _annotation_text; ///< <AnnotationText>
+ std::string _issue_date; ///< <IssueDate>
+ std::string _creator; ///< <Creator>
+ std::string _content_title_text; ///< <ContentTitleText>
+ ContentKind _content_kind; ///< <ContentKind>
+ std::string _content_version_id; ///< <Id> in <ContentVersion>
+ std::string _content_version_label_text; ///< <LabelText> in <ContentVersion>
std::list<boost::shared_ptr<Reel> > _reels;
-
- /** a SHA1 digest of our XML */
- mutable std::string _digest;
- /** length in bytes of the XML that we last wrote to disk */
- mutable int64_t _length;
};
}
}
void
-DCP::add (shared_ptr<Asset> asset)
+DCP::add (boost::shared_ptr<Asset> asset)
{
_assets.push_back (asset);
}
std::list<boost::shared_ptr<CPL> > cpls () const;
+ /** @return All this DCP's assets (note that CPLs are assets) */
+ std::list<boost::shared_ptr<Asset> > assets () const {
+ return _assets;
+ }
+
bool encrypted () const;
void add (KDM const &);
/** Write the PKL file.
* @param pkl_uuid UUID to use.
*/
- boost::filesystem::path write_pkl (Standard standard, std::string pkl_uuid, XMLMetadata metadata, boost::shared_ptr<const Signer> signer) const;
+ boost::filesystem::path write_pkl (
+ Standard standard,
+ std::string pkl_uuid,
+ XMLMetadata metadata,
+ boost::shared_ptr<const Signer> signer
+ ) const;
void write_volindex (Standard standard) const;
using boost::optional;
using namespace dcp;
-Font::Font (shared_ptr<const cxml::Node> node)
+Font::Font (boost::shared_ptr<const cxml::Node> node)
{
text = node->content ();
text_nodes = type_children<Text> (node, "Text");
}
-Font::Font (list<shared_ptr<Font> > const & font_nodes)
+Font::Font (std::list<boost::shared_ptr<Font> > const & font_nodes)
: size (0)
, italic (false)
, color ("FFFFFFFF")
}
-Image::Image (shared_ptr<const Image> other)
+Image::Image (boost::shared_ptr<const Image> other)
: _size (other->_size)
{
}
KDM::KDM (
- shared_ptr<const CPL> cpl, shared_ptr<const Signer> signer, shared_ptr<const Certificate> recipient_cert,
+ boost::shared_ptr<const CPL> cpl,
+ boost::shared_ptr<const Signer> signer,
+ boost::shared_ptr<const Certificate> recipient_cert,
boost::posix_time::ptime not_valid_before, boost::posix_time::ptime not_valid_after,
string annotation_text, string issue_date
)
}
KDMKey::KDMKey (
- shared_ptr<const Signer> signer, string cpl_id, string key_type, string key_id, boost::posix_time::ptime from, boost::posix_time::ptime until, Key key
+ boost::shared_ptr<const Signer> signer,
+ string cpl_id,
+ string key_type,
+ string key_id,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime until,
+ Key key
)
: _cpl_id (cpl_id)
, _key_type (key_type)
}
string
-KDMKey::encrypted_base64 (shared_ptr<const Certificate> recipient_cert) const
+KDMKey::encrypted_base64 (boost::shared_ptr<const Certificate> recipient_cert) const
{
assert (_key_type.length() == 4);
assert (_not_valid_before.length() == 25);
namespace dcp {
/** @class Key
- * @brief A key for encrypting MXFs.
+ * @brief A key for decrypting/encrypting MXFs.
*/
class Key
{
using boost::shared_ptr;
using namespace dcp;
-LoadFont::LoadFont (shared_ptr<const cxml::Node> node)
+LoadFont::LoadFont (boost::shared_ptr<const cxml::Node> node)
{
id = node->string_attribute ("Id");
uri = node->string_attribute ("URI");
{
return "MainPicture";
}
-
-int
-MonoPictureMXF::edit_rate_factor () const
-{
- return 1;
-}
/** Start a progressive write to a MonoPictureMXF */
boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path, Standard standard, bool);
+ bool equals (
+ boost::shared_ptr<const Content> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
+
boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
private:
std::string cpl_node_name () const;
- int edit_rate_factor () const;
};
}
return true;
}
+/** Set the (private) key that will be used to encrypt or decrypt this MXF's content.
+ * This is the top-secret key that is distributed (itself encrypted) to cinemas
+ * via Key Delivery Messages (KDMs).
+ * @param key Key to use.
+ */
void
MXF::set_key (Key key)
{
public:
MXF (Fraction edit_rate);
MXF (boost::filesystem::path file);
-
~MXF ();
- virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
virtual std::string key_type () const = 0;
-
+
std::string pkl_type () const {
return "application/x-smpte-mxf";
}
+ bool equals (
+ boost::shared_ptr<const Content> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
+
/** Fill in a ADSCP::WriteInfo struct.
* @param w struct to fill in.
* @param standard INTEROP or SMPTE.
*/
+/** @file src/mxf_writer.h
+ * @brief MXFWriter class.
+ */
+
#include "mxf_writer.h"
#include "mxf.h"
using namespace dcp;
+/** Create an MXFWriter.
+ * @param mxf MXF that we are writing.
+ * @param file File to write to.
+ */
MXFWriter::MXFWriter (MXF* mxf, boost::filesystem::path file)
: _mxf (mxf)
, _file (file)
, _frames_written (0)
, _finalized (false)
{
- mxf->_file = file;
- mxf->_hash.clear ();
+ mxf->set_file (file);
}
MXFWriter::~MXFWriter ()
*/
+/** @file src/mxf_writer.h
+ * @brief MXFWriter class.
+ */
+
#ifndef LIBDCP_MXF_WRITER_H
#define LIBDCP_MXF_WRITER_H
class MXF;
+/** @class MXFWriter
+ * @brief Parent class for classes which can write MXF files.
+ *
+ * The MXFWriter lasts for the duration of the write and is then discarded.
+ * They can only be created by calling start_write() on an MXF object.
+ */
class MXFWriter : public boost::noncopyable
{
public:
protected:
MXFWriter (MXF* mxf, boost::filesystem::path file);
+ /** MXF that we are writing */
MXF* _mxf;
+ /** File that we are writing to */
boost::filesystem::path _file;
+ /** Number of `frames' written so far; the definition of a frame
+ * varies depending on the subclass.
+ */
int64_t _frames_written;
+ /** true if finalize() has been called on this object */
bool _finalized;
};
#ifndef LIBDCP_PICTURE_MXF_H
#define LIBDCP_PICTURE_MXF_H
-/** @file src/picture_asset.h
- * @brief An asset made up of JPEG2000 data
+/** @file src/picture_mxf.h
+ * @brief PictureMXF class.
*/
-#include <openjpeg.h>
#include "mxf.h"
#include "util.h"
#include "metadata.h"
+#include <openjpeg.h>
namespace ASDCP {
namespace JP2K {
class StereoPictureFrame;
class PictureMXFWriter;
-/** @brief An asset made up of JPEG2000 data */
+/** @class PictureMXF
+ * @brief An asset made up of JPEG2000 data.
+ */
class PictureMXF : public MXF
{
public:
PictureMXF (boost::filesystem::path file);
PictureMXF (Fraction edit_rate);
- virtual boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path file, Standard standard, bool overwrite) = 0;
-
- void write_to_pkl (xmlpp::Node* node) const;
+ virtual boost::shared_ptr<PictureMXFWriter> start_write (
+ boost::filesystem::path file,
+ Standard standard,
+ bool overwrite
+ ) = 0;
Size size () const {
return _size;
return _screen_aspect_ratio;
}
- Fraction edit_rate () const {
- return _edit_rate;
- }
-
protected:
bool frame_buffer_equals (
) const;
bool descriptor_equals (
- ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function<void (NoteType, std::string)>
+ ASDCP::JP2K::PictureDescriptor const & a,
+ ASDCP::JP2K::PictureDescriptor const & b,
+ boost::function<void (NoteType, std::string)>
) const;
void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &);
private:
std::string key_type () const;
- virtual int edit_rate_factor () const = 0;
};
using boost::dynamic_pointer_cast;
using namespace dcp;
-Reel::Reel (shared_ptr<const cxml::Node> node)
+Reel::Reel (boost::shared_ptr<const cxml::Node> node)
: Object (node->string_child ("Id"))
{
shared_ptr<cxml::Node> asset_list = node->node_child ("AssetList");
class ReelSoundAsset;
class ReelSubtitleAsset;
-/** @brief A reel within a DCP; the part which actually contains picture, sound and subtitle data */
+/** @brief A reel within a DCP; the part which actually refers to picture, sound and subtitle data */
class Reel : public Object
{
public:
}
-ReelAsset::ReelAsset (shared_ptr<Content> content, int64_t entry_point)
+ReelAsset::ReelAsset (boost::shared_ptr<Content> content, int64_t entry_point)
: Object (content->id ())
, _content (content)
, _edit_rate (content->edit_rate ())
}
-ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
+ReelAsset::ReelAsset (boost::shared_ptr<const cxml::Node> node)
: Object (node->string_child ("Id"))
, _content (_id)
, _annotation_text (node->optional_string_child ("AnnotationText").get_value_or (""))
class Content;
+/** @class ReelAsset
+ * @brief An entry in a <Reel> which refers to a use of a piece of content.
+ *
+ * This class encapsulates the XML that exists in a <Reel> to say
+ * that a piece of content is used in this reel. It does not
+ * describe the content itself (but links to a Content object which does).
+ */
class ReelAsset : public Object
{
public:
ReelAsset (boost::shared_ptr<Content> content, int64_t entry_point);
ReelAsset (boost::shared_ptr<const cxml::Node>);
+ virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
+ virtual bool equals (
+ boost::shared_ptr<const ReelAsset>,
+ EqualityOptions,
+ boost::function<void (NoteType, std::string)>)
+ const {
+
+ return false;
+ }
+
+ /** @return a Ref to our actual content */
Ref<Content> content () const {
return _content;
}
+ /** @return true if a KeyId is specified for this asset, implying
+ * that its content is encrypted.
+ */
bool encrypted () const {
return !_key_id.empty ();
}
+ /** @return Key ID to describe the key that encrypts this asset's;
+ * content.
+ */
std::string key_id () const {
return _key_id;
}
- virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
- virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, boost::function<void (NoteType, std::string)>) const {
- return false;
- }
-
protected:
+ /** @return the node name that this asset uses in the CPL's <Reel> node
+ * e.g. MainPicture, MainSound etc.
+ */
virtual std::string cpl_node_name () const = 0;
+
+ /** @return Any attribute that should be used on the asset's node in the
+ * CPL.
+ */
virtual std::pair<std::string, std::string> cpl_node_attribute () const;
+ /** Reference to the content (MXF or XML file) that this reel entry
+ * applies to.
+ */
Ref<Content> _content;
private:
- std::string _annotation_text;
- Fraction _edit_rate;
- int64_t _intrinsic_duration;
- int64_t _entry_point;
- int64_t _duration;
- std::string _hash;
- std::string _key_id;
+
+ std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset
+ Fraction _edit_rate; ///< The <EditRate> from the reel's entry for this asset
+ int64_t _intrinsic_duration; ///< The <IntrinsicDuration> from the reel's entry for this asset
+ int64_t _entry_point; ///< The <EntryPoint> from the reel's entry for this asset
+ int64_t _duration; ///< The <Duration> from the reel's entry for this asset
+ std::string _hash; ///< The <Hash> from the reel's entry for this asset
+ std::string _key_id; ///< The <KeyId> from the reel's entry for this asset, or empty if there isn't one
};
}
}
-ReelMonoPictureAsset::ReelMonoPictureAsset (shared_ptr<MonoPictureMXF> mxf, int64_t entry_point)
+ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr<MonoPictureMXF> mxf, int64_t entry_point)
: ReelPictureAsset (mxf, entry_point)
{
}
-ReelMonoPictureAsset::ReelMonoPictureAsset (shared_ptr<const cxml::Node> node)
+ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr<const cxml::Node> node)
: ReelPictureAsset (node)
{
}
-ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureMXF> content, int64_t entry_point)
+ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<PictureMXF> content, int64_t entry_point)
: ReelAsset (content, entry_point)
, _frame_rate (content->frame_rate ())
, _screen_aspect_ratio (content->screen_aspect_ratio ())
}
-ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
+ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<const cxml::Node> node)
: ReelAsset (node)
{
_frame_rate = Fraction (node->string_child ("FrameRate"));
ReelPictureAsset (boost::shared_ptr<PictureMXF> content, int64_t entry_point);
ReelPictureAsset (boost::shared_ptr<const cxml::Node>);
+ virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
boost::shared_ptr<PictureMXF> mxf () {
return boost::dynamic_pointer_cast<PictureMXF> (_content.object ());
}
_screen_aspect_ratio = a;
}
- virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
-
private:
Fraction _frame_rate;
Fraction _screen_aspect_ratio;
using boost::shared_ptr;
using namespace dcp;
-ReelSoundAsset::ReelSoundAsset (shared_ptr<Content> content, int64_t entry_point)
+ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<Content> content, int64_t entry_point)
: ReelAsset (content, entry_point)
{
}
-ReelSoundAsset::ReelSoundAsset (shared_ptr<const cxml::Node> node)
+ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<const cxml::Node> node)
: ReelAsset (node)
{
node->ignore_child ("Language");
using boost::shared_ptr;
using namespace dcp;
-ReelStereoPictureAsset::ReelStereoPictureAsset (shared_ptr<const cxml::Node> node)
+ReelStereoPictureAsset::ReelStereoPictureAsset (boost::shared_ptr<const cxml::Node> node)
: ReelPictureAsset (node)
{
using boost::shared_ptr;
using namespace dcp;
-ReelSubtitleAsset::ReelSubtitleAsset (shared_ptr<SubtitleContent> content, int64_t entry_point)
+ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, int64_t entry_point)
: ReelAsset (content, entry_point)
{
}
-ReelSubtitleAsset::ReelSubtitleAsset (shared_ptr<const cxml::Node> node)
+ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<const cxml::Node> node)
: ReelAsset (node)
{
node->ignore_child ("Language");
*/
+/** @file src/ref.h
+ * @brief Ref class.
+ */
+
#ifndef LIBDCP_REF_H
#define LIBDCP_REF_H
namespace dcp {
+/** @class Ref
+ * @brief A reference to an object which is identified by a universally-unique identifier (UUID).
+ *
+ * This class is a `pointer' to a thing. It will always know the
+ * UUID of the thing, and it may have a shared_ptr to the C++ object
+ * which represents the thing.
+ *
+ * If the Ref does not have a shared_ptr it may be given one by
+ * calling resolve() with a list of objects. The shared_ptr will be
+ * set up using any object on the list which has a matching ID.
+ */
template<class T>
class Ref
{
public:
+ /** Initialise a Ref with an ID but no shared_ptr */
Ref (std::string id)
: _id (id)
{}
+ /** Initialise a Ref with a shared_ptr to an object */
Ref (boost::shared_ptr<T> object)
: _id (object->id ())
, _object (object)
{}
+ /** Set the ID of this Ref */
void set_id (std::string id)
{
_id = id;
}
+ /** Look through a list of objects and copy a shared_ptr to any object
+ * which matches the ID of this one.
+ */
void resolve (std::list<boost::shared_ptr<Object> > objects)
{
typename std::list<boost::shared_ptr<Object> >::iterator i = objects.begin();
}
}
+ /** @return the ID of the thing that we are pointing to */
std::string id () const {
return _id;
}
+ /** @return a shared_ptr to the thing; an UnresolvedRefError is thrown
+ * if the shared_ptr is not known.
+ */
boost::shared_ptr<T> object () const {
if (!_object) {
throw UnresolvedRefError (_id);
return _object;
}
+ /** operator-> to access the shared_ptr; an UnresolvedRefError is thrown
+ * if the shared_ptr is not known.
+ */
T * operator->() const {
if (!_object) {
throw UnresolvedRefError (_id);
return _object.get ();
}
+ /** @return true if a shared_ptr is known for this Ref */
bool resolved () const {
return _object;
}
private:
- std::string _id;
- boost::shared_ptr<T> _object;
+ std::string _id; ///< ID; will always be known
+ boost::shared_ptr<T> _object; ///< shared_ptr to the thing, may be null.
};
}
/** Convert an openjpeg XYZ image to RGB.
* @param xyz_frame Frame in XYZ.
+ * @param lut_in Input Gamma LUT to use.
+ * @param lut_out Output Gamma LUT to use.
* @return RGB image.
*/
shared_ptr<ARGBFrame>
-dcp::xyz_to_rgb (shared_ptr<const XYZFrame> xyz_frame, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out)
+dcp::xyz_to_rgb (
+ boost::shared_ptr<const XYZFrame> xyz_frame,
+ boost::shared_ptr<const LUT> lut_in,
+ boost::shared_ptr<const LUT> lut_out
+ )
{
int const max_colour = pow (2, lut_out->bit_depth()) - 1;
}
shared_ptr<dcp::XYZFrame>
-dcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out, double const colour_matrix[3][3])
+dcp::rgb_to_xyz (
+ boost::shared_ptr<const Image> rgb,
+ boost::shared_ptr<const LUT> lut_in,
+ boost::shared_ptr<const LUT> lut_out,
+ double const colour_matrix[3][3]
+ )
{
assert (lut_in->bit_depth() == 12);
assert (lut_out->bit_depth() == 16);
*/
-/** @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"
boost::shared_ptr<SoundMXFWriter> start_write (boost::filesystem::path file, Standard standard);
- bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ bool equals (
+ boost::shared_ptr<const Content> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
boost::shared_ptr<const SoundFrame> get_frame (int n) const;
return shared_ptr<StereoPictureMXFWriter> (new StereoPictureMXFWriter (this, file, standard, overwrite));
}
-int
-StereoPictureMXF::edit_rate_factor () const
-{
- return 2;
-}
-
bool
StereoPictureMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
/** Start a progressive write to a StereoPictureMXF */
boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path file, Standard, bool);
+ bool equals (
+ boost::shared_ptr<const Content> other,
+ EqualityOptions opt,
+ boost::function<void (NoteType, std::string)> note
+ ) const;
+
boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
-
-private:
- int edit_rate_factor () const;
};
}
using boost::lexical_cast;
using namespace dcp;
-Subtitle::Subtitle (shared_ptr<const cxml::Node> node)
+Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node)
{
in = Time (node->string_attribute ("TimeIn"));
out = Time (node->string_attribute ("TimeOut"));
return "text/xml";
}
- virtual bool equals (boost::shared_ptr<const Content>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
+ bool equals (
+ boost::shared_ptr<const Content>,
+ EqualityOptions,
+ boost::function<void (NoteType, std::string)> note
+ ) const {
/* XXX */
note (ERROR, "subtitle content not compared yet");
return true;
* in this object's member variables.
* @param node Node to read.
*/
-Text::Text (shared_ptr<const cxml::Node> node)
+Text::Text (boost::shared_ptr<const cxml::Node> node)
: v_align (CENTER)
{
text = node->content ();
: v_position (0)
, v_align (TOP)
{}
-
+
Text (boost::shared_ptr<const cxml::Node> node);
float v_position;
using namespace dcp;
using namespace boost;
+/** Construct a Fraction from a string of the form <numerator> <denominator>
+ * e.g. "1 3".
+ */
Fraction::Fraction (string s)
{
vector<string> b;
return (a.numerator != b.numerator || a.denominator != b.denominator);
}
+/** Construct a Color, initialising it to black. */
Color::Color ()
: r (0)
, g (0)
}
+/** Construct a Color from R, G and B. The values run between
+ * 0 and 255.
+ */
Color::Color (int r_, int g_, int b_)
: r (r_)
, g (g_)
EYE_LEFT,
EYE_RIGHT
};
-
+
+/** @class Fraction
+ * @brief A fraction (i.e. a thing with an integer numerator and an integer denominator).
+ */
class Fraction
{
public:
+ /** Construct a fraction of 0/0 */
Fraction () : numerator (0), denominator (0) {}
Fraction (std::string s);
+ /** Construct a fraction with a specified numerator and denominator.
+ * @param n Numerator.
+ * @param d Denominator.
+ */
Fraction (int n, int d) : numerator (n), denominator (d) {}
int numerator;