diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 36 | ||||
| -rwxr-xr-x | src/Dict.cpp | 6 | ||||
| -rwxr-xr-x | src/KLV.cpp | 26 | ||||
| -rwxr-xr-x | src/KLV.h | 3 | ||||
| -rwxr-xr-x | src/MXFTypes.cpp | 28 | ||||
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rwxr-xr-x | src/PCM_Parser.cpp | 4 | ||||
| -rw-r--r-- | src/as-02-info.cpp | 32 | ||||
| -rwxr-xr-x | src/as-02-wrap-iab.cpp | 351 | ||||
| -rwxr-xr-x | src/klvwalk.cpp | 18 |
10 files changed, 486 insertions, 22 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57b8d84..11c13e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,7 @@ endif (NOT WITHOUT_XML) set(UseRandomUUID OFF CACHE BOOL "")
-if (OpenSSLLib_PATH AND OpenSSLLib_include_DIR)
+if (NOT WITHOUT_SSL AND OpenSSLLib_PATH AND OpenSSLLib_include_DIR)
set (HAVE_OPENSSL 1)
message(STATUS "Building with encryption support")
add_definitions(/DHAVE_OPENSSL=1)
@@ -100,7 +100,7 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}") if (HAVE_OPENSSL)
include_directories("${OpenSSLLib_include_DIR}")
endif()
-if (WITH_XERCES)
+if (HAVE_XERCES_C)
include_directories("${XercescppLib_include_DIR}")
add_definitions(/DHAVE_XERCES_C=1)
endif()
@@ -217,6 +217,20 @@ if(WIN32) target_link_libraries(as-02-wrap general Advapi32.lib)
endif(WIN32)
+if (USE_ASDCP_JXS)
+ add_executable(as-02-wrap-jxs "as-02-wrap-jxs.cpp")
+ target_link_libraries(as-02-wrap-jxs general libas02)
+ if(WIN32)
+ target_link_libraries(as-02-wrap-jxs general Advapi32.lib)
+ endif(WIN32)
+endif (USE_ASDCP_JXS)
+
+add_executable(as-02-wrap-iab "as-02-wrap-iab.cpp")
+target_link_libraries(as-02-wrap-iab general libas02)
+if(WIN32)
+ target_link_libraries(as-02-wrap-iab general Advapi32.lib)
+endif(WIN32)
+
add_executable(as-02-unwrap "as-02-unwrap.cpp")
target_link_libraries(as-02-unwrap general libas02)
if(WIN32)
@@ -229,11 +243,23 @@ if(WIN32) target_link_libraries(as-02-info general Advapi32.lib)
endif(WIN32)
+set (install_includes)
+if (HAVE_OPENSSL)
+ list(APPEND install_includes "${OpenSSLLib_include_DIR}")
+endif()
+
+if (HAVE_XERCES_C)
+ list(APPEND install_includes "${XercescppLib_include_DIR}")
+endif()
# add the install target
-install(TARGETS libkumu libasdcp libas02 EXPORT asdcplibtargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib INCLUDES DESTINATION "${OpenSSLLib_include_DIR}" "${XercescppLib_include_DIR}")
+install(TARGETS libkumu libasdcp libas02 EXPORT asdcplibtargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib INCLUDES DESTINATION "${install_includes}")
+
+set(install_targets blackwave wavesplit klvwalk asdcp-test asdcp-wrap asdcp-unwrap asdcp-info asdcp-util j2c-test as-02-wrap as-02-wrap-iab as-02-unwrap as-02-info kmfilegen kmuuidgen kmrandgen)
-set(install_targets blackwave wavesplit klvwalk asdcp-test asdcp-wrap asdcp-unwrap asdcp-info asdcp-util j2c-test as-02-wrap as-02-unwrap as-02-info kmfilegen kmuuidgen kmrandgen)
+if (USE_ASDCP_JXS)
+ list(APPEND install_targets as-02-wrap-jxs)
+endif (USE_ASDCP_JXS)
install(TARGETS ${install_targets} RUNTIME DESTINATION bin)
install(FILES ${as02_deploy_header} ${asdcp_deploy_header} DESTINATION include)
-install(EXPORT asdcplibtargets DESTINATION targets)
\ No newline at end of file +install(EXPORT asdcplibtargets DESTINATION targets)
diff --git a/src/Dict.cpp b/src/Dict.cpp index 752b81a..d890f83 100755 --- a/src/Dict.cpp +++ b/src/Dict.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2006-2018, John Hurst +Copyright (c) 2006-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -322,6 +322,10 @@ ASDCP::Dictionary::FindULAnyVersion(const byte_t* ul_buf) const { found_entry = &m_MDD_Table[lower->second]; } + else if ( found_entry == 0 && lower->first.MatchIgnorePlaceholder(target) ) + { + found_entry = &m_MDD_Table[lower->second]; + } else if ( found_entry != 0 && ! lower->first.MatchIgnoreStream(target) ) { break; diff --git a/src/KLV.cpp b/src/KLV.cpp index 681a834..c29eb8c 100755 --- a/src/KLV.cpp +++ b/src/KLV.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2009, John Hurst +Copyright (c) 2005-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -167,14 +167,13 @@ ASDCP::KLVPacket::Dump(FILE* stream, const Dictionary& Dict, bool show_value) if ( m_KeyStart != 0 ) { - assert(m_ValueStart); UL TmpUL(m_KeyStart); fprintf(stream, "%s", TmpUL.EncodeString(buf, 64)); const MDDEntry* Entry = Dict.FindULAnyVersion(m_KeyStart); fprintf(stream, " len: %7llu (%s)\n", m_ValueLength, (Entry ? Entry->name : "Unknown")); - if ( show_value && m_ValueLength < 1000 ) + if ( m_ValueStart && show_value && m_ValueLength < 1000 ) Kumu::hexdump(m_ValueStart, Kumu::xmin(m_ValueLength, (ui64_t)128), stream); } else if ( m_UL.HasValue() ) @@ -234,16 +233,27 @@ ASDCP::KLVFilePacket::InitFromFile(const Kumu::IFileReader& Reader) return RESULT_FAIL; } + ui32_t ber_len = Kumu::BER_length(tmp_data + SMPTE_UL_LENGTH); + m_KLLength = SMPTE_UL_LENGTH + ber_len; + if ( tmp_size > MAX_KLV_PACKET_LENGTH ) { - Kumu::ui64Printer tmp_size_str(tmp_size); - DefaultLogSink().Error("Packet length %s exceeds internal limit\n", tmp_size_str.c_str()); - return RESULT_FAIL; + result = Reader.Seek(tmp_size - (tmp_read_size - SMPTE_UL_LENGTH - ber_len), Kumu::SP_POS); + + if ( ASDCP_SUCCESS(result) ) + { + memcpy(m_Buffer.Data(), tmp_data, SMPTE_UL_LENGTH); + m_KeyStart = m_Buffer.Data(); + + Kumu::ui64Printer tmp_size_str(tmp_size); + DefaultLogSink().Error("Packet length %s exceeds internal limit.\n", tmp_size_str.c_str()); + result = RESULT_ALLOC; + } + + return result; } ui32_t remainder = 0; - ui32_t ber_len = Kumu::BER_length(tmp_data + SMPTE_UL_LENGTH); - m_KLLength = SMPTE_UL_LENGTH + ber_len; assert(tmp_size <= 0xFFFFFFFFL); m_ValueLength = (ui32_t) tmp_size; ui32_t packet_length = m_ValueLength + m_KLLength; @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2018, John Hurst +Copyright (c) 2005-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -109,6 +109,7 @@ inline const char* ui64sz(ui64_t i, char* buf) bool operator==(const UL& rhs) const; bool MatchIgnoreStream(const UL& rhs) const; bool MatchExact(const UL& rhs) const; + bool MatchIgnorePlaceholder(const UL& rhs) const; }; // UMID diff --git a/src/MXFTypes.cpp b/src/MXFTypes.cpp index 58fb184..19e70ca 100755 --- a/src/MXFTypes.cpp +++ b/src/MXFTypes.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2019, John Hurst +Copyright (c) 2005-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -93,6 +93,32 @@ ASDCP::UL::MatchIgnoreStream(const UL& rhs) const // bool +ASDCP::UL::MatchIgnorePlaceholder(const UL& rhs) const +{ + if ( m_Value[0] == rhs.m_Value[0] && + m_Value[1] == rhs.m_Value[1] && + m_Value[2] == rhs.m_Value[2] && + m_Value[3] == rhs.m_Value[3] && + ( m_Value[4] == 0x7f || m_Value[4] == rhs.m_Value[4] ) && + ( m_Value[5] == 0x7f || m_Value[5] == rhs.m_Value[5] ) && + ( m_Value[6] == 0x7f || m_Value[6] == rhs.m_Value[6] ) && + // m_Value[7] == rhs.m_Value[7] && // version is ignored when performing lookups + ( m_Value[8] == 0x7f || m_Value[8] == rhs.m_Value[8] ) && + ( m_Value[9] == 0x7f || m_Value[9] == rhs.m_Value[9] ) && + ( m_Value[10] == 0x7f || m_Value[10] == rhs.m_Value[10] ) && + ( m_Value[11] == 0x7f || m_Value[11] == rhs.m_Value[11] ) && + ( m_Value[12] == 0x7f || m_Value[12] == rhs.m_Value[12] ) && + ( m_Value[13] == 0x7f || m_Value[13] == rhs.m_Value[13] ) && + ( m_Value[14] == 0x7f || m_Value[14] == rhs.m_Value[14] ) && + ( m_Value[15] == 0x7f || m_Value[15] == rhs.m_Value[15] ) + ) + return true; + + return false; +} + +// +bool ASDCP::UL::MatchExact(const UL& rhs) const { if ( m_Value[0] == rhs.m_Value[0] && diff --git a/src/Makefile.am b/src/Makefile.am index 3ea5cbd..20bccf5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -217,6 +217,7 @@ if USE_AS_02 bin_PROGRAMS += \ as-02-wrap \ as-02-wrap-jxs \ + as-02-wrap-iab \ as-02-unwrap \ as-02-info endif @@ -277,6 +278,9 @@ as_02_wrap_LDADD = libas02.la libasdcp.la libkumu.la as_02_wrap_jxs_SOURCES = as-02-wrap-jxs.cpp as_02_wrap_jxs_LDADD = libas02.la libasdcp.la libkumu.la +as_02_wrap_iab_SOURCES = as-02-wrap-iab.cpp +as_02_wrap_iab_LDADD = libas02.la libasdcp.la libkumu.la + as_02_unwrap_SOURCES = as-02-unwrap.cpp as_02_unwrap_LDADD = libas02.la libasdcp.la libkumu.la diff --git a/src/PCM_Parser.cpp b/src/PCM_Parser.cpp index b8dea71..9efd388 100755 --- a/src/PCM_Parser.cpp +++ b/src/PCM_Parser.cpp @@ -170,9 +170,9 @@ ASDCP::PCM::WAVParser::h__WAVParser::ReadFrame(FrameBuffer& FB) } ui32_t read_count = 0; - Result_t result = m_FileReader.Read(FB.Data(), m_FrameBufferSize, &read_count); + Result_t result = m_FileReader.Read(FB.Data(), (m_DataLength - m_ReadCount >= m_FrameBufferSize) ? m_FrameBufferSize : m_DataLength - m_ReadCount, &read_count); - if ( result == RESULT_ENDOFFILE ) + if ( result == RESULT_ENDOFFILE || (m_DataLength == m_ReadCount + read_count) ) { m_EOF = true; diff --git a/src/as-02-info.cpp b/src/as-02-info.cpp index 79fe41b..b9b281c 100644 --- a/src/as-02-info.cpp +++ b/src/as-02-info.cpp @@ -553,6 +553,33 @@ class MyAudioDescriptor : public PCM::AudioDescriptor } }; +struct IabDescriptor +{ + int ContainerDuration; + IabDescriptor() : ContainerDuration(0) {} +}; + +class MyIabDescriptor : public IabDescriptor +{ + public: + void FillDescriptor(AS_02::IAB::MXFReader& reader) { + const Dictionary& Dict = DefaultCompositeDict(); + IABEssenceDescriptor *essence_descriptor_mxf = 0; + + std::list<MXF::InterchangeObject*> object_list; + reader.OP1aHeader().GetMDObjectsByType(DefaultSMPTEDict().ul(MDD_IABEssenceDescriptor), object_list); + + if ( ! object_list.empty() ) + { + essence_descriptor_mxf = dynamic_cast<MXF::IABEssenceDescriptor*>(object_list.back()); + assert(essence_descriptor_mxf); + ContainerDuration = (int)essence_descriptor_mxf->ContainerDuration.get(); + } + } + void Dump(FILE* stream) {} + void MyDump(FILE* stream) {} +}; + class MyTextDescriptor : public TimedText::TimedTextDescriptor { public: @@ -927,6 +954,11 @@ show_file_info(CommandOptions& Options, const Kumu::IFileReaderFactory& fileRead if ( ASDCP_SUCCESS(result) && Options.showcoding_flag ) wrapper.dump_WaveAudioDescriptor(stdout); } + else if ( EssenceType == ESS_AS02_IAB ) + { + FileInfoWrapper<AS_02::IAB::MXFReader, MyIabDescriptor> wrapper(fileReaderFactory); + result = wrapper.file_info(Options, "IAB audio"); + } else { fprintf(stderr, "Unknown/unsupported essence type: %s\n", Options.filenames.front().c_str()); diff --git a/src/as-02-wrap-iab.cpp b/src/as-02-wrap-iab.cpp new file mode 100755 index 0000000..5e4c182 --- /dev/null +++ b/src/as-02-wrap-iab.cpp @@ -0,0 +1,351 @@ +/* +Copyright (c) 2021 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 as-02-wrap-iab.cpp + \version $Id$ + \brief AS-02 file manipulation utility + + This program wraps IAB sound essence into an AS-02 MXF file. + + For more information about AS-02, please refer to the header file AS_02.h + For more information about asdcplib, please refer to the header file AS_DCP.h +*/ +#include <KM_fileio.h> +#include <AS_02.h> +#include "AS_02_IAB.h" +#include <Metadata.h> + +using namespace ASDCP; + +const ui32_t FRAME_BUFFER_SIZE = 4 * Kumu::Megabyte; +const ASDCP::Dictionary *g_dict = 0; + +//------------------------------------------------------------------------------------------ +// +// command line option parser class + +static const char* PROGRAM_NAME = "as-02-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] = + { 0x13, 0x54, 0x4d, 0xec, 0x47, 0xf5, 0x49, 0xf4, + 0xb7, 0xb7, 0x83, 0x49, 0x61, 0xa5, 0x49, 0x4e + }; + + memcpy(ProductUUID, default_ProductUUID_Data, UUIDlen); + CompanyName = "WidgetCo"; + ProductName = "as-02-wrap-iab"; + 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; \ + } + +// +static void +create_random_uuid(byte_t* uuidbuf) +{ + Kumu::UUID tmp_id; + GenRandomValue(tmp_id); + memcpy(uuidbuf, tmp_id.Value(), tmp_id.Size()); +} + +// +void +banner(FILE* stream = stdout) +{ + fprintf(stream, "\n\ +%s (asdcplib %s)\n\n\ +Copyright (c) 2021, 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 [options] <input-directory> <output-file>\n\n", + PROGRAM_NAME, PROGRAM_NAME); + + fprintf(stream, "\ +Options:\n\ + -h | -help - Show help\n\ + -V - Show version information\n\ + -a <uuid> - Specify the Asset ID of the file\n\ + -g <rfc-5646-code>\n\ + - Create an MCA label having the given RFC 5646 language code\n\ + -r <n>/<d> - Edit Rate of the output file. 24/1 is the default\n\ + -v - Verbose, prints informative messages to stderr\n\ +\n\ + NOTES: o There is no option grouping, all options must be distinct arguments.\n\ + o All option arguments must be separated from the option by whitespace.\n\n"); +} + +// +class CommandOptions +{ + CommandOptions(); + +public: + bool error_flag; // true if the given options are in error or not complete + bool asset_id_flag; // true if an asset ID was given + bool verbose_flag; // true if the verbose option was selected + bool version_flag; // true if the version display option was selected + bool help_flag; // true if the help display option was selected + Rational edit_rate; // edit rate of JP2K sequence + ui32_t fb_size; // size of picture frame buffer + byte_t asset_id_value[UUIDlen];// value of asset ID (when asset_id_flag is true) + Kumu::PathList_t filenames; // list of filenames to be processed + std::string language; + std::string out_file; + + CommandOptions(int argc, const char** argv) : + error_flag(true), asset_id_flag(false), + verbose_flag(false), version_flag(false), help_flag(false), + edit_rate(24,1), fb_size(FRAME_BUFFER_SIZE) + { + for ( int i = 1; i < argc; i++ ) + { + + if ( (strcmp( argv[i], "-help") == 0) ) + { + help_flag = true; + continue; + } + + if ( argv[i][0] == '-' + && ( isalpha(argv[i][1]) || isdigit(argv[i][1]) ) + && argv[i][2] == 0 ) + { + switch ( argv[i][1] ) + { + case 'a': + asset_id_flag = true; + TEST_EXTRA_ARG(i, 'a'); + { + ui32_t length; + Kumu::hex2bin(argv[i], asset_id_value, UUIDlen, &length); + + if ( length != UUIDlen ) + { + fprintf(stderr, "Unexpected asset ID length: %u, expecting %u characters.\n", length, UUIDlen); + return; + } + } + break; + + case 'g': + TEST_EXTRA_ARG(i, 'g'); + language = argv[i]; + break; + + case 'h': help_flag = true; break; + + case 'r': + TEST_EXTRA_ARG(i, 'r'); + if ( ! DecodeRational(argv[i], edit_rate) ) + { + fprintf(stderr, "Error decoding edit rate value: %s\n", argv[i]); + return; + } + + break; + + case 'V': version_flag = true; break; + case 'v': verbose_flag = true; break; + + default: + fprintf(stderr, "Unrecognized option: %s\n", argv[i]); + return; + } + } + else + { + if ( argv[i][0] != '-' ) + { + filenames.push_back(argv[i]); + } + else + { + fprintf(stderr, "Unrecognized argument: %s\n", argv[i]); + return; + } + } + } + + if ( help_flag || version_flag ) + { + return; + } + + if ( filenames.size() != 2 ) + { + fputs("Two arguments are required: <input-directory> <output-file>\n", stderr); + return; + } + + out_file = filenames.back(); + filenames.pop_back(); + + error_flag = false; + } +}; + + +// Write an IAB audio stream into an AS-02 file. +// +Result_t +write_IAB_file(CommandOptions& Options) +{ + DCData::SequenceParser Parser; + AS_02::IAB::MXFWriter Writer; + DCData::FrameBuffer FrameBuffer(Options.fb_size); + std::vector<ASDCP::UL> conforms_to_spec; + conforms_to_spec.push_back(g_dict->ul(MDD_IMF_IABTrackFileLevel0)); + ASDCP::MXF::IABSoundfieldLabelSubDescriptor iab_subdescr(g_dict); + iab_subdescr.RFC5646SpokenLanguage = Options.language; + + // set up essence parser + assert(Options.filenames.size() == 1); + Result_t result = Parser.OpenRead(Options.filenames.front()); + + Kumu::PathList_t::const_iterator i; + + // set up MXF writer + if ( ASDCP_SUCCESS(result) ) + { + WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here + Info.LabelSetType = LS_MXF_SMPTE; + + if ( Options.asset_id_flag ) + memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen); + else + Kumu::GenRandomUUID(Info.AssetUUID); + + if ( ASDCP_SUCCESS(result) ) + { + result = Writer.OpenWrite(Options.out_file, + Info, + iab_subdescr, + conforms_to_spec, + Options.edit_rate); + } + } + + if ( ASDCP_SUCCESS(result) ) + { + result = Parser.Reset(); + + while ( ASDCP_SUCCESS(result) ) + { + result = Parser.ReadFrame(FrameBuffer); + + if ( ASDCP_SUCCESS(result) ) + { + result = Writer.WriteFrame(FrameBuffer); + } + } + + if ( result == RESULT_ENDOFFILE ) + result = RESULT_OK; + } + + if ( ASDCP_SUCCESS(result) ) + { + result = Writer.Finalize(); + } + + return result; +} + + +// +int +main(int argc, const char** argv) +{ + g_dict = &ASDCP::DefaultSMPTEDict(); + assert(g_dict); + + CommandOptions Options(argc, argv); + + if ( Options.version_flag ) + banner(); + + if ( Options.help_flag ) + usage(); + + if ( Options.version_flag || Options.help_flag ) + return 0; + + if ( Options.error_flag ) + { + fprintf(stderr, "There was a problem. Type %s -h for help.\n", PROGRAM_NAME); + return 3; + } + + Result_t result = write_IAB_file(Options); + + if ( ASDCP_FAILURE(result) ) + { + fputs("Program stopped on error.\n", stderr); + + if ( result != RESULT_FAIL ) + { + fputs(result, stderr); + fputc('\n', stderr); + } + + return 1; + } + + return 0; +} + + +// +// end as-02-wrap-iab.cpp +// diff --git a/src/klvwalk.cpp b/src/klvwalk.cpp index 1ba9908..dc9200f 100755 --- a/src/klvwalk.cpp +++ b/src/klvwalk.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2018, John Hurst +Copyright (c) 2005-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ banner(FILE* stream = stdout) { fprintf(stream, "\n\ %s (asdcplib %s)\n\n\ -Copyright (c) 2005-2013 John Hurst\n\ +Copyright (c) 2005-2021 John Hurst\n\ %s is part of the asdcplib DCP tools package.\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\ @@ -85,6 +85,7 @@ USAGE: %s [-r|-p] [-v] <input-file> [<input-file2> ...]\n\ -h | -help - Show help\n\ -r - When KLV data is an MXF OPAtom or OP 1a file, display headers\n\ -p - Display partition headers by walking the RIP\n\ + -s - Allow skipping huge packets when scanning\n\ -v - Verbose. Prints informative messages to stderr\n\ -V - Show version information\n\ \n\ @@ -106,11 +107,13 @@ USAGE: %s [-r|-p] [-v] <input-file> [<input-file2> ...]\n\ bool verbose_flag; // true if the informative messages option was selected bool read_mxf_flag; // true if the -r option was selected bool walk_parts_flag; // true if the -p option was selected + bool allow_skip_flag; // true if the -s option was selected FileList_t inFileList; // File to operate on CommandOptions(int argc, const char** argv) : error_flag(true), version_flag(false), help_flag(false), - verbose_flag(false), read_mxf_flag(false), walk_parts_flag(false) + verbose_flag(false), read_mxf_flag(false), walk_parts_flag(false), + allow_skip_flag(false) { for ( int i = 1; i < argc; i++ ) { @@ -128,6 +131,7 @@ USAGE: %s [-r|-p] [-v] <input-file> [<input-file2> ...]\n\ case 'h': help_flag = true; break; case 'r': read_mxf_flag = true; break; case 'p': walk_parts_flag = true; break; + case 's': allow_skip_flag = true; break; case 'V': version_flag = true; break; case 'v': verbose_flag = true; break; @@ -344,7 +348,13 @@ main(int argc, const char** argv) KP.Dump(stdout, DefaultCompositeDict(), true); pos = Reader->TellPosition(); result = KP.InitFromFile(*Reader); - } + + if ( result == RESULT_ALLOC && Options.allow_skip_flag ) + { + fprintf(stdout, "Skipping huge packet, reporting zero packet size.\n"); + result = RESULT_OK; + } + } if( result == RESULT_ENDOFFILE ) result = RESULT_OK; |
