AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
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  if (!mDevice.features().CanDoInputSource(mConfig.fInputSource))
119  {
120  cerr << "## ERROR: No such input '" << ::NTV2InputSourceToString(mConfig.fInputSource, /*compact?*/true)
121  << "' on '" << mDevice.GetDisplayName() << "'" << endl;
122  return AJA_STATUS_UNSUPPORTED;
123  }
124  if (!mConfig.fAncDataFilePath.empty() && !mDevice.features().CanDoHDMIAuxCapture())
125  {cerr << "## ERROR: HDMI aux capture requested, but '" << mDevice.GetDisplayName() << "' has no HDMI aux extractors" << endl; return AJA_STATUS_UNSUPPORTED;}
126 
127  // Set up the video and audio...
128  status = SetupVideo();
129  if (AJA_FAILURE(status))
130  return status;
131 
132  status = SetupAudio();
133  if (AJA_FAILURE(status))
134  return status;
135 
136  // Set up the circular buffers, the device signal routing, and both playout and capture AutoCirculate...
138  if (!RouteInputSignal())
139  return AJA_STATUS_FAIL;
140 
141  mDolbyState = 0;
142 
143  #if defined(_DEBUG)
144  cerr << mConfig;
145  if (mDevice.IsRemote())
146  cerr << "Device Description: " << mDevice.GetDescription() << endl;
147  cerr << endl;
148  #endif // defined(_DEBUG)
149  return AJA_STATUS_SUCCESS;
150 
151 } // Init
152 
153 
155 {
156  // Sometimes other applications disable some or all of the frame buffers, so turn on ours now...
157  mDevice.EnableChannel(mConfig.fInputChannel);
158 
159  // Enable and subscribe to the interrupts for the channel to be used...
160  mDevice.EnableInputInterrupt(mConfig.fInputChannel);
162 
163  // Determine the input video signal format...
164  mVideoFormat = mDevice.GetInputVideoFormat(mConfig.fInputSource);
165  if (mVideoFormat == NTV2_FORMAT_UNKNOWN)
166  { cerr << "## ERROR: No input signal or unknown format on '" << ::NTV2InputSourceToString(mConfig.fInputSource, true)
167  << "'" << endl;
168  return AJA_STATUS_NOINPUT;
169  }
170  if (!mDevice.features().CanDoVideoFormat(mVideoFormat))
171  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' cannot handle " << ::NTV2VideoFormatToString(mVideoFormat) << endl;
172  return AJA_STATUS_UNSUPPORTED; // Device can't handle this format
173  }
174  CAPNOTE(::NTV2VideoFormatToString(mVideoFormat) << " detected on " << ::NTV2InputSourceToString(mConfig.fInputSource,true) << " on " << mDevice.GetDisplayName());
175  mFormatDesc = NTV2FormatDescriptor(mVideoFormat, mConfig.fPixelFormat);
176 
177  // Set the device video format to whatever we detected at the input...
178  if (NTV2_IS_4K_VIDEO_FORMAT(mVideoFormat))
179  {
181  mDevice.SetVideoFormat (mVideoFormat, false, false, NTV2_CHANNEL1);
182  mDevice.SetTsiFrameEnable(true, NTV2_CHANNEL1);
184  }
185  else
186  {
188  mDevice.SetVideoFormat (mVideoFormat, false, false, mConfig.fInputChannel);
189  mDevice.SetTsiFrameEnable(false, mConfig.fInputChannel);
190  mDevice.SetFrameBufferFormat (mConfig.fInputChannel, mConfig.fPixelFormat);
191  }
192  return AJA_STATUS_SUCCESS;
193 
194 } // SetupVideo
195 
196 
198 {
199  return AJA_STATUS_SUCCESS;
200 
201 } // SetupAudio
202 
203 
205 {
206  // Let my circular buffer know when it's time to quit...
207  mAVCircularBuffer.SetAbortFlag (&mGlobalQuit);
208 
209  bool isProgressive = NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(mVideoFormat);
210  if (isProgressive)
212  else
214 
215  ULWord F1AncSize(0), F2AncSize(0);
216  ULWord F1OffsetFromEnd(0), F2OffsetFromEnd(0);
217  mDevice.ReadRegister(kVRegAncField1Offset, F1OffsetFromEnd); // # bytes from end of 8MB/16MB frame
218  mDevice.ReadRegister(kVRegAncField2Offset, F2OffsetFromEnd); // # bytes from end of 8MB/16MB frame
219  // Based on the offsets, calculate the max anc capacity
220  F1AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? 0 : F1OffsetFromEnd - F2OffsetFromEnd;
221  F2AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? F2OffsetFromEnd - F1OffsetFromEnd : F2OffsetFromEnd;
222 
223  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
224  const size_t audioBufferSize (NTV2_AUDIOSIZE_MAX);
225  mHostBuffers.reserve(size_t(CIRCULAR_BUFFER_SIZE));
226  while (mHostBuffers.size() < size_t(CIRCULAR_BUFFER_SIZE))
227  {
228  mHostBuffers.push_back(NTV2FrameData());
229  NTV2FrameData & frameData(mHostBuffers.back());
230  frameData.fVideoBuffer.Allocate(mFormatDesc.GetVideoWriteSize());
231  frameData.fAudioBuffer.Allocate(audioBufferSize);
232  frameData.fAncBuffer.Allocate(F1AncSize);
233  frameData.fAncBuffer2.Allocate(F2AncSize);
234  mAVCircularBuffer.Add(&frameData);
235 
236 #ifdef NTV2_BUFFER_LOCK
237  // Page lock the memory
238  if (frameData.fVideoBuffer)
239  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
240  if (frameData.fAncBuffer)
241  mDevice.DMABufferLock(frameData.fAncBuffer, true);
242  if (frameData.fAncBuffer2)
243  mDevice.DMABufferLock(frameData.fAncBuffer2, true);
244 #endif
245  } // for each NTV2FrameData
246 
247 } // SetupHostBuffers
248 
249 
251 {
252 
255  mDevice.GetHDMIInputColor (inputColorSpace, mConfig.fInputChannel);
256 
257  const bool isInputRGB (inputColorSpace == NTV2_LHIHDMIColorSpaceRGB);
258  NTV2XptConnections connections;
259 
260  return CNTV2DemoCommon::GetInputRouting (connections, mConfig, isInputRGB)
261  && mDevice.ApplySignalRoute(connections, !mConfig.fDoMultiFormat);
262 
263 } // RouteInputSignal
264 
265 
267 {
268  // Start the playout and capture threads...
271  return AJA_STATUS_SUCCESS;
272 
273 } // Run
274 
275 
277 
278 // This is where we will start the consumer thread
280 {
281  // Create and start the consumer thread...
282  mConsumerThread.Attach(ConsumerThreadStatic, this);
283  mConsumerThread.SetPriority(AJA_ThreadPriority_High);
284  mConsumerThread.Start();
285 
286 } // StartConsumerThread
287 
288 
289 // The consumer thread function
290 void NTV2DolbyCapture::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
291 {
292  (void) pThread;
293 
294  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
295  // then call its ConsumeFrames method...
296  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture *> (pContext));
297  pApp->ConsumeFrames();
298 
299 } // ConsumerThreadStatic
300 
301 
303 {
304  CAPNOTE("Thread started");
305  uint64_t ancTally(0);
306  uint64_t audioTally(0);
307  uint64_t dolbyTally(0);
308  ofstream * pOFS(mConfig.fAncDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fAncDataFilePath.c_str(), ios::binary));
309  ofstream * pAFS(mConfig.fAudioDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fAudioDataFilePath.c_str(), ios::binary));
310  ofstream * pDFS(mConfig.fDolbyDataFilePath.empty() ? AJA_NULL : new ofstream(mConfig.fDolbyDataFilePath.c_str(), ios::binary));
311  while (!mGlobalQuit)
312  {
313  // Wait for the next frame to become ready to "consume"...
314  NTV2FrameData * pFrameData (mAVCircularBuffer.StartConsumeNextBuffer ());
315  if (pFrameData)
316  {
317  // Do something useful with the frame data...
318  // . . . . . . . . . . . .
319  // . . . . . . . . . . . .
320  // . . . . . . . . . . . .
321  if (mConfig.fDoFrameStats && pFrameData->AncBuffer())
322  {
323  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer().GetHostAddress(0);
324  uint32_t i;
325  for (i = 0; i < pFrameData->AncBufferSize(); i += 32)
326  {
327  if (pData[i] == 0xff)
328  break;
329  }
330  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->AncBufferSize() /*pFrameData->NumCapturedAncBytes()*/, pFrameData->AudioBuffer());
331  cout << "f1 size reg " << DEC(pFrameData->NumCapturedAncBytes()) << " ffs " << DEC(i) << " samples " << DEC(audioSize/4) << endl << flush;
332  }
333 
334  if (mConfig.fDoFrameStats && pFrameData->AncBuffer2())
335  {
336  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer2().GetHostAddress(0);
337  uint32_t i;
338  for (i = 0; i < pFrameData->AncBuffer2Size(); i += 32)
339  {
340  if (pData[i] == 0xff)
341  break;
342  }
343  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->AncBuffer2Size() /*pFrameData->NumCapturedAnc2Bytes()*/, pFrameData->AudioBuffer());
344  cout << "f2 size reg " << DEC(pFrameData->NumCapturedAnc2Bytes()) << " ffs " << DEC(i) << " samples " << DEC(audioSize/4) << endl << flush;
345  }
346 
347  if (pOFS && pFrameData->AncBuffer())
348  {
349  if (pOFS && !ancTally++)
350  CAPNOTE("Writing raw anc to '" + mConfig.fAncDataFilePath + "'");
351  pOFS->write(pFrameData->AncBuffer(), streamsize(pFrameData->NumCapturedAncBytes()));
352  ancTally++;
353  if ( pFrameData->AncBuffer2())
354  {
355  if (pOFS && pFrameData->AncBuffer2())
356  pOFS->write(pFrameData->AncBuffer2(), streamsize(pFrameData->NumCapturedAnc2Bytes()));
357  }
358  }
359 
360  if (pAFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
361  {
362  if (pAFS && !audioTally++)
363  CAPNOTE("Writing raw audio to '" + mConfig.fAudioDataFilePath + "'");
364  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
365  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
366  audioTally++;
367  if ( pFrameData->AncBuffer2())
368  {
369  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
370  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
371  }
372  }
373 
374  if (pDFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
375  {
376  if (pDFS && !dolbyTally++)
377  CAPNOTE("Writing dolby file to '" + mConfig.fDolbyDataFilePath + "'");
378  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
379  uint32_t dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer());
380  pDFS->write(pFrameData->AncBuffer(), streamsize(dolbySize));
381  dolbyTally++;
382  if ( pFrameData->AncBuffer2())
383  {
384  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
385  dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer2());
386  pDFS->write(pFrameData->AncBuffer2(), streamsize(dolbySize));
387  }
388  }
389  // Now release and recycle the buffer...
390  mAVCircularBuffer.EndConsumeNextBuffer ();
391  } // if pFrameData
392  } // loop til quit signaled
393  if (pOFS)
394  { delete pOFS; cerr << "Wrote " << DEC(ancTally) << " frames of raw anc data" << endl; }
395  if (pAFS)
396  { delete pAFS; cerr << "Wrote " << DEC(audioTally) << " frames of raw audio data" << endl; }
397  if (pDFS)
398  { delete pDFS; cerr << "Wrote " << DEC(dolbyTally) << " frames of dolby data" << endl; }
399  CAPNOTE("Thread completed, will exit");
400 
401 } // ConsumeFrames
402 
403 
405 
406 // This starts the capture (producer) thread
408 {
409  // Create and start the capture thread...
410  mProducerThread.Attach(ProducerThreadStatic, this);
411  mProducerThread.SetPriority(AJA_ThreadPriority_High);
412  mProducerThread.Start();
413 
414 } // StartProducerThread
415 
416 
417 // The capture thread function
418 void NTV2DolbyCapture::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
419 {
420  (void) pThread;
421 
422  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
423  // then call its CaptureFrames method...
424  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture*>(pContext));
425  pApp->CaptureFrames ();
426 
427 } // ProducerThreadStatic
428 
429 
431 {
432  AUTOCIRCULATE_TRANSFER inputXfer; // AutoCirculate input transfer info
433  ULWord acOptions (0), overruns(0);
434  UWord hdmiSpigot (UWord(::NTV2InputSourceToChannel(mConfig.fInputSource)));
435  acOptions |= AUTOCIRCULATE_WITH_ANC;
436  acOptions |= AUTOCIRCULATE_WITH_HDMIAUX;
437 
438  CAPNOTE("Thread started");
439  // Initialize and start capture AutoCirculate...
440  mDevice.AutoCirculateStop(mConfig.fInputChannel); // Just in case
441  if (!mDevice.AutoCirculateInitForInput (mConfig.fInputChannel, // primary channel
442  mConfig.fFrames.count(), // numFrames (zero if specifying range)
443  mAudioSystem, // audio system (if any)
444  acOptions, // AutoCirculate options
445  1, // numChannels to gang
446  mConfig.fFrames.firstFrame(), mConfig.fFrames.lastFrame()))
447  mGlobalQuit = true;
448 
449  // The user can opt to INCLUDE only Audio Packets
450  // AuxExtractGetDefaultPacketFilters() retrieves Audio Packet filters DIDs
451  if (mConfig.fDoAudioFilter)
452  {
453  mDevice.AuxExtractSetFilterInclusionMode(hdmiSpigot, /*include?*/true);
454  mDevice.AuxExtractSetPacketFilters(hdmiSpigot, mDevice.AuxExtractGetDefaultPacketFilters());
455  }
456  else
457  { //Otherwise, exclude only 00 Values (excludes nothing / shows all)
458  mDevice.AuxExtractSetFilterInclusionMode(hdmiSpigot,/*include?*/false);
459  NTV2DIDSet zeroSet;
460  zeroSet.insert(0);
461  mDevice.AuxExtractSetPacketFilters(hdmiSpigot, zeroSet);
462  }
463 
464  if (!mGlobalQuit && !mDevice.AutoCirculateStart(mConfig.fInputChannel))
465  mGlobalQuit = true;
466 
467  // Ingest frames til Quit signaled...
468  while (!mGlobalQuit)
469  {
470  AUTOCIRCULATE_STATUS acStatus;
471  mDevice.AutoCirculateGetStatus (mConfig.fInputChannel, acStatus);
472 
473  if (acStatus.IsRunning() && acStatus.HasAvailableInputFrame())
474  {
475  // At this point, there's at least one fully-formed frame available in the device's
476  // frame buffer to transfer to the host. Reserve an NTV2FrameData to "produce", and
477  // use it in the next transfer from the device...
478  NTV2FrameData * pFrameData(mAVCircularBuffer.StartProduceNextBuffer());
479  if (!pFrameData)
480  continue;
481 
482  NTV2FrameData & frameData (*pFrameData);
483  inputXfer.SetVideoBuffer (frameData.VideoBuffer(), frameData.VideoBufferSize());
484  if (acStatus.WithCustomAnc())
485  inputXfer.SetAncBuffers (frameData.AncBuffer(), frameData.AncBufferSize(),
486  frameData.AncBuffer2(), frameData.AncBuffer2Size());
487 
488  // Transfer video/audio/anc from the device into our host buffers...
489  mDevice.AutoCirculateTransfer (mConfig.fInputChannel, inputXfer);
490 
491  // If capturing Anc, clear stale anc data from the anc buffers...
492  if (acStatus.WithCustomAnc() && frameData.AncBuffer())
493  { bool overrun(false);
494  mDevice.AuxExtractGetBufferOverrun (hdmiSpigot, overrun);
495  if (overrun)
496  {overruns++; CAPWARN(overruns << " aux overrun(s)");}
497  frameData.fNumAncBytes = inputXfer.GetCapturedAncByteCount(/*isF2*/false);
498  NTV2Buffer stale (frameData.fAncBuffer.GetHostAddress(frameData.fNumAncBytes),
499  frameData.fAncBuffer.GetByteCount() - frameData.fNumAncBytes);
500  stale.Fill(uint8_t(0));
501  }
502  if (acStatus.WithCustomAnc() && frameData.AncBuffer2())
503  {
504  frameData.fNumAnc2Bytes = inputXfer.GetCapturedAncByteCount(/*isF2*/true);
505  NTV2Buffer stale (frameData.fAncBuffer2.GetHostAddress(frameData.fNumAnc2Bytes),
506  frameData.fAncBuffer2.GetByteCount() - frameData.fNumAnc2Bytes);
507  stale.Fill(uint8_t(0));
508  }
509 
510  // Signal that we're done "producing" the frame, making it available for future "consumption"...
511  mAVCircularBuffer.EndProduceNextBuffer();
512  } // if A/C running and frame(s) are available for transfer
513  else
514  {
515  // Either AutoCirculate is not running, or there were no frames available on the device to transfer.
516  // Rather than waste CPU cycles spinning, waiting until a frame becomes available, it's far more
517  // efficient to wait for the next input vertical interrupt event to get signaled...
519  }
520 
521  } // loop til quit signaled
522 
523  // Stop AutoCirculate...
524  mDevice.AutoCirculateStop(mConfig.fInputChannel);
525  CAPNOTE("Thread completed, will exit");
526 
527 } // CaptureFrames
528 
529 
530 void NTV2DolbyCapture::GetACStatus (ULWord & outGoodFrames, ULWord & outDroppedFrames, ULWord & outBufferLevel)
531 {
532  AUTOCIRCULATE_STATUS status;
533  mDevice.AutoCirculateGetStatus(mConfig.fInputChannel, status);
534  outGoodFrames = status.GetProcessedFrameCount();
535  outDroppedFrames = status.GetDroppedFrameCount();
536  outBufferLevel = status.GetBufferLevel();
537 }
538 
539 uint32_t NTV2DolbyCapture::RecoverAudio (const NTV2Buffer & inAncBuffer, const uint32_t ancSize, NTV2Buffer & outAudioBuffer)
540 {
541  const uint8_t * pInAncData(inAncBuffer);
542  uint8_t * pOutAudioData(outAudioBuffer);
543  uint32_t audioSize(0);
544 
545  // Extract first 16-bit stereo pair from the aux data
546  for (uint32_t num(0); num < ancSize / 32; num++)
547  {
548  // Audio data aux packet?
549  if (pInAncData[0] == 0x02)
550  {
551  // First sample present?
552  if ((pInAncData[1] & 0x01))
553  {
554  // First sample flat?
555  if ((pInAncData[2] & 0x01))
556  {
557  *pOutAudioData++ = 0;
558  *pOutAudioData++ = 0;
559  *pOutAudioData++ = 0;
560  *pOutAudioData++ = 0;
561  }
562  else
563  {
564  *pOutAudioData++ = pInAncData[4];
565  *pOutAudioData++ = pInAncData[5];
566  *pOutAudioData++ = pInAncData[7];
567  *pOutAudioData++ = pInAncData[8];
568  }
569  audioSize += 4;
570  } // if first sample present
571 
572  // Only 2 channels?
573  if ((pInAncData[1] & 0x10) == 0)
574  {
575  // Second sample present?
576  if ((pInAncData[1] & 0x02))
577  {
578  // Second sample flat?
579  if ((pInAncData[2] & 0x02))
580  {
581  *pOutAudioData++ = 0;
582  *pOutAudioData++ = 0;
583  *pOutAudioData++ = 0;
584  *pOutAudioData++ = 0;
585  }
586  else
587  {
588  *pOutAudioData++ = pInAncData[11];
589  *pOutAudioData++ = pInAncData[12];
590  *pOutAudioData++ = pInAncData[14];
591  *pOutAudioData++ = pInAncData[15];
592  }
593  audioSize += 4;
594  }
595 
596  // Third sample present?
597  if ((pInAncData[1] & 0x04))
598  {
599  // Third sample flat?
600  if ((pInAncData[2] & 0x04))
601  {
602  *pOutAudioData++ = 0;
603  *pOutAudioData++ = 0;
604  *pOutAudioData++ = 0;
605  *pOutAudioData++ = 0;
606  }
607  else
608  {
609  *pOutAudioData++ = pInAncData[18];
610  *pOutAudioData++ = pInAncData[19];
611  *pOutAudioData++ = pInAncData[21];
612  *pOutAudioData++ = pInAncData[22];
613  }
614  audioSize += 4;
615  }
616 
617  // Fourth sample present?
618  if ((pInAncData[1] & 0x08))
619  {
620  // Fourth sample flat?
621  if ((pInAncData[2] & 0x08))
622  {
623  *pOutAudioData++ = 0;
624  *pOutAudioData++ = 0;
625  *pOutAudioData++ = 0;
626  *pOutAudioData++ = 0;
627  }
628  else
629  {
630  *pOutAudioData++ = pInAncData[25];
631  *pOutAudioData++ = pInAncData[26];
632  *pOutAudioData++ = pInAncData[28];
633  *pOutAudioData++ = pInAncData[29];
634  }
635  audioSize += 4;
636  } // if 4th sample present
637  } // if only 2 channels
638  } // if audio data aux packet
639  pInAncData += 32;
640  } // for loop
641  return audioSize;
642 } // RecoverAudio
643 
644 uint32_t NTV2DolbyCapture::RecoverDolby (const NTV2Buffer & inAudioBuffer, const uint32_t inAudioSize, NTV2Buffer & outDolbyBuffer)
645 {
646  const uint16_t * pInAudioData(inAudioBuffer);
647  uint16_t * pOutDolbyData(outDolbyBuffer);
648  uint32_t dolbySize(0);
649 
650  // Extract the dolby frames from the IEC61937 bursts...
651  for (uint32_t cnt(0); cnt < inAudioSize / 2; cnt++)
652  {
653  switch (mDolbyState)
654  {
655  // Find IEC61937 burst preamble
656  case 0: mDolbyState = (*pInAudioData == 0xf872) ? 1 : 0;
657  break;
658 
659  case 1: mDolbyState = (*pInAudioData == 0x4e1f) ? 2 : 0;
660  break;
661 
662  // Check dolby code
663  case 2: mDolbyState = ((*pInAudioData & 0xff) == 0x15) ? 3 : 0;
664  break;
665 
666  // Get burst length
667  case 3: mDolbyLength = uint32_t(*pInAudioData / 2);
668  mDolbyState = 4;
669  break;
670 
671  // Copy dolby samples
672  case 4: if (mDolbyLength)
673  {
674  if (dolbySize < outDolbyBuffer.GetByteCount() / 2)
675  {
676  // Endian swap the data...
677  *pOutDolbyData = (*pInAudioData >> 8) & 0xff;
678  *pOutDolbyData |= (*pInAudioData & 0xff) << 8;
679  pOutDolbyData++;
680  dolbySize++;
681  mDolbyLength--;
682  }
683  }
684  else
685  mDolbyState = 0;
686  break;
687 
688  default: mDolbyState = 0;
689  break;
690  } // switch
691  pInAudioData++;
692  } // for loop
693  return dolbySize * 2;
694 }
695 
696 
698 
699 
700 AJALabelValuePairs DolbyCaptureConfig::Get (const bool inCompact) const
701 {
702  AJALabelValuePairs result(CaptureConfig::Get(inCompact));
703  AJASystemInfo::append(result, "Audio Capture File", fAudioDataFilePath.empty() ? "---" : fAudioDataFilePath);
704  AJASystemInfo::append(result, "Dolby Capture File", fDolbyDataFilePath.empty() ? "---" : fDolbyDataFilePath);
705  return result;
706 }
707 
708 
709 std::ostream & operator << (std::ostream & ioStrm, const DolbyCaptureConfig & inObj)
710 {
711  ioStrm << AJASystemInfo::ToString(inObj.Get());
712  return ioStrm;
713 }
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:285
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:5083
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:418
NTV2ChannelToInputSource
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5192
ntv2dolbycapture.h
Declares the NTV2DolbyCapture class.
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5107
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
NTV2_IOKINDS_HDMI
@ NTV2_IOKINDS_HDMI
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1275
NTV2FormatDescriptor::GetVideoWriteSize
ULWord GetVideoWriteSize(ULWord inPageSize=4096UL) const
Definition: ntv2formatdescriptor.cpp:866
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:983
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:3631
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:1031
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:6022
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:530
NTV2DolbyCapture::RouteInputSignal
virtual bool RouteInputSignal(void)
Sets up device routing for capture.
Definition: ntv2dolbycapture.cpp:250
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6096
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:1306
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:430
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:374
AUTOCIRCULATE_STATUS::GetProcessedFrameCount
ULWord GetProcessedFrameCount(void) const
Definition: ntv2publicinterface.h:7249
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3850
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:282
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:982
AUTOCIRCULATE_STATUS::GetBufferLevel
ULWord GetBufferLevel(void) const
Definition: ntv2publicinterface.h:7254
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
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:278
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:1647
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3634
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:2745
CaptureConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2democommon.cpp:1771
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:1336
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:204
NTV2DolbyCapture::SetupVideo
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
Definition: ntv2dolbycapture.cpp:154
NTV2FrameData::VideoBuffer
NTV2Buffer & VideoBuffer(void)
Definition: ntv2democommon.h:106
NTV2_IS_4K_VIDEO_FORMAT
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:769
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:5528
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:7258
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:290
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:255
DolbyCaptureConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2dolbycapture.cpp:700
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:7193
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:539
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:8379
NTV2DolbyCapture::StartConsumerThread
virtual void StartConsumerThread(void)
Starts my frame consumer thread.
Definition: ntv2dolbycapture.cpp:279
UWord
uint16_t UWord
Definition: ajatypes.h:253
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:1266
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:8002
CaptureConfig::fDeviceSpec
std::string fDeviceSpec
The AJA device to use.
Definition: ntv2democommon.h:277
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6793
NTV2DolbyCapture::SetupAudio
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
Definition: ntv2dolbycapture.cpp:197
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1263
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:2729
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:1312
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:407
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:1247
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:199
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1348
CaptureConfig::fFrames
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
Definition: ntv2democommon.h:281
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:279
NTV2Buffer::GetHostAddress
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
Definition: ntv2publicinterface.cpp:1703
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:521
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:3633
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5606
false
#define false
Definition: ntv2devicefeatures.h:25
CAPWARN
#define CAPWARN(_expr_)
Definition: ntv2democommon.h:29
NTV2ACFrameRange::lastFrame
UWord lastFrame(void) const
Definition: ntv2utils.h:984
AUTOCIRCULATE_STATUS::IsRunning
bool IsRunning(void) const
Definition: ntv2publicinterface.h:7299
NTV2FrameBufferFormatToString
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6983
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:266
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:5531
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:7244
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:407
AUTOCIRCULATE_STATUS::HasAvailableInputFrame
bool HasAvailableInputFrame(void) const
Definition: ntv2publicinterface.h:7269
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:7334
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:6248
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:709
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:644
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:92
CaptureConfig::fInputSource
NTV2InputSource fInputSource
The device input connector to use.
Definition: ntv2democommon.h:280
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:302