From 3f630fb8334238ab8a58fbe1a0f513ae2c00de80 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Jan 2015 17:39:32 +0000 Subject: Simplify time representation; better in-tree DCP subtitle parser. --- asdcplib/src/asdcp-test.cpp | 2087 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2087 insertions(+) create mode 100755 asdcplib/src/asdcp-test.cpp (limited to 'asdcplib/src/asdcp-test.cpp') diff --git a/asdcplib/src/asdcp-test.cpp b/asdcplib/src/asdcp-test.cpp new file mode 100755 index 0000000..05f486f --- /dev/null +++ b/asdcplib/src/asdcp-test.cpp @@ -0,0 +1,2087 @@ +/* +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-test.cpp + \version $Id: asdcp-test.cpp,v 1.46 2012/02/03 19:49:56 jhurst Exp $ + \brief AS-DCP file manipulation utility + + This program provides command line access to the major features of the asdcplib + library, and serves as a library unit test which provides the functionality of + the supported use cases. + + 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 +#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-test"; // program name for messages +const ui32_t MAX_IN_FILES = 16; // maximum number of input files handled by + // the command option parser + +// 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-test"; + 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 -c [-3] [-a ] [-b ]\n\ + [-d ] [-e|-E] [-f ] [-j ]\n\ + [-k ] [-l