Tidy up metadata handling.
authorCarl Hetherington <cth@carlh.net>
Wed, 5 Feb 2014 11:18:01 +0000 (11:18 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 5 Feb 2014 11:18:01 +0000 (11:18 +0000)
src/cpl.cc
src/cpl.h
src/dcp.cc

index 215640d316b29b5598ea1403d3d9dff14d7f8720..cd255309dcb65fbdab8b3bd6d49d9dd2f518be97 100644 (file)
@@ -74,8 +74,9 @@ CPL::CPL (boost::filesystem::path file)
                _id = _id.substr (9);
        }
        _annotation_text = f.optional_string_child ("AnnotationText").get_value_or ("");
-       _issue_date = f.string_child ("IssueDate");
-       _creator = f.optional_string_child ("Creator").get_value_or ("");
+       _metadata.issuer = f.optional_string_child ("Issuer").get_value_or ("");
+       _metadata.creator = f.optional_string_child ("Creator").get_value_or ("");
+       _metadata.issue_date = f.string_child ("IssueDate");
        _content_title_text = f.string_child ("ContentTitleText");
        _content_kind = content_kind_from_string (f.string_child ("ContentKind"));
        shared_ptr<cxml::Node> content_version = f.optional_node_child ("ContentVersion");
@@ -106,11 +107,10 @@ CPL::add (boost::shared_ptr<Reel> reel)
 /** Write an CompositonPlaylist XML file.
  *  @param file Filename to write.
  *  @param standard INTEROP or SMPTE.
- *  @param metadata Metadata to use.
  *  @param signer Signer to sign the CPL, or 0 to add no signature.
  */
 void
-CPL::write_xml (boost::filesystem::path file, Standard standard, XMLMetadata metadata, shared_ptr<const Signer> signer) const
+CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<const Signer> signer) const
 {
        xmlpp::Document doc;
        xmlpp::Element* root;
@@ -126,9 +126,9 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, XMLMetadata met
        
        root->add_child("Id")->add_child_text ("urn:uuid:" + _id);
        root->add_child("AnnotationText")->add_child_text (_annotation_text);
-       root->add_child("IssueDate")->add_child_text (metadata.issue_date);
-       root->add_child("Issuer")->add_child_text (metadata.issuer);
-       root->add_child("Creator")->add_child_text (metadata.creator);
+       root->add_child("IssueDate")->add_child_text (_metadata.issue_date);
+       root->add_child("Issuer")->add_child_text (_metadata.issuer);
+       root->add_child("Creator")->add_child_text (_metadata.creator);
        root->add_child("ContentTitleText")->add_child_text (_content_title_text);
        root->add_child("ContentKind")->add_child_text (content_kind_to_string (_content_kind));
        {
index d28737e146e6acfad57f6d969c0ae19f9833f6f7..6af7fe56bab374395b6e72909fceb9f3adf1b0e8 100644 (file)
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -24,6 +24,7 @@
 #include "certificates.h"
 #include "key.h"
 #include "asset.h"
+#include "metadata.h"
 #include <libxml++/libxml++.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/function.hpp>
@@ -103,7 +104,6 @@ public:
        void write_xml (
                boost::filesystem::path file,
                Standard standard,
-               XMLMetadata,
                boost::shared_ptr<const Signer>
                ) const;
 
@@ -117,8 +117,10 @@ protected:
 
 private:
        std::string _annotation_text;               ///< <AnnotationText>
-       std::string _issue_date;                    ///< <IssueDate>
-       std::string _creator;                       ///< <Creator>
+       /** <Issuer>, <Creator> and <IssueDate>.  These are grouped
+        *  because they occur together in a few places.
+        */
+       XMLMetadata _metadata;
        std::string _content_title_text;            ///< <ContentTitleText>
        ContentKind _content_kind;                  ///< <ContentKind>
        std::string _content_version_id;            ///< <Id> in <ContentVersion>
index 2588c6548f15c5e096d315a1c0d1b1eaeaa7939a..36eedcf799d2814afa8c7b5f77b743f96fc1c566 100644 (file)
@@ -322,6 +322,11 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMeta
        doc.write_to_file (p.string (), "UTF-8");
 }
 
+/** Write all the XML files for this DCP.
+ *  @param standand INTEROP or SMPTE.
+ *  @param metadata Metadata to use for PKL and asset map files.
+ *  @param signer Signer to use, or 0.
+ */
 void
 DCP::write_xml (
        Standard standard,
@@ -332,7 +337,7 @@ DCP::write_xml (
        list<shared_ptr<CPL> > cpl = cpls ();
        for (list<shared_ptr<CPL> >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) {
                string const filename = (*i)->id() + "_cpl.xml";
-               (*i)->write_xml (_directory / filename, standard, metadata, signer);
+               (*i)->write_xml (_directory / filename, standard, signer);
        }
 
        string const pkl_uuid = make_uuid ();