AJA NTV2 SDK  18.1.0.2262
NTV2 SDK 18.1.0.2262
ntv2democommon.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #ifndef _NTV2DEMOCOMMON_H
10 #define _NTV2DEMOCOMMON_H
11 
12 #include "ntv2rp188.h"
13 #include "ntv2publicinterface.h"
14 #include "ntv2card.h"
15 #include "ntv2utils.h" // for NTV2ACFrameRange
20 #include "ajabase/system/debug.h"
21 #include "ajabase/system/info.h"
22 #include "ajabase/system/systemtime.h" // for AJATime
23 #include "ajabase/common/common.h" // for aja::strip & etc.
24 #include <algorithm>
25 #include <string>
26 
27 // Convenience macros for EZ logging:
28 #define CAPFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
29 #define CAPWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
30 #define CAPDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
31 #define CAPNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
32 #define CAPINFO(_expr_) AJA_sINFO (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
33 
34 #define PLFAIL(_xpr_) AJA_sERROR (AJA_DebugUnit_DemoPlayout, AJAFUNC << ": " << _xpr_)
35 #define PLWARN(_xpr_) AJA_sWARNING(AJA_DebugUnit_DemoPlayout, AJAFUNC << ": " << _xpr_)
36 #define PLNOTE(_xpr_) AJA_sNOTICE (AJA_DebugUnit_DemoPlayout, AJAFUNC << ": " << _xpr_)
37 #define PLINFO(_xpr_) AJA_sINFO (AJA_DebugUnit_DemoPlayout, AJAFUNC << ": " << _xpr_)
38 #define PLDBG(_xpr_) AJA_sDEBUG (AJA_DebugUnit_DemoPlayout, AJAFUNC << ": " << _xpr_)
39 
40 #define BURNFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
41 #define BURNWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
42 #define BURNDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
43 #define BURNNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
44 #define BURNINFO(_expr_) AJA_sINFO (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
45 
46 #define NTV2_AUDIOSIZE_MAX (401 * 1024)
47 #define NTV2_ANCSIZE_MAX (0x2000) // 8K
48 
49 
55 typedef struct
56 {
57  uint32_t * fVideoBuffer;
58  uint32_t * fVideoBuffer2;
59  uint32_t fVideoBufferSize;
60  uint32_t * fAudioBuffer;
61  uint32_t fAudioBufferSize;
62  uint32_t * fAncBuffer;
63  uint32_t fAncBufferSize;
64  uint32_t * fAncF2Buffer;
65  uint32_t fAncF2BufferSize;
66  uint32_t fAudioRecordSize;
67  uint32_t fAncRecordSize;
71  uint32_t fFrameFlags;
72 } AVDataBuffer;
73 
74 
80 {
81  public:
91  uint32_t fFrameFlags;
92  uint64_t fTimeStampAud;
93  uint64_t fTimeStampOS;
94  uint64_t fUserData;
95  public:
96  explicit inline NTV2FrameData()
97  : fVideoBuffer (0),
98  fVideoBuffer2 (0),
99  fAudioBuffer (0),
100  fAncBuffer (0),
101  fAncBuffer2 (0),
102  fTimecodes (),
103  fNumAudioBytes (0),
104  fNumAncBytes (0),
105  fNumAnc2Bytes (0),
106  fFrameFlags (0),
107  fTimeStampAud (0),
108  fTimeStampOS (0),
109  fUserData (0) {}
110 
111  // Inquiry Methods
112  inline NTV2Buffer & VideoBuffer (void) {return fVideoBuffer;}
113  inline ULWord VideoBufferSize (void) const {return ULWord(fVideoBuffer.GetByteCount());}
114 
115  inline NTV2Buffer & AudioBuffer (void) {return fAudioBuffer;}
116  inline ULWord AudioBufferSize (void) const {return ULWord(fAudioBuffer.GetByteCount());}
117  inline ULWord NumCapturedAudioBytes (void) const {return fNumAudioBytes;}
118  inline bool HasAudioSamples (void) const {return NumCapturedAudioBytes() && AudioBufferSize();}
119 
120  inline NTV2Buffer & AncBuffer (void) {return fAncBuffer;}
121  inline ULWord AncBufferSize (void) const {return ULWord(fAncBuffer.GetByteCount());}
122  inline ULWord NumCapturedAncBytes (void) const {return fNumAncBytes;}
123  inline bool HasF1Anc (void) const {return NumCapturedAncBytes() && AncBufferSize();}
124 
125  inline NTV2Buffer & AncBuffer2 (void) {return fAncBuffer2;}
126  inline ULWord AncBuffer2Size (void) const {return ULWord(fAncBuffer2.GetByteCount());}
127  inline ULWord NumCapturedAnc2Bytes (void) const {return fNumAnc2Bytes;}
128  inline bool HasF2Anc (void) const {return NumCapturedAnc2Bytes() && AncBuffer2Size();}
129 
130  inline NTV2Buffer & VideoBuffer2 (void) {return fVideoBuffer2;}
131  inline ULWord VideoBufferSize2 (void) const {return ULWord(fVideoBuffer2.GetByteCount());}
132 
133  inline bool IsNULL (void) const {return fVideoBuffer.IsNULL() && fVideoBuffer2.IsNULL()
134  && fAudioBuffer.IsNULL() && fAncBuffer.IsNULL()
135  && fAncBuffer2.IsNULL();}
136  inline bool HasTimecode (const NTV2TCIndex inTCNdx) const {return fTimecodes.find(inTCNdx) != fTimecodes.end();}
137  NTV2_RP188 Timecode (const NTV2TCIndex inTCNdx) const;
138  inline bool HasValidTimecode (const NTV2TCIndex inTCNdx) const {return Timecode(inTCNdx).IsValid();}
139  inline bool HasTimeStamp (void) const {return fTimeStampAud && fTimeStampOS;}
140  inline uint64_t TimeStamp (const bool useAudioClock = true) const {return useAudioClock ? fTimeStampAud : fTimeStampOS;}
141  inline uint64_t UserData (void) const {return fUserData;}
142  inline NTV2FrameData & SetUserData (const uint64_t val) {fUserData = val; return *this;}
143 
144  // Modifier Methods
145  inline void ZeroBuffers (void) { if (fVideoBuffer)
146  fVideoBuffer.Fill(ULWord(0));
147  if (fVideoBuffer2)
148  fVideoBuffer2.Fill(ULWord(0));
149  if (fAudioBuffer)
150  fAudioBuffer.Fill(ULWord(0));
151  if (fAncBuffer)
152  fAncBuffer.Fill(ULWord(0));
153  if (fAncBuffer2)
154  fAncBuffer2.Fill(ULWord(0));
155  fNumAudioBytes = fNumAncBytes = fNumAnc2Bytes = 0;
156  }
157  bool LockAll (CNTV2Card & inDevice);
158  bool UnlockAll (CNTV2Card & inDevice);
159 
160  inline bool Reset (void) {return fVideoBuffer.Allocate(0) && fVideoBuffer2.Allocate(0)
161  && fAudioBuffer.Allocate(0) && fAncBuffer.Allocate(0)
162  && fAncBuffer2.Allocate(0);}
163  bool SetCapturedFrameInfo (const AUTOCIRCULATE_TRANSFER & inXferInfo, const AUTOCIRCULATE_STATUS & acStatus);
164 }; // NTV2FrameData
165 
166 typedef std::vector<NTV2FrameData> NTV2FrameDataArray;
167 typedef NTV2FrameDataArray::iterator NTV2FrameDataArrayIter;
168 typedef NTV2FrameDataArray::const_iterator NTV2FrameDataArrayConstIter;
170 
171 
172 
173 static const size_t CIRCULAR_BUFFER_SIZE (10);
174 static const ULWord kDemoAppSignature NTV2_FOURCC('D','E','M','O');
175 
176 
181 template <typename T> class Bouncer
182 {
183  public:
184  inline Bouncer (const T inUpperLimit, const T inLowerLimit = T(0), const T inStartValue = T(0), const bool inStartAscend = true)
185  : mMin (inLowerLimit),
186  mMax (inUpperLimit),
187  mValue (inStartValue),
188  mIncrement (T(1)),
189  mAscend (inStartAscend)
190  {
191  if (mMin > mMax)
192  std::swap (mMin, mMax);
193  else if (mMin == mMax)
194  mMax = mMin + mIncrement;
195  if (mValue < mMin)
196  {
197  mValue = mMin;
198  mAscend = true;
199  }
200  if (mValue > mMax)
201  {
202  mValue = mMax;
203  mAscend = false;
204  }
205  }
206 
207  inline T Next (void)
208  {
209  if (mAscend)
210  {
211  if (mValue < mMax)
212  mValue += mIncrement;
213  else
214  mAscend = false;
215  }
216  else
217  {
218  if (mValue > mMin)
219  mValue -= mIncrement;
220  else
221  mAscend = true;
222  }
223  return mValue;
224  }
225 
226  inline void SetIncrement (const T inValue) {mIncrement = inValue;}
227  inline T Value (void) const {return mValue;}
228 
229  private:
230  T mMin, mMax, mValue, mIncrement;
231  bool mAscend;
232 
233 }; // Bouncer
234 
235 
237 {
244 #if !defined(NTV2_DEPRECATE_17_5)
245  // Deprecated old ones:
251 #endif // !defined(NTV2_DEPRECATE_17_5)
253 
255 
256 
258 {
268 
270 
271 
272 typedef enum _NTV2TCIndexKinds
273 {
283 
284 
289 {
290  public:
291  std::string fDeviceSpec;
292  std::string fAncDataFilePath;
300  bool fWithAnc;
301  bool fWithAudio;
303 
307  inline explicit CaptureConfig (const std::string & inDeviceSpec = "0")
308  : fDeviceSpec (inDeviceSpec),
309  fAncDataFilePath (),
310  fInputChannel (NTV2_CHANNEL_INVALID),
311  fInputSource (NTV2_INPUTSOURCE_INVALID),
312  fFrames (7),
313  fPixelFormat (NTV2_FBF_8BIT_YCBCR),
314  fNumAudioLinks (1),
315  fDoABConversion (false),
316  fDoMultiFormat (false),
317  fWithAnc (false),
318  fWithAudio (true),
319  fDoTSIRouting (true)
320  {
321  }
322 
323  AJALabelValuePairs Get (const bool inCompact = false) const;
324 
325 }; // CaptureConfig
326 
327 AJAExport std::ostream & operator << (std::ostream & ioStrm, const CaptureConfig & inObj);
328 
329 
333 typedef struct PlayerConfig
334 {
335  public:
336  std::string fDeviceSpec;
337  std::string fAncDataFilePath;
354 
358  inline explicit PlayerConfig (const std::string & inDeviceSpecifier = "0")
359  : fDeviceSpec (inDeviceSpecifier),
360  fAncDataFilePath (),
363  fFrames (7),
367  fNumAudioLinks (1),
377  {
378  }
379 
380  inline bool WithAudio(void) const {return !fSuppressAudio && fNumAudioLinks > 0;}
381  inline bool WithVideo(void) const {return !fSuppressVideo;}
382 
388  AJALabelValuePairs Get (const bool inCompact = false) const;
389 
390 } PlayerConfig;
391 
392 AJAExport std::ostream & operator << (std::ostream & ioStrm, const PlayerConfig & inObj);
393 
397 typedef struct BurnConfig
398 {
399  public:
400  std::string fDeviceSpec;
401  std::string fDeviceSpec2;
414  bool fWithAnc;
416  bool fWithHanc;
417  bool fVerbose;
418 
422  inline explicit BurnConfig (const std::string & inDeviceSpecifier = "0")
423  : fDeviceSpec (inDeviceSpecifier),
424  fDeviceSpec2 (),
429  fInputFrames (7),
430  fOutputFrames (7),
437  fWithAnc (false),
439  fWithHanc (false),
440  fVerbose (false)
441  {
442  }
443 
444  inline bool WithAudio(void) const {return !fSuppressAudio;}
445  inline bool WithVideo(void) const {return !fSuppressVideo;}
446  inline bool WithAnc(void) const {return fWithAnc;}
447  inline bool WithTallVANC(void) const {return fWithTallFrames;}
448  inline bool WithHanc(void) const {return fWithHanc;}
449  inline bool WithTimecode(void) const {return NTV2_IS_VALID_TIMECODE_INDEX(fTimecodeSource);}
450  inline bool FieldMode(void) const {return fIsFieldMode;}
451  inline bool OutputSpecified(void) const {return NTV2_IS_VALID_OUTPUT_DEST(fOutputDest);}
452  inline bool IsVerbose(void) const {return fVerbose;}
453  inline std::string ISrcStr(void) const {return ::NTV2InputSourceToString(fInputSource, true);}
455  inline bool ISrcIsSDI(void) const {return NTV2_INPUT_SOURCE_IS_SDI(fInputSource);}
456  inline std::string ODstStr(void) const {return ::NTV2OutputDestinationToString(fOutputDest, true);}
458  inline std::string IChStr(void) const {std::ostringstream oss; oss << "Ch" << int(fInputChannel); return oss.str();}
459  inline std::string OChStr(void) const {std::ostringstream oss; oss << "Ch" << int(fOutputChannel); return oss.str();}
460  inline bool ODstIsSDI(void) const {return NTV2_OUTPUT_DEST_IS_SDI(fOutputDest);}
461 
467  AJALabelValuePairs Get (const bool inCompact = false) const;
468 
469 } BurnConfig;
470 
477 inline std::ostream & operator << (std::ostream & strm, const BurnConfig & inObj) {return strm << AJASystemInfo::ToString(inObj.Get());}
478 
479 
480 
487 {
488  public:
492 
497  static NTV2VideoFormatSet GetSupportedVideoFormats (const NTV2VideoFormatKinds inKinds = VIDEO_FORMATS_SDHD);
498 
507  static std::string GetVideoFormatStrings (const NTV2VideoFormatKinds inKinds = VIDEO_FORMATS_SDHD,
508  const std::string inDevSpec = std::string());
509 
519  static NTV2VideoFormat GetVideoFormatFromString (const std::string & inStr,
521  const std::string & inDevSpec = std::string());
522 
528  static bool Get4KInputFormat (NTV2VideoFormat & inOutVideoFormat);
529 
535  static bool Get8KInputFormat (NTV2VideoFormat & inOutVideoFormat);
537 
541 
546  static NTV2PixelFormats GetSupportedPixelFormats (const NTV2PixelFormatKinds inKinds = PIXEL_FORMATS_ALL);
547 
556  static std::string GetPixelFormatStrings (const NTV2PixelFormatKinds inKinds = PIXEL_FORMATS_ALL,
557  const std::string inDevSpec = std::string());
558 
567  static NTV2PixelFormat GetPixelFormatFromString (const std::string & inStr,
568  const NTV2PixelFormatKinds inKinds = PIXEL_FORMATS_ALL,
569  const std::string inDevSpec = std::string());
570 
575  static AJA_PixelFormat GetAJAPixelFormat (const NTV2PixelFormat inFormat);
577 
581 
586  static const NTV2InputSourceSet GetSupportedInputSources (const NTV2IOKinds inKinds = NTV2_IOKINDS_ALL);
587 
596  static std::string GetInputSourceStrings (const NTV2IOKinds inKinds = NTV2_IOKINDS_ALL,
597  const std::string inDevSpec = std::string ());
598 
607  static NTV2InputSource GetInputSourceFromString (const std::string & inStr,
608  const NTV2IOKinds inKinds = NTV2_IOKINDS_ALL,
609  const std::string inDevSpec = std::string());
611 
615 
620  static const NTV2OutputDestinations GetSupportedOutputDestinations (const NTV2IOKinds inKinds);
621 
631  static std::string GetOutputDestinationStrings (const NTV2IOKinds inKinds, const std::string inDevSpec = std::string ());
632 
641  static NTV2OutputDestination GetOutputDestinationFromString (const std::string & inStr,
642  const NTV2IOKinds inKinds = NTV2_IOKINDS_ALL,
643  const std::string inDevSpec = std::string());
645 
649 
654  static const NTV2TCIndexes GetSupportedTCIndexes (const NTV2TCIndexKinds inKinds);
655 
668  static std::string GetTCIndexStrings (const NTV2TCIndexKinds inKinds = TC_INDEXES_ALL,
669  const std::string inDeviceSpecifier = std::string(),
670  const bool inIsInputOnly = true);
671 
679  static NTV2TCIndex GetTCIndexFromString (const std::string & inStr,
680  const NTV2TCIndexKinds inKinds = TC_INDEXES_ALL,
681  const std::string inDevSpec = std::string());
683 
687 
695  static std::string GetAudioSystemStrings (const std::string inDeviceSpecifier = std::string ());
696 
702  static NTV2AudioSystem GetAudioSystemFromString (const std::string & inStr);
704 
708 
714  static std::string GetTestPatternStrings (void);
715 
720  static std::string GetTestPatternNameFromString (const std::string & inStr);
722 
726 
732  static std::string GetVANCModeStrings (void);
733 
738  static NTV2VANCMode GetVANCModeFromString (const std::string & inStr);
740 
744 
751  static bool GetInputRouting (NTV2XptConnections & outConnections,
752  const CaptureConfig & inConfig,
753  const bool isInputRGB = false);
754 
762  static bool GetInputRouting4K ( NTV2XptConnections & outConnections,
763  const CaptureConfig & inConfig,
764  const NTV2DeviceID inDevID = DEVICE_ID_INVALID,
765  const bool isInputRGB = false);
766 
775  static bool GetInputRouting8K ( NTV2XptConnections & outConnections,
776  const CaptureConfig & inConfig,
777  const NTV2VideoFormat inVidFormat,
778  const NTV2DeviceID inDevID = DEVICE_ID_INVALID,
779  const bool isInputRGB = false);
781 
785 
792  static std::string ToLower (const std::string & inStr);
793 
799  static std::string StripFormatString (const std::string & inStr);
800 
805  static char ReadCharacterPress (void);
806 
810  static void WaitForEnterKeyPress (void);
811 
816  static TimecodeFormat NTV2FrameRate2TimecodeFormat(const NTV2FrameRate inFrameRate);
817 
822  static AJA_FrameRate GetAJAFrameRate (const NTV2FrameRate inFrameRate);
823 
827  static const char * GetGlobalMutexName (void);
828 
835  static NTV2ChannelList GetTSIMuxesForFrameStore (CNTV2Card & inDevice, const NTV2Channel in1stFrameStore, const UWord inCount);
836 
844  static bool ConfigureAudioSystems (CNTV2Card & inDevice, const CaptureConfig & inConfig, const NTV2AudioSystemSet inAudioSystems);
845 
846  static size_t SetDefaultPageSize (void);
848 
850 
851  typedef struct poptOption PoptOpts;
853  {
854  public:
855  Popt (const int inArgc, const char ** pArgs, const PoptOpts * pInOptionsTable);
856  virtual ~Popt();
857  virtual inline int parseResult(void) const {return mResult;}
858  virtual inline bool isGood (void) const {return parseResult() == -1;}
859  virtual inline operator bool() const {return isGood();}
860  virtual inline const std::string & errorStr (void) const {return mError;}
861  virtual inline const NTV2StringList & otherArgs (void) const {return mOtherArgs;}
862  private:
863  poptContext mContext;
864  int mResult;
865  std::string mError;
866  NTV2StringList mOtherArgs;
867  };
868 
869  static bool BFT(void);
870  static bool NTV2_DEPRECATED_18_1(IsValidDevice (const std::string & spec));
871 
872 }; // CNTV2DemoCommon
873 
874 
875 // These AJA_NTV2_AUDIO_RECORD* macros can, if enabled, record audio samples into a file in the current directory.
876 // Optionally used in the CNTV2Capture demo.
877 #if defined(AJA_RAW_AUDIO_RECORD)
878  #include "ntv2debug.h" // For NTV2DeviceString
879  #include <fstream> // For ofstream
880  // To open the raw audio file in Audacity -- see http://audacity.sourceforge.net/ ...
881  // 1) Choose File => Import => Raw Data...
882  // 2) Select "Signed 32 bit PCM", Little/No/Default Endian, "16 Channels" (or 8 if applicable), "48000" sample rate.
883  // 3) Click "Import"
884  #define AJA_NTV2_AUDIO_RECORD_BEGIN ostringstream _filename; \
885  _filename << ::NTV2DeviceString(mDeviceID) << "-" << mDevice.GetIndexNumber() \
886  << "." << ::NTV2ChannelToString(mConfig.fInputChannel,true) \
887  << "." << ::NTV2InputSourceToString(mConfig.fInputSource, true) \
888  << "." << ::NTV2VideoFormatToString(mVideoFormat) \
889  << "." << ::NTV2AudioSystemToString(mAudioSystem, true) \
890  << "." << AJAProcess::GetPid() \
891  << ".raw"; \
892  ofstream _ostrm(_filename.str(), ios::binary);
893 
894  #define AJA_NTV2_AUDIO_RECORD_DO if (NTV2_IS_VALID_AUDIO_SYSTEM(mAudioSystem)) \
895  if (pFrameData->fAudioBuffer) \
896  _ostrm.write(pFrameData->AudioBuffer(), \
897  streamsize(pFrameData->NumCapturedAudioBytes()));
898 
899  #define AJA_NTV2_AUDIO_RECORD_END
900 #elif defined(AJA_WAV_AUDIO_RECORD)
901  #include "ntv2debug.h" // For NTV2DeviceString
902  #include "ajabase/common/wavewriter.h" // For AJAWavWriter
903  #define AJA_NTV2_AUDIO_RECORD_BEGIN ostringstream _wavfilename; \
904  _wavfilename << ::NTV2DeviceString(mDeviceID) << "-" << mDevice.GetIndexNumber() \
905  << "." << ::NTV2ChannelToString(mConfig.fInputChannel,true) \
906  << "." << ::NTV2InputSourceToString(mConfig.fInputSource, true) \
907  << "." << ::NTV2VideoFormatToString(mVideoFormat) \
908  << "." << ::NTV2AudioSystemToString(mAudioSystem, true) \
909  << "." << AJAProcess::GetPid() \
910  << ".wav"; \
911  const int _wavMaxNumAudChls(mDevice.features().GetMaxAudioChannels()); \
912  AJAWavWriter _wavWriter (_wavfilename.str(), \
913  AJAWavWriterAudioFormat(_wavMaxNumAudChls, 48000, 32)); \
914  _wavWriter.open();
915 
916  #define AJA_NTV2_AUDIO_RECORD_DO if (NTV2_IS_VALID_AUDIO_SYSTEM(mAudioSystem)) \
917  if (pFrameData->fAudioBuffer) \
918  if (_wavWriter.IsOpen()) \
919  _wavWriter.write(pFrameData->AudioBuffer(), pFrameData->NumCapturedAudioBytes());
920 
921  #define AJA_NTV2_AUDIO_RECORD_END if (_wavWriter.IsOpen()) \
922  _wavWriter.close();
923 #else
924  #define AJA_NTV2_AUDIO_RECORD_BEGIN
925  #define AJA_NTV2_AUDIO_RECORD_DO
926  #define AJA_NTV2_AUDIO_RECORD_END
927 #endif
928 
929 // Optionally used in the CNTV2Capture4K demo.
930 #if defined(AJA_RECORD_MLAUDIO)
931  #include <fstream>
932  #define AJA_NTV2_MLAUDIO_RECORD_BEGIN ofstream ofs1, ofs2; \
933  if (mConfig.fNumAudioLinks > 1) \
934  { \
935  ofs1.open("temp1.raw", ios::out | ios::trunc | ios::binary); \
936  ofs2.open("temp2.raw", ios::out | ios::trunc | ios::binary); \
937  }
938 
939  #define AJA_NTV2_MLAUDIO_RECORD_DO if (mConfig.fNumAudioLinks > 1) \
940  { const ULWord halfBytes (pFrameData->NumCapturedAudioBytes() / 2); \
941  ofs1.write(pFrameData->AudioBuffer(), halfBytes); \
942  NTV2Buffer lastHalf (pFrameData->fAudioBuffer.GetHostAddress(halfBytes), halfBytes); \
943  ofs2.write(lastHalf, lastHalf.GetByteCount()); \
944  }
945 
946  #define AJA_NTV2_MLAUDIO_RECORD_END if (mConfig.fNumAudioLinks > 1) \
947  { \
948  ofs1.close(); \
949  ofs2.close(); \
950  }
951 #else
952  #define AJA_NTV2_MLAUDIO_RECORD_BEGIN
953  #define AJA_NTV2_MLAUDIO_RECORD_DO
954  #define AJA_NTV2_MLAUDIO_RECORD_END
955 #endif
956 
957 #endif // _NTV2DEMOCOMMON_H
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5050
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
enum _NTV2TCIndexKinds NTV2TCIndexKinds
The invalid video input.
Definition: ntv2enums.h:1279
bool fWithAnc
If true, capture & play anc data (LLBurn). Defaults to false.
T Next(void)
void ZeroBuffers(void)
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3898
std::set< NTV2TCIndex > NTV2TCIndexes
bool fSuppressAudio
If true, suppress audio; otherwise generate & xfer audio tone.
uint32_t fFrameFlags
Frame data flags.
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
std::string ODstStr(void) const
bool HasTimeStamp(void) const
bool IsNULL(void) const
AJA_PixelFormat
Definition: videotypes.h:121
bool IsNULL(void) const
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:221
ULWord AncBuffer2Size(void) const
ULWord NumCapturedAnc2Bytes(void) const
ULWord NumCapturedAncBytes(void) const
RP188_STRUCT fRP188Data2
For future use.
NTV2OutputDestination
Identifies a specific video output destination.
Definition: ntv2enums.h:1326
Declares the AJADebug class.
ULWord VideoBufferSize(void) const
NTV2VANCMode fVancMode
VANC mode to use.
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode...
std::set< NTV2InputSource > NTV2InputSourceSet
A set of distinct NTV2InputSource values.
uint32_t fFrameFlags
Frame data flags.
std::string NTV2OutputDestinationToString(const NTV2OutputDestination inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7065
ULWord AudioBufferSize(void) const
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
size_t GetByteCount(void) const
std::string IChStr(void) const
bool fDoLinkGrouping
If true, enables 6/12G output mode on IoX3/Kona5 (4K/8K)
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:71
bool HasF1Anc(void) const
bool fSuppressAudio
If true, suppress audio; otherwise include audio.
NTV2FrameDataArray::const_iterator NTV2FrameDataArrayConstIter
Handy const iterator.
struct BurnConfig BurnConfig
Configures an NTV2Burn or NTV2FieldBurn instance.
Declares the AJATime class.
bool fWithTallFrames
If true && fWithAnc, use "taller" VANC mode for anc. Defaults to false.
enum _NTV2PixelFormatKind NTV2PixelFormatKind
#define NTV2_FOURCC(_a_, _b_, _c_, _d_)
bool fWithAnc
If true, also capture Anc.
Specifies any/all input/output kinds.
Definition: ntv2enums.h:1297
#define NTV2_IS_VALID_OUTPUT_DEST(_dest_)
Definition: ntv2enums.h:1349
bool HasAudioSamples(void) const
PlayerConfig(const std::string &inDeviceSpecifier="0")
Constructs a default Player configuration.
NTV2FrameBufferFormatSet NTV2PixelFormats
#define NTV2_IS_VALID_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3987
ULWord fNumAudioBytes
Actual number of captured audio bytes.
bool fDoABConversion
If true, do level-A/B conversion; otherwise don&#39;t.
std::set< NTV2OutputDestination > NTV2OutputDestinations
A set of distinct NTV2OutputDestination values.
std::string fDeviceSpec
The AJA device to use.
#define false
bool WithTimecode(void) const
uint32_t ULWord
Definition: ajatypes.h:236
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1359
std::string fDeviceSpec2
Second AJA device to use (Burn4KQuadrant or BurnBoardToBoard only)
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
struct PlayerConfig PlayerConfig
Configures an NTV2Player instance.
uint8_t * fVideoBufferUnaligned
For future use.
uint32_t fAudioRecordSize
For future use.
bool fWithAudio
If true, also capture Audio.
NTV2ACFrameRange fOutputFrames
Playout frame count or range.
This struct replaces the old RP188_STRUCT.
std::ostream & operator<<(std::ostream &ioStrm, const CaptureConfig &inObj)
A handy class that makes it easy to "bounce" an unsigned integer value between a minimum and maximum ...
NTV2Channel fInputChannel
The device channel to use.
NTV2OutputDest fOutputDest
The device output connector to use (NTV2_OUTPUTDESTINATION_INVALID means unspecified) ...
NTV2Channel ISrcCh(void) const
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3954
bool Fill(const T &inValue)
Fills me with the given scalar value.
bool WithAudio(void) const
AutoCirculate Frame Range.
Definition: ntv2utils.h:970
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7042
NTV2PixelFormat fPixelFormat
The pixel format to use.
NTV2Channel NTV2OutputDestinationToChannel(const NTV2OutputDestination inOutputDest)
Converts a given NTV2OutputDestination to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5158
uint64_t TimeStamp(const bool useAudioClock=(!(0))) const
NTV2Channel fOutputChannel
The output channel to use.
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:414
#define true
bool fTransmitLTC
If true, embed LTC; otherwise embed VITC.
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
std::string fAncDataFilePath
Optional path to Anc binary data file.
UWord fNumAudioLinks
The number of audio systems to control for multi-link audio (4K/8K)
This class is used to configure an NTV2Capture instance.
bool WithTallVANC(void) const
ULWord AncBufferSize(void) const
bool fIsFieldMode
True if Field Mode, otherwise Frame Mode.
NTV2Buffer & AncBuffer2(void)
_NTV2VideoFormatKind
virtual const NTV2StringList & otherArgs(void) const
NTV2ACFrameRange ACFrameRange
#define NTV2_DEPRECATED_18_1(__f__)
Definition: ajatypes.h:591
Declares the CRP188 class. See SMPTE RP188 standard for details.
NTV2Buffer & AncBuffer(void)
bool WithHanc(void) const
NTV2PixelFormat fPixelFormat
The pixel format to use.
T Value(void) const
NTV2FrameData & SetUserData(const uint64_t val)
_NTV2PixelFormatKind
uint32_t * fAudioBuffer
Pointer to host audio buffer.
virtual const std::string & errorStr(void) const
bool FieldMode(void) const
virtual bool isGood(void) const
bool fDoABConversion
If true, do level-A/B conversion; otherwise don&#39;t.
ULWord NumCapturedAudioBytes(void) const
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
NTV2VideoFormat fVideoFormat
The video format to use.
bool HasTimecode(const NTV2TCIndex inTCNdx) const
bool Reset(void)
NTV2Buffer & VideoBuffer(void)
Configures an NTV2Burn or NTV2FieldBurn instance.
NTV2Buffer fAncBuffer
Host ancillary data buffer.
bool fDoRGBOnWire
If true, produce RGB on the wire; otherwise output YUV.
ULWord fNumAnc2Bytes
Actual number of captured F2 anc bytes.
bool ISrcIsSDI(void) const
This structure encapsulates the video, audio and anc buffers used in the AutoCirculate demos...
NTV2OutputDest fOutputDest
The desired output connector to use.
bool IsVerbose(void) const
ULWord NTV2PixelFormatKinds
bool HasValidTimecode(const NTV2TCIndex inTCNdx) const
UWord fNumAudioLinks
Number of audio links to capture.
NTV2Buffer fAncBuffer2
Additional "F2" host anc buffer.
std::string fDeviceSpec
The AJA device to use.
CaptureConfig(const std::string &inDeviceSpec="0")
Constructs a default NTV2Capture configuration.
#define NTV2_OUTPUT_DEST_IS_SDI(_dest_)
Definition: ntv2enums.h:1348
NTV2Buffer & VideoBuffer2(void)
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
std::map< NTV2TCIndex, NTV2_RP188 > NTV2TimeCodes
A mapping of NTV2TCIndex enum values to NTV2_RP188 structures.
bool fDoMultiFormat
If true, enable device-sharing; otherwise take exclusive control of device.
std::string OChStr(void) const
ULWord fNumAncBytes
Actual number of captured F1 anc bytes.
A set of common convenience functions used by the NTV2 Demonstration Applications. Most are used for converting a command line argument into NTV2VideoFormat, NTV2FrameBufferFormat, etc. types.
ULWord VideoBufferSize2(void) const
NTV2Buffer & AudioBuffer(void)
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1264
uint32_t * fVideoBuffer
Pointer to host video buffer.
bool HasF2Anc(void) const
std::vector< NTV2FrameData > NTV2FrameDataArray
A vector of NTV2FrameData elements.
virtual int parseResult(void) const
Declaration of AJACircularBuffer template class.
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
uint32_t fAudioBufferSize
Size of host audio buffer, in bytes.
Declares the AJAWavWriter class.
uint32_t * fVideoBuffer2
Pointer to an additional host video buffer, usually field 2.
NTV2InputSource fInputSource
The device input connector to use.
#define AJAExport
Definition: export.h:33
bool fDoTsiRouting
If true, enable TSI routing; otherwise route for square division (4K/8K)
bool WithAudio(void) const
NTV2Channel fOutputChannel
The device channel to use.
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData&#39;s in our ring.
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
Declares numerous NTV2 utility functions.
void swap(nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j1, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24538
Declares the AJASystemInfo class.
bool fDoMultiFormat
If true, enables device-sharing; otherwise takes exclusive control of the device. ...
AJACircularBuffer< NTV2FrameData * > FrameDataRingBuffer
Buffer ring of NTV2FrameData&#39;s.
bool fVerbose
If true, emit explanatory messages to stdout/stderr. Defaults to false.
uint32_t * fAncF2Buffer
Pointer to "Field 2" ANC buffer.
uint64_t fTimeStampOS
VBI timestamp (host OS clock)
uint32_t fAncF2BufferSize
Size of "Field 2" ANC buffer, in bytes.
bool WithAnc(void) const
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
NTV2ACFrameRange fInputFrames
Ingest frame count or range.
bool fSuppressVideo
If true, suppress video; otherwise include video.
uint16_t UWord
Definition: ajatypes.h:234
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1361
uint32_t fAncBufferSize
Size of ANC buffer, in bytes.
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3800
TimecodeFormat
Definition: ntv2rp188.h:22
NTV2PixelFormat fPixelFormat
Pixel format to use.
bool OutputSpecified(void) const
NTV2Channel ODstCh(void) const
NTV2Buffer fVideoBuffer2
Additional host video buffer, usually F2.
Declares the AJAAncillaryData class.
ULWord NTV2VideoFormatKinds
Declares the CNTV2Card class.
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos. I&#39;m a more modern version of the AVDataBuffer.
NTV2Buffer fVideoBuffer
Host video buffer.
uint64_t fUserData
User data (frame tag/id, for playback)
enum NTV2OutputDestination NTV2OutputDest
NTV2Channel fInputChannel
The input channel to use.
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
NTV2TCIndex fTimecodeSource
Timecode source to use.
Private include file for all ajabase sources.
Configures an NTV2Player instance.
std::vector< NTV2Channel > NTV2ChannelList
An ordered sequence of NTV2Channel values.
std::string ISrcStr(void) const
std::string fDeviceSpec
The AJA device to use.
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
_NTV2TCIndexKinds
std::vector< std::string > NTV2StringList
uint32_t fAncRecordSize
For future use.
uint32_t * fAncBuffer
Pointer to ANC buffer.
uint64_t fTimeStampAud
VBI timestamp (device audio clock)
enum _NTV2VideoFormatKind NTV2VideoFormatKind
bool fWithHanc
If true, capture & play HANC data, including audio (LLBurn). Defaults to false.
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1285
bool WithVideo(void) const
BurnConfig(const std::string &inDeviceSpecifier="0")
Constructs a default Player configuration.
uint32_t fVideoBufferSize
Size of host video buffer, in bytes.
Declares the enumeration constants used in the ajabase library.
Declares enums and structs used by all platform drivers and the SDK.
NTV2FrameDataArray::iterator NTV2FrameDataArrayIter
Handy non-const iterator.
uint64_t UserData(void) const
void SetIncrement(const T inValue)
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1271
AJA_FrameRate
Definition: videotypes.h:210
virtual void ToString(std::string &outAllLabelsAndValues) const
Answers with a multi-line string that contains the complete host system info table.
RP188_STRUCT fRP188Data
For future use.
NTV2TimeCodes fTimecodes
Map of TC indexes to NTV2_RP188 values.
NTV2Buffer fAudioBuffer
Host audio buffer.
SDI 1 embedded VITC.
Definition: ntv2enums.h:3957
bool fDoHDMIOutput
If true, enable HDMI output; otherwise, disable HDMI output.
bool fSuppressVideo
If true, suppress video; otherwise generate & xfer test patterns.
bool WithVideo(void) const
This identifies the mode in which there are no VANC lines in the frame buffer.
Definition: ntv2enums.h:3802
Bouncer(const T inUpperLimit, const T inLowerLimit=T(0), const T inStartValue=T(0), const bool inStartAscend=(!(0)))
Specifies channel or FrameStore 3 (or the 3rd item).
Definition: ntv2enums.h:1363
bool ODstIsSDI(void) const
ULWord NTV2IOKinds
Definition: ntv2enums.h:1312
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:225
bool fDoTSIRouting
If true, do TSI routing; otherwise squares.
std::string fAncDataFilePath
Optional path to Anc binary data file to playout.
NTV2InputSource fInputSource
The device input connector to use.