X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcpl.cc;h=0677ec36c0c7ded0bc4caf8c4da9280fb4aa376e;hb=03fb9d475366b6e02b6bde4421607f7dcd9936ad;hp=766b91c315660d858880dac57aa57414b5d4aa95;hpb=2ae92dcc97765deb2845dd07a338858aeb375cb3;p=libdcp.git diff --git a/src/cpl.cc b/src/cpl.cc index 766b91c3..0677ec36 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington 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 @@ -21,7 +21,7 @@ #include "util.h" #include "reel.h" #include "metadata.h" -#include "signer.h" +#include "certificate_chain.h" #include "xml.h" #include "reel_picture_asset.h" #include "reel_sound_asset.h" @@ -51,11 +51,11 @@ CPL::CPL (string annotation_text, ContentKind content_kind) , _content_kind (content_kind) , _content_version_id ("urn:uuid:" + make_uuid ()) { - /* default _content_version_id to and _content_version_label to + /* default _content_version_id to a random ID and _content_version_label to a random ID and the current time. */ - _content_version_id = "urn:uuid:" + make_uuid() + LocalTime().as_string (); - _content_version_label_text = _content_version_id; + _content_version_id = "urn:uuid:" + make_uuid(); + _content_version_label_text = _content_version_id + LocalTime().as_string (); } /** Construct a CPL object from a XML 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 (""); @@ -107,7 +104,7 @@ CPL::add (boost::shared_ptr reel) * @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 signer) const +CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr signer) const { xmlpp::Document doc; xmlpp::Element* root; @@ -236,10 +233,10 @@ CPL::add (DecryptedKDM const & kdm) } void -CPL::resolve_refs (list > objects) +CPL::resolve_refs (list > assets) { BOOST_FOREACH (shared_ptr i, _reels) { - i->resolve_refs (objects); + i->resolve_refs (assets); } } @@ -256,3 +253,12 @@ CPL::pkl_type (Standard standard) const } } +int64_t +CPL::duration () const +{ + int64_t d = 0; + BOOST_FOREACH (shared_ptr i, _reels) { + d += i->duration (); + } + return d; +}