From 71de90f74085744d1c5ca35253eec003e41497a2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 8 Feb 2014 13:30:42 +0000 Subject: Fix a couple of errors in Interop XML Reported-by: Ivan Pullman --- src/asset.cc | 9 +++++++-- src/asset.h | 5 ++++- src/cpl.cc | 8 ++++++-- src/cpl.h | 2 +- src/dcp.cc | 11 ++++++++--- src/picture_asset.h | 6 +++++- src/sound_asset.h | 6 ++++++ src/subtitle_asset.h | 6 ++++++ 8 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/asset.cc b/src/asset.cc index 91a19e69..f6642d9c 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -31,6 +31,7 @@ #include "asset.h" #include "util.h" #include "metadata.h" +#include "compose.hpp" using namespace std; using namespace boost; @@ -51,14 +52,18 @@ Asset::Asset (boost::filesystem::path directory, boost::filesystem::path file_na } void -Asset::write_to_pkl (xmlpp::Node* node) const +Asset::write_to_pkl (xmlpp::Node* node, bool interop) const { xmlpp::Node* asset = node->add_child ("Asset"); asset->add_child("Id")->add_child_text ("urn:uuid:" + _uuid); asset->add_child("AnnotationText")->add_child_text (_file_name.string ()); asset->add_child("Hash")->add_child_text (digest ()); asset->add_child("Size")->add_child_text (lexical_cast (filesystem::file_size(path()))); - asset->add_child("Type")->add_child_text ("application/mxf"); + if (interop) { + asset->add_child("Type")->add_child (String::compose ("application/x-smpte-mxf;asdcpKind=%1", asdcp_kind ())); + } else { + asset->add_child("Type")->add_child_text ("application/mxf"); + } } void diff --git a/src/asset.h b/src/asset.h index 269d5c4b..773e3d48 100644 --- a/src/asset.h +++ b/src/asset.h @@ -65,7 +65,7 @@ public: /** Write details of the asset to a PKL AssetList node. * @param p Parent node. */ - void write_to_pkl (xmlpp::Node *) const; + void write_to_pkl (xmlpp::Node *, bool interop) const; /** Write details of the asset to a ASSETMAP stream. * @param s Stream. @@ -129,6 +129,9 @@ public: virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function) const; protected: + + /** @return Interop PKL asdcpKind for the <Type> tag e.g. Picture, Sound etc. */ + virtual std::string asdcp_kind () const = 0; std::string digest () const; diff --git a/src/cpl.cc b/src/cpl.cc index dcb730ff..e333df0d 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -243,13 +243,17 @@ CPL::write_xml (bool interop, XMLMetadata const & metadata, shared_ptradd_child ("Asset"); asset->add_child("Id")->add_child_text ("urn:uuid:" + _id); asset->add_child("Hash")->add_child_text (_digest); asset->add_child("Size")->add_child_text (lexical_cast (_length)); - asset->add_child("Type")->add_child_text ("text/xml"); + if (interop) { + asset->add_child("Type")->add_child_text ("text/xml;asdcpKind=CPL"); + } else { + asset->add_child("Type")->add_child_text ("text/xml"); + } } list > diff --git a/src/cpl.h b/src/cpl.h index aadc7347..c50d8f90 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -96,7 +96,7 @@ public: void write_xml (bool, XMLMetadata const &, boost::shared_ptr) const; void write_to_assetmap (xmlpp::Node *) const; - void write_to_pkl (xmlpp::Node *) const; + void write_to_pkl (xmlpp::Node *, bool) const; void add_kdm (KDM const &); diff --git a/src/dcp.cc b/src/dcp.cc index f80726fc..ae692256 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -111,11 +111,11 @@ DCP::write_pkl (string pkl_uuid, bool interop, XMLMetadata const & metadata, sha xmlpp::Element* asset_list = pkl->add_child("AssetList"); list > a = assets (); for (list >::const_iterator i = a.begin(); i != a.end(); ++i) { - (*i)->write_to_pkl (asset_list); + (*i)->write_to_pkl (asset_list, interop); } for (list >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { - (*i)->write_to_pkl (asset_list); + (*i)->write_to_pkl (asset_list, interop); } if (signer) { @@ -138,7 +138,12 @@ DCP::write_volindex (bool interop) const } xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("VolumeIndex", "http://www.smpte-ra.org/schemas/429-9/2007/AM"); + xmlpp::Element* root; + if (interop) { + root = doc.create_root_node ("VolumeIndex", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#"); + } else { + root = doc.create_root_node ("VolumeIndex", "http://www.smpte-ra.org/schemas/429-9/2007/AM"); + } root->add_child("Index")->add_child_text ("1"); doc.write_to_file (p.string (), "UTF-8"); } diff --git a/src/picture_asset.h b/src/picture_asset.h index b8dab052..c09808e2 100644 --- a/src/picture_asset.h +++ b/src/picture_asset.h @@ -78,7 +78,11 @@ public: void write_to_cpl (xmlpp::Element *) const; -protected: +protected: + + std::string asdcp_kind () const { + return "Picture"; + } bool frame_buffer_equals ( int frame, EqualityOptions opt, boost::function note, diff --git a/src/sound_asset.h b/src/sound_asset.h index d2e49bd1..c52a5436 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -112,6 +112,12 @@ public: return _sampling_rate; } +protected: + + std::string asdcp_kind () const { + return "Sound"; + } + private: std::string key_type () const; void construct (boost::function get_path); diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index 74ab9873..0598a296 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -161,6 +161,12 @@ public: void write_xml () const; Glib::ustring xml_as_string () const; +protected: + + std::string asdcp_kind () const { + return "Subtitle"; + } + private: std::string font_id_to_name (std::string id) const; -- cgit v1.2.3