o Fixed MinorVersion error (was "2", is now "3") when writing BodyPartition packs...
authorjhurst <jhurst@cinecert.com>
Sun, 25 Mar 2018 22:54:20 +0000 (22:54 +0000)
committerjhurst <>
Sun, 25 Mar 2018 22:54:20 +0000 (22:54 +0000)
 o Fixed AS-DCP timed text writer, was creating DM Segment instead of SourceClip in the source package.
 o Changed SourcePackage timecode track start to 00:00:00:00 (was 01:00:00:00)
 o Fixed reference counting errors in asdcp.MXFWriter and asdcp.TimedTextWriter that were causing asdcp.MXFReader and asdcp.TimedTextReader (respectively) to remain allocated after all references had been deleted, thus leaking file handles and memory.
 o Fixed broken arg parser (missing format token in format string for "EssenceType" argument) in TimedTextWriter

src/AS_02.h
src/AS_02_internal.h
src/AS_DCP_TimedText.cpp
src/AS_DCP_internal.h
src/ST2052_TextParser.cpp
src/as-02-wrap.cpp

index c768507286d872145790fdd6450aca5e01e9abba..33163c3a6462c483bc314c22f45a86beacdbd29f 100644 (file)
@@ -367,12 +367,16 @@ namespace AS_02
 
          // Opens an XML file for reading, parses data to provide a complete
          // set of stream metadata for the MXFWriter below.
-         Result_t OpenRead(const std::string& filename, const std::string& profile_name) const;
+         Result_t OpenRead(const std::string& filename) const;
 
          // Parse an XML string 
-         Result_t OpenRead(const std::string& xml_doc, const std::string& filename,
-                           const std::string& profile_name) const;
+         Result_t OpenRead(const std::string& xml_doc, const std::string& filename) const;
 
+         // The "profile_name" parameter was removed from OpenRead() because it made the API
+         // awkward WRT lexical compatibility with TimedText_Parser. The value can still be
+         // modified by changing the descriptor's NamespaceName property after the call to
+         // FillTimedTextDescriptor() has set it.
+                             
          // Fill a TimedTextDescriptor struct with the values from the file's contents.
          // Returns RESULT_INIT if the file is not open.
          Result_t FillTimedTextDescriptor(ASDCP::TimedText::TimedTextDescriptor&) const;
index 9153ac94b4c6d6c411a7b176e10bfdd1ad53685c..560fb6c0107ebaf7390b520d0b22feb32885ddf8 100644 (file)
@@ -179,6 +179,8 @@ namespace AS_02
 
        this->m_IndexWriter.SetPrimerLookup(&this->m_HeaderPart.m_Primer);
        this->m_RIP.PairArray.push_back(RIP::PartitionPair(0, 0)); // Header partition RIP entry
+       this->m_IndexWriter.MajorVersion = m_HeaderPart.MajorVersion;
+       this->m_IndexWriter.MinorVersion = m_HeaderPart.MinorVersion;
        this->m_IndexWriter.OperationalPattern = this->m_HeaderPart.OperationalPattern;
        this->m_IndexWriter.EssenceContainers = this->m_HeaderPart.EssenceContainers;
 
index ab8dab9bc6c5c6fff1e464756cbab6e10900edff..6e34a5d8bcae2c884c0563cc9ea7966967b26f5b 100644 (file)
@@ -594,11 +594,10 @@ ASDCP::TimedText::MXFWriter::h__Writer::SetSourceStream(ASDCP::TimedText::TimedT
        }
 
       // timecode rate and essence rate are the same
-      AddDMSegment(m_TDesc.EditRate, m_TDesc.EditRate, derive_timecode_rate_from_edit_rate(m_TDesc.EditRate), TIMED_TEXT_DEF_LABEL,
-                  UL(m_Dict->ul(MDD_DataDataDef)), TIMED_TEXT_PACKAGE_LABEL);
+      AddSourceClip(m_TDesc.EditRate, m_TDesc.EditRate, derive_timecode_rate_from_edit_rate(m_TDesc.EditRate),
+                   TIMED_TEXT_DEF_LABEL, m_EssenceUL, UL(m_Dict->ul(MDD_DataDataDef)), TIMED_TEXT_PACKAGE_LABEL);
 
       AddEssenceDescriptor(UL(m_Dict->ul(MDD_TimedTextWrappingClip)));
