Merge pull request #19 from radford-for-smpte/sign-language-video-label
[asdcplib.git] / src / AtmosSyncChannel_Mixer.cpp
index 70cfbfdc93260e43ba1e5b6d7fe19087801dfa3e..b0353414cbbc786e9480939fb4e4548fdbaae124 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2013-2013, John Hurst
+Copyright (c) 2013-2014, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -64,11 +64,14 @@ ASDCP::AtmosSyncChannelMixer::clear()
 Result_t
 ASDCP::AtmosSyncChannelMixer::OpenRead(ui32_t argc, const char** argv, const Rational& PictureRate)
 {
-  ASDCP_TEST_NULL_STR(argv);
+  ASDCP_TEST_NULL(argv);
   PathList_t TmpFileList;
 
   for ( ui32_t i = 0; i < argc; ++i )
-    TmpFileList.push_back(argv[i]);
+    {
+      ASDCP_TEST_NULL_STR(argv[i]);
+      TmpFileList.push_back(argv[i]);
+    }
 
   return OpenRead(TmpFileList, PictureRate);
 }
@@ -252,6 +255,45 @@ ASDCP::AtmosSyncChannelMixer::MixInAtmosSyncChannel()
   return result;
 }
 
+//
+Result_t
+ASDCP::AtmosSyncChannelMixer::AppendSilenceChannels(const ui32_t& channel_count)
+{
+  if ( m_ADesc.QuantizationBits == 0 )
+    {
+      DefaultLogSink().Error("Mixer object contains no channels, call OpenRead() first.\n");
+      return RESULT_PARAM;
+    }
+
+  Result_t result = RESULT_OK;
+  PCM::AudioDescriptor tmpDesc;
+
+  if ( channel_count > 0 )
+    {
+      Kumu::mem_ptr<SilenceDataProvider> I =
+       new SilenceDataProvider(channel_count,
+                               m_ADesc.QuantizationBits,
+                               m_ADesc.AudioSamplingRate.Numerator,
+                               m_ADesc.EditRate);
+
+      result = I->FillAudioDescriptor(tmpDesc);
+
+      if ( ASDCP_SUCCESS(result) )
+       {
+         m_ADesc.BlockAlign += tmpDesc.BlockAlign;
+         m_ChannelCount += tmpDesc.ChannelCount;
+         m_ADesc.ChannelCount = m_ChannelCount;
+         m_ADesc.AvgBps = (ui32_t)(ceil(m_ADesc.AudioSamplingRate.Quotient()) * m_ADesc.BlockAlign);
+
+         m_outputs.push_back(std::make_pair(channel_count, I.get()));
+         m_inputs.push_back(I);
+         I.release();
+       }
+    }
+
+  return result;
+}
+
 //
 Result_t
 ASDCP::AtmosSyncChannelMixer::FillAudioDescriptor(PCM::AudioDescriptor& ADesc) const