using std::pair;
using std::map;
using boost::shared_ptr;
+using boost::optional;
using namespace dcp;
static void
/* 93 is not-valid-after (a string) [25 bytes] */
p += 25;
/* 118 is the key [ASDCP::KeyLen bytes] */
- add_key ("", key_id, Key (p), cpl_id);
+ add_key (optional<string>(), key_id, Key (p), cpl_id);
break;
}
case 138:
* @param cpl_id ID of CPL that the key is for.
*/
void
-DecryptedKDM::add_key (string type, string key_id, Key key, string cpl_id)
+DecryptedKDM::add_key (optional<string> type, string key_id, Key key, string cpl_id)
{
_keys.push_back (DecryptedKDMKey (type, key_id, key, cpl_id));
}
list<pair<string, string> > key_ids;
list<string> keys;
BOOST_FOREACH (DecryptedKDMKey const & i, _keys) {
- key_ids.push_back (make_pair (i.type(), i.id ()));
+ /* We're making SMPTE keys so we must have a type for each one */
+ DCP_ASSERT (i.type());
+ key_ids.push_back (make_pair (i.type().get(), i.id ()));
/* XXX: SMPTE only */
uint8_t block[138];
p += 20;
put_uuid (&p, i.cpl_id ());
- put (&p, i.type ());
+ put (&p, i.type().get());
put_uuid (&p, i.id ());
put (&p, _not_valid_before.as_string ());
put (&p, _not_valid_after.as_string ());
Formulation formulation
) const;
- void add_key (std::string type, std::string key_id, Key key, std::string cpl_id);
+ void add_key (boost::optional<std::string> type, std::string key_id, Key key, std::string cpl_id);
void add_key (DecryptedKDMKey key);
/** @return This KDM's (decrypted) keys, which could be used to decrypt assets. */
#define LIBDCP_DECRYPTED_KDM_KEY_H
#include "key.h"
+#include <boost/optional.hpp>
namespace dcp {
class DecryptedKDMKey
{
public:
- DecryptedKDMKey (std::string type, std::string id, Key key, std::string cpl_id)
+ DecryptedKDMKey (boost::optional<std::string> type, std::string id, Key key, std::string cpl_id)
: _type (type)
, _id (id)
, _key (key)
, _cpl_id (cpl_id)
{}
- std::string type () const {
+ boost::optional<std::string> type () const {
return _type;
}
}
private:
- std::string _type;
+ boost::optional<std::string> _type;
std::string _id;
Key _key;
std::string _cpl_id;
BOOST_FOREACH (dcp::DecryptedKDMKey i, dec_kdm.keys ()) {
cout << "\n";
cout << "\tID: " << i.id() << "\n";
- cout << "\tType: " << i.type() << "\n";
+ if (i.type()) {
+ cout << "\tType: " << i.type().get() << "\n";
+ }
cout << "\tKey: " << i.key().hex() << "\n";
}
} catch (dcp::KDMDecryptionError& e) {