diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-05 14:01:00 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-05 14:01:00 +0000 |
| commit | 342aad2ddf893aaaafa9a2c9980579d2dc4ec125 (patch) | |
| tree | 85cd4c34316d76679c18ea49c7de33e8066a6a1c /src | |
| parent | aa632b458fc2aa5ff1ca2e2702dcf589ae627d7d (diff) | |
Try to rationalise handling of urn:uuid: prefixes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 5 | ||||
| -rw-r--r-- | src/dcp.cc | 2 | ||||
| -rw-r--r-- | src/encrypted_kdm.cc | 8 | ||||
| -rw-r--r-- | src/object.cc | 3 | ||||
| -rw-r--r-- | src/reel.cc | 2 | ||||
| -rw-r--r-- | src/reel_asset.cc | 7 | ||||
| -rw-r--r-- | src/reel_mxf.cc | 5 | ||||
| -rw-r--r-- | src/smpte_load_font_node.cc | 3 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.cc | 2 | ||||
| -rw-r--r-- | src/util.cc | 7 | ||||
| -rw-r--r-- | src/util.h | 2 |
11 files changed, 25 insertions, 21 deletions
@@ -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 (""); @@ -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 */ diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index 22bb86e4..205d591b 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -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")) diff --git a/src/object.cc b/src/object.cc index 315e501a..f8107218 100644 --- a/src/object.cc +++ b/src/object.cc @@ -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:"); } diff --git a/src/reel.cc b/src/reel.cc index 3ab9993f..772ac717 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -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"); diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 654cde03..2414c69f 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -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 diff --git a/src/reel_mxf.cc b/src/reel_mxf.cc index f9e8890a..c03acfa8 100644 --- a/src/reel_mxf.cc +++ b/src/reel_mxf.cc @@ -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); } } diff --git a/src/smpte_load_font_node.cc b/src/smpte_load_font_node.cc index 3efd2d58..14a1c9fc 100644 --- a/src/smpte_load_font_node.cc +++ b/src/smpte_load_font_node.cc @@ -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())) { } diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 00a9299a..b4190dd5 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -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 ( diff --git a/src/util.cc b/src/util.cc index 64c695d1..b9c21dc5 100644 --- a/src/util.cc +++ b/src/util.cc @@ -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); +} @@ -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); |
