AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2streamgrabber.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include <ostream>
8 #include "ntv2streamgrabber.h"
9 #include "ntv2democommon.h"
10 #include "ntv2devicefeatures.h"
11 #include "ntv2devicescanner.h"
12 #include "ntv2utils.h"
13 #if defined (INCLUDE_AJACC)
16  using namespace std;
17 #endif
18 
19 #define NTV2_NUM_IMAGES (10)
20 
21 // Convenience macros for EZ logging:
22 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
23 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
24 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
25 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
26 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
27 
28 static QMutex gMutex;
29 
30 
32  : QThread (parent),
33  mRestart (true),
34  mAbort (false),
35  mbFixedReference (false),
36  mBoardNumber (0),
37  mDeviceID (DEVICE_ID_NOTFOUND),
38  mChannel (NTV2_CHANNEL1),
39  mStream (NTV2_CHANNEL2),
40  mCurrentVideoFormat (NTV2_FORMAT_UNKNOWN),
41  mCurrentColorSpace (NTV2_LHIHDMIColorSpaceYCbCr),
42  mLastVideoFormat (NTV2_FORMAT_UNKNOWN),
43  mDebounceCounter (0),
44  mFormatIsProgressive (true),
45  mInputSource (NTV2_NUM_INPUTSOURCES),
46  mFrameBufferFormat (NTV2_FBF_ARGB),
47  mDoMultiChannel (false)
48 {
49 
50 } // constructor
51 
52 
54 {
55  mAbort = true;
56  while (isRunning ())
57  ; // Wait for grabber thread to finish
58 
59  StopStream ();
60 
61 } // destructor
62 
63 
65 {
66  if (inInputSource != mInputSource)
67  {
68  qDebug() << "## DEBUG: NTV2StreamGrabber::SetInputSource" << ::NTV2InputSourceToString (inInputSource).c_str ();
69  gMutex.lock ();
70  mInputSource = inInputSource;
71  mRestart = true;
72  gMutex.unlock ();
73  }
74 
75 } // SetInputSource
76 
77 
78 void NTV2StreamGrabber::SetDeviceIndex (const UWord inDeviceIndex)
79 {
80  if (inDeviceIndex != mBoardNumber)
81  {
82  gMutex.lock ();
83  mBoardNumber = inDeviceIndex;
84  mRestart = true;
85  gMutex.unlock ();
86  }
87 } // SetDeviceIndex
88 
89 
91 {
92  gMutex.lock ();
93  const UWord result (mBoardNumber);
94  gMutex.unlock ();
95  return result;
96 }
97 
98 
100 {
101  // Set up 2 images to ping-pong between capture and display...
102  NTV2Buffer buffers[NTV2_NUM_IMAGES];
103  ULWord framesCaptured (0);
104  FGNOTE("Thread started");
105 
106  // Make sure all Bidirectionals are set to Inputs.
107  if (mNTV2Card.Open(mBoardNumber))
108  {
109  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
110  {
111  // We have not acquired the board continue until something changes...
112  qDebug ("Could not acquire board number %d", GetDeviceIndex());
113  mNTV2Card.Close ();
114  mDeviceID = DEVICE_ID_NOTFOUND;
115  }
116  else
117  {
118  mNTV2Card.GetTaskMode (mSavedTaskMode); // Save the current state before we change it
119  mNTV2Card.SetTaskMode (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
120  }
121  }
122 
123  while (true)
124  {
125  if (mAbort)
126  break;
127 
128  if (!NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
129  {
130  // No input chosen, so display banner...
131  QImage currentImage (STREAMPREVIEW_WIDGET_X, STREAMPREVIEW_WIDGET_Y, QImage::Format_RGB32);
132  currentImage.load (":/resources/splash.png");
133  emit newStatusString ("");
134  emit newFrame (currentImage, true);
135  if (::NTV2DeviceHasBiDirectionalSDI (mNTV2Card.GetDeviceID())) // If device has bidirectional SDI connectors...
136  {
137  bool waitForInput = false;
138  UWord numInputs = NTV2DeviceGetNumVideoInputs(mNTV2Card.GetDeviceID());
139  for (UWord offset = 0; offset < numInputs; offset++)
140  {
141  bool outputEnabled;
142  mNTV2Card.GetSDITransmitEnable (NTV2Channel(offset), outputEnabled);
143  if (outputEnabled)
144  {
145  waitForInput = true;
146  mNTV2Card.SetSDITransmitEnable (NTV2Channel(offset), false);
147  }
148  }
149  // Only if we had to change an output to input do we need to wait.
150  if (waitForInput)
151  msleep(500);
152  }
153  msleep(200);
154  continue;
155  }
156 
157  if (mRestart)
158  {
159  gMutex.lock ();
160  if (mNTV2Card.IsOpen ())
161  {
162  StopStream();
163  if (!mDoMultiChannel)
164  {
166  mNTV2Card.SetTaskMode (mSavedTaskMode);
167  }
168  mNTV2Card.Close ();
169  mDeviceID = DEVICE_ID_NOTFOUND;
170  }
171  gMutex.unlock ();
172 
173  if (mNTV2Card.Open(mBoardNumber))
174  {
175  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
176  {
177  //We have not acquired the board continue until something changes
178  qDebug() << "Could not acquire board number " << GetDeviceIndex();
179  msleep (1000);
180  mNTV2Card.Close ();
181  mDeviceID = DEVICE_ID_NOTFOUND;
182  continue;
183  }
184 
185  mNTV2Card.GetTaskMode (mSavedTaskMode); // Save the current state before we change it
186  mNTV2Card.SetTaskMode (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
187 
188  mDeviceID = mNTV2Card.GetDeviceID ();
189  if (::NTV2DeviceCanDoMultiFormat (mDeviceID))
190  mNTV2Card.SetMultiFormatMode (false);
191 
192  if (!mNTV2Card.IsDeviceReady (false))
193  {
194  qDebug ("Device not ready");
195  msleep (1000); // Keep the UI responsive while waiting for device to become ready
196  }
197  else if (SetupInput ())
198  {
199  NTV2StreamChannel strStatus;
200  NTV2StreamBuffer bfrStatus;
201  ULWord status = 0;
202 
203  gMutex.lock ();
204  if (!mNTV2Card.StreamChannelInitialize (mStream))
205  {
206  qDebug() << "## WARNING: Cannot acquire stream channel " << (int)(mStream);
207  continue;
208  }
209  gMutex.unlock ();
210 
211  // Unlock the old buffers
212  mNTV2Card.DMABufferUnlockAll();
213 
214  // Configure new buffers for streaming
215  for (ULWord i = 0; i < NTV2_NUM_IMAGES; i++)
216  {
217  // Create a new buffer of the correct size
218  buffers[i].Allocate (mFrameDimensions.width () * mFrameDimensions.height () * 4, true);
219 
220  // Prelock and map the buffer
221  if (!mNTV2Card.DMABufferLock(reinterpret_cast<PULWord>(buffers[i].GetHostAddress (0)),
222  buffers[i].GetByteCount(),
223  true))
224  {
225  qDebug() << "## WARNING: Cannot DMA lock input buffer";
226  continue;
227  }
228 
229  // Queue the buffer for streaming capture
230  status = mNTV2Card.StreamBufferQueue(mStream,
231  buffers[i],
232  i,
233  bfrStatus);
234  if (status != NTV2_STREAM_STATUS_SUCCESS)
235  {
236  qDebug() << "## WARNING: Cannot add buffer to stream: " << bfrStatus.mStatus;
237  }
238  }
239 
240  // Now start the stream capture
241  status = mNTV2Card.StreamChannelStart(mStream, strStatus);
242  if (status != NTV2_STREAM_STATUS_SUCCESS)
243  {
244  qDebug() << "## WARNING: Stream start failed: " << bfrStatus.mStatus;
245  }
246 
247  framesCaptured = 0;
248  mRestart = false;
249  } // if board set up ok
250  else
251  {
252  msleep (1000); // This keeps the UI responsive if/while this channel has no input
253  }
254  } // if board opened ok
255  else
256  {
257  qDebug() << "## WARNING: Open failed for device " << GetDeviceIndex ();
258  msleep (200);
259  continue;
260  }
261 
262  emit newStatusString (::NTV2InputSourceToString (mInputSource, true).c_str());
263  } // if mRestart
264 
265  if (CheckForValidInput () == false && NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
266  {
267  QImage currentImage (mFrameDimensions.width (),
268  mFrameDimensions.height (),
269  QImage::Format_RGB32);
270  currentImage.fill (qRgba (40, 40, 40, 255));
271 
272  QString status (QString("%1: No Detected Input").arg(::NTV2InputSourceToString(mInputSource, true).c_str()));
273  emit newStatusString (status);
274  emit newFrame (currentImage, true);
275  msleep (200);
276  continue;
277  }
278 
279  if (mNTV2Card.IsOpen())
280  {
281  NTV2StreamChannel strStatus;
282  NTV2StreamBuffer bfrStatus;
283  ULWord status = 0;
284 
285  // Look for captured buffers
286  status = mNTV2Card.StreamBufferRelease(mStream, bfrStatus);
287  if ((status == NTV2_STREAM_STATUS_SUCCESS) && (bfrStatus.mBufferCookie < NTV2_NUM_IMAGES))
288  {
289  ULWord index = bfrStatus.mBufferCookie;
290 
291  // Update the status string
292  QString outString (::NTV2InputSourceToString (mInputSource, true).c_str());
293  outString.append (" ");
294  outString.append (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
295  emit newStatusString (outString);
296 
297  // Output the new video
298  QImage img = QImage((uchar*)(buffers[index].GetHostAddress (0)),
299  mFrameDimensions.width (),
300  mFrameDimensions.height (),
301  QImage::Format_RGB32);
302 
303  emit newFrame (img, false);
304 
305  // Queue the buffer back to the stream
306  status = mNTV2Card.StreamBufferQueue(mStream,
307  buffers[index],
308  index,
309  bfrStatus);
310  if (status != NTV2_STREAM_STATUS_SUCCESS)
311  {
312  qDebug() << "## WARNING: Cannot add buffer to stream";
313  }
314 
315  framesCaptured++;
316  }
317  else
318  {
319  // Wait for one or more buffers to become available on the device, which should occur at next VBI...
320  status = mNTV2Card.StreamChannelWait(mStream, strStatus);
321  if (status != NTV2_STREAM_STATUS_SUCCESS)
322  {
323  qDebug() << "## WARNING: stream wait failed";
324  break;
325  }
326  }
327  }
328  } // loop til break
329 
330  if (mNTV2Card.IsOpen ())
331  {
332  gMutex.lock ();
333  msleep (1000);
334  if (!mDoMultiChannel)
335  {
336  mNTV2Card.ReleaseStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())); // Release the device
337  mNTV2Card.SetTaskMode (mSavedTaskMode); // Restore prior task mode
338  }
339  mNTV2Card.Close ();
340  mDeviceID = DEVICE_ID_NOTFOUND;
341  gMutex.unlock ();
342  }
343 
344  for (int i = 0; i < NTV2_NUM_IMAGES; i++)
345  {
346  buffers[i].Deallocate();
347  }
348 
349  FGNOTE("Thread completed, will exit for device" << mNTV2Card.GetDisplayName() << " input source " << ::NTV2InputSourceToString(mInputSource));
350 
351 } // run
352 
353 
355 {
356  bool validInput (false);
357 
358  NTV2_ASSERT (mNTV2Card.IsOpen ());
359  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
360 
361  NTV2Channel inputChannel = ::NTV2InputSourceToChannel (mInputSource);
362  if(inputChannel == NTV2_CHANNEL_INVALID)
363  inputChannel = NTV2_CHANNEL1;
364 
365  mCurrentVideoFormat = GetVideoFormatFromInputSource ();
366  mCurrentColorSpace = GetColorSpaceFromInputSource ();
368 
369  if (NTV2_IS_VALID_VIDEO_FORMAT (mCurrentVideoFormat))
370  {
371  validInput = true;
372  switch (mCurrentVideoFormat)
373  {
375  mCurrentVideoFormat = NTV2_FORMAT_1080p_5000_A;
376  break;
378  mCurrentVideoFormat = NTV2_FORMAT_1080p_5994_A;
379  break;
381  mCurrentVideoFormat = NTV2_FORMAT_1080p_6000_A;
382  break;
383  default:
384  break;
385  }
386  mNTV2Card.SetVideoFormat (mCurrentVideoFormat, false, false, mChannel);
388  mNTV2Card.GetVANCMode(vm, mChannel);
389  const NTV2FormatDescriptor fd(mCurrentVideoFormat, mFrameBufferFormat, vm);
390  mFrameDimensions.set (fd.GetRasterWidth(), fd.GetRasterHeight());
391  const QString vfString (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
392  qDebug() << "## DEBUG: mInputSource=" << mChannel << ", mCurrentVideoFormat=" << vfString << ", width=" << mFrameDimensions.width() << ", height=" << mFrameDimensions.height();
393 
394  mFormatIsProgressive = IsProgressivePicture (mCurrentVideoFormat);
395  if (!mbFixedReference)
397 
398  if (NTV2_INPUT_SOURCE_IS_SDI (mInputSource))
399  {
400  if (::NTV2DeviceGetNumCSCs (mDeviceID) > (UWord)mChannel)
401  {
402  mNTV2Card.Connect (::GetCSCInputXptFromChannel (inputChannel), ::GetSDIInputOutputXptFromChannel (inputChannel));
403  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel), ::GetCSCOutputXptFromChannel ((inputChannel), false/*isKey*/, true/*isRGB*/));
404  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
405  }
406  else
407  {
408  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel), ::GetSDIInputOutputXptFromChannel (inputChannel));
409  mNTV2Card.SetFrameBufferFormat (mChannel, NTV2_FBF_8BIT_YCBCR);
410  }
411  mNTV2Card.EnableChannel (mChannel);
412  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
413  mNTV2Card.SetSDIInLevelBtoLevelAConversion (inputChannel, IsInput3Gb (mInputSource) ? true : false);
414  }
415  else if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
416  {
417  if (!mbFixedReference)
418  mNTV2Card.SetReference (::NTV2InputSourceToReferenceSource(mInputSource));
419 
420  {
421  mNTV2Card.EnableChannel (mChannel);
422  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
423  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
424  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
425  {
426  mNTV2Card.Connect (::GetCSCInputXptFromChannel (mChannel),
427  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
428  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel),
429  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
430  }
431  else
432  {
433  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel),
434  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
435  }
436  }
437  }
438  else
439  qDebug () << "## DEBUG: NTV2StreamGrabber::SetupInput: Bad mInputSource switch value " << ::NTV2InputSourceToChannelSpec (mInputSource);
440  } // if video format not unknown
441 
442  return validInput;
443 
444 } // SetupInput
445 
446 
448 {
449  if (mNTV2Card.IsOpen ())
450  {
451  // Release stream ownership
452  mNTV2Card.StreamChannelRelease(mStream);
453  }
454 } // StopStream
455 
456 
458 {
461 
462  switch (videoFormat)
463  {
465  videoFormat = NTV2_FORMAT_1080p_5000_A;
466  break;
468  videoFormat = NTV2_FORMAT_1080p_5994_A;
469  break;
471  videoFormat = NTV2_FORMAT_1080p_6000_A;
472  break;
473  default:
474  break;
475  }
476  if (videoFormat == NTV2_FORMAT_UNKNOWN)
477  {
478  mCurrentVideoFormat = videoFormat;
479  return false;
480  } // if no video or unknown format
481  else if ((mCurrentVideoFormat != videoFormat) ||
482  (mCurrentColorSpace != colorSpace))
483  {
484  if (mDebounceCounter == 0)
485  {
486  // Check to see if the video input has stabilized...
487  mLastVideoFormat = videoFormat;
488  mDebounceCounter++;
489  }
490  else if (mDebounceCounter == 6)
491  {
492  // The new format is stable -- restart autocirculate...
493  mRestart = true;
494  mCurrentVideoFormat = videoFormat;
495  mDebounceCounter = 0;
496  }
497  else
498  {
499  if (mLastVideoFormat == videoFormat)
500  mDebounceCounter++; // New format still stable -- keep counting
501  else
502  mDebounceCounter = 0; // Input changed again -- start over
503  }
504 
505  return true;
506  } // else if video format changed
507  else
508  return true;
509 
510 } // CheckForValidInput
511 
512 
514 {
515  NTV2VideoFormat videoFormat (NTV2_FORMAT_UNKNOWN);
516  NTV2_ASSERT (mNTV2Card.IsOpen ());
517  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
518 
519  switch (mInputSource)
520  {
522  break; // indicates no source is currently selected
523 
524  default:
525  videoFormat = mNTV2Card.GetInputVideoFormat (mInputSource);
526  break;
527  }
528 
529  return videoFormat;
530 
531 } // GetVideoFormatFromInputSource
532 
533 
535 {
536  if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
537  {
539  mNTV2Card.GetHDMIInputColor (hdmiColor, mChannel);
540  return hdmiColor;
541  }
542 
544 }
545 
546 
548 {
549  bool is3Gb (false);
550 
551  mNTV2Card.GetSDIInput3GbPresent (is3Gb, ::NTV2InputSourceToChannel (inputSource));
552 
553  return is3Gb;
554 } // IsInput3Gb
555 
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5047
virtual bool ReleaseStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::ReleaseStreamForApplication useful for process g...
virtual ULWord StreamChannelInitialize(const NTV2Channel inChannel)
Initialize a stream. Put the stream queue and hardware in a known good state ready for use...
Definition: ntv2stream.cpp:11
virtual bool SetTaskMode(const NTV2TaskMode inMode)
Sets the device&#39;s task mode.
virtual ULWord StreamBufferQueue(const NTV2Channel inChannel, NTV2Buffer &inBuffer, ULWord64 bufferCookie, NTV2StreamBuffer &status)
Queue a buffer to the stream. The bufferCookie is a user defined identifier of the buffer used by the...
Definition: ntv2stream.cpp:67
virtual bool GetSDITransmitEnable(const NTV2Channel inChannel, bool &outEnabled)
Answers whether or not the specified SDI connector is currently acting as a transmitter (i...
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...
Header file for the NTV2StreamGrabber class.
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...
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3802
virtual ULWord StreamChannelRelease(const NTV2Channel inChannel)
Release a stream. Releases all buffers remaining in the queue.
Definition: ntv2stream.cpp:19
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.
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
virtual bool IsDeviceReady(const bool inCheckValid=(0))
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
bool IsInput3Gb(const NTV2InputSource inputSource)
ULWord width(void) const
Declares the AJAAncillaryData_Cea608_line21 class.
static uint64_t GetPid()
Definition: process.cpp:35
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
Capture (input) mode, which writes into device SDRAM.
Definition: ntv2enums.h:1243
virtual bool Close(void)
Closes me, releasing host resources that may have been allocated in a previous Open call...
virtual bool GetSDIInput3GbPresent(bool &outValue, const NTV2Channel channel)
virtual bool Open(const UWord inDeviceIndex)
Opens a local/physical AJA device so it can be monitored/controlled.
UWord NTV2DeviceGetNumCSCs(const NTV2DeviceID inDeviceID)
Definition: json.hpp:5362
#define false
uint32_t ULWord
Definition: ajatypes.h:223
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.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
void newFrame(const QImage &inImage, const bool inClear)
This is signaled (called) when a new frame has been captured and is available for display...
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
virtual bool GetHDMIInputColor(NTV2LHIHDMIColorSpace &outValue, const NTV2Channel inHDMIInput=NTV2_CHANNEL1)
Answers with the current colorspace for the given HDMI input.
Definition: ntv2hdmi.cpp:70
bool IsProgressivePicture(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5391
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:476
ULWord height(void) const
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device&#39;s current task mode.
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7377
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
bool Deallocate(void)
Deallocates my user-space storage (if I own it – i.e. from a prior call to Allocate).
#define STREAMPREVIEW_WIDGET_Y
#define true
virtual bool SetMode(const NTV2Channel inChannel, const NTV2Mode inNewValue, const bool inIsRetail=(!(0)))
Determines if a given FrameStore on the AJA device will be used to capture or playout video...
virtual bool IsOpen(void) const
ULWord GetRasterHeight(const bool inVisibleOnly=false) const
Invalid or "not found".
Definition: ntv2enums.h:98
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1281
NTV2VideoFormat GetVideoFormatFromInputSource(void)
NTV2Crosspoint NTV2InputSourceToChannelSpec(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Crosspoint value.
Definition: ntv2utils.cpp:4999
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 bool GetVANCMode(NTV2VANCMode &outVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Retrieves the current VANC mode for the given FrameStore.
virtual std::string GetDisplayName(void)
Answers with this device&#39;s display name.
Definition: ntv2card.cpp:88
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
virtual ULWord StreamBufferRelease(const NTV2Channel inChannel, NTV2StreamBuffer &status)
Remove the oldest buffer released by the streaming engine from the buffer queue.
Definition: ntv2stream.cpp:77
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...
2: OEM (recommended): device configured by client application(s) with some driver involvement...
virtual ULWord StreamChannelStart(const NTV2Channel inChannel, NTV2StreamChannel &status)
Start a stream. Put the stream is the active state to start processing queued buffers. For frame based video, the stream will start with the current buffer on the next frame sync.
Definition: ntv2stream.cpp:27
virtual ~NTV2StreamGrabber()
My destructor.
NTV2InputXptID GetFrameStoreInputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsBInput=false)
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6746
static QMutex gMutex
bool NTV2DeviceHasBiDirectionalSDI(const NTV2DeviceID inDeviceID)
bool SetupInput(void)
Configures my AJA device for capture.
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:224
virtual bool AcquireStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::AcquireStreamForApplication useful for process g...
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
Definition: ntv2dma.cpp:457
#define STREAMPREVIEW_WIDGET_X
Specifies channel or FrameStore 2 (or the 2nd item).
Definition: ntv2enums.h:1360
virtual NTV2DeviceID GetDeviceID(void)
UWord NTV2DeviceGetNumVideoInputs(const NTV2DeviceID inDeviceID)
#define FGNOTE(_expr_)
Declares the CNTV2DeviceScanner class.
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=(0))
Connects the given widget signal input (sink) to the given widget signal output (source).
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1262
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
virtual ULWord StreamChannelWait(const NTV2Channel inChannel, NTV2StreamChannel &status)
Wait for any stream event. Returns for any state or buffer change.
Definition: ntv2stream.cpp:59
void StopStream(void)
Stops capturing.
virtual void run(void)
My thread function.
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1284
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.
uint16_t UWord
Definition: ajatypes.h:221
ULWord GetRasterWidth(void) const
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1359
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3797
virtual bool SetSDIInLevelBtoLevelAConversion(const NTV2ChannelSet &inSDIInputs, const bool inEnable)
Enables or disables 3G level B to 3G level A conversion at the SDI input(s).
#define NTV2_STREAM_STATUS_SUCCESS
Used in NTV2Stream success.
ULWord mStatus
Action status.
This file contains some structures, constants, classes and functions that are used in some of the dem...
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:725
UWord GetDeviceIndex(void) const
NTV2OutputXptID GetSDIInputOutputXptFromChannel(const NTV2Channel inSDIInput, const bool inIsDS2=false)
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1283
Declares the AJAAncillaryList class.
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
NTV2FrameSize & set(const ULWord inWidth, const ULWord inHeight)
Sets my dimension values.
#define NTV2_NUM_IMAGES
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
ULWord64 mBufferCookie
Buffer User cookie.
Declares device capability functions.
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3678
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5023
NTV2StreamGrabber(QObject *pInParentObject=NULL)
Constructs me.
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:223
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.