Try to rationalise handling of urn:uuid: prefixes.
authorCarl Hetherington <cth@carlh.net>
Tue, 5 Jan 2016 14:01:00 +0000 (14:01 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 5 Jan 2016 14:01:00 +0000 (14:01 +0000)
src/cpl.cc
src/dcp.cc
src/encrypted_kdm.cc
src/object.cc
src/reel.cc
src/reel_asset.cc
src/reel_mxf.cc
src/smpte_load_font_node.cc
src/smpte_subtitle_asset.cc
src/util.cc
src/util.h

index 9633abc45293245b79857926812e605c589c91b1..0677ec36c0c7ded0bc4caf8c4da9280fb4aa376e 100644 (file)
@@ -66,10 +66,7 @@ CPL::CPL (boost::filesystem::path file)
        cxml::Document f ("CompositionPlaylist");
        f.read_file (file);
 
-       _id = f.string_child ("Id");
-       if (_id.length() > 9) {
-               _id = _id.substr (9);
-       }
+       _id = remove_urn_uuid (f.string_child ("Id"));
        _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 ("");
index 40d288b89781ad79ce24bbc3a3d0a38f64415779..2aa1d57579334345bf44ea783e1825254f1d557e 100644 (file)
@@ -112,7 +112,7 @@ DCP::read (bool keep_going, ReadErrors* errors)
                if (starts_with (p, "file://")) {
                        p = p.substr (7);
                }
-               paths.insert (make_pair (i->string_child ("Id"), p));
+               paths.insert (make_pair (remove_urn_uuid (i->string_child ("Id")), p));
        }
 
        /* Read all the assets from the asset map */
index 22bb86e4f46eadd13176e8610f6785922d522462..205d591b53ab85ca613148322ad24dd97cf1e4fa 100644 (file)
@@ -221,7 +221,7 @@ public:
 
        TypedKeyId (shared_ptr<const cxml::Node> node)
                : key_type (node->string_child ("KeyType"))
-               , key_id (node->string_child ("KeyId").substr (9))
+               , key_id (remove_urn_uuid (node->string_child ("KeyId")))
        {
 
        }
@@ -275,7 +275,7 @@ public:
        AuthorizedDeviceInfo () {}
 
        AuthorizedDeviceInfo (shared_ptr<const cxml::Node> node)
