From e0f46a5384974afa6f0be8a738e4989853323fbe Mon Sep 17 00:00:00 2001 From: jhurst Date: Fri, 3 Feb 2012 19:49:57 +0000 Subject: megachanges --- src/asdcp-wrap.cpp | 1149 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1149 insertions(+) create mode 100755 src/asdcp-wrap.cpp (limited to 'src/asdcp-wrap.cpp') diff --git a/src/asdcp-wrap.cpp b/src/asdcp-wrap.cpp new file mode 100755 index 0000000..916f37f --- /dev/null +++ b/src/asdcp-wrap.cpp @@ -0,0 +1,1149 @@ +/* +Copyright (c) 2003-2012, John Hurst +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/*! \file asdcp-wrap.cpp + \version $Id$ + \brief AS-DCP file manipulation utility + + This program wraps d-cinema essence (picture, sound or text) in t an AS-DCP + MXF file. + + For more information about asdcplib, please refer to the header file AS_DCP.h + + WARNING: While the asdcplib library attempts to provide a complete and secure + implementation of the cryptographic features of the AS-DCP file formats, this + unit test program is NOT secure and is therefore NOT SUITABLE FOR USE in a + production environment without some modification. + + In particular, this program uses weak IV generation and externally generated + plaintext keys. These shortcomings exist because cryptographic-quality + random number generation and key management are outside the scope of the + asdcplib library. Developers using asdcplib for commercial implementations + claiming SMPTE conformance are expected to provide proper implementations of + these features. +*/ + +#include +#include +#include +#include +#include + +using namespace ASDCP; + +const ui32_t FRAME_BUFFER_SIZE = 4 * Kumu::Megabyte; + +//------------------------------------------------------------------------------------------ +// +// command line option parser class + +static const char* PROGRAM_NAME = "asdcp-wrap"; // program name for messages + +// local program identification info written to file headers +class MyInfo : public WriterInfo +{ +public: + MyInfo() + { + static byte_t default_ProductUUID_Data[UUIDlen] = + { 0x7d, 0x83, 0x6e, 0x16, 0x37, 0xc7, 0x4c, 0x22, + 0xb2, 0xe0, 0x46, 0xa7, 0x17, 0xe8, 0x4f, 0x42 }; + + memcpy(ProductUUID, default_ProductUUID_Data, UUIDlen); + CompanyName = "WidgetCo"; + ProductName = "asdcp-wrap"; + ProductVersion = ASDCP::Version(); + } +} s_MyInfo; + + + +// Increment the iterator, test for an additional non-option command line argument. +// Causes the caller to return if there are no remaining arguments or if the next +// argument begins with '-'. +#define TEST_EXTRA_ARG(i,c) \ + if ( ++i >= argc || argv[(i)][0] == '-' ) { \ + fprintf(stderr, "Argument not found for option -%c.\n", (c)); \ + return; \ + } + +// +void +banner(FILE* stream = stdout) +{ + fprintf(stream, "\n\ +%s (asdcplib %s)\n\n\ +Copyright (c) 2003-2012 John Hurst\n\n\ +asdcplib may be copied only under the terms of the license found at\n\ +the top of every file in the asdcplib distribution kit.\n\n\ +Specify the -h (help) option for further information about %s\n\n", + PROGRAM_NAME, ASDCP::Version(), PROGRAM_NAME); +} + +// +void +usage(FILE* stream = stdout) +{ + fprintf(stream, "\ +USAGE: %s [-h|-help] [-V]\n\ +\n\ + %s [-3] [-a ] [-b ] [-C
    ] [-d ] [-e|-E] [-f ] [-j ] [-k ] [-l