Strict C++ compliance.
[asdcplib.git] / src / AS_DCP_MXF.cpp
index 1d4f473bd51acb7ec070c1a5523450279fdc8cae..6b30da94d45f35100b1f8453c7eb808288ea8fec 100755 (executable)
@@ -35,12 +35,40 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "JP2K.h"
 #include "MPEG.h"
 #include "Wav.h"
+#include <iostream>
+#include <iomanip>
 
 
 //------------------------------------------------------------------------------------------
 // misc subroutines
 
 
+//
+std::ostream&
+ASDCP::operator << (std::ostream& strm, const WriterInfo& Info)
+{
+  char str_buf[40];
+
+  strm << "       ProductUUID: " << UUID(Info.ProductUUID).EncodeHex(str_buf, 40) << std::endl;
+  strm << "    ProductVersion: " << Info.ProductVersion << std::endl;
+  strm << "       CompanyName: " << Info.CompanyName << std::endl;
+  strm << "       ProductName: " << Info.ProductName << std::endl;
+  strm << "  EncryptedEssence: " << (Info.EncryptedEssence ? "Yes" : "No") << std::endl;
+
+  if ( Info.EncryptedEssence )
+    {
+      strm << "              HMAC: " << (Info.UsesHMAC ? "Yes" : "No") << std::endl;
+      strm << "         ContextID: " << UUID(Info.ContextID).EncodeHex(str_buf, 40) << std::endl;
+      strm << "CryptographicKeyID: " << UUID(Info.CryptographicKeyID).EncodeHex(str_buf, 40) << std::endl;
+    }
+
+  strm << "         AssetUUID: " << UUID(Info.AssetUUID).EncodeHex(str_buf, 40) << std::endl;
+  strm << "    Label Set Type: " << (Info.LabelSetType == LS_MXF_SMPTE ? "SMPTE" :
+                                    (Info.LabelSetType == LS_MXF_INTEROP ? "MXF Interop" :
+                                     "Unknown")) << std::endl;
+  return strm;
+}
+
 //
 void
 ASDCP::WriterInfoDump(const WriterInfo& Info, FILE* stream)
@@ -158,7 +186,7 @@ ASDCP::EssenceType(const char* filename, EssenceType_t& type)
        type = ESS_PCM_24b_48k;
       else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(MPEG2VideoDescriptor))) )
        type = ESS_MPEG2_VES;
-      else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(DCTimedTextDescriptor))) )
+      else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(TimedTextDescriptor))) )
        type = ESS_TIMED_TEXT;
     }
 
@@ -200,16 +228,27 @@ ASDCP::RawEssenceType(const char* filename, EssenceType_t& type)
          while ( p[i] == 0 ) i++;
 
          if ( i > 1 && p[i] == 1 &&  (p[i+1] == ASDCP::MPEG2::SEQ_START || p[i+1] == ASDCP::MPEG2::PIC_START) )
-           type = ESS_MPEG2_VES;
-
-         else if ( Kumu::StringIsXML((const char*)p, FB.Size()) )
-           type = ESS_TIMED_TEXT;
-
+           {
+             type = ESS_MPEG2_VES;
+           }
          else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(p, read_count, &data_offset)) )
-           type = ESS_PCM_24b_48k;
-
+           {
+             switch ( WavHeader.samplespersec )
+               {
+               case 48000: type = ESS_PCM_24b_48k; break;
+               case 96000: type = ESS_PCM_24b_96k; break;
+               default:
+                 return RESULT_FORMAT;
+               }
+           }
          else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(p, read_count, &data_offset)) )
-           type = ESS_PCM_24b_48k;
+           {
+             type = ESS_PCM_24b_48k;
+           }
+         else if ( Kumu::StringIsXML((const char*)p, FB.Size()) )
+           {
+             type = ESS_TIMED_TEXT;
+           }
        }
     }
   else if ( Kumu::PathIsDirectory(filename) )