Remove XMLMetadata from DCP::write_xml and DCP::write_assetmap.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Aug 2020 15:04:28 +0000 (17:04 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Sep 2020 17:29:21 +0000 (19:29 +0200)
src/dcp.cc
src/dcp.h
src/wscript
test/dcp_test.cc
test/encryption_test.cc
test/write_subtitle_test.cc

index bf8366f3dd97288b598b34f8aa6c7a7fd8538356..b00a6a19a16a9c5110bb782e4a4c1352f95df1e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -378,7 +378,10 @@ DCP::write_volindex (Standard standard) const
 }
 
 void
-DCP::write_assetmap (Standard standard, string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const
+DCP::write_assetmap (
+       Standard standard, string pkl_uuid, boost::filesystem::path pkl_path,
+       string issuer, string creator, string issue_date, string annotation_text
+       ) const
 {
        boost::filesystem::path p = _directory;
 
@@ -408,20 +411,20 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, boost::filesystem::path
        }
 
        root->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid());
-       root->add_child("AnnotationText")->add_child_text (metadata.annotation_text);
+       root->add_child("AnnotationText")->add_child_text (annotation_text);
 
        switch (standard) {
        case INTEROP:
                root->add_child("VolumeCount")->add_child_text ("1");
-               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 (issue_date);
+               root->add_child("Issuer")->add_child_text (issuer);
+               root->add_child("Creator")->add_child_text (creator);
                break;
        case SMPTE:
-               root->add_child("Creator")->add_child_text (metadata.creator);
+               root->add_child("Creator")->add_child_text (creator);
                root->add_child("VolumeCount")->add_child_text ("1");
-               root->add_child("IssueDate")->add_child_text (metadata.issue_date);
-               root->add_child("Issuer")->add_child_text (metadata.issuer);
+               root->add_child("IssueDate")->add_child_text (issue_date);
+               root->add_child("Issuer")->add_child_text (issuer);
                break;
        default:
                DCP_ASSERT (false);
@@ -455,7 +458,10 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, boost::filesystem::path
 void
 DCP::write_xml (
        Standard standard,
-       XMLMetadata metadata,
+       string issuer,
+       string creator,
+       string issue_date,
+       string annotation_text,
        shared_ptr<const CertificateChain> signer,
        NameFormat name_format
        )
@@ -469,7 +475,7 @@ DCP::write_xml (
        shared_ptr<PKL> pkl;
 
        if (_pkls.empty()) {
-               pkl.reset (new PKL (standard, metadata.annotation_text, metadata.issue_date, metadata.issuer, metadata.creator));
+               pkl.reset (new PKL(standard, annotation_text, issue_date, issuer, creator));
                _pkls.push_back (pkl);
                BOOST_FOREACH (shared_ptr<Asset> i, assets ()) {
                        i->add_to_pkl (pkl, _directory);
@@ -484,7 +490,7 @@ DCP::write_xml (
        pkl->write (pkl_path, signer);
 
        write_volindex (standard);
-       write_assetmap (standard, pkl->id(), pkl_path, metadata);
+       write_assetmap (standard, pkl->id(), pkl_path, issuer, creator, issue_date, annotation_text);
 }
 
 list<shared_ptr<CPL> >
index d6648783e89a9172a675c2458f0aa392c1ce0f18..8b5bd746fc991de11ea87853b5298afbe902dfcf 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
 #ifndef LIBDCP_DCP_H
 #define LIBDCP_DCP_H
 
+#include "compose.hpp"
 #include "types.h"
 #include "util.h"
 #include "certificate.h"
 #include "metadata.h"
 #include "name_format.h"
 #include "verify.h"
+#include "version.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <string>
@@ -62,7 +64,6 @@ class PKL;
 class Content;
 class Reel;
 class CPL;
-class XMLMetadata;
 class CertificateChain;
 class DecryptedKDM;
 class Asset;
@@ -111,7 +112,10 @@ public:
 
        void write_xml (
                Standard standard,
-               XMLMetadata metadata = XMLMetadata (),
+               std::string issuer = String::compose("libdcp %1", dcp::version),
+               std::string creator = String::compose("libdcp %1", dcp::version),
+               std::string issue_date = LocalTime().as_string(),
+               std::string annotation_text = String::compose("Created by libdcp %1", dcp::version),
                boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> (),
                NameFormat name_format = NameFormat("%t")
        );
@@ -148,7 +152,10 @@ private:
         *  @param pkl_uuid UUID of our PKL.
         *  @param pkl_path Pathname of our PKL file.
         */
-       void write_assetmap (Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const;
+       void write_assetmap (
+               Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path,
+               std::string issuer, std::string creator, std::string issue_date, std::string annotation_text
+               ) const;
 
        /** The directory that we are writing to */
        boost::filesystem::path _directory;
index fd215d76b21b8f4ef5010fbe97e41080f25436ea..46b5a5ea7a735d490652dbddcb2eff3963cddb91 100644 (file)
@@ -124,6 +124,7 @@ def build(bld):
               chromaticity.h
               colour_conversion.h
               combine.h
+              compose.hpp
               cpl.h
               crypto_context.h
               dcp.h
index 30c5ca3043bee7adec913ce6ddec826a6fcc2421..21ed2f6c1ff05e5d7775add3736b2fb7558558fa 100644 (file)
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (dcp_test1)
        xml_meta.issuer = "OpenDCP 0.0.25";
        xml_meta.creator = "OpenDCP 0.0.25";
        xml_meta.issue_date = "2012-07-17T04:45:18+00:00";
-       make_simple("build/test/DCP/dcp_test1")->write_xml (dcp::SMPTE, xml_meta);
+       make_simple("build/test/DCP/dcp_test1")->write_xml (dcp::SMPTE, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
        /* build/test/DCP/dcp_test1 is checked against test/ref/DCP/dcp_test1 by run/tests */
 }
 
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE (dcp_test2)
        d.add (cpl);
 
        xml_meta.annotation_text = "Created by libdcp";
-       d.write_xml (dcp::SMPTE, xml_meta);
+       d.write_xml (dcp::SMPTE, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
 
        /* build/test/DCP/dcp_test2 is checked against test/ref/DCP/dcp_test2 by run/tests */
 }
@@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE (dcp_test5)
        d.add (cpl);
 
        xml_meta.annotation_text = "Created by libdcp";
-       d.write_xml (dcp::SMPTE, xml_meta);
+       d.write_xml (dcp::SMPTE, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
 
        /* build/test/DCP/dcp_test5 is checked against test/ref/DCP/dcp_test5 by run/tests */
 }
@@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE (dcp_test7)
        xml_meta.issuer = "OpenDCP 0.0.25";
        xml_meta.creator = "OpenDCP 0.0.25";
        xml_meta.issue_date = "2012-07-17T04:45:18+00:00";
-       make_simple("build/test/DCP/dcp_test7")->write_xml (dcp::INTEROP, xml_meta);
+       make_simple("build/test/DCP/dcp_test7")->write_xml(dcp::INTEROP, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
        /* build/test/DCP/dcp_test7 is checked against test/ref/DCP/dcp_test7 by run/tests */
 }
 
index 4b9e525e44fd285982d276ad1e98091b007bc3d4..3bb52c2fb700a4bdd47a174456ef846958ee054d 100644 (file)
@@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE (encryption_test)
        d.add (cpl);
 
        xml_metadata.annotation_text = "Created by libdcp";
-       d.write_xml (dcp::SMPTE, xml_metadata, signer);
+       d.write_xml (dcp::SMPTE, xml_metadata.issuer, xml_metadata.creator, xml_metadata.issue_date, xml_metadata.annotation_text, signer);
 
        dcp::DecryptedKDM kdm (
                cpl,
index 266a1039ca3848d5e8eddd4c950813185b3dc8d5..da2ec35c9d74b2bf0125c8208c70f90e7bebcd08 100644 (file)
@@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
 
        dcp::DCP dcp ("build/test/write_interop_subtitle_test3");
        dcp.add (cpl);
-       dcp.write_xml (dcp::INTEROP, xml_meta);
+       dcp.write_xml (dcp::INTEROP, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
 
        check_xml (
                dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),