-               : device_list_identifier (node->string_child ("DeviceListIdentifier").substr (9))
+               : device_list_identifier (remove_urn_uuid (node->string_child ("DeviceListIdentifier")))
                , device_list_description (node->optional_string_child ("DeviceListDescription"))
        {
                BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("DeviceList")->node_children("CertificateThumbprint")) {
@@ -352,7 +352,7 @@ public:
 
        KDMRequiredExtensions (shared_ptr<const cxml::Node> node)
                : recipient (node->node_child ("Recipient"))
-               , composition_playlist_id (node->string_child ("CompositionPlaylistId").substr (9))
+               , composition_playlist_id (remove_urn_uuid (node->string_child ("CompositionPlaylistId")))
                , content_title_text (node->string_child ("ContentTitleText"))
                , not_valid_before (node->string_child ("ContentKeysNotValidBefore"))
                , not_valid_after (node->string_child ("ContentKeysNotValidAfter"))
@@ -420,7 +420,7 @@ public:
        {}
 
        AuthenticatedPublic (shared_ptr<const cxml::Node> node)
-               : message_id (node->string_child ("MessageId").substr (9))
+               : message_id (remove_urn_uuid (node->string_child ("MessageId")))
                , annotation_text (node->string_child ("AnnotationText"))
                , issue_date (node->string_child ("IssueDate"))
                , signer (node->node_child ("Signer"))
index 315e501aaf4403f37f5de4a68439d2b783a9489a..f8107218faafaf9bee739a64bb3a7fa24f9c4650 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "object.h"
+#include "dcp_assert.h"
 #include "util.h"
 
 using std::string;
@@ -40,5 +41,5 @@ Object::Object ()
 Object::Object (string id)
        : _id (id)
 {
-
+       DCP_ASSERT (_id.substr(0, 9) != "urn:uuid:");
 }
index 3ab9993f9bab14c0ed769772effee05040965a32..772ac717409a3cbdd12897229121a6ea1ddae8b5 100644 (file)
@@ -42,7 +42,7 @@ using boost::dynamic_pointer_cast;
 using namespace dcp;
 
 Reel::Reel (boost::shared_ptr<const cxml::Node> node)
-       : Object (node->string_child ("Id"))
+       : Object (remove_urn_uuid (node->string_child ("Id")))
 {
        shared_ptr<cxml::Node> asset_list = node->node_child ("AssetList");
 
index 654cde031effe73f83304b53710d102697d5c999..2414c69fd4b68287328c7d151b89afc77c0fb30a 100644 (file)
@@ -67,7 +67,7 @@ ReelAsset::ReelAsset (shared_ptr<Asset> asset, Fraction edit_rate, int64_t intri
 }
 
 ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
-       : Object (node->string_child ("Id"))
+       : Object (remove_urn_uuid (node->string_child ("Id")))
        , _asset_ref (_id)
        , _annotation_text (node->optional_string_child ("AnnotationText").get_value_or (""))
        , _edit_rate (Fraction (node->string_child ("EditRate")))
@@ -76,10 +76,7 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
        , _duration (node->number_child<int64_t> ("Duration"))
        , _hash (node->optional_string_child ("Hash").get_value_or (""))
 {
-       if (_id.length() > 9) {
-               _id = _id.substr (9);
-               _asset_ref.set_id (_id);
-       }
+
 }
 
 void
index f9e8890afed05d772c58b24a7900fba1a681e4e9..c03acfa84cf7b53303d91498eed6d70114394a1d 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "reel_mxf.h"
+#include "util.h"
 #include "mxf.h"
 #include "dcp_assert.h"
 #include <libcxml/cxml.h>
@@ -37,7 +38,7 @@ ReelMXF::ReelMXF (optional<string> key_id)
 ReelMXF::ReelMXF (shared_ptr<const cxml::Node> node)
        : _key_id (node->optional_string_child ("KeyId"))
 {
-       if (_key_id && _key_id.get().length() > 9) {
-               _key_id = _key_id.get().substr (9);
+       if (_key_id) {
+               _key_id = remove_urn_uuid (*_key_id);
        }
 }
index 3efd2d58d46a46eb44276f3e3724ce3c6fb08db8..14a1c9fcd9d6eac77b343ff78b7ecc1b7a4210a3 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "smpte_load_font_node.h"
+#include "util.h"
 #include <libcxml/cxml.h>
 
 using std::string;
@@ -33,7 +34,7 @@ SMPTELoadFontNode::SMPTELoadFontNode (string id, string urn_)
 
 SMPTELoadFontNode::SMPTELoadFontNode (shared_ptr<const cxml::Node> node)
        : LoadFontNode (node->string_attribute ("ID"))
-       , urn (node->content().substr (9))
+       , urn (remove_urn_uuid (node->content()))
 {
 
 }
index 00a9299aacf7957cff023375267dac1ba83a84da..b4190dd518d9d186f85b13383d642756f5bccb4d 100644 (file)
@@ -81,7 +81,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
                reader.reset ();
                try {
                        xml->read_file (file);
-                       _id = xml->string_child ("Id").substr (9);
+                       _id = remove_urn_uuid (xml->string_child ("Id"));
                } catch (cxml::Error& e) {
                        boost::throw_exception (
                                DCPReadError (
index 64c695d13d88a8e2062c091e144c6b30252a0111..b9c21dc55fb3e700e8ea7ea211c76788dd7e990c 100644 (file)
@@ -395,3 +395,10 @@ dcp::find_child (xmlpp::Node const * node, string name)
        DCP_ASSERT (i != c.end ());
        return *i;
 }
+
+string
+dcp::remove_urn_uuid (string raw)
+{
+       DCP_ASSERT (raw.substr(0, 9) == "urn:uuid:");
+       return raw.substr (9);
+}
index 27afdfa2834f30bf373baf28ead1f0411f33a0b1..70c07f1dd84f554eb90487d0f0f7499b3c0cb766 100644 (file)
@@ -55,7 +55,7 @@ extern std::string content_kind_to_string (ContentKind kind);
 extern ContentKind content_kind_from_string (std::string kind);
 extern bool empty_or_white_space (std::string s);
 extern bool ids_equal (std::string a, std::string b);
-
+extern std::string remove_urn_uuid (std::string raw);
 extern void init ();
 
 extern int base64_decode (std::string const & in, unsigned char* out, int out_length);