summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/im_cpl.cc113
-rw-r--r--src/im_cpl.h57
-rw-r--r--src/im_package.cc57
-rw-r--r--src/im_package.h9
-rw-r--r--src/mono_picture_asset.cc15
-rw-r--r--src/package.h1
-rw-r--r--src/resource.cc38
-rw-r--r--src/resource.h45
-rw-r--r--src/segment.cc42
-rw-r--r--src/segment.h39
-rw-r--r--src/sequence.cc34
-rw-r--r--src/sequence.h39
-rw-r--r--src/wscript5
-rw-r--r--test/imp_test.cc29
-rw-r--r--test/wscript1
15 files changed, 513 insertions, 11 deletions
diff --git a/src/im_cpl.cc b/src/im_cpl.cc
new file mode 100644
index 00000000..f45a3db0
--- /dev/null
+++ b/src/im_cpl.cc
@@ -0,0 +1,113 @@
+/*
+ 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 "im_cpl.h"
+#include "util.h"
+#include "xml.h"
+#include "dcp_assert.h"
+#include "segment.h"
+#include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
+
+using std::list;
+using std::string;
+using boost::shared_ptr;
+using namespace dcp::im;
+
+CPL::CPL (boost::filesystem::path file)
+ : Asset (file)
+{
+ cxml::Document f ("CompositionPlaylist");
+ f.read_file (file);
+
+ _id = remove_urn_uuid (f.string_child ("Id"));
+
+ /* XXX: I don't know whether these things are required or optional */
+
+ _annotation = f.optional_string_child("Annotation").get_value_or ("");
+ _issue_date = f.string_child("IssueDate");
+ _issuer = f.optional_string_child("Issuer").get_value_or ("");
+ _creator = f.optional_string_child("Creator").get_value_or ("");
+ /* ContentOriginator? */
+ _content_title = f.optional_string_child("ContentTitle").get_value_or ("");
+ _content_kind = content_kind_from_string (f.string_child ("ContentKind"));
+ BOOST_FOREACH (cxml::ConstNodePtr i, f.node_child("ContentVersionList")->node_children("ContentVersion")) {
+ _content_versions.push_back (make_pair (remove_urn_uuid(i->string_child("Id")), i->string_child("LabelText")));
+ }
+ /* EssenceDescriptorList */
+ _edit_rate = Fraction (f.string_child("EditRate"));
+ /* ExtensionProperties */
+
+ _segments = type_grand_children<Segment> (f, "SegmentList", "Segment");
+
+ /* f.done (); */
+}
+
+void
+CPL::resolve_refs (list<shared_ptr<Asset> > assets)
+{
+ /* XXX */
+}
+
+string
+CPL::pkl_type (Standard standard) const
+{
+ switch (standard) {
+ case DCP_INTEROP:
+ case DCP_SMPTE:
+ /* This class shouldn't be writing DCP CPLs */
+ DCP_ASSERT (false);
+ case IMP:
+ return "text/xml";
+ }
+
+ return "";
+}
+
+/** Write an CompositonPlaylist XML file.
+ * @param file Filename to write.
+ * @param standard Must be IMP.
+ * @param signer Signer to sign the CPL, or 0 to add no signature.
+ */
+void
+CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<const CertificateChain> signer) const
+{
+ xmlpp::Document doc;
+ xmlpp::Element* root = 0;
+
+ switch (standard) {
+ case DCP_INTEROP:
+ case DCP_SMPTE:
+ /* This class shouldn't be writing DCP CPLs */
+ root = doc.create_root_node ("CompositionPlaylist", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#");
+ break;
+ case IMP:
+ root = doc.create_root_node ("CompositionPlaylist", "http://www.smpte-ra.org/schemas/429-7/2006/CPL");
+ break;
+ }
+
+ if (signer) {
+ root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
+ }
+
+ /* XXX */
+
+ set_file (file);
+}
diff --git a/src/im_cpl.h b/src/im_cpl.h
new file mode 100644
index 00000000..2b91c6a4
--- /dev/null
+++ b/src/im_cpl.h
@@ -0,0 +1,57 @@
+/*
+ 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 "asset.h"
+#include "certificate_chain.h"
+
+namespace dcp {
+namespace im {
+
+class Segment;
+
+class CPL : public dcp::Asset
+{
+public:
+ CPL (boost::filesystem::path file);
+
+ void write_xml (
+ boost::filesystem::path file,
+ Standard standard,
+ boost::shared_ptr<const dcp::CertificateChain>
+ ) const;
+
+ void resolve_refs (std::list<boost::shared_ptr<dcp::Asset> >);
+
+protected:
+ std::string pkl_type (Standard standard) const;
+
+private:
+ std::string _annotation;
+ std::string _issue_date;
+ std::string _issuer;
+ std::string _creator;
+ std::string _content_title;
+ std::string _content_kind;
+ std::list<std::pair<std::string, std::string> > _content_versions;
+ dcp::Fraction _edit_rate;
+ std::list<boost::shared_ptr<Segment> > _segments;
+};
+
+}
+}
diff --git a/src/im_package.cc b/src/im_package.cc
index a7b4674e..c845844f 100644
--- a/src/im_package.cc
+++ b/src/im_package.cc
@@ -18,7 +18,15 @@
*/
#include "im_package.h"
+#include "asset.h"
+#include "mono_picture_asset.h"
+#include "sound_asset.h"
+#include "smpte_subtitle_asset.h"
+#include "AS_DCP.h"
+using std::list;
+using std::string;
+using boost::shared_ptr;
using namespace dcp::im;
Package::Package (boost::filesystem::path directory)
@@ -27,17 +35,58 @@ Package::Package (boost::filesystem::path directory)
}
-list<Asset>
+list<shared_ptr<dcp::Asset> >
Package::assets () const
{
/* XXX */
- return list<Asset> ();
+ return list<shared_ptr<Asset> > ();
}
void
-Package::write_xml (dcp::XMLMetadata metadata, shared_ptr<const CertificateChain> signer = shared_ptr<const CertificateChain> ())
+Package::write_xml (dcp::XMLMetadata metadata, shared_ptr<const dcp::CertificateChain> signer)
{
- do_write_xml (dcp::IMF, metadata, signer);
+ do_write_xml (dcp::IMP, metadata, signer);
+}
+
+shared_ptr<dcp::Asset>
+Package::xml_asset_factory (boost::filesystem::path file, string root) const
+{
+ shared_ptr<dcp::Asset> asset;
+
+ if (root == "CompositionPlaylist") {
+ asset.reset (new CPL (file));
+ }
+
+ return asset;
+}
+
+shared_ptr<dcp::Asset>
+Package::mxf_asset_factory (boost::filesystem::path file) const
+{
+ shared_ptr<dcp::Asset> asset;
+
+ ASDCP::EssenceType_t type;
+ if (ASDCP::EssenceType (file.string().c_str(), type) != ASDCP::RESULT_OK) {
+ throw PackageReadError ("Could not find essence type");
+ }
+
+ switch (type) {
+ case ASDCP::ESS_UNKNOWN:
+ case ASDCP::ESS_AS02_JPEG_2000:
+ asset.reset (new dcp::MonoPictureAsset (file));
+ break;
+ case ASDCP::ESS_AS02_PCM_24b_48k:
+ case ASDCP::ESS_AS02_PCM_24b_96k:
+ asset.reset (new dcp::SoundAsset (file));
+ break;
+ case ASDCP::ESS_AS02_TIMED_TEXT:
+ asset.reset (new dcp::SMPTESubtitleAsset (file));
+ break;
+ default:
+ throw PackageReadError ("Unknown MXF essence type");
+ }
+
+ return asset;
}
string
diff --git a/src/im_package.h b/src/im_package.h
index 4ce4aad6..f3d77c31 100644
--- a/src/im_package.h
+++ b/src/im_package.h
@@ -17,9 +17,13 @@
*/
+#include "package.h"
+
namespace dcp {
namespace im {
+class CPL;
+
class Package : public dcp::Package<CPL>
{
public:
@@ -29,9 +33,12 @@ public:
void write_xml (
dcp::XMLMetadata metadata = dcp::XMLMetadata (),
- boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> ()
+ boost::shared_ptr<const dcp::CertificateChain> signer = boost::shared_ptr<const dcp::CertificateChain> ()
);
+private:
+ boost::shared_ptr<dcp::Asset> xml_asset_factory (boost::filesystem::path file, std::string root) const;
+ boost::shared_ptr<dcp::Asset> mxf_asset_factory (boost::filesystem::path file) const;
std::string pkl_annotation_text () const;
};
diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc
index e7838ad7..b1786f0c 100644
--- a/src/mono_picture_asset.cc
+++ b/src/mono_picture_asset.cc
@@ -20,6 +20,8 @@
#include "mono_picture_asset.h"
#include "mono_picture_asset_writer.h"
#include "AS_DCP.h"
+/* XXX */
+#include "AS_02.h"
#include "KM_fileio.h"
#include "exceptions.h"
#include "dcp_assert.h"
@@ -37,18 +39,19 @@ using namespace dcp;
MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file)
: PictureAsset (file)
{
- ASDCP::JP2K::MXFReader reader;
+ /* XXX */
+ AS_02::JP2K::MXFReader reader;
Kumu::Result_t r = reader.OpenRead (file.string().c_str());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
}
- ASDCP::JP2K::PictureDescriptor desc;
- if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
- boost::throw_exception (PackageReadError ("could not read video MXF information"));
- }
+// ASDCP::JP2K::PictureDescriptor desc;
+// if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
+// boost::throw_exception (PackageReadError ("could not read video MXF information"));
+// }
- read_picture_descriptor (desc);
+// read_picture_descriptor (desc);
ASDCP::WriterInfo info;
if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
diff --git a/src/package.h b/src/package.h
index b0733b53..a0adbed2 100644
--- a/src/package.h
+++ b/src/package.h
@@ -22,6 +22,7 @@
#include "package_base.h"
#include "dc_cpl.h"
+#include "im_cpl.h"
#include "util.h"
#include <boost/foreach.hpp>
diff --git a/src/resource.cc b/src/resource.cc
new file mode 100644
index 00000000..cffb873f
--- /dev/null
+++ b/src/resource.cc
@@ -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.
+
+*/
+
+#include "resource.h"
+#include "util.h"
+
+using namespace dcp::im;
+
+Resource::Resource (cxml::ConstNodePtr node)
+ : Object (remove_urn_uuid (node->string_child ("Id")))
+ , _annotation (node->string_child ("Annotation"))
+ , _edit_rate (node->string_child ("EditRate"))
+ , _intrinsic_duration (node->number_child<int64_t> ("IntrinsicDuration"))
+ , _entry_point (node->number_child<int64_t> ("EntryPoint"))
+ , _source_duration (node->number_child<int64_t> ("SourceDuration"))
+ , _repeat_count (node->number_child<int> ("RepeatCount"))
+ , _source_encoding (remove_urn_uuid (node->string_child ("SourceEncoding")))
+ , _track_file_id (remove_urn_uuid (node->string_child ("TrackFileId")))
+ , _hash (node->string_child ("TrackFileId"))
+{
+
+}
diff --git a/src/resource.h b/src/resource.h
new file mode 100644
index 00000000..2f4fded5
--- /dev/null
+++ b/src/resource.h
@@ -0,0 +1,45 @@
+/*
+ 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 "types.h"
+#include <libcxml/cxml.h>
+
+namespace dcp {
+namespace im {
+
+class Resource : public Object
+{
+public:
+ Resource (cxml::ConstNodePtr node);
+
+private:
+ std::string _annotation;
+ dcp::Fraction _edit_rate;
+ int64_t _intrinsic_duration;
+ int64_t _entry_point;
+ int64_t _source_duration;
+ int _repeat_count;
+ std::string _source_encoding;
+ std::string _track_file_id;
+ std::string _hash;
+};
+
+}
+}
diff --git a/src/segment.cc b/src/segment.cc
new file mode 100644
index 00000000..055da203
--- /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"
+#include "util.h"
+
+using namespace dcp::im;
+
+Segment::Segment (cxml::ConstNodePtr node)
+ : Object (remove_urn_uuid (node->string_child ("Id")))
+{
+ cxml::ConstNodePtr sequence_list = node->node_child ("SequenceList");
+
+ cxml::ConstNodePtr main_image = sequence_list->node_child ("MainImageSequence");
+ if (main_image) {
+ _main_image.reset (new Sequence (main_image));
+ }
+
+ cxml::ConstNodePtr main_audio = sequence_list->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..6cffcf46
--- /dev/null
+++ b/src/segment.h
@@ -0,0 +1,39 @@
+/*
+ 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 {
+namespace im {
+
+class Sequence;
+
+class Segment : public Object
+{
+public:
+ Segment (cxml::ConstNodePtr);
+
+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..11a64715
--- /dev/null
+++ b/src/sequence.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 "sequence.h"
+#include "util.h"
+#include "xml.h"
+#include "resource.h"
+#include "xml.h"
+
+using namespace dcp::im;
+
+Sequence::Sequence (cxml::ConstNodePtr node)
+ : Object (remove_urn_uuid (node->string_child ("Id")))
+ , _track_id (remove_urn_uuid (node->string_child ("TrackId")))
+ , _resources (dcp::type_grand_children<Resource> (node, "ResourceList", "Resource"))
+{
+
+}
diff --git a/src/sequence.h b/src/sequence.h
new file mode 100644
index 00000000..ee1c664a
--- /dev/null
+++ b/src/sequence.h
@@ -0,0 +1,39 @@
+/*
+ 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 {
+namespace im {
+
+class Resource;
+
+class Sequence : public Object
+{
+public:
+ Sequence (cxml::ConstNodePtr node);
+
+private:
+ std::string _track_id;
+ std::list<boost::shared_ptr<Resource> > _resources;
+};
+
+}
+}
diff --git a/src/wscript b/src/wscript
index 8442c6de..d41a2fee 100644
--- a/src/wscript
+++ b/src/wscript
@@ -37,6 +37,8 @@ def build(bld):
font_asset.cc
font_node.cc
gamma_transfer_function.cc
+ im_cpl.cc
+ im_package.cc
interop_load_font_node.cc
interop_subtitle_asset.cc
j2k.cc
@@ -63,7 +65,10 @@ def build(bld):
reel_stereo_picture_asset.cc
reel_subtitle_asset.cc
ref.cc
+ resource.cc
rgb_xyz.cc
+ segment.cc
+ sequence.cc
smpte_load_font_node.cc
smpte_subtitle_asset.cc
sound_asset.cc
diff --git a/test/imp_test.cc b/test/imp_test.cc
new file mode 100644
index 00000000..dda47b2e
--- /dev/null
+++ b/test/imp_test.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 "im_package.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+/** Test basic reading of a IMP */
+BOOST_AUTO_TEST_CASE (imp_test)
+{
+ dcp::im::Package package (private_test / "data" / "BelleSebastian2_TLR-2-2398_HD-239_DE-XX_CH_51_HD_PATH_20151229_DGL_SMPTE_IMPAPP2_OV");
+ package.read ();
+}
diff --git a/test/wscript b/test/wscript
index 60a781f6..d2bade33 100644
--- a/test/wscript
+++ b/test/wscript
@@ -60,6 +60,7 @@ def build(bld):
exception_test.cc
fraction_test.cc
gamma_transfer_function_test.cc
+ imp_test.cc
interop_load_font_test.cc
local_time_test.cc
kdm_test.cc