version bump
[asdcplib.git] / src / PCM_Parser.cpp
index 2f96d2359047b6a6a9bd6173f47d85f1946b3aae..30e5d2884ece6122322b732d03a04284bfa88509 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2011, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@ using Kumu::DefaultLogSink;
 using namespace ASDCP;
 using namespace ASDCP::PCM;
 using namespace ASDCP::Wav;
+using namespace ASDCP::RF64;
 
 
 //------------------------------------------------------------------------------------------
@@ -47,8 +48,8 @@ class ASDCP::PCM::WAVParser::h__WAVParser
   Kumu::FileReader m_FileReader;
   bool             m_EOF;
   ui32_t           m_DataStart;
-  ui32_t           m_DataLength;
-  ui32_t           m_ReadCount;
+  ui64_t           m_DataLength;
+  ui64_t           m_ReadCount;
   ui32_t           m_FrameBufferSize;
   ui32_t           m_FramesRead;
   Rational         m_PictureRate;
@@ -68,7 +69,7 @@ public:
     Close();
    }
 
-  Result_t OpenRead(const char* filename, const Rational& PictureRate);
+  Result_t OpenRead(const std::string& filename, const Rational& PictureRate);
   void     Close();
   void     Reset();
   Result_t ReadFrame(FrameBuffer&);
@@ -93,10 +94,8 @@ ASDCP::PCM::WAVParser::h__WAVParser::Reset()
 
 //
 ASDCP::Result_t
-ASDCP::PCM::WAVParser::h__WAVParser::OpenRead(const char* filename, const Rational& PictureRate)
+ASDCP::PCM::WAVParser::h__WAVParser::OpenRead(const std::string& filename, const Rational& PictureRate)
 {
-  ASDCP_TEST_NULL_STR(filename);
-
   Result_t result = m_FileReader.OpenRead(filename);
 
   if ( ASDCP_SUCCESS(result) )
@@ -129,6 +128,22 @@ ASDCP::PCM::WAVParser::h__WAVParser::OpenRead(const char* filename, const Ration
              m_ADesc.ChannelFormat = PCM::CF_NONE;
              Reset();
            }
+      else
+        {
+          SimpleRF64Header RF64Header;
+          m_FileReader.Seek(0);
+          result = RF64Header.ReadFromFile(m_FileReader, &m_DataStart);
+
+          if ( ASDCP_SUCCESS(result) )
+            {
+                RF64Header.FillADesc(m_ADesc, PictureRate);
+                m_FrameBufferSize = ASDCP::PCM::CalcFrameBufferSize(m_ADesc);
+                m_DataLength = RF64Header.data_len;
+                m_ADesc.ContainerDuration = m_DataLength / m_FrameBufferSize;
+                m_ADesc.ChannelFormat = PCM::CF_NONE;
+                Reset();
+            }
+        }
        }
     }
 
@@ -186,7 +201,7 @@ ASDCP::PCM::WAVParser::~WAVParser()
 // Opens the stream for reading, parses enough data to provide a complete
 // set of stream metadata for the MXFWriter below.
 ASDCP::Result_t
-ASDCP::PCM::WAVParser::OpenRead(const char* filename, const Rational& PictureRate) const
+ASDCP::PCM::WAVParser::OpenRead(const std::string& filename, const Rational& PictureRate) const
 {
   const_cast<ASDCP::PCM::WAVParser*>(this)->m_Parser = new h__WAVParser;