diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-04 21:28:36 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-04 21:28:36 +0000 |
| commit | 11438c8a93dfcf1c0febe7aeb888b4d94cf67e8f (patch) | |
| tree | abb08f929eb9e6c122a4f12c08fc335d03574a86 | |
| parent | b13403b9098b115b9b4f57a771aff92a33610116 (diff) | |
Various development of IMF.
| -rw-r--r-- | src/cpl.cc | 33 | ||||
| -rw-r--r-- | src/cpl.h | 22 | ||||
| -rw-r--r-- | src/dcp_cpl.cc | 31 | ||||
| -rw-r--r-- | src/dcp_cpl.h | 16 | ||||
| -rw-r--r-- | src/essence_descriptor.cc | 44 | ||||
| -rw-r--r-- | src/essence_descriptor.h | 38 | ||||
| -rw-r--r-- | src/imp_cpl.cc | 32 | ||||
| -rw-r--r-- | src/imp_cpl.h | 9 | ||||
| -rw-r--r-- | src/resource.cc | 29 | ||||
| -rw-r--r-- | src/resource.h | 35 | ||||
| -rw-r--r-- | src/rgba_descriptor.cc | 34 | ||||
| -rw-r--r-- | src/rgba_descriptor.h | 36 | ||||
| -rw-r--r-- | src/segment.cc | 42 | ||||
| -rw-r--r-- | src/segment.h | 37 | ||||
| -rw-r--r-- | src/sequence.cc | 30 | ||||
| -rw-r--r-- | src/sequence.h | 36 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.cc | 2 | ||||
| -rw-r--r-- | src/types.cc | 14 | ||||
| -rw-r--r-- | src/types.h | 3 | ||||
| -rw-r--r-- | src/wave_pcm_descriptor.cc | 33 | ||||
| -rw-r--r-- | src/wave_pcm_descriptor.h | 35 | ||||
| -rw-r--r-- | src/wscript | 12 |
22 files changed, 552 insertions, 51 deletions
@@ -18,7 +18,10 @@ */ #include "cpl.h" +#include "util.h" +#include "local_time.h" +using boost::shared_ptr; using namespace dcp; CPL::CPL () @@ -28,6 +31,36 @@ CPL::CPL () CPL::CPL (boost::filesystem::path file) : Asset (file) + , _content_kind (FEATURE) { } + +CPL::CPL (ContentKind content_kind) + : _content_kind (content_kind) +{ + +} + +shared_ptr<cxml::Document> +CPL::read_common (boost::filesystem::path file) +{ + shared_ptr<cxml::Document> f (new cxml::Document ("CompositionPlaylist")); + f->read_file (file); + + _id = f->string_child ("Id"); + if (_id.length() > 9) { + _id = _id.substr (9); + } + + _metadata.issuer = f->optional_string_child ("Issuer").get_value_or (""); + _metadata.creator = f->optional_string_child ("Creator").get_value_or (""); + _metadata.issue_date = f->string_child ("IssueDate"); + + _content_kind = content_kind_from_string (f->string_child ("ContentKind")); + + f->ignore_child ("Signer"); + f->ignore_child ("Signature"); + + return f; +} @@ -18,6 +18,8 @@ */ #include "asset.h" +#include "metadata.h" +#include <libcxml/cxml.h> namespace dcp { @@ -28,14 +30,34 @@ class CPL : public Asset { public: CPL (); + CPL (ContentKind content_kind); CPL (boost::filesystem::path file); + void set_metadata (XMLMetadata m) { + _metadata = m; + } + + /** @return the type of the content, used by media servers + * to categorise things (e.g. feature, trailer, etc.) + */ + ContentKind content_kind () const { + return _content_kind; + } + virtual void resolve_refs (std::list<boost::shared_ptr<Asset> >) = 0; virtual int64_t duration () const = 0; virtual bool encrypted () const = 0; virtual void add (DecryptedKDM const &) = 0; /** @return string to use for AnnotationText in a PKL */ virtual std::string pkl_annotation () const = 0; + +protected: + boost::shared_ptr<cxml::Document> read_common (boost::filesystem::path file); + /** <Issuer>, <Creator> and <IssueDate>. These are grouped + * because they occur together in a few places. + */ + XMLMetadata _metadata; + ContentKind _content_kind; ///< <ContentKind> }; }; diff --git a/src/dcp_cpl.cc b/src/dcp_cpl.cc index 0320052d..2d4ba602 100644 --- a/src/dcp_cpl.cc +++ b/src/dcp_cpl.cc @@ -45,11 +45,10 @@ using boost::dynamic_pointer_cast; using namespace dcp; DCPCPL::DCPCPL (string annotation_text, ContentKind content_kind) - : _annotation_text (annotation_text) + : CPL (content_kind) + , _annotation_text (annotation_text) /* default _content_title_text to _annotation_text */ , _content_title_text (annotation_text) - , _content_kind (content_kind) - , _content_version_id ("urn:uuid:" + make_uuid ()) { /* default _content_version_id to a random ID and _content_version_label to a random ID and the current time. @@ -61,35 +60,21 @@ DCPCPL::DCPCPL (string annotation_text, ContentKind content_kind) /** Construct a DCPCPL object from a XML file */ DCPCPL::DCPCPL (boost::filesystem::path file) : CPL (file) - , _content_kind (FEATURE) { - cxml::Document f ("CompositionPlaylist"); - f.read_file (file); + shared_ptr<cxml::Document> f = read_common (file); - _id = f.string_child ("Id"); - if (_id.length() > 9) { - _id = _id.substr (9); - } - _annotation_text = f.optional_string_child ("AnnotationText").get_value_or (""); - _metadata.issuer = f.optional_string_child ("Issuer").get_value_or (""); - _metadata.creator = f.optional_string_child ("Creator").get_value_or (""); - _metadata.issue_date = f.string_child ("IssueDate"); - _content_title_text = f.string_child ("ContentTitleText"); - _content_kind = content_kind_from_string (f.string_child ("ContentKind")); - shared_ptr<cxml::Node> content_version = f.optional_node_child ("ContentVersion"); + _annotation_text = f->optional_string_child ("AnnotationText").get_value_or (""); + _content_title_text = f->string_child ("ContentTitleText"); + shared_ptr<cxml::Node> content_version = f->optional_node_child ("ContentVersion"); if (content_version) { _content_version_id = content_version->optional_string_child ("Id").get_value_or (""); _content_version_label_text = content_version->string_child ("LabelText"); content_version->done (); } - f.ignore_child ("RatingList"); + f->ignore_child ("RatingList"); _reels = type_grand_children<Reel> (f, "ReelList", "Reel"); - f.ignore_child ("Issuer"); - f.ignore_child ("Signer"); - f.ignore_child ("Signature"); - - f.done (); + f->done (); } /** Add a reel to this CPL. diff --git a/src/dcp_cpl.h b/src/dcp_cpl.h index 3f0e43e3..54312d74 100644 --- a/src/dcp_cpl.h +++ b/src/dcp_cpl.h @@ -91,13 +91,6 @@ public: _content_version_label_text = text; } - /** @return the type of the content, used by media servers - * to categorise things (e.g. feature, trailer, etc.) - */ - ContentKind content_kind () const { - return _content_kind; - } - /** @return the reels in this CPL */ std::list<boost::shared_ptr<Reel> > reels () const { return _reels; @@ -107,10 +100,6 @@ public: */ std::list<boost::shared_ptr<const ReelAsset> > reel_assets () const; - void set_metadata (XMLMetadata m) { - _metadata = m; - } - void write_xml ( boost::filesystem::path file, Standard standard, @@ -123,12 +112,7 @@ protected: private: std::string _annotation_text; ///< <AnnotationText> - /** <Issuer>, <Creator> and <IssueDate>. These are grouped - * because they occur together in a few places. - */ - XMLMetadata _metadata; 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; diff --git a/src/essence_descriptor.cc b/src/essence_descriptor.cc new file mode 100644 index 00000000..49c40eb2 --- /dev/null +++ b/src/essence_descriptor.cc @@ -0,0 +1,44 @@ +/* + Copyright (C) 2016 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 "rgba_descriptor.h" +#include "wave_pcm_descriptor.h" +#include "exceptions.h" + +using boost::shared_ptr; +using namespace dcp; + +EssenceDescriptor::EssenceDescriptor (cxml::ConstNodePtr node) + : Object (node->string_child ("Id")) +{ + +} + +shared_ptr<EssenceDescriptor> +EssenceDescriptor::create (cxml::ConstNodePtr node) +{ + if (node->optional_node_child("RGBADescriptor")) { + return shared_ptr<EssenceDescriptor> (new RGBADescriptor (node)); + } else if (node->optional_node_child("WAVEPCMDescriptor")) { + return shared_ptr<EssenceDescriptor> (new WAVEPCMDescriptor (node)); + } + + throw PackageReadError ("unrecognised essence descriptor"); + return shared_ptr<EssenceDescriptor> (); +} diff --git a/src/essence_descriptor.h b/src/essence_descriptor.h new file mode 100644 index 00000000..3d10ea8a --- /dev/null +++ b/src/essence_descriptor.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2016 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. + +*/ + +#ifndef LIBDCP_ESSENCE_DESCRIPTOR_H +#define LIBDCP_ESSENCE_DESCRIPTOR_H + +#include "object.h" +#include <libcxml/cxml.h> + +namespace dcp { + +class EssenceDescriptor : public Object +{ +public: + EssenceDescriptor (cxml::ConstNodePtr node); + + static boost::shared_ptr<EssenceDescriptor> create (cxml::ConstNodePtr node); +}; + +} + +#endif diff --git a/src/imp_cpl.cc b/src/imp_cpl.cc index 23fe3271..2b36f02b 100644 --- a/src/imp_cpl.cc +++ b/src/imp_cpl.cc @@ -18,19 +18,40 @@ */ #include "imp_cpl.h" +#include "xml.h" +#include "essence_descriptor.h" +#include "segment.h" #include <libcxml/cxml.h> +#include <boost/foreach.hpp> using std::string; +using boost::shared_ptr; using namespace dcp; /** Construct a DCPCPL object from a XML file */ IMPCPL::IMPCPL (boost::filesystem::path file) : CPL (file) { - cxml::Document f ("CompositionPlaylist"); - f.read_file (file); + shared_ptr<cxml::Document> f = read_common (file); - /* XXX */ + /* XXX: find out which of these are compulsory and which are optional */ + + _annotation = f->optional_string_child("Annotation").get_value_or(""); + _content_title = f->string_child("ContentTitle"); + _content_originator = f->optional_string_child("ContentOriginator").get_value_or(""); + + BOOST_FOREACH (cxml::ConstNodePtr i, f->node_child("EssenceDescriptorList")->node_children("EssenceDescriptor")) { + _essence_descriptors.push_back (EssenceDescriptor::create (i)); + } + + _edit_rate = Fraction (f->string_child ("EditRate")); + + f->ignore_child ("ContentVersionList"); + f->ignore_child ("ExtensionProperties"); + + _segments = type_grand_children<Segment> (f, "SegmentList", "Segment"); + + f->done (); } void @@ -49,14 +70,14 @@ IMPCPL::duration () const bool IMPCPL::encrypted () const { - /* XXX */ + /* No IMP encryption (yet) */ return false; } void IMPCPL::add (DecryptedKDM const &) { - /* XXX */ + /* No IMP encryption (yet) */ } string @@ -72,4 +93,3 @@ IMPCPL::pkl_type (Standard) const { return "text/xml"; } - diff --git a/src/imp_cpl.h b/src/imp_cpl.h index 53cc3ad2..7a1337db 100644 --- a/src/imp_cpl.h +++ b/src/imp_cpl.h @@ -21,6 +21,9 @@ namespace dcp { +class EssenceDescriptor; +class Segment; + class IMPCPL : public CPL { public: @@ -36,6 +39,12 @@ public: private: std::string pkl_type (Standard standard) const; + std::string _annotation; + std::string _content_title; + std::string _content_originator; + std::list<boost::shared_ptr<EssenceDescriptor> > _essence_descriptors; + Fraction _edit_rate; + std::list<boost::shared_ptr<Segment> > _segments; }; } diff --git a/src/resource.cc b/src/resource.cc new file mode 100644 index 00000000..50ab57b4 --- /dev/null +++ b/src/resource.cc @@ -0,0 +1,29 @@ +/* + Copyright (C) 2016 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 "resource.h" + +using namespace dcp; + +Resource::Resource (cxml::ConstNodePtr node) + : Object (node->string_child ("Id")) +{ + _intrinsic_duration = node->number_child<int64_t> ("IntrinsicDuration"); + _entry_point = node->number_child<int64_t> ("EntryPoint"); +} diff --git a/src/resource.h b/src/resource.h new file mode 100644 index 00000000..f75d03fc --- /dev/null +++ b/src/resource.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2016 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 "object.h" +#include <libcxml/cxml.h> + +namespace dcp { + +class Resource : public Object +{ +public: + Resource (cxml::ConstNodePtr node); + +private: + int64_t _intrinsic_duration; + int64_t _entry_point; +}; + +} diff --git a/src/rgba_descriptor.cc b/src/rgba_descriptor.cc new file mode 100644 index 00000000..2d9c6996 --- /dev/null +++ b/src/rgba_descriptor.cc @@ -0,0 +1,34 @@ +/* + Copyright (C) 2016 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 "rgba_descriptor.h" + +using namespace dcp; + +RGBADescriptor::RGBADescriptor (cxml::ConstNodePtr node) + : EssenceDescriptor (node) +{ + /* Lots of stuff not parsed here */ + + cxml::ConstNodePtr d = node->node_child ("RGBADescriptor"); + + _sample_rate = Fraction (d->string_child ("SampleRate")); + _stored_width = d->number_child<int> ("StoredWidth"); + _stored_height = d->number_child<int> ("StoredHeight"); +} diff --git a/src/rgba_descriptor.h b/src/rgba_descriptor.h new file mode 100644 index 00000000..c6d20516 --- /dev/null +++ b/src/rgba_descriptor.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2016 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 "essence_descriptor.h" +#include "util.h" + +namespace dcp { + +class RGBADescriptor : public EssenceDescriptor +{ +public: + RGBADescriptor (cxml::ConstNodePtr node); + +private: + Fraction _sample_rate; + int _stored_width; + int _stored_height; +}; + +} diff --git a/src/segment.cc b/src/segment.cc new file mode 100644 index 00000000..20f2bf1e --- /dev/null +++ b/src/segment.cc @@ -0,0 +1,42 @@ +/* + Copyright (C) 2016 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 "segment.h" +#include "sequence.h" + +using boost::shared_ptr; +using namespace dcp; + +Segment::Segment (cxml::ConstNodePtr node) + : Object (node->string_child ("Id")) +{ + shared_ptr<cxml::Node> sequence_list = node->node_child ("SequenceList"); + + shared_ptr<cxml::Node> main_image = sequence_list->optional_node_child ("MainImageSequence"); + if (main_image) { + _main_image.reset (new Sequence (main_image)); + } + + shared_ptr<cxml::Node> main_audio = sequence_list->optional_node_child ("MainAudioSequence"); + if (main_audio) { + _main_audio.reset (new Sequence (main_audio)); + } + + node->done (); +} diff --git a/src/segment.h b/src/segment.h new file mode 100644 index 00000000..1b6e470d --- /dev/null +++ b/src/segment.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2016 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 "object.h" +#include <libcxml/cxml.h> + +namespace dcp { + +class Sequence; + +class Segment : public Object +{ +public: + Segment (cxml::ConstNodePtr node); + +private: + boost::shared_ptr<Sequence> _main_image; + boost::shared_ptr<Sequence> _main_audio; +}; + +} diff --git a/src/sequence.cc b/src/sequence.cc new file mode 100644 index 00000000..3584a5b2 --- /dev/null +++ b/src/sequence.cc @@ -0,0 +1,30 @@ +/* + Copyright (C) 2016 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 "sequence.h" +#include "xml.h" +#include "resource.h" + +using namespace dcp; + +Sequence::Sequence (cxml::ConstNodePtr node) + : Object (node->string_child ("Id")) +{ + _resources = type_grand_children<Resource> (node, "ResourceList", "Resource"); +} diff --git a/src/sequence.h b/src/sequence.h new file mode 100644 index 00000000..74216ea5 --- /dev/null +++ b/src/sequence.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2016 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 "object.h" +#include <libcxml/cxml.h> + +namespace dcp { + +class Resource; + +class Sequence : public Object +{ +public: + Sequence (cxml::ConstNodePtr node); + +private: + std::list<boost::shared_ptr<Resource> > _resources; +}; + +} diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 7b214489..8f40af5f 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -207,7 +207,7 @@ SMPTESubtitleAsset::xml_as_string () const if (_language) { root->add_child("Language", "dcst")->add_child_text (_language.get ()); } - root->add_child("EditRate", "dcst")->add_child_text (_edit_rate.as_string ()); + root->add_child("EditRate", "dcst")->add_child_text (_edit_rate.as_space_string ()); root->add_child("TimeCodeRate", "dcst")->add_child_text (raw_convert<string> (_time_code_rate)); if (_start_time) { root->add_child("StartTime", "dcst")->add_child_text (_start_time.get().as_string (SMPTE)); diff --git a/src/types.cc b/src/types.cc index 36b04664..d61a3c4c 100644 --- a/src/types.cc +++ b/src/types.cc @@ -30,13 +30,13 @@ using namespace std; using namespace dcp; using namespace boost; -/** Construct a Fraction from a string of the form <numerator> <denominator> - * e.g. "1 3". +/** Construct a Fraction from a string of the form <numerator> <denominator> (e.g. "1 3") + * or <numerator>/<denominator> (e.g. "1/3") */ Fraction::Fraction (string s) { vector<string> b; - split (b, s, is_any_of (" ")); + split (b, s, is_any_of (" /")); if (b.size() != 2) { boost::throw_exception (XMLError ("malformed fraction " + s + " in XML node")); } @@ -45,11 +45,17 @@ Fraction::Fraction (string s) } string -Fraction::as_string () const +Fraction::as_space_string () const { return String::compose ("%1 %2", numerator, denominator); } +string +Fraction::as_slash_string () const +{ + return String::compose ("%1/%2", numerator, denominator); +} + bool dcp::operator== (Fraction const & a, Fraction const & b) { diff --git a/src/types.h b/src/types.h index 16000daa..481c1a46 100644 --- a/src/types.h +++ b/src/types.h @@ -139,7 +139,8 @@ public: return float (numerator) / denominator; } - std::string as_string () const; + std::string as_space_string () const; + std::string as_slash_string () const; int numerator; int denominator; diff --git a/src/wave_pcm_descriptor.cc b/src/wave_pcm_descriptor.cc new file mode 100644 index 00000000..84797196 --- /dev/null +++ b/src/wave_pcm_descriptor.cc @@ -0,0 +1,33 @@ +/* + Copyright (C) 2016 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 "wave_pcm_descriptor.h" + +using namespace dcp; + +WAVEPCMDescriptor::WAVEPCMDescriptor (cxml::ConstNodePtr node) + : EssenceDescriptor (node) +{ + /* Lots of stuff not parsed here */ + + cxml::ConstNodePtr d = node->node_child ("WAVEPCMDescriptor"); + + _audio_sample_rate = Fraction (d->string_child ("AudioSampleRate")); + _channel_count = d->number_child<int> ("ChannelCount"); +} diff --git a/src/wave_pcm_descriptor.h b/src/wave_pcm_descriptor.h new file mode 100644 index 00000000..53850ddc --- /dev/null +++ b/src/wave_pcm_descriptor.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2016 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 "essence_descriptor.h" +#include "types.h" + +namespace dcp { + +class WAVEPCMDescriptor : public EssenceDescriptor +{ +public: + WAVEPCMDescriptor (cxml::ConstNodePtr node); + +private: + Fraction _audio_sample_rate; + int _channel_count; +}; + +} diff --git a/src/wscript b/src/wscript index ce86e8e6..34894608 100644 --- a/src/wscript +++ b/src/wscript @@ -33,6 +33,7 @@ def build(bld): decrypted_kdm.cc decrypted_kdm_key.cc encrypted_kdm.cc + essence_descriptor.cc exceptions.cc file.cc font_asset.cc @@ -66,7 +67,11 @@ def build(bld): reel_stereo_picture_asset.cc reel_subtitle_asset.cc ref.cc + resource.cc rgb_xyz.cc + rgba_descriptor.cc + segment.cc + sequence.cc smpte_load_font_node.cc smpte_subtitle_asset.cc sound_asset.cc @@ -83,6 +88,7 @@ def build(bld): types.cc util.cc version.cc + wave_pcm_descriptor.cc """ headers = """ @@ -100,6 +106,7 @@ def build(bld): decrypted_kdm.h decrypted_kdm_key.h encrypted_kdm.h + essence_descriptor.h exceptions.h font_asset.h gamma_transfer_function.h @@ -123,7 +130,9 @@ def build(bld): picture_asset.h picture_asset_writer.h raw_convert.h + resource.h rgb_xyz.h + rgba_descriptor.h reel.h reel_asset.h reel_mono_picture_asset.h @@ -133,6 +142,8 @@ def build(bld): reel_stereo_picture_asset.h reel_subtitle_asset.h ref.h + segment.h + sequence.h smpte_load_font_node.h smpte_subtitle_asset.h sound_frame.h @@ -147,6 +158,7 @@ def build(bld): types.h util.h version.h + wave_pcm_descriptor.h """ # Main library |
