#include "asset.h"
#include "util.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include <libxml++/libxml++.h>
void
Asset::write_to_pkl (xmlpp::Node* node, Standard standard) const
{
- assert (!_file.empty ());
+ DCP_ASSERT (!_file.empty ());
xmlpp::Node* asset = node->add_child ("Asset");
asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
void
Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
{
- assert (!_file.empty ());
+ DCP_ASSERT (!_file.empty ());
xmlpp::Node* asset = node->add_child ("Asset");
asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
string
Asset::hash (function<void (float)> progress) const
{
- assert (!_file.empty ());
+ DCP_ASSERT (!_file.empty ());
if (_hash.empty ()) {
_hash = make_digest (_file, progress);
#include "compose.hpp"
#include "exceptions.h"
#include "util.h"
+#include "dcp_assert.h"
#include <libxml++/nodes/element.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
string
Certificate::certificate (bool with_begin_end) const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
BIO* bio = BIO_new (BIO_s_mem ());
if (!bio) {
string
Certificate::issuer () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
return name_for_xml (X509_get_issuer_name (_certificate));
}
{
int p = -1;
p = X509_NAME_get_index_by_NID (n, nid, p);
- assert (p != -1);
+ DCP_ASSERT (p != -1);
return asn_to_utf8 (X509_NAME_ENTRY_get_data (X509_NAME_get_entry (n, p)));
}
string
Certificate::name_for_xml (X509_NAME * n)
{
- assert (n);
+ DCP_ASSERT (n);
string s = String::compose (
"dnQualifier=%1,CN=%2,OU=%3,O=%4",
string
Certificate::subject () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
return name_for_xml (X509_get_subject_name (_certificate));
}
string
Certificate::common_name () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
return get_name_part (X509_get_subject_name (_certificate), NID_commonName);
}
string
Certificate::serial () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
ASN1_INTEGER* s = X509_get_serialNumber (_certificate);
- assert (s);
+ DCP_ASSERT (s);
BIGNUM* b = ASN1_INTEGER_to_BN (s, 0);
char* c = BN_bn2dec (b);
string
Certificate::thumbprint () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
uint8_t buffer[8192];
uint8_t* p = buffer;
RSA *
Certificate::public_key () const
{
- assert (_certificate);
+ DCP_ASSERT (_certificate);
if (_public_key) {
return _public_key;
Certificate
CertificateChain::root () const
{
- assert (!_certificates.empty());
+ DCP_ASSERT (!_certificates.empty());
return _certificates.front ();
}
Certificate
CertificateChain::leaf () const
{
- assert (_certificates.size() >= 2);
+ DCP_ASSERT (_certificates.size() >= 2);
return _certificates.back ();
}
#include "reel_sound_asset.h"
#include "reel_subtitle_asset.h"
#include "local_time.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include <libxml/parser.h>
case SMPTE:
return "text/xml";
default:
- assert (false);
+ DCP_ASSERT (false);
}
}
#include "AS_DCP.h"
#include "decrypted_kdm.h"
#include "decrypted_kdm_key.h"
+#include "dcp_assert.h"
#include <xmlsec/xmldsig.h>
#include <xmlsec/app.h>
#include <libxml++/libxml++.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
-#include <cassert>
#include <iostream>
using std::string;
pkl->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid);
/* XXX: this is a bit of a hack */
- assert (cpls().size() > 0);
+ DCP_ASSERT (cpls().size() > 0);
pkl->add_child("AnnotationText")->add_child_text (cpls().front()->annotation_text ());
pkl->add_child("IssueDate")->add_child_text (metadata.issue_date);
p /= "VOLINDEX.xml";
break;
default:
- assert (false);
+ DCP_ASSERT (false);
}
xmlpp::Document doc;
root = doc.create_root_node ("VolumeIndex", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
break;
default:
- assert (false);
+ DCP_ASSERT (false);
}
root->add_child("Index")->add_child_text ("1");
p /= "ASSETMAP.xml";
break;
default:
- assert (false);
+ DCP_ASSERT (false);
}
xmlpp::Document doc;
root = doc.create_root_node ("AssetMap", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
break;
default:
- assert (false);
+ DCP_ASSERT (false);
}
root->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid());
root->add_child("Issuer")->add_child_text (metadata.issuer);
break;
default:
- assert (false);
+ DCP_ASSERT (false);
}
xmlpp::Node* asset_list = root->add_child ("AssetList");
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "exceptions.h"
+
+#define DCP_ASSERT(x) if (!(x)) throw ProgrammingError (__FILE__, __LINE__);
#include "cpl.h"
#include "mxf.h"
#include "signer.h"
+#include "dcp_assert.h"
#include "AS_DCP.h"
#include "KM_util.h"
#include "compose.hpp"
break;
}
default:
- assert (false);
+ DCP_ASSERT (false);
}
delete[] decrypted;
{
}
+
+
+ProgrammingError::ProgrammingError (string file, int line)
+ : StringError (String::compose ("Programming error at %1:%2", file, line))
+{
+
+}
~NotEncryptedError () throw () {}
};
+class ProgrammingError : public StringError
+{
+public:
+ ProgrammingError (std::string file, int line);
+};
+
}
#endif
#include "file.h"
#include "util.h"
+#include "dcp_assert.h"
#include <stdio.h>
using namespace dcp;
_size = boost::filesystem::file_size (file);
_data = new uint8_t[_size];
FILE* f = dcp::fopen_boost (file, "r");
- assert (f);
+ DCP_ASSERT (f);
fread (_data, 1, _size, f);
fclose (f);
}
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "mono_picture_frame.h"
#include "compose.hpp"
}
shared_ptr<const MonoPictureMXF> other_picture = dynamic_pointer_cast<const MonoPictureMXF> (other);
- assert (other_picture);
+ DCP_ASSERT (other_picture);
for (int i = 0; i < _intrinsic_duration; ++i) {
if (i >= other_picture->intrinsic_duration()) {
#include "mono_picture_mxf_writer.h"
#include "exceptions.h"
#include "picture_mxf.h"
+#include "dcp_assert.h"
#include "picture_mxf_writer_common.cc"
FrameInfo
MonoPictureMXFWriter::write (uint8_t* data, int size)
{
- assert (!_finalized);
+ DCP_ASSERT (!_finalized);
if (!_started) {
start (data, size);
void
MonoPictureMXFWriter::fake_write (int size)
{
- assert (_started);
- assert (!_finalized);
+ DCP_ASSERT (_started);
+ DCP_ASSERT (!_finalized);
Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size);
if (ASDCP_FAILURE (r)) {
#include "util.h"
#include "metadata.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include <libxml++/nodes/element.h>
#include <boost/filesystem.hpp>
}
unsigned int c;
Kumu::hex2bin (_id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
- assert (c == Kumu::UUID_Length);
+ DCP_ASSERT (c == Kumu::UUID_Length);
if (_key) {
Kumu::GenRandomUUID (writer_info->ContextID);
unsigned int c;
Kumu::hex2bin (_key_id.c_str(), writer_info->CryptographicKeyID, Kumu::UUID_Length, &c);
- assert (c == Kumu::UUID_Length);
+ DCP_ASSERT (c == Kumu::UUID_Length);
}
}
case SMPTE:
return "application/mxf";
default:
- assert (false);
+ DCP_ASSERT (false);
}
}
#include "mxf_writer.h"
#include "mxf.h"
+#include "dcp_assert.h"
using namespace dcp;
void
MXFWriter::finalize ()
{
- assert (!_finalized);
+ DCP_ASSERT (!_finalized);
_finalized = true;
_mxf->_intrinsic_duration = _frames_written;
}
#include "reel_mxf_asset.h"
#include "mxf.h"
+#include "dcp_assert.h"
#include <libcxml/cxml.h>
using boost::shared_ptr;
++i;
}
- assert (i != c.end ());
+ DCP_ASSERT (i != c.end ());
if (!_key_id.empty ()) {
(*i)->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id);
#include "content.h"
#include "reel_picture_asset.h"
#include "picture_mxf.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include <libcxml/cxml.h>
#include <iomanip>
++i;
}
- assert (i != c.end ());
+ DCP_ASSERT (i != c.end ());
(*i)->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
if (standard == INTEROP) {
#include "colour_matrix.h"
#include "colour_conversion.h"
#include "transfer_function.h"
+#include "dcp_assert.h"
#include <cmath>
using std::min;
uint8_t* argb_line = argb;
for (int x = 0; x < xyz_frame->size().width; ++x) {
- assert (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_y < 4096 && *xyz_z < 4096);
+ DCP_ASSERT (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_y < 4096 && *xyz_z < 4096);
/* In gamma LUT */
s.x = lut_in[*xyz_x++];
uint8_t* buffer_line = buffer;
for (int x = 0; x < xyz_frame->size().width; ++x) {
- assert (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_y < 4096 && *xyz_z < 4096);
+ DCP_ASSERT (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_y < 4096 && *xyz_z < 4096);
/* In gamma LUT */
s.x = lut_in[*xyz_x++];
d.y = d.y * DCI_COEFFICIENT * 65535;
d.z = d.z * DCI_COEFFICIENT * 65535;
- assert (d.x >= 0 && d.x < 65536);
- assert (d.y >= 0 && d.y < 65536);
- assert (d.z >= 0 && d.z < 65536);
+ DCP_ASSERT (d.x >= 0 && d.x < 65536);
+ DCP_ASSERT (d.y >= 0 && d.y < 65536);
+ DCP_ASSERT (d.z >= 0 && d.z < 65536);
/* Out gamma LUT */
xyz->data(0)[jn] = lut_out[(int) d.x] * 4096;
#include "sound_mxf_writer.h"
#include "sound_mxf.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include "AS_DCP.h"
void
SoundMXFWriter::write (float const * const * data, int frames)
{
- assert (!_finalized);
+ DCP_ASSERT (!_finalized);
for (int i = 0; i < frames; ++i) {
}
_frame_buffer_offset += 3 * _sound_mxf->channels();
- assert (_frame_buffer_offset <= int (_state->frame_buffer.Capacity()));
+ DCP_ASSERT (_frame_buffer_offset <= int (_state->frame_buffer.Capacity()));
/* Finish the MXF frame if required */
if (_frame_buffer_offset == int (_state->frame_buffer.Capacity())) {
#include "stereo_picture_frame.h"
#include "exceptions.h"
#include "stereo_picture_mxf_writer.h"
+#include "dcp_assert.h"
using std::string;
using std::pair;
}
shared_ptr<const StereoPictureMXF> other_picture = dynamic_pointer_cast<const StereoPictureMXF> (other);
- assert (other_picture);
+ DCP_ASSERT (other_picture);
for (int i = 0; i < _intrinsic_duration; ++i) {
shared_ptr<const StereoPictureFrame> frame_A = get_frame (i);
#include "stereo_picture_mxf_writer.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "picture_mxf.h"
#include "AS_DCP.h"
#include "KM_fileio.h"
FrameInfo
StereoPictureMXFWriter::write (uint8_t* data, int size)
{
- assert (!_finalized);
+ DCP_ASSERT (!_finalized);
if (!_started) {
start (data, size);
void
StereoPictureMXFWriter::fake_write (int size)
{
- assert (_started);
- assert (!_finalized);
+ DCP_ASSERT (_started);
+ DCP_ASSERT (!_finalized);
Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size, _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT);
if (ASDCP_FAILURE (r)) {
#include "font.h"
#include "text.h"
#include "subtitle_string.h"
+#include "dcp_assert.h"
#include "AS_DCP.h"
#include "KM_util.h"
#include <libxml++/nodes/element.h>
return;
}
- assert (!parse_state.text_nodes.empty ());
- assert (!parse_state.subtitle_nodes.empty ());
+ DCP_ASSERT (!parse_state.text_nodes.empty ());
+ DCP_ASSERT (!parse_state.subtitle_nodes.empty ());
dcp::Font effective_font (parse_state.font_nodes);
dcp::Text effective_text (*parse_state.text_nodes.back ());
#include "argb_frame.h"
#include "certificates.h"
#include "xyz_frame.h"
+#include "dcp_assert.h"
#include "compose.hpp"
#include "KM_util.h"
#include "KM_fileio.h"
return "advertisement";
}
- assert (false);
+ DCP_ASSERT (false);
}
/** Convert a string from a <ContentKind> node to a libdcp ContentKind.
return ADVERTISEMENT;
}
- assert (false);
+ DCP_ASSERT (false);
}
/** Decompress a JPEG2000 image to a bitmap.
*/
#include "xyz_frame.h"
-#include <cassert>
+#include "dcp_assert.h"
#include <stdexcept>
using namespace dcp;
XYZFrame::XYZFrame (opj_image_t* image)
: _opj_image (image)
{
- assert (_opj_image->numcomps == 3);
+ DCP_ASSERT (_opj_image->numcomps == 3);
}
/** Construct a new XYZFrame with undefined contents.
int *
XYZFrame::data (int c) const
{
- assert (c >= 0 && c < 3);
+ DCP_ASSERT (c >= 0 && c < 3);
return _opj_image->comps[c].data;
}