AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
ntv2dolbycapture.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #include "ntv2dolbycapture.h"
10 #include "ntv2devicescanner.h"
11 #include "ajabase/system/process.h"
12 #include <fstream> // for ofstream
13 
14 using namespace std;
15 
16 #define NTV2_BUFFER_LOCK
17 
18 #define NTV2_AUDIOSIZE_MAX (401 * 1024)
19 #define NTV2_ANCILLARYSIZE_MAX (256 * 1024)
20 
21 
23 
25  : mConsumerThread (AJAThread()),
26  mProducerThread (AJAThread()),
27  mDeviceID (DEVICE_ID_NOTFOUND),
28  mConfig (inConfig),
29  mVideoFormat (NTV2_FORMAT_UNKNOWN),
30  mSavedTaskMode (NTV2_DISABLE_TASKS),
31  mAudioSystem (NTV2_AUDIOSYSTEM_1),
32  mHostBuffers (),
33  mAVCircularBuffer (),
34  mGlobalQuit (false)
35 {
36 } // constructor
37 
38 
40 {
41  // Stop my capture and consumer threads, then destroy them...
42  Quit();
43 
44  // Unsubscribe from input vertical event...
46 
47 } // destructor
48 
49 
51 {
52  // Set the global 'quit' flag, and wait for the threads to go inactive...
53  mGlobalQuit = true;
54 
55  while (mConsumerThread.Active())
56  AJATime::Sleep(10);
57 
58  while (mProducerThread.Active())
59  AJATime::Sleep(10);
60 
61  // Restore some of the device's former state...
62  if (!mConfig.fDoMultiFormat)
63  {
65  mDevice.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
66  }
67 
68 } // Quit
69 
70 
72 {
74 
75  // Open the device...
77  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not found" << endl; return AJA_STATUS_OPEN;}
78 
79  if (!mDevice.IsDeviceReady(false))
80  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' not ready" << endl; return AJA_STATUS_INITIALIZE;}
81 
82  mDeviceID = mDevice.GetDeviceID(); // Keep the device ID handy, as it's used frequently
83  if (!mDevice.features().CanDoCapture())
84  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' is playback-only" << endl; return AJA_STATUS_FEATURE;}
85 
86  if (!mDevice.features().CanDoFrameBufferFormat(mConfig.fPixelFormat))
87  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' doesn't support '"
88  << ::NTV2FrameBufferFormatToString(mConfig.fPixelFormat, true) << "' ("
89  << ::NTV2FrameBufferFormatToString(mConfig.fPixelFormat, false) << ", " << DEC(mConfig.fPixelFormat) << ")" << endl;
91  }
92 
93  ULWord appSignature (0);
94  int32_t appPID (0);
95  mDevice.GetStreamingApplication (appSignature, appPID); // Who currently "owns" the device?
96  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current device state
97  if (!mConfig.fDoMultiFormat)
98  {
100  {
101  cerr << "## ERROR: Unable to acquire '" << mDevice.GetDisplayName() << "' because another app (pid " << appPID << ") owns it" << endl;
102  return AJA_STATUS_BUSY; // Another app is using the device
103  }
104  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current state before we change it
105  }
106  mDevice.SetEveryFrameServices(NTV2_OEM_TASKS); // Prevent interference from AJA retail services
107 
108  if (mDevice.features().CanDoMultiFormat())
109  mDevice.SetMultiFormatMode(mConfig.fDoMultiFormat);
110 
111  // This demo permits input source and channel to be specified independently.
113  mConfig.fInputChannel = NTV2_CHANNEL1;
118  // On KonaHDMI, map specified SDI input to equivalent HDMI input...
119  if (mDevice.features().GetNumHDMIVideoInputs() > 1 && NTV2_INPUT_SOURCE_IS_HDMI(mConfig.fInputSource))
121  if (!mDevice.features().CanDoInputSource(mConfig.fInputSource))
122  {
123  cerr << "## ERROR: No such input '" << ::NTV2InputSourceToString(mConfig.fInputSource, /*compact?*/true)
124  << "' on '" << mDevice.GetDisplayName() << "'" << endl;
125  return AJA_STATUS_UNSUPPORTED;
126  }
127  if (!mConfig.fAncDataFilePath.empty() && !mDevice.features().CanDoHDMIAuxCapture())
128  {cerr << "## ERROR: HDMI aux capture requested, but '" << mDevice.GetDisplayName() << "' has no HDMI aux extractors" << endl; return AJA_STATUS_UNSUPPORTED;}
129 
130  // Set up the video and audio...
131  status = SetupVideo();
132  if (AJA_FAILURE(status))
133  return status;
134 
135  status = SetupAudio();
136  if (AJA_FAILURE(status))
137  return status;
138 
139  // Set up the circular buffers, the device signal routing, and both playout and capture AutoCirculate...
141  if (!RouteInputSignal())
142  return AJA_STATUS_FAIL;
143 
144  mDolbyState = 0;
145 
146  #if defined(_DEBUG)
147  cerr << mConfig;
148  if (mDevice.IsRemote())
149  cerr << "Device Description: " << mDevice.GetDescription() << endl;
150  cerr << endl;
151  #endif // defined(_DEBUG)
152  return AJA_STATUS_SUCCESS;
153 
154 } // Init
155 
156 
158 {
159  // Sometimes other applications disable some or all of the frame buffers, so turn on ours now...
160  mDevice.EnableChannel(mConfig.fInputChannel);
161 
162  // Enable and subscribe to the interrupts for the channel to be used...
163  mDevice.EnableInputInterrupt(mConfig.fInputChannel);
165 
166  // Determine the input video signal format...
167  mVideoFormat = mDevice.GetInputVideoFormat(mConfig.fInputSource);
168  if (mVideoFormat == NTV2_FORMAT_UNKNOWN)
169  {cerr << "## ERROR: No input signal or unknown format" << endl; return AJA_STATUS_NOINPUT;}
170  if (!mDevice.features().CanDoVideoFormat(mVideoFormat))
171  {
172  cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' cannot handle " << ::NTV2VideoFormatToString(mVideoFormat) << endl;
173  return AJA_STATUS_UNSUPPORTED; // Device can't handle this format
174  }
175  CAPNOTE(::NTV2VideoFormatToString(mVideoFormat) << " detected on " << ::NTV2InputSourceToString(mConfig.fInputSource,true) << " on " << mDevice.GetDisplayName());
176  mFormatDesc = NTV2FormatDescriptor(mVideoFormat, mConfig.fPixelFormat);
177 
178  // Set the device video format to whatever we detected at the input...
179  if (NTV2_IS_4K_VIDEO_FORMAT(mVideoFormat))
180  {
182  mDevice.SetVideoFormat (mVideoFormat, false, false, NTV2_CHANNEL1);
183  mDevice.SetTsiFrameEnable(true, NTV2_CHANNEL1);
185  }
186  else
187  {
189  mDevice.SetVideoFormat (mVideoFormat, false, false, mConfig.fInputChannel);
190  mDevice.SetTsiFrameEnable(false, mConfig.fInputChannel);
191  mDevice.SetFrameBufferFormat (mConfig.fInputChannel, mConfig.fPixelFormat);
192  }
193 
194  return AJA_STATUS_SUCCESS;
195 
196 } // SetupVideo
197 
198 
200 {
201  return AJA_STATUS_SUCCESS;
202 
203 } // SetupAudio
204 
205 
207 {
208  // Let my circular buffer know when it's time to quit...
209  mAVCircularBuffer.SetAbortFlag (&mGlobalQuit);
210 
211  bool isProgressive = NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(mVideoFormat);
212  if (isProgressive)
214  else
216 
217  ULWord F1AncSize(0), F2AncSize(0);
218  ULWord F1OffsetFromEnd(0), F2OffsetFromEnd(0);
219  mDevice.ReadRegister(kVRegAncField1Offset, F1OffsetFromEnd); // # bytes from end of 8MB/16MB frame
220  mDevice.ReadRegister(kVRegAncField2Offset, F2OffsetFromEnd); // # bytes from end of 8MB/16MB frame
221  // Based on the offsets, calculate the max anc capacity
222  F1AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? 0 : F1OffsetFromEnd - F2OffsetFromEnd;
223  F2AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? F2OffsetFromEnd - F1OffsetFromEnd : F2OffsetFromEnd;
224 
225  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
226  const size_t audioBufferSize (NTV2_AUDIOSIZE_MAX);
227  mHostBuffers.reserve(size_t(CIRCULAR_BUFFER_SIZE));
228  while (mHostBuffers.size() < size_t(CIRCULAR_BUFFER_SIZE))
229  {
230  mHostBuffers.push_back(NTV2FrameData());
231  NTV2FrameData & frameData(mHostBuffers.back());
232  frameData.fVideoBuffer.Allocate(mFormatDesc.GetVideoWriteSize());
233  frameData.fAudioBuffer.Allocate(audioBufferSize);
234  frameData.fAncBuffer.Allocate(F1AncSize);
235  frameData.fAncBuffer2.Allocate(F2AncSize);
236  mAVCircularBuffer.Add(&frameData);
237 
238 #ifdef NTV2_BUFFER_LOCK
239  // Page lock the memory
240  if (frameData.fVideoBuffer)
241  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
242  if (frameData.fAncBuffer)
243  mDevice.DMABufferLock(frameData.fAncBuffer, true);
244  if (frameData.fAncBuffer2)
245  mDevice.DMABufferLock(frameData.fAncBuffer2, true);
246 #endif
247  } // for each NTV2FrameData
248 
249 } // SetupHostBuffers
250 
251 
253 {
254 
257  mDevice.GetHDMIInputColor (inputColorSpace, mConfig.fInputChannel);
258 
259  const bool isInputRGB (inputColorSpace == NTV2_LHIHDMIColorSpaceRGB);
260  NTV2XptConnections connections;
261 
262  return CNTV2DemoCommon::GetInputRouting (connections, mConfig, isInputRGB)
263  && mDevice.ApplySignalRoute(connections, !mConfig.fDoMultiFormat);
264 
265 } // RouteInputSignal
266 
267 
269 {
270  // Start the playout and capture threads...
273  return AJA_STATUS_SUCCESS;
274 
275 } // Run
276 
277 
279 
280 // This is where we will start the consumer thread
282 {
283  // Create and start the consumer thread...
284  mConsumerThread.Attach(ConsumerThreadStatic, this);
285  mConsumerThread.SetPriority(AJA_ThreadPriority_High);
286  mConsumerThread.Start();
287 
288 } // StartConsumerThread
289 
290 
291 // The consumer thread function
292 void NTV2DolbyCapture::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
293 {
294  (void) pThread;
295 
296  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
297  // then call its ConsumeFrames method...
298  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture *> (pContext));
299  pApp->ConsumeFrames();
300 
301 } // ConsumerThreadStatic
302 
303 
305 {
306  CAPNOTE("Thread started");
307  uint64_t ancTally(0);
308  uint64_t audioTally(0);
309  uint64_t dolbyTally(0);
310  ofstream * pOFS(mConfig.fAncDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fAncDataFilePath.c_str(), ios::binary));
311  ofstream * pAFS(mConfig.fAudioDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fAudioDataFilePath.c_str(), ios::binary));
312  ofstream * pDFS(mConfig.fDolbyDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fDolbyDataFilePath.c_str(), ios::binary));
313  while (!mGlobalQuit)
314  {
315  // Wait for the next frame to become ready to "consume"...
316  NTV2FrameData * pFrameData (mAVCircularBuffer.StartConsumeNextBuffer ());
317  if (pFrameData)
318  {
319  // Do something useful with the frame data...
320  // . . . . . . . . . . . .
321  // . . . . . . . . . . . .
322  // . . . . . . . . . . . .
323  if (mConfig.fDoFrameStats && pFrameData->AncBuffer())
324  {
325  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer().GetHostAddress(0);
326  uint32_t i;
327  for (i = 0; i < pFrameData->AncBufferSize(); i += 32)
328  {
329  if (pData[i] == 0xff)
330  break;
331  }
332  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->AncBufferSize() /*pFrameData->NumCapturedAncBytes()*/, pFrameData->AudioBuffer());
333  cout << "f1 size reg " << DEC(pFrameData->NumCapturedAncBytes()) << " ffs " << DEC(i) << " samples " << DEC(audioSize/4) << endl << flush;
334  }
335 
336  if (mConfig.fDoFrameStats && pFrameData->AncBuffer2())
337  {
338  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer2().GetHostAddress(0);
339  uint32_t i;
340  for (i = 0; i < pFrameData->AncBuffer2Size(); i += 32)
341  {
342  if (pData[i] == 0xff)
343  break;
344  }
345  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->AncBuffer2Size() /*pFrameData->NumCapturedAnc2Bytes()*/, pFrameData->AudioBuffer());
346  cout << "f2 size reg " << DEC(pFrameData->NumCapturedAnc2Bytes()) << " ffs " << DEC(i) << " samples " << DEC(audioSize/4) << endl << flush;
347  }
348 
349  if (pOFS && pFrameData->AncBuffer())
350  {
351  if (pOFS && !ancTally++)
352  CAPNOTE("Writing raw anc to '" + mConfig.fAncDataFilePath + "'");
353  pOFS->write(pFrameData->AncBuffer(), streamsize(pFrameData->NumCapturedAncBytes()));
354  ancTally++;
355  if ( pFrameData->AncBuffer2())
356  {
357  if (pOFS && pFrameData->AncBuffer2())
358  pOFS->write(pFrameData->AncBuffer2(), streamsize(pFrameData->NumCapturedAnc2Bytes()));
359  }
360  }
361 
362  if (pAFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
363  {
364  if (pAFS && !audioTally++)
365  CAPNOTE("Writing raw audio to '" + mConfig.fAudioDataFilePath + "'");
366  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
367  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
368  audioTally++;
369  if ( pFrameData->AncBuffer2())
370  {
371  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
372  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
373  }
374  }
375 
376  if (pDFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
377  {
378  if (pDFS && !dolbyTally++)
379  CAPNOTE("Writing dolby file to '" + mConfig.fDolbyDataFilePath + "'");
380  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
381  uint32_t dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer());
382  pDFS->write(pFrameData->AncBuffer(), streamsize(dolbySize));
383  dolbyTally++;
384  if ( pFrameData->AncBuffer2())
385  {
386  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
387  dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer2());
388  pDFS->write(pFrameData->AncBuffer2(), streamsize(dolbySize));
389  }
390  }
391  // Now release and recycle the buffer...
392  mAVCircularBuffer.EndConsumeNextBuffer ();
393  } // if pFrameData
394  } // loop til quit signaled
395  if (pOFS)
396  { delete pOFS; cerr << "Wrote " << DEC(ancTally) << " frames of raw anc data" << endl; }
397  if (pAFS)
398  { delete pAFS; cerr << "Wrote " << DEC(audioTally) << " frames of raw audio data" << endl; }
399  if (pDFS)
400  { delete pDFS; cerr << "Wrote " << DEC(dolbyTally) << " frames of dolby data" << endl; }
401  CAPNOTE("Thread completed, will exit");
402 
403 } // ConsumeFrames
404 
405 
407 
408 // This starts the capture (producer) thread
410 {
411  // Create and start the capture thread...
412  mProducerThread.Attach(ProducerThreadStatic, this);
413  mProducerThread.SetPriority(AJA_ThreadPriority_High);
414  mProducerThread.Start();
415 
416 } // StartProducerThread
417 
418 
419 // The capture thread function
420 void NTV2DolbyCapture::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
421 {
422  (void) pThread;
423 
424  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
425  // then call its CaptureFrames method...
426  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture*>(pContext));
427  pApp->CaptureFrames ();
428 
429 } // ProducerThreadStatic
430 
431 
433 {
434  AUTOCIRCULATE_TRANSFER inputXfer; // AutoCirculate input transfer info
435  ULWord acOptions (0), overruns(0);
436  UWord hdmiSpigot (UWord(::NTV2InputSourceToChannel(mConfig.fInputSource)));
437  acOptions |= AUTOCIRCULATE_WITH_ANC;
438  acOptions |= AUTOCIRCULATE_WITH_HDMIAUX;
439 
440  CAPNOTE("Thread started");
441  // Initialize and start capture AutoCirculate...
442  mDevice.AutoCirculateStop(mConfig.fInputChannel); // Just in case
443  if (!mDevice.AutoCirculateInitForInput (mConfig.fInputChannel, // primary channel
444  mConfig.fFrames.count(), // numFrames (zero if specifying range)
445  mAudioSystem, // audio system (if any)
446  acOptions, // AutoCirculate options
447  1, // numChannels to gang
448  mConfig.fFrames.firstFrame(), mConfig.fFrames.lastFrame()))
449  mGlobalQuit = true;
450 
451  // The user can opt to INCLUDE only Audio Packets
452  // AuxExtractGetDefaultPacketFilters() retrieves Audio Packet filters DIDs
453  if (mConfig.fDoAudioFilter)
454  {
455  mDevice.AuxExtractSetFilterInclusionMode(hdmiSpigot, /*include?*/true);
456  mDevice.AuxExtractSetPacketFilters(hdmiSpigot, mDevice.AuxExtractGetDefaultPacketFilters());
457  }
458  else
459  { //Otherwise, exclude only 00 Values (excludes nothing / shows all)
460  mDevice.AuxExtractSetFilterInclusionMode(hdmiSpigot,/*include?*/false);
461  NTV2DIDSet zeroSet;
462  zeroSet.insert(0);
463  mDevice.AuxExtractSetPacketFilters(hdmiSpigot, zeroSet);
464  }
465 
466  if (!mGlobalQuit && !mDevice.AutoCirculateStart(mConfig.fInputChannel))
467  mGlobalQuit = true;
468 
469  // Ingest frames til Quit signaled...
470  while (!mGlobalQuit)
471  {
472  AUTOCIRCULATE_STATUS acStatus;
473  mDevice.AutoCirculateGetStatus (mConfig.fInputChannel, acStatus);
474 
475  if (acStatus.IsRunning() && acStatus.HasAvailableInputFrame())
476  {
477  // At this point, there's at least one fully-formed frame available in the device's
478  // frame buffer to transfer to the host. Reserve an NTV2FrameData to "produce", and
479  // use it in the next transfer from the device...
480  NTV2FrameData * pFrameData(mAVCircularBuffer.StartProduceNextBuffer());
481  if (!pFrameData)
482  continue;
483 
484  NTV2FrameData & frameData (*pFrameData);
485  inputXfer.SetVideoBuffer (frameData.VideoBuffer(), frameData.VideoBufferSize());
486  if (acStatus.WithCustomAnc())
487  inputXfer.SetAncBuffers (frameData.AncBuffer(), frameData.AncBufferSize(),
488  frameData.AncBuffer2(), frameData.AncBuffer2Size());
489 
490  // Transfer video/audio/anc from the device into our host buffers...
491  mDevice.AutoCirculateTransfer (mConfig.fInputChannel, inputXfer);
492 
493  // If capturing Anc, clear stale anc data from the anc buffers...
494  if (acStatus.WithCustomAnc() && frameData.AncBuffer())
495  { bool overrun(false);
496  mDevice.AuxExtractGetBufferOverrun (hdmiSpigot, overrun);
497  if (overrun)
498  {overruns++; CAPWARN(overruns << " aux overrun(s)");}
499  frameData.fNumAncBytes = inputXfer.GetCapturedAncByteCount(/*isF2*/false);
500  NTV2Buffer stale (frameData.fAncBuffer.GetHostAddress(frameData.fNumAncBytes),
501  frameData.fAncBuffer.GetByteCount() - frameData.fNumAncBytes);
502  stale.Fill(uint8_t(0));
503  }
504  if (acStatus.WithCustomAnc() && frameData.AncBuffer2())
505  {
506  frameData.fNumAnc2Bytes = inputXfer.GetCapturedAncByteCount(/*isF2*/true);
507  NTV2Buffer stale (frameData.fAncBuffer2.GetHostAddress(frameData.fNumAnc2Bytes),
508  frameData.fAncBuffer2.GetByteCount() - frameData.fNumAnc2Bytes);
509  stale.Fill(uint8_t(0));
510  }
511 
512  // Signal that we're done "producing" the frame, making it available for future "consumption"...
513  mAVCircularBuffer.EndProduceNextBuffer();
514  } // if A/C running and frame(s) are available for transfer
515  else
516  {
517  // Either AutoCirculate is not running, or there were no frames available on the device to transfer.
518  // Rather than waste CPU cycles spinning, waiting until a frame becomes available, it's far more
519  // efficient to wait for the next input vertical interrupt event to get signaled...
521  }
522 
523  } // loop til quit signaled
524 
525  // Stop AutoCirculate...
526  mDevice.AutoCirculateStop(mConfig.fInputChannel);
527  CAPNOTE("Thread completed, will exit");
528 
529 } // CaptureFrames
530 
531 
532 void NTV2DolbyCapture::GetACStatus (ULWord & outGoodFrames, ULWord & outDroppedFrames, ULWord & outBufferLevel)
533 {
534  AUTOCIRCULATE_STATUS status;
535  mDevice.AutoCirculateGetStatus(mConfig.fInputChannel, status);
536  outGoodFrames = status.GetProcessedFrameCount();
537  outDroppedFrames = status.GetDroppedFrameCount();
538  outBufferLevel = status.GetBufferLevel();
539 }
540 
541 uint32_t NTV2DolbyCapture::RecoverAudio (const NTV2Buffer & inAncBuffer, const uint32_t ancSize, NTV2Buffer & outAudioBuffer)
542 {
543  const uint8_t * pInAncData(inAncBuffer);
544  uint8_t * pOutAudioData(outAudioBuffer);
545  uint32_t audioSize(0);
546 
547  // Extract first 16-bit stereo pair from the aux data
548  for (uint32_t num(0); num < ancSize / 32; num++)
549  {
550  // Audio data aux packet?
551  if (pInAncData[0] == 0x02)
552  {
553  // First sample present?
554  if ((pInAncData[1] & 0x01))
555  {
556  // First sample flat?
557  if ((pInAncData[2] & 0x01))
558  {
559  *pOutAudioData++ = 0;
560  *pOutAudioData++ = 0;
561  *pOutAudioData++ = 0;
562  *pOutAudioData++ = 0;
563  }
564  else
565  {
566  *pOutAudioData++ = pInAncData[4];
567  *pOutAudioData++ = pInAncData[5];
568  *pOutAudioData++ = pInAncData[7];
569  *pOutAudioData++ = pInAncData[8];
570  }
571  audioSize += 4;
572  } // if first sample present
573 
574  // Only 2 channels?
575  if ((pInAncData[1] & 0x10) == 0)
576  {
577  // Second sample present?
578  if ((pInAncData[1] & 0x02))
579  {
580  // Second sample flat?
581  if ((pInAncData[2] & 0x02))
582  {
583  *pOutAudioData++ = 0;
584  *pOutAudioData++ = 0;
585  *pOutAudioData++ = 0;
586  *pOutAudioData++ = 0;
587  }
588  else
589  {
590  *pOutAudioData++ = pInAncData[11];
591  *pOutAudioData++ = pInAncData[12];
592  *pOutAudioData++ = pInAncData[14];
593  *pOutAudioData++ = pInAncData[15];
594  }
595  audioSize += 4;
596  }
597 
598  // Third sample present?
599  if ((pInAncData[1] & 0x04))
600  {
601  // Third sample flat?
602  if ((pInAncData[2] & 0x04))
603  {
604  *pOutAudioData++ = 0;
605  *pOutAudioData++ = 0;
606  *pOutAudioData++ = 0;
607  *pOutAudioData++ = 0;
608  }
609  else
610  {
611  *pOutAudioData++ = pInAncData[18];
612  *pOutAudioData++ = pInAncData[19];
613  *pOutAudioData++ = pInAncData[21];
614  *pOutAudioData++ = pInAncData[22];
615  }
616  audioSize += 4;
617  }
618 
619  // Fourth sample present?
620  if ((pInAncData[1] & 0x08))
621  {
622  // Fourth sample flat?
623  if ((pInAncData[2] & 0x08))
624  {
625  *pOutAudioData++ = 0;
626  *pOutAudioData++ = 0;
627  *pOutAudioData++ = 0;
628  *pOutAudioData++ = 0;
629  }
630  else
631  {
632  *pOutAudioData++ = pInAncData[25];
633  *pOutAudioData++ = pInAncData[26];
634  *pOutAudioData++ = pInAncData[28];
635  *pOutAudioData++ = pInAncData[29];
636  }
637  audioSize += 4;
638  } // if 4th sample present
639  } // if only 2 channels
640  } // if audio data aux packet
641  pInAncData += 32;
642  } // for loop
643  return audioSize;
644 } // RecoverAudio
645 
646 uint32_t NTV2DolbyCapture::RecoverDolby (const NTV2Buffer & inAudioBuffer, const uint32_t inAudioSize, NTV2Buffer & outDolbyBuffer)
647 {
648  const uint16_t * pInAudioData(inAudioBuffer);
649  uint16_t * pOutDolbyData(outDolbyBuffer);
650  uint32_t dolbySize(0);
651 
652  // Extract the dolby frames from the IEC61937 bursts...
653  for (uint32_t cnt(0); cnt < inAudioSize / 2; cnt++)
654  {
655  switch (mDolbyState)
656  {
657  // Find IEC61937 burst preamble
658  case 0: mDolbyState = (*pInAudioData == 0xf872) ? 1 : 0;
659  break;
660 
661  case 1: mDolbyState = (*pInAudioData == 0x4e1f) ? 2 : 0;
662  break;
663 
664  // Check dolby code
665  case 2: mDolbyState = ((*pInAudioData & 0xff) == 0x15) ? 3 : 0;
666  break;
667 
668  // Get burst length
669  case 3: mDolbyLength = uint32_t(*pInAudioData / 2);
670  mDolbyState = 4;
671  break;
672 
673  // Copy dolby samples
674  case 4: if (mDolbyLength)
675  {
676  if (dolbySize < outDolbyBuffer.GetByteCount() / 2)
677  {
678  // Endian swap the data...
679  *pOutDolbyData = (*pInAudioData >> 8) & 0xff;
680  *pOutDolbyData |= (*pInAudioData & 0xff) << 8;
681  pOutDolbyData++;
682  dolbySize++;
683  mDolbyLength--;
684  }
685  }
686  else
687  mDolbyState = 0;
688  break;
689 
690  default: mDolbyState = 0;
691  break;
692  } // switch
693  pInAudioData++;
694  } // for loop
695  return dolbySize * 2;
696 }
697 
698 
700 
701 
702 AJALabelValuePairs DolbyCaptureConfig::Get (const bool inCompact) const
703 {
704  AJALabelValuePairs result(CaptureConfig::Get(inCompact));
705  AJASystemInfo::append(result, "Audio Capture File", fAudioDataFilePath.empty() ? "---" : fAudioDataFilePath);
706  AJASystemInfo::append(result, "Dolby Capture File", fDolbyDataFilePath.empty() ? "---" : fDolbyDataFilePath);
707  return result;
708 }
709 
710 
711 std::ostream & operator << (std::ostream & ioStrm, const DolbyCaptureConfig & inObj)
712 {
713  ioStrm << AJASystemInfo::ToString(inObj.Get());
714  return ioStrm;
715 }
NTV2FrameData::NumCapturedAnc2Bytes
ULWord NumCapturedAnc2Bytes(void) const
Definition: ntv2democommon.h:119
CaptureConfig::fDoMultiFormat
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode.
Definition: ntv2democommon.h:276
DolbyCaptureConfig::fDolbyDataFilePath
std::string fDolbyDataFilePath
Optional path to Dolby binary data file.
Definition: ntv2dolbycapture.h:23
NTV2InputSourceToReferenceSource
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5081
CNTV2Card::SetMultiFormatMode
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
Definition: ntv2register.cpp:4379
NTV2DolbyCapture::ProducerThreadStatic
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the capture thread's static callback function that gets called when the capture thread runs....
Definition: ntv2dolbycapture.cpp:420
NTV2ChannelToInputSource
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5190
ntv2dolbycapture.h
Declares the NTV2DolbyCapture class.
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5105
DeviceCapabilities::CanDoVideoFormat
bool CanDoVideoFormat(const NTV2VideoFormat inVF)
Definition: ntv2devicecapabilities.h:251
DolbyCaptureConfig::fDoAudioFilter
bool fDoAudioFilter
If true, capture only audio anc.
Definition: ntv2dolbycapture.h:24
NTV2FormatDescriptor::GetVideoWriteSize
ULWord GetVideoWriteSize(ULWord inPageSize=4096UL) const
Definition: ntv2formatdescriptor.cpp:862
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
NTV2DolbyCapture::NTV2DolbyCapture
NTV2DolbyCapture(const DolbyCaptureConfig &inConfig)
Constructs me using the given settings.
Definition: ntv2dolbycapture.cpp:24
NTV2ACFrameRange::firstFrame
UWord firstFrame(void) const
Definition: ntv2utils.h:975
CNTV2Card::SetVideoFormat
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=(!(0)), const bool inKeepVancSettings=(0), const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
Definition: ntv2register.cpp:204
NTV2_ANCILLARYSIZE_MAX
#define NTV2_ANCILLARYSIZE_MAX
Definition: ntv2dolbycapture.cpp:19
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3597
CNTV2MacDriverInterface::ReadRegister
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device....
Definition: ntv2macdriverinterface.cpp:389
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
DolbyCaptureConfig
This class is used to configure an NTV2Capture instance.
Definition: ntv2dolbycapture.h:19
NTV2FrameData
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos....
Definition: ntv2democommon.h:79
NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE
#define NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(__f__)
Definition: ntv2enums.h:1008
NTV2FrameData::fNumAncBytes
ULWord fNumAncBytes
Actual number of captured F1 anc bytes.
Definition: ntv2democommon.h:89
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:5993
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition: types.h:381
NTV2DolbyCapture::GetACStatus
virtual void GetACStatus(ULWord &outGoodFrames, ULWord &outDroppedFrames, ULWord &outBufferLevel)
Provides status information about my input (capture) process.
Definition: ntv2dolbycapture.cpp:532
NTV2DolbyCapture::RouteInputSignal
virtual bool RouteInputSignal(void)
Sets up device routing for capture.
Definition: ntv2dolbycapture.cpp:252
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6066
CNTV2Card::AuxExtractSetFilterInclusionMode
virtual bool AuxExtractSetFilterInclusionMode(const UWord inHDMIInput, const bool inEnable)
Enables or disables HDMI AUX packet filtering for the given HDMI input.
Definition: ntv2aux.cpp:912
NTV2DolbyCapture::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2dolbycapture.cpp:71
AJAThread::Attach
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: thread.cpp:169
CNTV2Card::WaitForInputVerticalInterrupt
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
Definition: ntv2subscriptions.cpp:149
CNTV2Card::EnableInputInterrupt
virtual bool EnableInputInterrupt(const NTV2Channel channel=NTV2_CHANNEL1)
Allows the CNTV2Card instance to wait for and respond to input vertical blanking interrupts originati...
Definition: ntv2interrupts.cpp:23
NTV2FrameData::AncBuffer2
NTV2Buffer & AncBuffer2(void)
Definition: ntv2democommon.h:117
CNTV2DemoCommon::GetInputRouting
static bool GetInputRouting(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given capture configuration.
Definition: ntv2democommon.cpp:1199
AJA_STATUS_BUSY
@ AJA_STATUS_BUSY
Definition: types.h:391
NTV2DolbyCapture::CaptureFrames
virtual void CaptureFrames(void)
Repeatedly captures frames using AutoCirculate (until global quit flag set).
Definition: ntv2dolbycapture.cpp:432
CNTV2DeviceScanner::GetFirstDeviceFromArgument
static bool GetFirstDeviceFromArgument(const std::string &inArgument, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device that matches a command li...
Definition: ntv2devicescanner.cpp:366
AUTOCIRCULATE_STATUS::GetProcessedFrameCount
ULWord GetProcessedFrameCount(void) const
Definition: ntv2publicinterface.h:7216
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3816
AJACircularBuffer::StartConsumeNextBuffer
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function to ...
Definition: circularbuffer.h:153
CaptureConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
Pixel format to use.
Definition: ntv2democommon.h:273
NTV2DolbyCapture::~NTV2DolbyCapture
virtual ~NTV2DolbyCapture()
Definition: ntv2dolbycapture.cpp:39
CNTV2Card::AncSetFrameBufferSize
virtual bool AncSetFrameBufferSize(const ULWord inF1Size, const ULWord inF2Size)
Sets the capacity of the SDI ANC or HDMI AUX buffers in device frame memory. (Call NTV2DeviceCanDoCus...
Definition: ntv2anc.cpp:123
NTV2ACFrameRange::count
UWord count(void) const
Definition: ntv2utils.h:974
AUTOCIRCULATE_STATUS::GetBufferLevel
ULWord GetBufferLevel(void) const
Definition: ntv2publicinterface.h:7221
CNTV2Card::AutoCirculateInitForInput
virtual bool AutoCirculateInitForInput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate ingest, designating a contiguous block of frame buffers on the ...
Definition: ntv2autocirculate.cpp:221
NTV2_AUDIOSIZE_MAX
#define NTV2_AUDIOSIZE_MAX
Definition: ntv2dolbycapture.cpp:18
CNTV2MacDriverInterface::ReleaseStreamForApplication
virtual bool ReleaseStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Releases exclusive use of the AJA device for the given process, permitting other processes to acquire...
Definition: ntv2macdriverinterface.cpp:516
NTV2_IOKINDS_HDMI
@ NTV2_IOKINDS_HDMI
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1252
NTV2FrameData::fAncBuffer2
NTV2Buffer fAncBuffer2
Additional "F2" host anc buffer.
Definition: ntv2democommon.h:86
AJACircularBuffer::EndProduceNextBuffer
void EndProduceNextBuffer(void)
The producer thread calls this function to signal that it has finished populating the frame it obtain...
Definition: circularbuffer.h:259
CaptureConfig::fAncDataFilePath
std::string fAncDataFilePath
Optional path to Anc binary data file.
Definition: ntv2democommon.h:269
NTV2Buffer::Allocate
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...
Definition: ntv2publicinterface.cpp:1630
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3600
CNTV2Card::ApplySignalRoute
virtual bool ApplySignalRoute(const CNTV2SignalRouter &inRouter, const bool inReplace=(0))
Applies the given routing table to the AJA device.
Definition: ntv2regroute.cpp:242
AUTOCIRCULATE_TRANSFER::SetAncBuffers
bool SetAncBuffers(ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my ancillary data buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2724
CaptureConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2democommon.cpp:1664
NTV2FrameData::fAncBuffer
NTV2Buffer fAncBuffer
Host ancillary data buffer.
Definition: ntv2democommon.h:85
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=(!(0)), NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1812
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
NTV2DolbyCapture::SetupHostBuffers
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Definition: ntv2dolbycapture.cpp:206
NTV2DolbyCapture::SetupVideo
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
Definition: ntv2dolbycapture.cpp:157
NTV2FrameData::VideoBuffer
NTV2Buffer & VideoBuffer(void)
Definition: ntv2democommon.h:106
NTV2_IS_4K_VIDEO_FORMAT
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:746
kVRegAncField2Offset
@ kVRegAncField2Offset
Anc Field2 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP)
Definition: ntv2virtualregisters.h:336
CNTV2Card::DMABufferLock
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=(0), bool inRDMA=(0))
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
Definition: ntv2dma.cpp:429
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:141
AJAThread
Definition: thread.h:69
AUTOCIRCULATE_WITH_ANC
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
Definition: ntv2publicinterface.h:5527
NTV2FrameData::NumCapturedAncBytes
ULWord NumCapturedAncBytes(void) const
Definition: ntv2democommon.h:115
AJAThread::Active
virtual bool Active()
Definition: thread.cpp:116
DolbyCaptureConfig::fAudioDataFilePath
std::string fAudioDataFilePath
Optional path to Audio binary data file.
Definition: ntv2dolbycapture.h:22
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:86
AJA_STATUS_NOINPUT
@ AJA_STATUS_NOINPUT
Definition: types.h:400
AJAStatus
AJAStatus
Definition: types.h:378
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7215
process.h
Declares the AJAProcess class.
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
AJACircularBuffer::Add
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
Definition: circularbuffer.h:92
NTV2DolbyCapture::ConsumerThreadStatic
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread runs...
Definition: ntv2dolbycapture.cpp:292
AJA_STATUS_FEATURE
@ AJA_STATUS_FEATURE
Definition: types.h:393
AJA_STATUS_FAIL
@ AJA_STATUS_FAIL
Definition: types.h:382
ULWord
uint32_t ULWord
Definition: ajatypes.h:253
DolbyCaptureConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2dolbycapture.cpp:702
AJASystemInfo::append
static AJALabelValuePairs & append(AJALabelValuePairs &inOutTable, const std::string &inLabel, const std::string &inValue=std::string())
A convenience function that appends the given label and value strings to the provided AJALabelValuePa...
Definition: info.h:168
CNTV2Card::GetDescription
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:124
NTV2FrameData::fVideoBuffer
NTV2Buffer fVideoBuffer
Host video buffer.
Definition: ntv2democommon.h:82
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7160
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2FrameData::VideoBufferSize
ULWord VideoBufferSize(void) const
Definition: ntv2democommon.h:107
kVRegAncField1Offset
@ kVRegAncField1Offset
Anc Field1 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP)
Definition: ntv2virtualregisters.h:335
CNTV2MacDriverInterface::GetStreamingApplication
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outProcessID)
Answers with the four-CC type and process ID of the application that currently "owns" the AJA device ...
Definition: ntv2macdriverinterface.cpp:651
NTV2DolbyCapture::RecoverAudio
virtual uint32_t RecoverAudio(const NTV2Buffer &inAncBuffer, const uint32_t inAncSize, NTV2Buffer &outAudioBuffer)
Recover audio from ancillary data.
Definition: ntv2dolbycapture.cpp:541
CNTV2Card::UnsubscribeInputVerticalEvent
virtual bool UnsubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Unregisters me so I'm no longer notified when an input VBI is signaled on the given input channel.
Definition: ntv2subscriptions.cpp:75
AJASystemInfo::ToString
virtual void ToString(std::string &outAllLabelsAndValues) const
Answers with a multi-line string that contains the complete host system info table.
AJAProcess::GetPid
static uint64_t GetPid()
Definition: process.cpp:35
NTV2FrameData::AncBufferSize
ULWord AncBufferSize(void) const
Definition: ntv2democommon.h:114
AUTOCIRCULATE_TRANSFER::GetCapturedAncByteCount
ULWord GetCapturedAncByteCount(const bool inField2=false) const
Definition: ntv2publicinterface.h:8346
NTV2DolbyCapture::StartConsumerThread
virtual void StartConsumerThread(void)
Starts my frame consumer thread.
Definition: ntv2dolbycapture.cpp:281
UWord
uint16_t UWord
Definition: ajatypes.h:251
AJACircularBuffer::StartProduceNextBuffer
FrameDataPtr StartProduceNextBuffer(void)
The thread that's responsible for providing frames – the producer – calls this function to populate t...
Definition: circularbuffer.h:109
CNTV2Card::AutoCirculateGetStatus
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
Definition: ntv2autocirculate.cpp:646
NTV2FrameData::AncBuffer2Size
ULWord AncBuffer2Size(void) const
Definition: ntv2democommon.h:118
NTV2_IS_VALID_INPUT_SOURCE
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1243
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:7969
CaptureConfig::fDeviceSpec
std::string fDeviceSpec
The AJA device to use.
Definition: ntv2democommon.h:268
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
NTV2DolbyCapture::SetupAudio
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
Definition: ntv2dolbycapture.cpp:199
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1240
NTV2FrameData::AudioBuffer
NTV2Buffer & AudioBuffer(void)
Definition: ntv2democommon.h:109
AUTOCIRCULATE_TRANSFER::SetVideoBuffer
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2708
CNTV2Card::AuxExtractSetPacketFilters
virtual bool AuxExtractSetPacketFilters(const UWord inHDMIInput, const NTV2DIDSet &inDIDs)
Replaces the HDMI packet types to be excluded (filtered) by the given HDMI input's Aux extractor.
Definition: ntv2aux.cpp:886
CNTV2Card::AuxExtractGetBufferOverrun
virtual bool AuxExtractGetBufferOverrun(const UWord inHDMIInput, bool &outIsOverrun, const UWord inField=0)
Answers whether or not the given HDMI input's Aux extractor reached its buffer limits.
Definition: ntv2aux.cpp:982
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1284
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
DeviceCapabilities::CanDoInputSource
bool CanDoInputSource(const NTV2InputSource inSrc)
Definition: ntv2devicecapabilities.h:233
AJACircularBuffer::EndConsumeNextBuffer
void EndConsumeNextBuffer(void)
The consumer thread calls this function to signal that it has finished processing the frame it obtain...
Definition: circularbuffer.h:266
NTV2DolbyCapture::StartProducerThread
virtual void StartProducerThread(void)
Starts my capture thread.
Definition: ntv2dolbycapture.cpp:409
CNTV2Card::SetTsiFrameEnable
virtual bool SetTsiFrameEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 two-sample interleave (Tsi) frame mode on the device.
Definition: ntv2register.cpp:1311
NTV2_INPUTSOURCE_HDMI1
@ NTV2_INPUTSOURCE_HDMI1
Identifies the 1st HDMI video input.
Definition: ntv2enums.h:1224
CNTV2Card::GetInputVideoFormat
virtual NTV2VideoFormat GetInputVideoFormat(const NTV2InputSource inVideoSource=NTV2_INPUTSOURCE_SDI1, const bool inIsProgressive=(0))
Returns the video format of the signal that is present on the given input source.
Definition: ntv2register.cpp:3365
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
AJA_STATUS_UNSUPPORTED
@ AJA_STATUS_UNSUPPORTED
Definition: types.h:394
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:197
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1319
CaptureConfig::fFrames
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
Definition: ntv2democommon.h:272
NTV2_DISABLE_TASKS
@ NTV2_DISABLE_TASKS
0: Disabled: Device is completely configured by controlling application(s) – no driver involvement.
Definition: ntv2publicinterface.h:4290
CaptureConfig::fInputChannel
NTV2Channel fInputChannel
The device channel to use.
Definition: ntv2democommon.h:270
NTV2Buffer::GetHostAddress
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
Definition: ntv2publicinterface.cpp:1686
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
NTV2FrameData::fAudioBuffer
NTV2Buffer fAudioBuffer
Host audio buffer.
Definition: ntv2democommon.h:84
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition: types.h:386
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3599
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5605
false
#define false
Definition: ntv2devicefeatures.h:25
CAPWARN
#define CAPWARN(_expr_)
Definition: ntv2democommon.h:29
NTV2ACFrameRange::lastFrame
UWord lastFrame(void) const
Definition: ntv2utils.h:976
AUTOCIRCULATE_STATUS::IsRunning
bool IsRunning(void) const
Definition: ntv2publicinterface.h:7266
NTV2FrameBufferFormatToString
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6940
DolbyCaptureConfig::fDoFrameStats
bool fDoFrameStats
if true, output per frame statistics
Definition: ntv2dolbycapture.h:25
NTV2DolbyCapture::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2dolbycapture.cpp:268
NTV2XptConnections
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
Definition: ntv2signalrouter.h:39
std
Definition: json.hpp:5362
AUTOCIRCULATE_WITH_HDMIAUX
#define AUTOCIRCULATE_WITH_HDMIAUX
Use this to AutoCirculate with HDMI auxiliary data.
Definition: ntv2publicinterface.h:5530
CNTV2Card::AutoCirculateTransfer
virtual bool AutoCirculateTransfer(const NTV2Channel inChannel, AUTOCIRCULATE_TRANSFER &transferInfo)
Transfers all or part of a frame as specified in the given AUTOCIRCULATE_TRANSFER object to/from the ...
Definition: ntv2autocirculate.cpp:695
AUTOCIRCULATE_STATUS::GetDroppedFrameCount
ULWord GetDroppedFrameCount(void) const
Definition: ntv2publicinterface.h:7211
NTV2FrameData::fNumAnc2Bytes
ULWord fNumAnc2Bytes
Actual number of captured F2 anc bytes.
Definition: ntv2democommon.h:90
CNTV2Card::GetHDMIInputColor
virtual bool GetHDMIInputColor(NTV2LHIHDMIColorSpace &outValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Answers with the current colorspace for the given HDMI input.
Definition: ntv2hdmi.cpp:52
CIRCULAR_BUFFER_SIZE
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData's in our ring.
CNTV2MacDriverInterface::AcquireStreamForApplication
virtual bool AcquireStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Reserves exclusive use of the AJA device for a given process, preventing other processes on the host ...
Definition: ntv2macdriverinterface.cpp:481
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:381
AUTOCIRCULATE_STATUS::HasAvailableInputFrame
bool HasAvailableInputFrame(void) const
Definition: ntv2publicinterface.h:7236
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
NTV2DolbyCapture::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2dolbycapture.cpp:50
AUTOCIRCULATE_STATUS::WithCustomAnc
bool WithCustomAnc(void) const
Definition: ntv2publicinterface.h:7301
AJACircularBuffer::SetAbortFlag
void SetAbortFlag(const bool *pAbortFlag)
Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any th...
Definition: circularbuffer.h:51
NTV2Buffer::Fill
bool Fill(const T &inValue)
Fills me with the given scalar value.
Definition: ntv2publicinterface.h:6218
AJAThread::SetPriority
virtual AJAStatus SetPriority(AJAThreadPriority priority)
Definition: thread.cpp:133
CNTV2Card::AutoCirculateStart
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
Definition: ntv2autocirculate.cpp:503
CNTV2Card::SetReference
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=(0))
Sets the device's clock reference source. See Video Output Clocking & Synchronization for more inform...
Definition: ntv2register.cpp:1484
AJA_STATUS_OPEN
@ AJA_STATUS_OPEN
Definition: types.h:388
NTV2DolbyCapture
I capture HDMI Dolby audio from an HDMI input of an AJA device.
Definition: ntv2dolbycapture.h:45
operator<<
std::ostream & operator<<(std::ostream &ioStrm, const DolbyCaptureConfig &inObj)
Definition: ntv2dolbycapture.cpp:711
AJAThread::Start
virtual AJAStatus Start()
Definition: thread.cpp:91
NTV2DIDSet
std::set< UByte > NTV2DIDSet
A set of distinct NTV2DID values.
Definition: ntv2publicinterface.h:76
CNTV2Card::AuxExtractGetDefaultPacketFilters
static NTV2DIDSet AuxExtractGetDefaultPacketFilters(void)
Definition: ntv2aux.cpp:1034
AJALabelValuePairs
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:69
CNTV2Card::SubscribeInputVerticalEvent
virtual bool SubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Causes me to be notified when an input vertical blanking interrupt occurs on the given input channel.
Definition: ntv2subscriptions.cpp:39
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:371
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2097
DeviceCapabilities::CanDoFrameBufferFormat
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
Definition: ntv2devicecapabilities.h:223
NTV2FrameData::AncBuffer
NTV2Buffer & AncBuffer(void)
Definition: ntv2democommon.h:113
NTV2DolbyCapture::RecoverDolby
virtual uint32_t RecoverDolby(const NTV2Buffer &inAudioBuffer, const uint32_t inAudioSize, NTV2Buffer &outDolbyBuffer)
Recover Dolby data from the given audio data.
Definition: ntv2dolbycapture.cpp:646
CNTV2Card::AutoCirculateStop
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=(0))
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Definition: ntv2autocirculate.cpp:519
DEVICE_ID_NOTFOUND
@ DEVICE_ID_NOTFOUND
Invalid or "not found".
Definition: ntv2enums.h:90
CaptureConfig::fInputSource
NTV2InputSource fInputSource
The device input connector to use.
Definition: ntv2democommon.h:271
CAPNOTE
#define CAPNOTE(_expr_)
Definition: ntv2democommon.h:31
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM: Device is configured by controlling application(s), with minimal driver involvement.
Definition: ntv2publicinterface.h:4292
NTV2DolbyCapture::ConsumeFrames
virtual void ConsumeFrames(void)
Repeatedly consumes frames from the circular buffer (until global quit flag set).
Definition: ntv2dolbycapture.cpp:304