-
       result = m_HeaderPart.WriteToFile(m_File, m_HeaderSize);
       
       if ( KM_SUCCESS(result) )
index aaa9e606e09058ada3a0b38307b9d3d9b7db5ce4..aad500eef3106890abca8b3b663e8af777a6d021 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2016, John Hurst
+Copyright (c) 2004-2018, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -130,6 +130,13 @@ namespace ASDCP
     MXFVersion_MAX
   };
 
+  // version numbers from the MXF spec, to be written into files
+  
+  ui8_t const MXF_ObjectModelVersion = 1;
+  ui8_t const MXF_2004_MinorVersion = 2;
+  ui8_t const MXF_2011_MinorVersion = 3;
+           
+
   //------------------------------------------------------------------------------------------
   //
 
@@ -552,16 +559,16 @@ namespace ASDCP
 
          if ( mxf_ver == MXFVersion_2004 )
            {
-             m_HeaderPart.MinorVersion = 2;
-             m_HeaderPart.m_Preface->Version = 258;
-             m_HeaderPart.m_Preface->ObjectModelVersion = 1;
+             m_HeaderPart.MinorVersion = MXF_2004_MinorVersion;
+             m_HeaderPart.m_Preface->Version = ((MXF_ObjectModelVersion < 8) | MXF_2004_MinorVersion);
+             m_HeaderPart.m_Preface->ObjectModelVersion = MXF_ObjectModelVersion;
            }
          else
            {
              assert(mxf_ver == MXFVersion_2011);
-             m_HeaderPart.MinorVersion = 3;
-             m_HeaderPart.m_Preface->Version = 259;
-             m_HeaderPart.m_Preface->ObjectModelVersion = 1;
+             m_HeaderPart.MinorVersion = MXF_2011_MinorVersion;
+             m_HeaderPart.m_Preface->Version = ((MXF_ObjectModelVersion < 8) | MXF_2011_MinorVersion);
+             m_HeaderPart.m_Preface->ObjectModelVersion = MXF_ObjectModelVersion;
            }
 
          // Identification
@@ -658,8 +665,7 @@ namespace ASDCP
 
          TrackSet<TimecodeComponent> FPTCTrack =
            CreateTimecodeTrack<SourcePackage>(m_HeaderPart, *m_FilePackage,
-                                              tc_edit_rate, TCFrameRate,
-                                              ui64_C(3600) * TCFrameRate, m_Dict);
+                                              tc_edit_rate, TCFrameRate, 0, m_Dict);
 
          FPTCTrack.Sequence->Duration.set_has_value();
          m_DurationUpdateList.push_back(&(FPTCTrack.Sequence->Duration.get()));
index a98b4cabb03446b0e16d433aac418a44d0769e31..305f46ff836b882cda0b3ca7f67400a27b4fe34e 100644 (file)
@@ -230,7 +230,7 @@ class AS_02::TimedText::ST2052_TextParser::h__TextParser
 {
   XMLElement  m_Root;
   ResourceTypeMap_t m_ResourceTypes;
-  Result_t OpenRead(const std::string& profile_name);
+  Result_t OpenRead();
 
   ASDCP_NO_COPY_CONSTRUCT(h__TextParser);
 
@@ -259,22 +259,22 @@ public:
     return m_DefaultResolver;
   }
 
-  Result_t OpenRead(const std::string& filename, const std::string& profile_name);
-  Result_t OpenRead(const std::string& xml_doc, const std::string& filename, const std::string& profile_name);
+  Result_t OpenRead(const std::string& filename);
+  Result_t OpenRead(const std::string& xml_doc, const std::string& filename);
   Result_t ReadAncillaryResource(const byte_t *uuid, ASDCP::TimedText::FrameBuffer& FrameBuf,
                                 const ASDCP::TimedText::IResourceResolver& Resolver) const;
 };
 
 //
 Result_t
-AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string& filename, const std::string& profile_name)
+AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string& filename)
 {
   Result_t result = ReadFileIntoString(filename, m_XMLDoc);
 
   if ( KM_SUCCESS(result) )
     {
       m_Filename = filename;
-      result = OpenRead(profile_name);
+      result = OpenRead();
     }
 
   return result;
@@ -282,12 +282,11 @@ AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string&
 
 //
 Result_t
-AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string& xml_doc, const std::string& filename,
-                                                            const std::string& profile_name)
+AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string& xml_doc, const std::string& filename)
 {
   m_XMLDoc = xml_doc;
   m_Filename = filename;
-  return OpenRead(profile_name);
+  return OpenRead();
 }
 
 
