diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-08-30 17:27:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-08-30 17:27:22 +0100 |
| commit | ff38c8737a36e5aced5f2dede5bccd2832fc446a (patch) | |
| tree | 652a0548b76cfff2f4e7438c477cd4ac18f7a089 /src/dcp.cc | |
| parent | d0e025d26cab0eecfea1528343638dac69f363cd (diff) | |
Partial.rework-again
Diffstat (limited to 'src/dcp.cc')
| -rw-r--r-- | src/dcp.cc | 58 |
1 files changed, 14 insertions, 44 deletions
@@ -69,7 +69,7 @@ DCP::DCP (string directory) void DCP::write_xml (bool interop, XMLMetadata const & metadata, shared_ptr<Encryption> crypt) const { - for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { + for (list<shared_ptr<CPL> >::const_iterator i = cpls.begin(); i != cpls.end(); ++i) { (*i)->write_xml (_directory, interop, metadata, crypt); } @@ -83,7 +83,7 @@ DCP::write_xml (bool interop, XMLMetadata const & metadata, shared_ptr<Encryptio std::string DCP::write_pkl (string pkl_uuid, bool interop, XMLMetadata const & metadata, shared_ptr<Encryption> crypt) const { - assert (!_cpls.empty ()); + assert (!cpls.empty ()); boost::filesystem::path p; p /= _directory; @@ -105,18 +105,17 @@ DCP::write_pkl (string pkl_uuid, bool interop, XMLMetadata const & metadata, sha pkl->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid); /* XXX: this is a bit of a hack */ - pkl->add_child("AnnotationText")->add_child_text(_cpls.front()->annotation_text); + pkl->add_child("AnnotationText")->add_child_text(cpls.front()->annotation_text); pkl->add_child("IssueDate")->add_child_text (metadata.issue_date); pkl->add_child("Issuer")->add_child_text (metadata.issuer); pkl->add_child("Creator")->add_child_text (metadata.creator); xmlpp::Element* asset_list = pkl->add_child("AssetList"); - list<shared_ptr<const Asset> > a = assets (); - for (list<shared_ptr<const Asset> >::const_iterator i = a.begin(); i != a.end(); ++i) { + for (list<shared_ptr<const Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) { (*i)->write_to_pkl (asset_list); } - for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { + for (list<shared_ptr<CPL> >::const_iterator i = cpls.begin(); i != cpls.end(); ++i) { (*i)->write_to_pkl (asset_list); } @@ -182,12 +181,11 @@ DCP::write_assetmap (string pkl_uuid, int pkl_length, bool interop, XMLMetadata chunk->add_child("Offset")->add_child_text ("0"); chunk->add_child("Length")->add_child_text (lexical_cast<string> (pkl_length)); - for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { + for (list<shared_ptr<CPL> >::const_iterator i = cpls.begin(); i != cpls.end(); ++i) { (*i)->write_to_assetmap (asset_list); } - list<shared_ptr<const Asset> > a = assets (); - for (list<shared_ptr<const Asset> >::const_iterator i = a.begin(); i != a.end(); ++i) { + for (list<shared_ptr<const Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) { (*i)->write_to_assetmap (asset_list); } @@ -272,28 +270,26 @@ DCP::read (bool require_mxfs) /* Cross-check */ /* XXX */ - _asset_maps.push_back (make_pair (boost::filesystem::absolute (_directory).string(), asset_map)); - for (list<string>::iterator i = files.cpls.begin(); i != files.cpls.end(); ++i) { boost::filesystem::path p; p /= _directory; p /= *i; - _cpls.push_back (shared_ptr<CPL> (new CPL (p, _asset_maps, require_mxfs))); + cpls.push_back (shared_ptr<CPL> (new CPL (p))); } } bool DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { - if (_cpls.size() != other._cpls.size()) { + if (cpls.size() != other.cpls.size()) { note (ERROR, "CPL counts differ"); return false; } - list<shared_ptr<CPL> >::const_iterator a = _cpls.begin (); - list<shared_ptr<CPL> >::const_iterator b = other._cpls.begin (); + list<shared_ptr<CPL> >::const_iterator a = cpls.begin (); + list<shared_ptr<CPL> >::const_iterator b = other.cpls.begin (); - while (a != _cpls.end ()) { + while (a != cpls.end ()) { if (!(*a)->equals (*b->get(), opt, note)) { return false; } @@ -304,12 +300,6 @@ DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (NoteT return true; } -void -DCP::add_cpl (shared_ptr<CPL> cpl) -{ - _cpls.push_back (cpl); -} - class AssetComparator { public: @@ -318,24 +308,10 @@ public: } }; -list<shared_ptr<const Asset> > -DCP::assets () const -{ - list<shared_ptr<const Asset> > a; - for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { - list<shared_ptr<const Asset> > t = (*i)->assets (); - a.merge (t); - } - - a.sort (AssetComparator ()); - a.unique (); - return a; -} - bool DCP::encrypted () const { - for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { + for (list<shared_ptr<CPL> >::const_iterator i = cpls.begin(); i != cpls.end(); ++i) { if ((*i)->encrypted ()) { return true; } @@ -349,7 +325,7 @@ DCP::add_kdm (KDM const & kdm) { list<KDMCipher> ciphers = kdm.ciphers (); - for (list<shared_ptr<CPL> >::iterator i = _cpls.begin(); i != _cpls.end(); ++i) { + for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) { for (list<KDMCipher>::iterator j = ciphers.begin(); j != ciphers.end(); ++j) { if (j->cpl_id() == (*i)->id()) { (*i)->add_kdm (kdm); @@ -357,9 +333,3 @@ DCP::add_kdm (KDM const & kdm) } } } - -void -DCP::add_assets_from (DCP const & ov) -{ - copy (ov._asset_maps.begin(), ov._asset_maps.end(), back_inserter (_asset_maps)); -} |
