diff options
| author | jhurst <jhurst@cinecert.com> | 2009-08-14 18:21:35 +0000 |
|---|---|---|
| committer | jhurst <> | 2009-08-14 18:21:35 +0000 |
| commit | 02e0d37bf7b192fcac4b8bb8c4c39a62d47c9531 (patch) | |
| tree | 1ffeb5db9b8458cb7bebebe32ce087c2f0dedb75 | |
| parent | 49d8c24675d057db801c68d0a3063ceb3eab366f (diff) | |
new mode
| -rwxr-xr-x | src/AS_DCP.h | 7 | ||||
| -rwxr-xr-x | src/KM_error.h | 3 | ||||
| -rw-r--r-- | src/KM_xml.cpp | 16 | ||||
| -rw-r--r-- | src/Makefile.am | 7 | ||||
| -rw-r--r-- | src/TimedText_Parser.cpp | 47 | ||||
| -rwxr-xr-x | src/Wav.cpp | 4 | ||||
| -rwxr-xr-x | src/wavesplit.cpp | 64 |
7 files changed, 112 insertions, 36 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h index 3cbc481..f8711d1 100755 --- a/src/AS_DCP.h +++ b/src/AS_DCP.h @@ -1346,10 +1346,15 @@ namespace ASDCP { DCSubtitleParser(); virtual ~DCSubtitleParser(); - // Opens the XML file for reading, parse data to provide a complete + // Opens an XML file for reading, parses data to provide a complete // set of stream metadata for the MXFWriter below. Result_t OpenRead(const char* filename) const; + // Parses an XML document to provide a complete set of stream metadata + // for the MXFWriter below. The optional filename argument is used to + // initialize the default resource resolver (see ReadAncillaryResource). + Result_t OpenRead(const std::string& xml_doc, const char* filename = 0) const; + // Fill a TimedTextDescriptor struct with the values from the file's contents. // Returns RESULT_INIT if the file is not open. Result_t FillTimedTextDescriptor(TimedTextDescriptor&) const; diff --git a/src/KM_error.h b/src/KM_error.h index b0d40d1..8c2f5fc 100755 --- a/src/KM_error.h +++ b/src/KM_error.h @@ -88,7 +88,8 @@ namespace Kumu const Result_t RESULT_FILEEXISTS (-18, "Filename already exists."); const Result_t RESULT_NOTAFILE (-19, "Filename not found."); const Result_t RESULT_UNKNOWN (-20, "Unknown result code."); - const Result_t RESULT_DIR_CREATE (-21, "Unable to create directory."); + const Result_t RESULT_DIR_CREATE (-21, "Unable to create directory."); + // -22 is reserved } // namespace Kumu diff --git a/src/KM_xml.cpp b/src/KM_xml.cpp index 412e5ca..6f2092f 100644 --- a/src/KM_xml.cpp +++ b/src/KM_xml.cpp @@ -310,11 +310,14 @@ void Kumu::XMLElement::DeleteAttrWithName(const char* name) { assert(name); - AttributeList::iterator i; - for ( i = m_AttrList.begin(); i != m_AttrList.end(); i++ ) + AttributeList::iterator i = m_AttrList.begin(); + + while ( i != m_AttrList.end() ) { if ( i->name == std::string(name) ) - m_AttrList.erase(i); + m_AttrList.erase(i++); + else + ++i; } } @@ -322,10 +325,10 @@ Kumu::XMLElement::DeleteAttrWithName(const char* name) void Kumu::XMLElement::DeleteChildren() { - for ( ElementList::iterator i = m_ChildList.begin(); i != m_ChildList.end(); i++ ) + while ( ! m_ChildList.empty() ) { - delete *i; - m_ChildList.erase(i); + delete m_ChildList.back(); + m_ChildList.pop_back(); } } @@ -763,7 +766,6 @@ Kumu::XMLElement::ParseString(const std::string& document) parser->setDoNamespaces(true); // optional MyTreeHandler* docHandler = new MyTreeHandler(this); - ErrorHandler* errHandler = (ErrorHandler*)docHandler; parser->setDocumentHandler(docHandler); parser->setErrorHandler(docHandler); diff --git a/src/Makefile.am b/src/Makefile.am index 44b6dbc..f85d9a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -83,7 +83,7 @@ lib_LTLIBRARIES += libpyasdcp.la nodist_libpyasdcp_la_SOURCES = asdcp_python.cpp asdcp_python.h \ asdcp_python_writerinfo.h asdcp_python_misc.cpp \ asdcp_python_reader.cpp asdcp_python_writer.cpp asdcp_wrappers.h \ - asdcp_python_descriptor.cpp \ + asdcp_python_descriptor.cpp TimedText_Transform.h TimedText_Transform.cpp \ kumu_python.cpp kumu_python.h libpyasdcp_la_CPPFLAGS = @PYTHON_CPPFLAGS@ @@ -130,7 +130,7 @@ wavesplit_LDADD = libasdcp.la # list of programs that need to be compiled for use in test suite check_PROGRAMS = asdcp-mem-test path-test jp2k-test S429-5-cgi \ - fips-186-rng-test asdcp-version + fips-186-rng-test asdcp-version tt-xform # sources for a test program # list of libraries to link against for a test program @@ -146,7 +146,8 @@ fips_186_rng_test_SOURCES = fips-186-rng-test.cpp fips_186_rng_test_LDADD = libasdcp.la asdcp_version_SOURCES = asdcp-version.cpp asdcp_version_LDADD = libkumu.la - +tt_xform_SOURCES = tt-xform.cpp TimedText_Transform.h TimedText_Transform.cpp +tt_xform_LDADD = libasdcp.la # list of test scripts to execute during "make check" diff --git a/src/TimedText_Parser.cpp b/src/TimedText_Parser.cpp index 2519669..9b7ce38 100644 --- a/src/TimedText_Parser.cpp +++ b/src/TimedText_Parser.cpp @@ -97,6 +97,7 @@ class ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser { XMLElement m_Root; ResourceTypeMap_t m_ResourceTypes; + Result_t OpenRead(); ASDCP_NO_COPY_CONSTRUCT(h__SubtitleParser); @@ -122,6 +123,7 @@ public: } Result_t OpenRead(const char* filename); + Result_t OpenRead(const std::string& xml_doc, const char* filename); Result_t ReadAncillaryResource(const byte_t* uuid, FrameBuffer& FrameBuf, const IResourceResolver& Resolver) const; }; @@ -166,13 +168,34 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const char* file { Result_t result = ReadFileIntoString(filename, m_XMLDoc); - if ( KM_FAILURE(result) ) - return result; + if ( KM_SUCCESS(result) ) + result = OpenRead(); + + m_Filename = filename; + return result; +} + +// +Result_t +ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const std::string& xml_doc, const char* filename) +{ + m_XMLDoc = xml_doc; + + if ( filename != 0 ) + m_Filename = filename; + else + m_Filename = "<string>"; + return OpenRead(); +} + +// +Result_t +ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead() +{ if ( ! m_Root.ParseString(m_XMLDoc.c_str()) ) return RESULT_FORMAT; - m_Filename = filename; m_TDesc.EncodingName = "UTF-8"; // the XML parser demands UTF-8 m_TDesc.ResourceList.clear(); m_TDesc.ContainerDuration = 0; @@ -184,7 +207,9 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const char* file m_TDesc.NamespaceName = c_dcst_namespace_name; } else - m_TDesc.NamespaceName = ns->Name(); + { + m_TDesc.NamespaceName = ns->Name(); + } UUID DocID; if ( ! get_UUID_from_child_element("Id", &m_Root, DocID) ) @@ -355,6 +380,20 @@ ASDCP::TimedText::DCSubtitleParser::OpenRead(const char* filename) const return result; } +// Parses an XML document to provide a complete set of stream metadata for the MXFWriter below. +Result_t +ASDCP::TimedText::DCSubtitleParser::OpenRead(const std::string& xml_doc, const char* filename) const +{ + const_cast<ASDCP::TimedText::DCSubtitleParser*>(this)->m_Parser = new h__SubtitleParser; + + Result_t result = m_Parser->OpenRead(xml_doc, filename); + + if ( ASDCP_FAILURE(result) ) + const_cast<ASDCP::TimedText::DCSubtitleParser*>(this)->m_Parser = 0; + + return result; +} + // ASDCP::Result_t ASDCP::TimedText::DCSubtitleParser::FillTimedTextDescriptor(TimedTextDescriptor& TDesc) const diff --git a/src/Wav.cpp b/src/Wav.cpp index 886a183..27a57d8 100755 --- a/src/Wav.cpp +++ b/src/Wav.cpp @@ -138,7 +138,7 @@ ASDCP::Wav::SimpleWaveHeader::ReadFromBuffer(const byte_t* buf, ui32_t buf_len, fourcc test_RIFF(p); p += 4; if ( test_RIFF != FCC_RIFF ) { - DefaultLogSink().Debug("File does not begin with RIFF header\n"); + // DefaultLogSink().Debug("File does not begin with RIFF header\n"); return RESULT_RAW_FORMAT; } @@ -305,7 +305,7 @@ ASDCP::AIFF::SimpleAIFFHeader::ReadFromBuffer(const byte_t* buf, ui32_t buf_len, fourcc test_FORM(p); p += 4; if ( test_FORM != FCC_FORM ) { - DefaultLogSink().Debug("File does not begin with FORM header\n"); + // DefaultLogSink().Debug("File does not begin with FORM header\n"); return RESULT_RAW_FORMAT; } diff --git a/src/wavesplit.cpp b/src/wavesplit.cpp index f7030ca..13153cd 100755 --- a/src/wavesplit.cpp +++ b/src/wavesplit.cpp @@ -44,7 +44,7 @@ static const char* PROGRAM_NAME = "wavesplit"; // program name for messages // Macros used to test command option data state. // True if a major mode has already been selected. -#define TEST_MAJOR_MODE() ( create_flag ) +#define TEST_MAJOR_MODE() ( create_flag || info_flag ) // Causes the caller to return if a major mode has already been selected, // otherwise sets the given flag. @@ -82,21 +82,23 @@ void usage(FILE* stream = stderr) { fprintf(stream, "\ -USAGE: %s [-i|-c <root-name> [-v]] <filename>\n\ +USAGE: %s [-v] -V\n\ + %s [-v] -c <root-name> [-d <duration>] [-f <start-frame>] <filename>\n\ + %s [-v] -i <filename>\n\ \n\ Major modes:\n\ - -c <root-name> - Create a WAV file for each channel in the input file (default is two channel files)\n\ - -V - Show version\n\ - -h - Show help\n\ -\n\ -Read/Write Options:\n\ - -f <frame-num> - Starting frame number, default 0\n\ + -c <root-name> - Create a WAV file for each channel in the input file\n\ + (default is two-channel files)\n\ -d <duration> - Number of frames to process, default all\n\ + -f <frame-num> - Starting frame number, default 0\n\ + -h - Show help\n\ + -i - Show input file metadata (no output created)\n\ + -V - Show version\n\ -v - Print extra info while processing\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", PROGRAM_NAME); +\n", PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME); } // @@ -108,6 +110,7 @@ class CommandOptions public: bool error_flag; // true if the given options are in error or not complete bool create_flag; // true if the file create mode was selected + bool info_flag; // true if the file info mode was selected bool version_flag; // true if the version display option was selected bool help_flag; // true if the help display option was selected bool verbose_flag; // true for extra info during procesing @@ -127,23 +130,25 @@ public: { switch ( argv[i][1] ) { - case 'V': version_flag = true; break; - case 'h': help_flag = true; break; case 'c': TEST_SET_MAJOR_MODE(create_flag); TEST_EXTRA_ARG(i, 'c'); file_root = argv[i]; break; + case 'd': + TEST_EXTRA_ARG(i, 'd'); + duration = atoi(argv[i]); // TODO: test for negative value, should use strtol() + break; + case 'f': TEST_EXTRA_ARG(i, 'f'); start_frame = atoi(argv[i]); // TODO: test for negative value, should use strtol() break; - case 'd': - TEST_EXTRA_ARG(i, 'd'); - duration = atoi(argv[i]); // TODO: test for negative value, should use strtol() - break; + case 'h': help_flag = true; break; + case 'i': TEST_SET_MAJOR_MODE(info_flag); break; + case 'V': version_flag = true; break; default: fprintf(stderr, "Unrecognized option: %c\n", argv[i][1]); @@ -181,8 +186,30 @@ public: } }; - // +Result_t +wav_file_info(CommandOptions& Options) +{ + PCM::AudioDescriptor ADesc; + Rational PictureRate = EditRate_24; + PCM::WAVParser Parser; + + // set up essence parser + Result_t result = Parser.OpenRead(Options.filename, PictureRate); + + if ( ASDCP_SUCCESS(result) ) + { + Parser.FillAudioDescriptor(ADesc); + ADesc.SampleRate = PictureRate; + fprintf(stderr, "48Khz PCM Audio, %s fps (%u spf)\n", "24", + PCM::CalcSamplesPerFrame(ADesc)); + fputs("AudioDescriptor:\n", stderr); + PCM::AudioDescriptorDump(ADesc); + } + + return result; +} + // void split_buffer(ui32_t sample_size, PCM::FrameBuffer& FrameBuffer, @@ -208,8 +235,6 @@ split_buffer(ui32_t sample_size, PCM::FrameBuffer& FrameBuffer, R_FrameBuffer.Size(R_FrameBuffer.Capacity()); } - -// // Result_t split_wav_file(CommandOptions& Options) @@ -346,6 +371,9 @@ main(int argc, const char** argv) if ( Options.version_flag ) banner(); + if ( Options.info_flag ) + result = wav_file_info(Options); + if ( Options.create_flag ) result = split_wav_file(Options); |
