summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-08 15:40:19 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-08 15:40:19 +0100
commit9e871b60fc7430650f239cfd9291ab65cb5aeba8 (patch)
treecfc77d0079fef2aeeb896fe6c7e50716fc696fa1
parent656519fb0028c90fd16c1cc13103177ccd52664d (diff)
Require only DCP::add() for the CPL; other assets found by looking in the CPL.
-rw-r--r--examples/make_dcp.cc2
-rw-r--r--src/dcp.cc46
-rw-r--r--src/dcp.h12
-rw-r--r--src/reel_asset.h7
-rw-r--r--test/dcp_test.cc4
-rw-r--r--test/encryption_test.cc2
6 files changed, 44 insertions, 29 deletions
diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc
index 7b15e5e0..ae7890a5 100644
--- a/examples/make_dcp.cc
+++ b/examples/make_dcp.cc
@@ -105,8 +105,6 @@ main ()
/* Write the DCP */
dcp::DCP dcp ("DCP");
dcp.add (cpl);
- dcp.add (picture_asset);
- dcp.add (sound_asset);
dcp.write_xml (dcp::SMPTE);
return 0;
diff --git a/src/dcp.cc b/src/dcp.cc
index 27ff5b6a..da12e4f9 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -39,6 +39,7 @@
#include "decrypted_kdm.h"
#include "decrypted_kdm_key.h"
#include "dcp_assert.h"
+#include "reel_asset.h"
#include <xmlsec/xmldsig.h>
#include <xmlsec/app.h>
#include <libxml++/libxml++.h>
@@ -114,6 +115,12 @@ DCP::read (bool keep_going, ReadErrors* errors)
/* XXX: I think we should be looking at the PKL here to decide type, not
the extension of the file.
*/
+
+ /* Make a list of non-CPL assets so that we can resolve the references
+ from the CPL.
+ */
+ list<shared_ptr<Asset> > other_assets;
+
for (map<string, boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
boost::filesystem::path path = _directory / i->second;
@@ -135,9 +142,9 @@ DCP::read (bool keep_going, ReadErrors* errors)
delete p;
if (root == "CompositionPlaylist") {
- _assets.push_back (shared_ptr<CPL> (new CPL (path)));
+ _cpls.push_back (shared_ptr<CPL> (new CPL (path)));
} else if (root == "DCSubtitle") {
- _assets.push_back (shared_ptr<InteropSubtitleAsset> (new InteropSubtitleAsset (path)));
+ other_assets.push_back (shared_ptr<InteropSubtitleAsset> (new InteropSubtitleAsset (path)));
}
} else if (boost::filesystem::extension (path) == ".mxf") {
ASDCP::EssenceType_t type;
@@ -149,17 +156,17 @@ DCP::read (bool keep_going, ReadErrors* errors)
case ASDCP::ESS_MPEG2_VES:
throw DCPReadError ("MPEG2 video essences are not supported");
case ASDCP::ESS_JPEG_2000:
- _assets.push_back (shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path)));
+ other_assets.push_back (shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path)));
break;
case ASDCP::ESS_PCM_24b_48k:
case ASDCP::ESS_PCM_24b_96k:
- _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (path)));
+ other_assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (path)));
break;
case ASDCP::ESS_JPEG_2000_S:
- _assets.push_back (shared_ptr<StereoPictureAsset> (new StereoPictureAsset (path)));
+ other_assets.push_back (shared_ptr<StereoPictureAsset> (new StereoPictureAsset (path)));
break;
case ASDCP::ESS_TIMED_TEXT:
- _assets.push_back (shared_ptr<SMPTESubtitleAsset> (new SMPTESubtitleAsset (path)));
+ other_assets.push_back (shared_ptr<SMPTESubtitleAsset> (new SMPTESubtitleAsset (path)));
break;
default:
throw DCPReadError ("Unknown MXF essence type");
@@ -168,7 +175,7 @@ DCP::read (bool keep_going, ReadErrors* errors)
}
BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
- i->resolve_refs (list_of_type<Asset, Object> (assets ()));
+ i->resolve_refs (list_of_type<Asset, Object> (other_assets));
}
}
@@ -200,9 +207,9 @@ DCP::equals (DCP const & other, EqualityOptions opt, NoteHandler note) const
}
void
-DCP::add (boost::shared_ptr<Asset> asset)
+DCP::add (boost::shared_ptr<CPL> cpl)
{
- _assets.push_back (asset);
+ _cpls.push_back (cpl);
}
bool
@@ -260,7 +267,7 @@ DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared
pkl->add_child("Creator")->add_child_text (metadata.creator);
xmlpp::Element* asset_list = pkl->add_child("AssetList");
- BOOST_FOREACH (shared_ptr<Asset> i, _assets) {
+ BOOST_FOREACH (shared_ptr<Asset> i, assets ()) {
i->write_to_pkl (asset_list, standard);
}
@@ -370,7 +377,7 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMeta
chunk->add_child("Offset")->add_child_text ("0");
chunk->add_child("Length")->add_child_text (raw_convert<string> (pkl_length));
- BOOST_FOREACH (shared_ptr<Asset> i, _assets) {
+ BOOST_FOREACH (shared_ptr<Asset> i, assets ()) {
i->write_to_assetmap (asset_list, _directory);
}
@@ -405,5 +412,20 @@ DCP::write_xml (
list<shared_ptr<CPL> >
DCP::cpls () const
{
- return list_of_type<Asset, CPL> (_assets);
+ return _cpls;
+}
+
+/** @return All assest (including CPLs) */
+list<shared_ptr<Asset> >
+DCP::assets () const
+{
+ list<shared_ptr<Asset> > assets;
+ BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
+ assets.push_back (i);
+ BOOST_FOREACH (shared_ptr<const ReelAsset> j, i->reel_assets ()) {
+ assets.push_back (j->asset_ref().object ());
+ }
+ }
+
+ return assets;
}
diff --git a/src/dcp.h b/src/dcp.h
index 46ae2b34..03f0a802 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -82,14 +82,10 @@ public:
*/
bool equals (DCP const & other, EqualityOptions options, NoteHandler note) const;
- void add (boost::shared_ptr<Asset> asset);
+ void add (boost::shared_ptr<CPL> cpl);
std::list<boost::shared_ptr<CPL> > cpls () const;
-
- /** @return All this DCP's assets (note that CPLs are assets) */
- std::list<boost::shared_ptr<Asset> > assets () const {
- return _assets;
- }
+ std::list<boost::shared_ptr<Asset> > assets () const;
bool encrypted () const;
@@ -123,8 +119,8 @@ private:
/** the directory that we are writing to */
boost::filesystem::path _directory;
- /** the assets that make up this DCP */
- std::list<boost::shared_ptr<Asset> > _assets;
+ /** the CPLs that make up this DCP */
+ std::list<boost::shared_ptr<CPL> > _cpls;
};
}
diff --git a/src/reel_asset.h b/src/reel_asset.h
index 118f10a1..981d70db 100644
--- a/src/reel_asset.h
+++ b/src/reel_asset.h
@@ -55,10 +55,15 @@ public:
virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, NoteHandler) const;
/** @return a Ref to our actual asset */
- Ref<Asset>& asset_ref () {
+ Ref<Asset> const & asset_ref () const {
return _asset_ref;
}
+ /** @return a Ref to our actual asset */
+ Ref<Asset>& asset_ref () {
+ return _asset_ref;
+ }
+
int64_t entry_point () const {
return _entry_point;
}
diff --git a/test/dcp_test.cc b/test/dcp_test.cc
index c4950704..0338e1f8 100644
--- a/test/dcp_test.cc
+++ b/test/dcp_test.cc
@@ -101,8 +101,6 @@ BOOST_AUTO_TEST_CASE (dcp_test1)
));
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_meta);
@@ -175,8 +173,6 @@ BOOST_AUTO_TEST_CASE (dcp_test2)
));
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_meta);
diff --git a/test/encryption_test.cc b/test/encryption_test.cc
index d09f04bd..7786292d 100644
--- a/test/encryption_test.cc
+++ b/test/encryption_test.cc
@@ -124,8 +124,6 @@ BOOST_AUTO_TEST_CASE (encryption_test)
cpl->set_metadata (xml_metadata);
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_metadata, signer);