#include "dcp_assert.h"
#include "compose.hpp"
#include <libxml/parser.h>
+#include <boost/foreach.hpp>
using std::string;
using std::stringstream;
root->add_child("RatingList");
xmlpp::Element* reel_list = root->add_child ("ReelList");
-
- for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
- (*i)->write_to_cpl (reel_list, standard);
+
+ BOOST_FOREACH (shared_ptr<Reel> i, _reels) {
+ i->write_to_cpl (reel_list, standard);
}
if (signer) {
{
list<shared_ptr<const ReelAsset> > c;
- for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
- if ((*i)->main_picture ()) {
- c.push_back ((*i)->main_picture());
+ BOOST_FOREACH (shared_ptr<Reel> i, _reels) {
+ if (i->main_picture ()) {
+ c.push_back (i->main_picture());
}
- if ((*i)->main_sound ()) {
- c.push_back ((*i)->main_sound());
+ if (i->main_sound ()) {
+ c.push_back (i->main_sound());
}
- if ((*i)->main_subtitle ()) {
- c.push_back ((*i)->main_subtitle());
+ if (i->main_subtitle ()) {
+ c.push_back (i->main_subtitle());
}
}
bool
CPL::encrypted () const
{
- for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
- if ((*i)->encrypted ()) {
+ BOOST_FOREACH (shared_ptr<Reel> i, _reels) {
+ if (i->encrypted ()) {
return true;
}
}
void
CPL::add (DecryptedKDM const & kdm)
{
- for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
- (*i)->add (kdm);
+ BOOST_FOREACH (shared_ptr<Reel> i, _reels) {
+ i->add (kdm);
}
}
void
CPL::resolve_refs (list<shared_ptr<Object> > objects)
{
- for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
- (*i)->resolve_refs (objects);
+ BOOST_FOREACH (shared_ptr<Reel> i, _reels) {
+ i->resolve_refs (objects);
}
}
#include <libxml++/libxml++.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
#include <iostream>
using std::string;
asset_map.read_file (asset_map_file);
list<shared_ptr<cxml::Node> > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset");
map<string, boost::filesystem::path> paths;
- for (list<shared_ptr<cxml::Node> >::const_iterator i = asset_nodes.begin(); i != asset_nodes.end(); ++i) {
- if ((*i)->node_child("ChunkList")->node_children("Chunk").size() != 1) {
+ BOOST_FOREACH (shared_ptr<cxml::Node> i, asset_nodes) {
+ if (i->node_child("ChunkList")->node_children("Chunk").size() != 1) {
boost::throw_exception (XMLError ("unsupported asset chunk count"));
}
- string p = (*i)->node_child("ChunkList")->node_child("Chunk")->string_child ("Path");
+ string p = i->node_child("ChunkList")->node_child("Chunk")->string_child ("Path");
if (starts_with (p, "file://")) {
p = p.substr (7);
}
- paths.insert (make_pair ((*i)->string_child ("Id"), p));
+ paths.insert (make_pair (i->string_child ("Id"), p));
}
/* Read all the assets from the asset map */
}
}
- list<shared_ptr<CPL> > cpl = cpls ();
- for (list<shared_ptr<CPL> >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) {
- (*i)->resolve_refs (list_of_type<Asset, Object> (assets ()));
+ BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
+ i->resolve_refs (list_of_type<Asset, Object> (assets ()));
}
}
bool r = true;
- for (list<shared_ptr<CPL> >::const_iterator i = a.begin(); i != a.end(); ++i) {
+ BOOST_FOREACH (shared_ptr<CPL> i, a) {
list<shared_ptr<CPL> >::const_iterator j = b.begin ();
- while (j != b.end() && !(*j)->equals (*i, opt, note)) {
+ while (j != b.end() && !(*j)->equals (i, opt, note)) {
++j;
}
bool
DCP::encrypted () const
{
- list<shared_ptr<CPL> > cpl = cpls ();
- for (list<shared_ptr<CPL> >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) {
- if ((*i)->encrypted ()) {
+ BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
+ if (i->encrypted ()) {
return true;
}
}
DCP::add (DecryptedKDM const & kdm)
{
list<DecryptedKDMKey> keys = kdm.keys ();
- list<shared_ptr<CPL> > cpl = cpls ();
-
- for (list<shared_ptr<CPL> >::iterator i = cpl.begin(); i != cpl.end(); ++i) {
- for (list<DecryptedKDMKey>::iterator j = keys.begin(); j != keys.end(); ++j) {
- if (j->cpl_id() == (*i)->id()) {
- (*i)->add (kdm);
+
+ BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
+ BOOST_FOREACH (DecryptedKDMKey const & j, kdm.keys ()) {
+ if (j.cpl_id() == i->id()) {
+ i->add (kdm);
}
}
}
pkl->add_child("Creator")->add_child_text (metadata.creator);
xmlpp::Element* asset_list = pkl->add_child("AssetList");
- for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
- (*i)->write_to_pkl (asset_list, standard);
+ BOOST_FOREACH (shared_ptr<Asset> i, _assets) {
+ i->write_to_pkl (asset_list, standard);
}
if (signer) {
chunk->add_child("VolumeIndex")->add_child_text ("1");
chunk->add_child("Offset")->add_child_text ("0");
chunk->add_child("Length")->add_child_text (raw_convert<string> (pkl_length));
-
- for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
- (*i)->write_to_assetmap (asset_list, _directory);
+
+ BOOST_FOREACH (shared_ptr<Asset> i, _assets) {
+ i->write_to_assetmap (asset_list, _directory);
}
/* This must not be the _formatted version otherwise signature digests will be wrong */
shared_ptr<const Signer> signer
)
{
- 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, signer);
+ BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
+ string const filename = i->id() + "_cpl.xml";
+ i->write_xml (_directory / filename, standard, signer);
}
string const pkl_uuid = make_uuid ();
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
+#include <boost/foreach.hpp>
using std::list;
using std::string;
/* Use the private key to decrypt the keys */
- list<string> const encrypted_keys = kdm.keys ();
- for (list<string>::const_iterator i = encrypted_keys.begin(); i != encrypted_keys.end(); ++i) {
-
+ BOOST_FOREACH (string const & i, kdm.keys ()) {
/* Decode the base-64-encoded cipher value from the KDM */
unsigned char cipher_value[256];
- int const cipher_value_len = base64_decode (*i, cipher_value, sizeof (cipher_value));
+ int const cipher_value_len = base64_decode (i, cipher_value, sizeof (cipher_value));
/* Decrypt it */
unsigned char * decrypted = new unsigned char[RSA_size(rsa)];
, _issue_date (issue_date)
{
/* Create DecryptedKDMKey objects for each MXF asset */
- list<shared_ptr<const ReelAsset> > assets = cpl->reel_assets ();
- for (list<shared_ptr<const ReelAsset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+ BOOST_FOREACH(shared_ptr<const ReelAsset> i, cpl->reel_assets ()) {
/* XXX: do non-MXF assets need keys? */
- shared_ptr<const ReelMXFAsset> mxf = boost::dynamic_pointer_cast<const ReelMXFAsset> (*i);
+ shared_ptr<const ReelMXFAsset> mxf = boost::dynamic_pointer_cast<const ReelMXFAsset> (i);
if (mxf) {
if (mxf->key_id().empty ()) {
throw NotEncryptedError (mxf->id());
{
list<pair<string, string> > key_ids;
list<string> keys;
- for (list<DecryptedKDMKey>::const_iterator i = _keys.begin(); i != _keys.end(); ++i) {
-
- key_ids.push_back (make_pair (i->type(), i->id ()));
+ BOOST_FOREACH (DecryptedKDMKey const & i, _keys) {
+ key_ids.push_back (make_pair (i.type(), i.id ()));
/* XXX: SMPTE only */
uint8_t block[138];
base64_decode (signer->certificates().leaf().thumbprint (), p, 20);
p += 20;
- put_uuid (&p, i->cpl_id ());
- put (&p, i->type ());
- put_uuid (&p, i->id ());
+ put_uuid (&p, i.cpl_id ());
+ put (&p, i.type ());
+ put_uuid (&p, i.id ());
put (&p, _not_valid_before.as_string ());
put (&p, _not_valid_after.as_string ());
- put (&p, i->key().value(), ASDCP::KeyLen);
+ put (&p, i.key().value(), ASDCP::KeyLen);
/* Encrypt using the projector's public key */
RSA* rsa = recipient.public_key ();