@@ -297,7 +296,7 @@ std::string const IMSC1_textProfile = "http://www.w3.org/ns/ttml/profile/imsc1/t
 
 //
 Result_t
-AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string& profile_name)
+AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead()
 {
   setup_default_font_family_list();
 
@@ -310,7 +309,6 @@ AS_02::TimedText::ST2052_TextParser::h__TextParser::OpenRead(const std::string&
   m_TDesc.EncodingName = "UTF-8"; // the XML parser demands UTF-8
   m_TDesc.ResourceList.clear();
   m_TDesc.ContainerDuration = 0;
-  m_TDesc.NamespaceName = profile_name; // set the profile explicitly
   std::set<std::string>::const_iterator i;
 
   // Attempt to set the profile from <conformsToStandard>
@@ -466,11 +464,11 @@ AS_02::TimedText::ST2052_TextParser::~ST2052_TextParser()
 // Opens the stream for reading, parses enough data to provide a complete
 // set of stream metadata for the MXFWriter below.
 ASDCP::Result_t
-AS_02::TimedText::ST2052_TextParser::OpenRead(const std::string& filename, const std::string& profile_name) const
+AS_02::TimedText::ST2052_TextParser::OpenRead(const std::string& filename) const
 {
   const_cast<AS_02::TimedText::ST2052_TextParser*>(this)->m_Parser = new h__TextParser;
 
-  Result_t result = m_Parser->OpenRead(filename, profile_name);
+  Result_t result = m_Parser->OpenRead(filename);
 
   if ( ASDCP_FAILURE(result) )
     const_cast<AS_02::TimedText::ST2052_TextParser*>(this)->m_Parser = 0;
@@ -480,12 +478,11 @@ AS_02::TimedText::ST2052_TextParser::OpenRead(const std::string& filename, const
 
 // Parses an XML document to provide a complete set of stream metadata for the MXFWriter below.
 Result_t
-AS_02::TimedText::ST2052_TextParser::OpenRead(const std::string& xml_doc, const std::string& filename,
-                                             const std::string& profile_name) const
+AS_02::TimedText::ST2052_TextParser::OpenRead(const std::string& xml_doc, const std::string& filename) const
 {
   const_cast<AS_02::TimedText::ST2052_TextParser*>(this)->m_Parser = new h__TextParser;
 
-  Result_t result = m_Parser->OpenRead(xml_doc, filename, profile_name);
+  Result_t result = m_Parser->OpenRead(xml_doc, filename);
 
   if ( ASDCP_FAILURE(result) )
     const_cast<AS_02::TimedText::ST2052_TextParser*>(this)->m_Parser = 0;
index 8a32d71efde2b6f1abda1fdfd35ba092f0bb7a38..49b552f73ff83a7d2ff7f72a73ac01bda6ee2afa 100755 (executable)
@@ -707,7 +707,7 @@ public:
          }
       }
 
-    if ( help_flag || version_flag )
+    if ( help_flag || version_flag || show_ul_values_flag )
       return;
     
     if ( filenames.size() < 2 )
@@ -1110,8 +1110,7 @@ write_timed_text_file(CommandOptions& Options)
   Kumu::FortunaRNG  RNG;
 
   // set up essence parser
-  Result_t result = Parser.OpenRead(Options.filenames.front().c_str(),
-                                   Options.profile_name);
+  Result_t result = Parser.OpenRead(Options.filenames.front());
 
   // set up MXF writer
   if ( ASDCP_SUCCESS(result) )
@@ -1121,6 +1120,11 @@ write_timed_text_file(CommandOptions& Options)
       TDesc.ContainerDuration = Options.duration;
       FrameBuffer.Capacity(Options.fb_size);
 
+      if ( ! Options.profile_name.empty() )
+       {
+         TDesc.NamespaceName = Options.profile_name;
+       }
+
       if ( Options.verbose_flag )
        {
          fputs("IMF Timed-Text Descriptor:\n", stderr);