#include "openjpeg_image.h"
#include "dcp_assert.h"
#include "compose.hpp"
-#include "KM_util.h"
-#include "KM_fileio.h"
-#include "AS_DCP.h"
+#include <openjpeg.h>
+#include <asdcp/KM_util.h>
+#include <asdcp/KM_fileio.h>
+#include <asdcp/AS_DCP.h>
#include <xmlsec/xmldsig.h>
#include <xmlsec/dl.h>
#include <xmlsec/app.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <stdexcept>
-#include <sstream>
#include <iostream>
#include <iomanip>
using std::string;
using std::wstring;
using std::cout;
-using std::stringstream;
using std::min;
using std::max;
using std::list;
return string (buffer);
}
+string
+dcp::make_digest (Data data)
+{
+ SHA_CTX sha;
+ SHA1_Init (&sha);
+ SHA1_Update (&sha, data.data().get(), data.size());
+ byte_t byte_buffer[SHA_DIGEST_LENGTH];
+ SHA1_Final (byte_buffer, &sha);
+ char digest[64];
+ return Kumu::base64encode (byte_buffer, SHA_DIGEST_LENGTH, digest, 64);
+}
/** Create a digest for a file.
* @param filename File name.
if (xmlSecCryptoInit() < 0) {
throw MiscError ("could not initialise xmlsec-crypto");
}
-}
-
-bool dcp::operator== (dcp::Size const & a, dcp::Size const & b)
-{
- return (a.width == b.width && a.height == b.height);
-}
-bool dcp::operator!= (dcp::Size const & a, dcp::Size const & b)
-{
- return !(a == b);
-}
-
-ostream& dcp::operator<< (ostream& s, dcp::Size const & a)
-{
- s << a.width << "x" << a.height;
- return s;
+ OpenSSL_add_all_algorithms();
}
/** Decode a base64 string. The base64 decode routine in KM_util.cpp
{
uintmax_t len = boost::filesystem::file_size (p);
if (len > max_length) {
- throw MiscError ("Unexpectedly long file");
+ throw MiscError (String::compose ("Unexpectedly long file (%1)", p.string()));
}
FILE* f = fopen_boost (p, "r");
DCP_ASSERT (raw.substr(0, 9) == "urn:uuid:");
return raw.substr (9);
}
+
+string
+dcp::openjpeg_version ()
+{
+ return opj_version ();
+}