AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2capture8k.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2capture8k.h"
9 #include "ntv2devicescanner.h"
10 #include "ntv2utils.h"
11 #include "ntv2devicefeatures.h"
12 #include "ajabase/system/process.h"
13 
14 using namespace std;
15 
16 
18 
20  : mConsumerThread (AJAThread()),
21  mProducerThread (AJAThread()),
22  mDeviceID (DEVICE_ID_NOTFOUND),
23  mConfig (inConfig),
25  mSavedTaskMode (NTV2_DISABLE_TASKS),
26  mAudioSystem (inConfig.fWithAudio ? NTV2_AUDIOSYSTEM_1 : NTV2_AUDIOSYSTEM_INVALID),
27  mHostBuffers (),
28  mAVCircularBuffer (),
29  mGlobalQuit (false)
30 {
31 } // constructor
32 
33 
35 {
36  // Stop my capture and consumer threads, then destroy them...
37  Quit();
38 
39  // Unsubscribe from VBI events...
42 
43 } // destructor
44 
45 
47 {
48  // Set the global 'quit' flag, and wait for the threads to go inactive...
49  mGlobalQuit = true;
50 
51  while (mConsumerThread.Active())
52  AJATime::Sleep(10);
53 
54  while (mProducerThread.Active())
55  AJATime::Sleep(10);
56 
57  mDevice.DMABufferUnlockAll();
58 
59  // Restore some of the device's former state...
60  if (!mConfig.fDoMultiFormat)
61  {
63  mDevice.SetTaskMode(mSavedTaskMode); // Restore prior task mode
64  }
65 
66 } // Quit
67 
68 
70 {
72 
73  // Open the device...
75  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not found" << endl; return AJA_STATUS_OPEN;}
76 
77  if (!mDevice.IsDeviceReady())
78  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' not ready" << endl; return AJA_STATUS_INITIALIZE;}
79 
80  mDeviceID = mDevice.GetDeviceID(); // Keep the device ID handy, as it's used frequently
81  if (!mDevice.features().CanDoCapture())
82  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' is playback-only" << endl; return AJA_STATUS_FEATURE;}
83  if (!mDevice.features().CanDo12gRouting())
84  {cerr << "## ERROR: '" << ::NTV2DeviceIDToString(mDeviceID,true) << "' lacks 12G SDI"; 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.GetTaskMode(mSavedTaskMode); // Save the current task mode
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  }
105  mDevice.SetTaskMode(NTV2_OEM_TASKS); // Prevent interference from AJA retail services
106 
107  if (mDevice.features().CanDoMultiFormat())
108  mDevice.SetMultiFormatMode(mConfig.fDoMultiFormat);
109 
110  // This demo permits only the input channel/frameStore to be specified. Set the input source here...
111  const NTV2Channel origCh (mConfig.fInputChannel);
112  if (UWord(origCh) >= mDevice.features().GetNumFrameStores())
113  {
114  cerr << "## ERROR: No such Ch" << DEC(origCh+1) << " for '" << ::NTV2DeviceIDToString(mDeviceID,true) << "'" << endl;
115  return AJA_STATUS_BAD_PARAM;
116  }
117  // Must use Ch1/Ch3/Ch5/Ch7; Must use Ch1 for squares...
118  if ((origCh & 1) || (origCh && !mConfig.fDoTSIRouting))
119  {
120  cerr << "## ERROR: Cannot use Ch" << DEC(origCh+1) << " for '" << ::NTV2DeviceIDToString(mDeviceID,true) << "'" << endl;
121  return AJA_STATUS_BAD_PARAM;
122  }
123  mConfig.fInputSource = ::NTV2ChannelToInputSource(mConfig.fInputChannel); // Must use corresponding SDI inputs
124 
125  // Determine input connectors and frameStores to be used...
126  mActiveFrameStores = ::NTV2MakeChannelSet (mConfig.fInputChannel, mConfig.fDoTSIRouting ? 2 : 4);
127  mActiveSDIs = ::NTV2MakeChannelSet (mConfig.fInputChannel, mConfig.fDoTSIRouting ? (::IsRGBFormat(mConfig.fPixelFormat) ? 4 : 2) : 4);
128  // Note for TSI into YUV framestore: if input signal is QuadQuadHFR, we'll add 2 more SDIs (see below in SetupVideo)
129 
130  // Set up the video and audio...
131  status = SetupVideo();
132  if (AJA_FAILURE(status))
133  return status;
134 
135  if (mConfig.fWithAudio)
136  status = SetupAudio();
137  if (AJA_FAILURE(status))
138  return status;
139 
140  // Set up the circular buffers, the device signal routing, and both playout and capture AutoCirculate...
142  if (!RouteInputSignal())
143  return AJA_STATUS_FAIL;
144 
145  #if defined(_DEBUG)
146  cerr << mConfig << endl << "FrameStores: " << ::NTV2ChannelSetToStr(mActiveFrameStores) << endl
147  << "Inputs: " << ::NTV2ChannelSetToStr(mActiveSDIs) << endl;
148  if (mDevice.IsRemote())
149  cerr << "Device Description: " << mDevice.GetDescription() << endl << endl;
150  #endif // defined(_DEBUG)
151  return AJA_STATUS_SUCCESS;
152 
153 } // Init
154 
155 
157 {
158  // Enable the FrameStores we intend to use...
159  mDevice.EnableChannels (mActiveFrameStores, !mConfig.fDoMultiFormat); // Disable the rest if we own the device
160 
161  // Enable and subscribe to VBIs (critical on Windows)...
162  mDevice.EnableInputInterrupt(mConfig.fInputChannel);
165 
166  // If the device supports bi-directional SDI and the requested input is SDI,
167  // ensure the SDI connector(s) are configured to receive...
169  {
170  mDevice.SetSDITransmitEnable (mActiveSDIs, false); // Set SDI connector(s) to receive
171  mDevice.WaitForOutputVerticalInterrupt (NTV2_CHANNEL1, 10); // Wait 10 VBIs to allow reciever to lock
172  }
173 
174  // Determine the input video signal format...
175  mVideoFormat = mDevice.GetInputVideoFormat(mConfig.fInputSource);
176  if (mVideoFormat == NTV2_FORMAT_UNKNOWN)
177  {cerr << "## ERROR: No input signal or unknown format" << endl; return AJA_STATUS_NOINPUT;}
178  CNTV2DemoCommon::Get8KInputFormat(mVideoFormat); // Convert to 8K format
179  mFormatDesc = NTV2FormatDescriptor(mVideoFormat, mConfig.fPixelFormat);
180  if (mConfig.fDoTSIRouting && !::IsRGBFormat(mConfig.fPixelFormat) && NTV2_IS_QUAD_QUAD_HFR_VIDEO_FORMAT(mVideoFormat))
181  {
182  mActiveSDIs = ::NTV2MakeChannelSet (mConfig.fInputChannel, 4); // Add 2 more SDIs for TSI + YUV frameStores + QuadQuadHFR
183  mDevice.SetSDITransmitEnable (mActiveSDIs, false); // Set SDIs to receive
184  }
185 
186  // Setting SDI output clock timing/reference is unimportant for capture-only apps...
187  if (!mConfig.fDoMultiFormat) // ...if not sharing the device...
188  mDevice.SetReference(NTV2_REFERENCE_FREERUN); // ...let it free-run
189 
190  // Set the device video format to whatever was detected at the input(s)...
191  mDevice.SetVideoFormat (mVideoFormat, false, false, mConfig.fInputChannel);
192  mDevice.SetVANCMode (mActiveFrameStores, NTV2_VANCMODE_OFF); // Disable VANC
193  mDevice.SetQuadQuadFrameEnable (true, mConfig.fInputChannel); // UHD2/8K requires QuadQuad mode
194  mDevice.SetQuadQuadSquaresEnable (!mConfig.fDoTSIRouting, mConfig.fInputChannel); // Set QuadQuadSquares mode if not TSI
195 
196  // Set the frame buffer pixel format for the FrameStore(s) to be used on the device...
197  mDevice.SetFrameBufferFormat (mActiveFrameStores, mConfig.fPixelFormat);
198  return AJA_STATUS_SUCCESS;
199 
200 } // SetupVideo
201 
202 
204 {
205  // In multiformat mode, base the audio system on the channel...
206  if (mConfig.fDoMultiFormat)
207  if (mDevice.features().GetNumAudioSystems() > 1)
208  if (UWord(mConfig.fInputChannel) < mDevice.features().GetNumAudioSystems())
209  mAudioSystem = ::NTV2ChannelToAudioSystem(mConfig.fInputChannel);
210 
211  NTV2AudioSystemSet audSystems (::NTV2MakeAudioSystemSet (mAudioSystem, 1));
212  CNTV2DemoCommon::ConfigureAudioSystems (mDevice, mConfig, audSystems);
213  return AJA_STATUS_SUCCESS;
214 
215 } // SetupAudio
216 
217 
219 {
220  // Let my circular buffer know when it's time to quit...
221  mAVCircularBuffer.SetAbortFlag(&mGlobalQuit);
222 
223  ULWord F1AncSize(0), F2AncSize(0);
224  if (mConfig.fWithAnc)
225  { // Use the max anc size stipulated by the AncFieldOffset VReg values...
226  ULWord F1OffsetFromEnd(0), F2OffsetFromEnd(0);
227  mDevice.ReadRegister(kVRegAncField1Offset, F1OffsetFromEnd); // # bytes from end of 8MB/16MB frame
228  mDevice.ReadRegister(kVRegAncField2Offset, F2OffsetFromEnd); // # bytes from end of 8MB/16MB frame
229  // Based on the offsets, calculate the max anc capacity
230  F1AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? 0 : F1OffsetFromEnd - F2OffsetFromEnd;
231  F2AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? F2OffsetFromEnd - F1OffsetFromEnd : F2OffsetFromEnd;
232  }
233 
234  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
235  const size_t audioBufferSize (NTV2_AUDIOSIZE_MAX);
236  mHostBuffers.reserve(size_t(CIRCULAR_BUFFER_SIZE));
237  cout << "## NOTE: Buffer size: vid=" << mFormatDesc.GetVideoWriteSize() << " aud=" << audioBufferSize << " anc=" << F1AncSize << endl;
238  while (mHostBuffers.size() < size_t(CIRCULAR_BUFFER_SIZE))
239  {
240  mHostBuffers.push_back(NTV2FrameData());
241  NTV2FrameData & frameData(mHostBuffers.back());
242  frameData.fVideoBuffer.Allocate(mFormatDesc.GetVideoWriteSize());
243  frameData.fAudioBuffer.Allocate(NTV2_IS_VALID_AUDIO_SYSTEM(mAudioSystem) ? audioBufferSize : 0);
244  frameData.fAncBuffer.Allocate(F1AncSize);
245  frameData.fAncBuffer2.Allocate(F2AncSize);
246  mAVCircularBuffer.Add(&frameData);
247 
248  // 8K requires page-locked buffers
249  if (frameData.fVideoBuffer)
250  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
251  if (frameData.fAudioBuffer)
252  mDevice.DMABufferLock(frameData.fAudioBuffer, true);
253  if (frameData.fAncBuffer)
254  mDevice.DMABufferLock(frameData.fAncBuffer, true);
255  } // for each NTV2FrameData
256 
257 } // SetupHostBuffers
258 
259 
261 {
263  return CNTV2DemoCommon::GetInputRouting8K (connections, mConfig, mVideoFormat)
264  && mDevice.ApplySignalRoute(connections, !mConfig.fDoMultiFormat);
265 
266 } // RouteInputSignal
267 
268 
270 {
271  // Start the playout and capture threads...
274  return AJA_STATUS_SUCCESS;
275 
276 } // Run
277 
278 
280 
281 // This starts the consumer thread
283 {
284  // Create and start the consumer thread...
285  mConsumerThread.Attach(ConsumerThreadStatic, this);
286  mConsumerThread.SetPriority(AJA_ThreadPriority_High);
287  mConsumerThread.Start();
288 
289 } // StartConsumerThread
290 
291 
292 // The consumer thread function
293 void NTV2Capture8K::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
294 {
295  (void) pThread;
296 
297  // Grab the NTV2Capture instance pointer from the pContext parameter,
298  // then call its ConsumeFrames method...
299  NTV2Capture8K * pApp (reinterpret_cast<NTV2Capture8K*>(pContext));
300  pApp->ConsumeFrames();
301 
302 } // ConsumerThreadStatic
303 
304 
306 {
307  CAPNOTE("Thread started");
308  while (!mGlobalQuit)
309  {
310  // Wait for the next frame to become ready to "consume"...
311  NTV2FrameData * pFrameData(mAVCircularBuffer.StartConsumeNextBuffer());
312  if (pFrameData)
313  {
314  // Do something useful with the frame data...
315  // . . . . . . . . . . . .
316  // . . . . . . . . . . . .
317  // . . . . . . . . . . . .
318 
319  // Now release and recycle the buffer...
320  mAVCircularBuffer.EndConsumeNextBuffer();
321  } // if pFrameData
322  } // loop til quit signaled
323  CAPNOTE("Thread completed, will exit");
324 
325 } // ConsumeFrames
326 
327 
329 
330 // This starts the capture (producer) thread
332 {
333  // Create and start the capture thread...
334  mProducerThread.Attach(ProducerThreadStatic, this);
335  mProducerThread.SetPriority(AJA_ThreadPriority_High);
336  mProducerThread.Start();
337 
338 } // StartProducerThread
339 
340 
341 // The capture thread function
342 void NTV2Capture8K::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
343 {
344  (void) pThread;
345 
346  // Grab the NTV2Capture instance pointer from the pContext parameter,
347  // then call its CaptureFrames method...
348  NTV2Capture8K * pApp (reinterpret_cast<NTV2Capture8K*>(pContext));
349  pApp->CaptureFrames();
350 
351 } // ProducerThreadStatic
352 
353 
355 {
356  AUTOCIRCULATE_TRANSFER inputXfer; // AutoCirculate input transfer info
357  CAPNOTE("Thread started");
358 
359  // Tell capture AutoCirculate to use frame buffers 0 thru 6 (7 frames) on the device...
360  mConfig.fFrames.setExactRange (0, 6);
361  mDevice.AutoCirculateStop(mActiveFrameStores); // Just in case
362  if (!mDevice.AutoCirculateInitForInput (mConfig.fInputChannel, mConfig.fFrames, mAudioSystem, AUTOCIRCULATE_WITH_RP188 | AUTOCIRCULATE_WITH_ANC))
363  mGlobalQuit = true;
364  if (!mGlobalQuit && !mDevice.AutoCirculateStart(mConfig.fInputChannel))
365  mGlobalQuit = true;
366 
367  // Ingest frames til Quit signaled...
368  while (!mGlobalQuit)
369  {
370  AUTOCIRCULATE_STATUS acStatus;
371  mDevice.AutoCirculateGetStatus (mConfig.fInputChannel, acStatus);
372 
373  if (acStatus.IsRunning() && acStatus.HasAvailableInputFrame())
374  {
375  // At this point, there's at least one fully-formed frame available in the device's
376  // frame buffer to transfer to the host. Reserve an NTV2FrameData to "produce", and
377  // use it in the next transfer from the device...
378  NTV2FrameData * pFrameData (mAVCircularBuffer.StartProduceNextBuffer());
379  if (!pFrameData)
380  continue;
381 
382  NTV2FrameData & frameData (*pFrameData);
383  inputXfer.SetVideoBuffer (frameData.VideoBuffer(), frameData.VideoBufferSize());
384  if (acStatus.WithAudio())
385  inputXfer.SetAudioBuffer (frameData.AudioBuffer(), frameData.AudioBufferSize());
386  if (acStatus.WithCustomAnc())
387  inputXfer.SetAncBuffers (frameData.AncBuffer(), frameData.AncBufferSize(),
388  frameData.AncBuffer2(), frameData.AncBuffer2Size());
389 
390  // Transfer video/audio/anc from the device into our host buffers...
391  mDevice.AutoCirculateTransfer (mConfig.fInputChannel, inputXfer);
392 
393  // Remember the actual amount of audio captured...
394  if (acStatus.WithAudio())
395  frameData.fNumAudioBytes = inputXfer.GetCapturedAudioByteCount();
396 
397  // Grab all valid timecodes that were captured...
398  inputXfer.GetInputTimeCodes (frameData.fTimecodes, mConfig.fInputChannel, /*ValidOnly*/ true);
399 
400  // Signal that we're done "producing" the frame, making it available for future "consumption"...
401  mAVCircularBuffer.EndProduceNextBuffer();
402  } // if A/C running and frame(s) are available for transfer
403  else
404  {
405  // Either AutoCirculate is not running, or there were no frames available on the device to transfer.
406  // Rather than waste CPU cycles spinning, waiting until a frame becomes available, it's far more
407  // efficient to wait for the next input vertical interrupt event to get signaled...
409  }
410  } // loop til quit signaled
411 
412  // Stop AutoCirculate...
413  mDevice.AutoCirculateStop (mConfig.fInputChannel);
414  CAPNOTE("Thread completed, will exit");
415 
416 } // CaptureFrames
417 
418 
419 void NTV2Capture8K::GetACStatus (ULWord & outGoodFrames, ULWord & outDroppedFrames, ULWord & outBufferLevel)
420 {
421  AUTOCIRCULATE_STATUS status;
422  mDevice.AutoCirculateGetStatus(mConfig.fInputChannel, status);
423  outGoodFrames = status.GetProcessedFrameCount();
424  outDroppedFrames = status.GetDroppedFrameCount();
425  outBufferLevel = status.GetBufferLevel();
426 }
Anc Field2 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
ULWord GetVideoWriteSize(ULWord inPageSize=4096UL) const
virtual ~NTV2Capture8K()
NTV2Capture8K(const CaptureConfig &inConfig)
Constructs me using the given settings.
virtual bool SetTaskMode(const NTV2TaskMode inMode)
Sets the device&#39;s task mode.
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
std::string NTV2ChannelSetToStr(const NTV2ChannelSet &inObj, const bool inCompact=true)
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...
Specifies the device&#39;s internal clock.
Definition: ntv2enums.h:1459
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=(0))
Sets the device&#39;s clock reference source. See Video Output Clocking & Synchronization for more inform...
virtual bool ReleaseStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Releases exclusive use of the AJA device for the given process, permitting other processes to acquire...
bool WithCustomAnc(void) const
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
ULWord AncBuffer2Size(void) const
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.
AJAStatus
Definition: types.h:380
ULWord VideoBufferSize(void) const
#define NTV2_IS_QUAD_QUAD_HFR_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:826
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode...
ULWord GetCapturedAudioByteCount(void) const
virtual bool IsDeviceReady(const bool inCheckValid=(0))
virtual void ConsumeFrames(void)
Repeatedly consumes frames from the circular buffer (until global quit flag set). ...
ULWord AudioBufferSize(void) const
static uint64_t GetPid()
Definition: process.cpp:35
ULWord GetBufferLevel(void) const
#define AJA_FAILURE(_status_)
Definition: types.h:373
static bool GetInputRouting8K(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const NTV2VideoFormat inVidFormat, const NTV2DeviceID inDevID=DEVICE_ID_INVALID, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given 8K/UHD2 capture configuration...
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5132
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread&#39;s static callback function that gets called when the consumer thread runs...
bool WithAudio(void) const
NTV2AudioSystemSet NTV2MakeAudioSystemSet(const NTV2AudioSystem inFirstAudioSystem, const UWord inCount=1)
virtual AJAStatus SetPriority(AJAThreadPriority priority)
Definition: thread.cpp:133
FrameDataPtr StartConsumeNextBuffer(void)
The thread that&#39;s responsible for processing incoming frames – the consumer – calls this function t...
bool fWithAnc
If true, also capture Anc.
ULWord fNumAudioBytes
Actual number of captured audio bytes.
Definition: json.hpp:5362
virtual AJAStatus Start()
Definition: thread.cpp:91
virtual bool EnableInputInterrupt(const NTV2Channel channel=NTV2_CHANNEL1)
Allows the CNTV2Card instance to wait for and respond to input vertical blanking interrupts originati...
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...
void EndConsumeNextBuffer(void)
The consumer thread calls this function to signal that it has finished processing the frame it obtain...
#define false
uint32_t ULWord
Definition: ajatypes.h:223
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
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.
virtual bool RouteInputSignal(void)
Sets up device routing for capture.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
mVideoFormat
Definition: ntv2vcam.cpp:801
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:148
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
ULWord GetProcessedFrameCount(void) const
bool fWithAudio
If true, also capture Audio.
int32_t appPID(0)
Anc Field1 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
#define NTV2_AUDIOSIZE_MAX
NTV2Channel fInputChannel
The device channel to use.
virtual bool IsRemote(void) const
virtual bool Active()
Definition: thread.cpp:116
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device&#39;s current task mode.
virtual void Quit(void)
Gracefully stops me from running.
virtual AJAStatus Run(void)
Runs me.
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the capture thread&#39;s static callback function that gets called when the capture thread runs...
virtual bool EnableChannels(const NTV2ChannelSet &inChannels, const bool inDisableOthers=(0))
Enables the given FrameStore(s).
0: Disabled (never recommended): device configured exclusively by client application(s).
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:139
This class is used to configure an NTV2Capture instance.
ULWord AncBufferSize(void) const
virtual bool UnsubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Unregisters me so I&#39;m no longer notified when an output VBI is signaled on the given output channel...
Invalid or "not found".
Definition: ntv2enums.h:98
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...
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
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 ...
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 ...
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
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
NTV2Buffer & AncBuffer2(void)
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...
virtual std::string GetDisplayName(void)
Answers with this device&#39;s display name.
Definition: ntv2card.cpp:88
NTV2Buffer & AncBuffer(void)
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. ...
Describes a video frame for a given video standard or format and pixel format, including the total nu...
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
2: OEM (recommended): device configured by client application(s) with some driver involvement...
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Definition: ntv2capture8k.h:19
virtual bool ApplySignalRoute(const CNTV2SignalRouter &inRouter, const bool inReplace=(0))
Applies the given routing table to the AJA device.
NTV2XptConnections connections
Definition: ntv2vcam.cpp:1011
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
static bool Get8KInputFormat(NTV2VideoFormat &inOutVideoFormat)
Given a video format, if all 4 inputs are the same and promotable to 8K, this function does the promo...
NTV2Buffer & VideoBuffer(void)
ULWord GetDroppedFrameCount(void) const
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
Definition: ntv2dma.cpp:457
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
virtual NTV2DeviceID GetDeviceID(void)
Declares the CNTV2DeviceScanner class.
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...
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...
Declares the AJAProcess class.
virtual bool UnsubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Unregisters me so I&#39;m no longer notified when an input VBI is signaled on the given input channel...
NTV2Buffer & AudioBuffer(void)
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:4608
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5410
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
virtual void StartConsumerThread(void)
Starts my frame consumer thread.
NTV2InputSource fInputSource
The device input connector to use.
#define DEC(__x__)
void EndProduceNextBuffer(void)
The producer thread calls this function to signal that it has finished populating the frame it obtain...
This identifies the first Audio System.
Definition: ntv2enums.h:3897
virtual bool WaitForOutputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData&#39;s in our ring.
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
Declares numerous NTV2 utility functions.
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: thread.cpp:169
FrameDataPtr StartProduceNextBuffer(void)
The thread that&#39;s responsible for providing frames – the producer – calls this function to populate...
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Intended for capture, answers with the timecodes captured in my acTransferStatus member&#39;s acFrameStam...
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
uint16_t UWord
Definition: ajatypes.h:221
virtual bool SetQuadQuadFrameEnable(const bool inValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Enables or disables "quad-quad" 8K frame mode on the device.
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1359
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
bool setExactRange(const UWord inFirstFrame, const UWord inLastFrame)
Definition: ntv2utils.h:1000
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
ULWord appSignature(0)
virtual bool SubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Causes me to be notified when an output vertical blanking interrupt is generated for the given output...
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
NTV2PixelFormat fPixelFormat
Pixel format to use.
#define NTV2_IS_VALID_AUDIO_SYSTEM(__x__)
Definition: ntv2enums.h:3914
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.
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6936
Declares the NTV2Capture class.
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos. I&#39;m a more modern version of the AVDataBuffer.
NTV2Buffer fVideoBuffer
Host video buffer.
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4869
bool HasAvailableInputFrame(void) const
NTV2ChannelSet NTV2MakeChannelSet(const NTV2Channel inFirstChannel, const UWord inNumChannels=1)
static bool ConfigureAudioSystems(CNTV2Card &inDevice, const CaptureConfig &inConfig, const NTV2AudioSystemSet inAudioSystems)
Configures capture audio systems.
bool IsRunning(void) const
virtual bool SetQuadQuadSquaresEnable(const bool inValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Enables or disables quad-quad-frame (8K) squares mode on the device.
virtual void CaptureFrames(void)
Repeatedly captures frames using AutoCirculate (until global quit flag set).
std::string fDeviceSpec
The AJA device to use.
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
virtual void GetACStatus(ULWord &outGoodFrames, ULWord &outDroppedFrames, ULWord &outBufferLevel)
Provides status information about my input (capture) process.
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 ...
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1283
bool SetAudioBuffer(ULWord *pInAudioBuffer, const ULWord inAudioByteCount)
Sets my audio buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
#define CAPNOTE(_expr_)
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
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 ...
NTV2TimeCodes fTimecodes
Map of TC indexes to NTV2_RP188 values.
Declares device capability functions.
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 ...
This identifies the mode in which there are no VANC lines in the frame buffer.
Definition: ntv2enums.h:3799
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
bool fDoTSIRouting
If true, do TSI routing; otherwise squares.
virtual void StartProducerThread(void)
Starts my capture thread.