#include "encrypted_kdm.h"
#include "decrypted_kdm.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
#include "key.h"
#include "util.h"
#include "atmos_asset.h"
#include "atmos_asset_writer.h"
#include "exceptions.h"
#include <asdcp/AS_DCP.h>
-#include <boost/foreach.hpp>
#include <getopt.h>
#include <string>
using std::cerr;
using std::cout;
using boost::optional;
-using boost::shared_ptr;
+using std::shared_ptr;
static void
help (string n)
{
cerr << "Syntax: " << n << " [OPTION] <MXF>]\n"
- << " -v, --version show DCP-o-matic version\n"
+ << " -v, --version show libdcp version\n"
<< " -h, --help show this help\n"
<< " -o, --output output filename\n"
<< " -k, --kdm KDM file\n"
<< " -p, --private-key private key file\n";
}
-int
-atmos (
- ASDCP::ATMOS::MXFReader& reader,
- boost::filesystem::path output_file,
- dcp::DecryptedKDM kdm
- )
-{
- ASDCP::WriterInfo info;
- if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
- cerr << "Could not read ATMOS MXF information\n";
- exit (EXIT_FAILURE);
- }
-
- if (!info.EncryptedEssence) {
- cerr << "MXF is not encrypted!\n";
- exit (EXIT_FAILURE);
- }
-
- char key_buffer[64];
- Kumu::bin2UUIDhex (info.CryptographicKeyID, ASDCP::UUIDlen, key_buffer, sizeof (key_buffer));
- string const key_id = key_buffer;
-
- optional<dcp::Key> key;
- BOOST_FOREACH (dcp::DecryptedKDMKey const & i, kdm.keys()) {
- if (i.id() == key_id) {
- key = i.key();
- }
- }
-
- if (!key) {
- cerr << "Could not find key in KDM.\n";
- exit (EXIT_FAILURE);
- }
-
- dcp::DecryptionContext dc (key.get());
-
- ASDCP::ATMOS::AtmosDescriptor desc;
- if (ASDCP_FAILURE (reader.FillAtmosDescriptor (desc))) {
- cerr << "could not read ATMOS descriptor.\n";
- exit (EXIT_FAILURE);
- }
-
- ASDCP::DCData::FrameBuffer buffer (Kumu::Megabyte);
-
- for (size_t i = 0; i < desc.ContainerDuration; ++i) {
- reader.ReadFrame (i, buffer, dc.decryption(), 0);
- }
-
- return 0;
-}
-
int
main (int argc, char* argv[])
{
+ dcp::init ();
+
optional<boost::filesystem::path> output_file;
optional<boost::filesystem::path> kdm_file;
optional<boost::filesystem::path> private_key_file;
dcp::EncryptedKDM encrypted_kdm (dcp::file_to_string (kdm_file.get ()));
dcp::DecryptedKDM decrypted_kdm (encrypted_kdm, dcp::file_to_string (private_key_file.get()));
+ /* XXX: only works for Atmos! */
+
try {
dcp::AtmosAsset in (input_file);
shared_ptr<dcp::AtmosAssetReader> reader = in.start_read ();
in.first_frame(),
in.max_channel_count(),
in.max_object_count(),
- in.atmos_id(),
in.atmos_version()
);
shared_ptr<dcp::AtmosAssetWriter> writer = out.start_write (output_file.get());
shared_ptr<const dcp::AtmosFrame> f = reader->get_frame (i);
writer->write (f->data(), f->size());
}
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
cerr << "Unknown MXF format.\n";
return EXIT_FAILURE;
}