AJA NTV2 SDK  18.1.0.2262
NTV2 SDK 18.1.0.2262
ntv2streamgrabber.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "ntv2streamgrabber.h"
8 #include "ntv2democommon.h"
9 #include "ntv2utils.h"
10 #include "ajabase/system/process.h"
11 
12 #define NTV2_NUM_IMAGES (10)
13 
14 // Convenience macros for EZ logging:
15 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
16 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
17 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
18 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
19 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
20 
21 static QMutex gMutex;
22 
23 
25  : QThread (parent),
26  mRestart (true),
27  mAbort (false),
28  mbFixedReference (false),
29  mBoardNumber (0),
30  mDeviceID (DEVICE_ID_NOTFOUND),
31  mChannel (NTV2_CHANNEL1),
32  mStream (NTV2_CHANNEL2),
33  mCurrentVideoFormat (NTV2_FORMAT_UNKNOWN),
34  mCurrentColorSpace (NTV2_LHIHDMIColorSpaceYCbCr),
35  mLastVideoFormat (NTV2_FORMAT_UNKNOWN),
36  mDebounceCounter (0),
37  mFormatIsProgressive (true),
38  mInputSource (NTV2_NUM_INPUTSOURCES),
39  mFrameBufferFormat (NTV2_FBF_ARGB),
40  mDoMultiChannel (false)
41 {
42 
43 } // constructor
44 
45 
47 {
48  mAbort = true;
49  while (isRunning ())
50  ; // Wait for grabber thread to finish
51 
52  StopStream ();
53 
54 } // destructor
55 
56 
58 {
59  if (inInputSource != mInputSource)
60  {
61  qDebug() << "## DEBUG: NTV2StreamGrabber::SetInputSource" << ::NTV2InputSourceToString (inInputSource).c_str ();
62  gMutex.lock ();
63  mInputSource = inInputSource;
64  mRestart = true;
65  gMutex.unlock ();
66  }
67 
68 } // SetInputSource
69 
70 
71 void NTV2StreamGrabber::SetDeviceIndex (const UWord inDeviceIndex)
72 {
73  if (inDeviceIndex != mBoardNumber)
74  {
75  gMutex.lock ();
76  mBoardNumber = inDeviceIndex;
77  mRestart = true;
78  gMutex.unlock ();
79  }
80 } // SetDeviceIndex
81 
82 
84 {
85  gMutex.lock ();
86  const UWord result (mBoardNumber);
87  gMutex.unlock ();
88  return result;
89 }
90 
91 
93 {
94  // Set up 2 images to ping-pong between capture and display...
95  NTV2Buffer buffers[NTV2_NUM_IMAGES];
96  ULWord framesCaptured (0);
97  FGNOTE("Thread started");
98 
99  // Make sure all Bidirectionals are set to Inputs.
100  if (mNTV2Card.Open(mBoardNumber))
101  {
102  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
103  {
104  // We have not acquired the board continue until something changes...
105  qDebug ("Could not acquire board number %d", GetDeviceIndex());
106  mNTV2Card.Close ();
107  mDeviceID = DEVICE_ID_NOTFOUND;
108  }
109  else
110  {
111  mNTV2Card.GetTaskMode (mSavedTaskMode); // Save the current state before we change it
112  mNTV2Card.SetTaskMode (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
113  }
114  }
115 
116  while (true)
117  {
118  if (mAbort)
119  break;
120 
121  if (!NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
122  {
123  // No input chosen, so display banner...
124  QImage currentImage (STREAMPREVIEW_WIDGET_X, STREAMPREVIEW_WIDGET_Y, QImage::Format_RGB32);
125  currentImage.load (":/resources/splash.png");
126  emit newStatusString ("");
127  emit newFrame (currentImage, true);
128  if (::NTV2DeviceHasBiDirectionalSDI (mNTV2Card.GetDeviceID())) // If device has bidirectional SDI connectors...
129  {
130  bool waitForInput = false;
131  UWord numInputs = NTV2DeviceGetNumVideoInputs(mNTV2Card.GetDeviceID());
132  for (UWord offset = 0; offset < numInputs; offset++)
133  {
134  bool outputEnabled;
135  mNTV2Card.GetSDITransmitEnable (NTV2Channel(offset), outputEnabled);
136  if (outputEnabled)
137  {
138  waitForInput = true;
139  mNTV2Card.SetSDITransmitEnable (NTV2Channel(offset), false);
140  }
141  }
142  // Only if we had to change an output to input do we need to wait.
143  if (waitForInput)
144  msleep(500);
145  }
146  msleep(200);
147  continue;
148  }
149 
150  if (mRestart)
151  {
152  gMutex.lock ();
153  if (mNTV2Card.IsOpen ())
154  {
155  StopStream();
156  if (!mDoMultiChannel)
157  {
159  mNTV2Card.SetTaskMode (mSavedTaskMode);
160  }
161  mNTV2Card.Close ();
162  mDeviceID = DEVICE_ID_NOTFOUND;
163  }
164  gMutex.unlock ();
165 
166  if (mNTV2Card.Open(mBoardNumber))
167  {
168  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
169  {
170  //We have not acquired the board continue until something changes
171  qDebug() << "Could not acquire board number " << GetDeviceIndex();
172  msleep (1000);
173  mNTV2Card.Close ();
174  mDeviceID = DEVICE_ID_NOTFOUND;
175  continue;
176  }
177 
178  mNTV2Card.GetTaskMode (mSavedTaskMode); // Save the current state before we change it
179  mNTV2Card.SetTaskMode (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
180 
181  mDeviceID = mNTV2Card.GetDeviceID ();
182  if (::NTV2DeviceCanDoMultiFormat (mDeviceID))
183  mNTV2Card.SetMultiFormatMode (false);
184 
185  if (!mNTV2Card.IsDeviceReady (false))
186  {
187  qDebug ("Device not ready");
188  msleep (1000); // Keep the UI responsive while waiting for device to become ready
189  }
190  else if (SetupInput ())
191  {
192  NTV2StreamChannel strStatus;
193  NTV2StreamBuffer bfrStatus;
194  ULWord status = 0;
195 
196  gMutex.lock ();
197  if (!mNTV2Card.StreamChannelInitialize (mStream))
198  {
199  qDebug() << "## WARNING: Cannot acquire stream channel " << (int)(mStream);
200  continue;
201  }
202  gMutex.unlock ();
203 
204  // Unlock the old buffers
205  mNTV2Card.DMABufferUnlockAll();
206 
207  // Configure new buffers for streaming
208  for (ULWord i = 0; i < NTV2_NUM_IMAGES; i++)
209  {
210  // Create a new buffer of the correct size
211  buffers[i].Allocate (mFrameDimensions.width () * mFrameDimensions.height () * 4, true);
212 
213  // Prelock and map the buffer
214  if (!mNTV2Card.DMABufferLock(reinterpret_cast<PULWord>(buffers[i].GetHostAddress (0)),
215  ULWord(buffers[i].GetByteCount()),
216  true))
217  {
218  qDebug() << "## WARNING: Cannot DMA lock input buffer";
219  continue;
220  }
221 
222  // Queue the buffer for streaming capture
223  status = mNTV2Card.StreamBufferQueue(mStream,
224  buffers[i],
225  i,
226  bfrStatus);
227  if (status != NTV2_STREAM_STATUS_SUCCESS)
228  {
229  qDebug() << "## WARNING: Cannot add buffer to stream: " << bfrStatus.mStatus;
230  }
231  }
232 
233  // Now start the stream capture
234  status = mNTV2Card.StreamChannelStart(mStream, strStatus);
235  if (status != NTV2_STREAM_STATUS_SUCCESS)
236  {
237  qDebug() << "## WARNING: Stream start failed: " << bfrStatus.mStatus;
238  }
239 
240  framesCaptured = 0;
241  mRestart = false;
242  } // if board set up ok
243  else
244  {
245  msleep (1000); // This keeps the UI responsive if/while this channel has no input
246  }
247  } // if board opened ok
248  else
249  {
250  qDebug() << "## WARNING: Open failed for device " << GetDeviceIndex ();
251  msleep (200);
252  continue;
253  }
254 
255  emit newStatusString (::NTV2InputSourceToString (mInputSource, true).c_str());
256  } // if mRestart
257 
258  if (CheckForValidInput () == false && NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
259  {
260  QImage currentImage (mFrameDimensions.width (),
261  mFrameDimensions.height (),
262  QImage::Format_RGB32);
263  currentImage.fill (qRgba (40, 40, 40, 255));
264 
265  QString status (QString("%1: No Detected Input").arg(::NTV2InputSourceToString(mInputSource, true).c_str()));
266  emit newStatusString (status);
267  emit newFrame (currentImage, true);
268  msleep (200);
269  continue;
270  }
271 
272  if (mNTV2Card.IsOpen())
273  {
274  NTV2StreamChannel strStatus;
275  NTV2StreamBuffer bfrStatus;
276  ULWord status = 0;
277 
278  // Look for captured buffers
279  status = mNTV2Card.StreamBufferRelease(mStream, bfrStatus);
280  if ((status == NTV2_STREAM_STATUS_SUCCESS) && (bfrStatus.mBufferCookie < NTV2_NUM_IMAGES))
281  {
282  ULWord index = bfrStatus.mBufferCookie;
283 
284  // Update the status string
285  QString outString (::NTV2InputSourceToString (mInputSource, true).c_str());
286  outString.append (" ");
287  outString.append (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
288  emit newStatusString (outString);
289 
290  // Output the new video
291  QImage img = QImage((uchar*)(buffers[index].GetHostAddress (0)),
292  mFrameDimensions.width (),
293  mFrameDimensions.height (),
294  QImage::Format_RGB32);
295 
296  emit newFrame (img, false);
297 
298  // Queue the buffer back to the stream
299  status = mNTV2Card.StreamBufferQueue(mStream,
300  buffers[index],
301  index,
302  bfrStatus);
303  if (status != NTV2_STREAM_STATUS_SUCCESS)
304  {
305  qDebug() << "## WARNING: Cannot add buffer to stream";
306  }
307 
308  framesCaptured++;
309  }
310  else
311  {
312  // Wait for one or more buffers to become available on the device, which should occur at next VBI...
313  status = mNTV2Card.StreamChannelWait(mStream, strStatus);
314  if (status != NTV2_STREAM_STATUS_SUCCESS)
315  {
316  qDebug() << "## WARNING: stream wait failed";
317  break;
318  }
319  }
320  }
321  } // loop til break
322 
323  if (mNTV2Card.IsOpen ())
324  {
325  gMutex.lock ();
326  msleep (1000);
327  if (!mDoMultiChannel)
328  {
329  mNTV2Card.ReleaseStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())); // Release the device
330  mNTV2Card.SetTaskMode (mSavedTaskMode); // Restore prior task mode
331  }
332  mNTV2Card.Close ();
333  mDeviceID = DEVICE_ID_NOTFOUND;
334  gMutex.unlock ();
335  }
336 
337  for (int i = 0; i < NTV2_NUM_IMAGES; i++)
338  {
339  buffers[i].Deallocate();
340  }
341 
342  FGNOTE("Thread completed, will exit for device" << mNTV2Card.GetDisplayName() << " input source " << ::NTV2InputSourceToString(mInputSource));
343 
344 } // run
345 
346 
348 {
349  bool validInput (false);
350 
351  NTV2_ASSERT (mNTV2Card.IsOpen ());
352  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
353 
354  NTV2Channel inputChannel = ::NTV2InputSourceToChannel (mInputSource);
355  if(inputChannel == NTV2_CHANNEL_INVALID)
356  inputChannel = NTV2_CHANNEL1;
357 
358  mCurrentVideoFormat = GetVideoFormatFromInputSource ();
359  mCurrentColorSpace = GetColorSpaceFromInputSource ();
361 
362  if (NTV2_IS_VALID_VIDEO_FORMAT (mCurrentVideoFormat))
363  {
364  validInput = true;
365  switch (mCurrentVideoFormat)
366  {
368  mCurrentVideoFormat = NTV2_FORMAT_1080p_5000_A;
369  break;
371  mCurrentVideoFormat = NTV2_FORMAT_1080p_5994_A;
372  break;
374  mCurrentVideoFormat = NTV2_FORMAT_1080p_6000_A;
375  break;
376  default:
377  break;
378  }
379  mNTV2Card.SetVideoFormat (mCurrentVideoFormat, false, false, mChannel);
381  mNTV2Card.GetVANCMode(vm, mChannel);
382  const NTV2FormatDescriptor fd(mCurrentVideoFormat, mFrameBufferFormat, vm);
383  mFrameDimensions.set (fd.GetRasterWidth(), fd.GetRasterHeight());
384  const QString vfString (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
385  qDebug() << "## DEBUG: mInputSource=" << mChannel << ", mCurrentVideoFormat=" << vfString << ", width=" << mFrameDimensions.width() << ", height=" << mFrameDimensions.height();
386 
387  mFormatIsProgressive = IsProgressivePicture (mCurrentVideoFormat);
388  if (!mbFixedReference)
390 
391  if (NTV2_INPUT_SOURCE_IS_SDI (mInputSource))
392  {
393  if (::NTV2DeviceGetNumCSCs (mDeviceID) > (UWord)mChannel)
394  {
395  mNTV2Card.Connect (::GetCSCInputXptFromChannel (inputChannel), ::GetSDIInputOutputXptFromChannel (inputChannel));
396  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel), ::GetCSCOutputXptFromChannel ((inputChannel), false/*isKey*/, true/*isRGB*/));
397  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
398  }
399  else
400  {
401  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel), ::GetSDIInputOutputXptFromChannel (inputChannel));
402  mNTV2Card.SetFrameBufferFormat (mChannel, NTV2_FBF_8BIT_YCBCR);
403  }
404  mNTV2Card.EnableChannel (mChannel);
405  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
406  mNTV2Card.SetSDIInLevelBtoLevelAConversion (inputChannel, IsInput3Gb (mInputSource) ? true : false);
407  }
408  else if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
409  {
410  if (!mbFixedReference)
411  mNTV2Card.SetReference (::NTV2InputSourceToReferenceSource(mInputSource));
412 
413  {
414  mNTV2Card.EnableChannel (mChannel);
415  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
416  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
417  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
418  {
419  mNTV2Card.Connect (::GetCSCInputXptFromChannel (mChannel),
420  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
421  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel),
422  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
423  }
424  else
425  {
426  mNTV2Card.Connect (::GetFrameStoreInputXptFromChannel (mChannel),
427  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
428  }
429  }
430  }
431  else
432  qDebug () << "## DEBUG: NTV2StreamGrabber::SetupInput: Bad mInputSource switch value " << ::NTV2InputSourceToChannelSpec (mInputSource);
433  } // if video format not unknown
434 
435  return validInput;
436 
437 } // SetupInput
438 
439 
441 {
442  if (mNTV2Card.IsOpen ())
443  {
444  // Release stream ownership
445  mNTV2Card.StreamChannelRelease(mStream);
446  }
447 } // StopStream
448 
449 
451 {
454 
455  switch (videoFormat)
456  {
458  videoFormat = NTV2_FORMAT_1080p_5000_A;
459  break;
461  videoFormat = NTV2_FORMAT_1080p_5994_A;
462  break;
464  videoFormat = NTV2_FORMAT_1080p_6000_A;
465  break;
466  default:
467  break;
468  }
469  if (videoFormat == NTV2_FORMAT_UNKNOWN)
470  {
471  mCurrentVideoFormat = videoFormat;
472  return false;
473  } // if no video or unknown format
474  else if ((mCurrentVideoFormat != videoFormat) ||
475  (mCurrentColorSpace != colorSpace))
476  {
477  if (mDebounceCounter == 0)
478  {
479  // Check to see if the video input has stabilized...
480  mLastVideoFormat = videoFormat;
481  mDebounceCounter++;
482  }
483  else if (mDebounceCounter == 6)
484  {
485  // The new format is stable -- restart autocirculate...
486  mRestart = true;
487  mCurrentVideoFormat = videoFormat;
488  mDebounceCounter = 0;
489  }
490  else
491  {
492  if (mLastVideoFormat == videoFormat)
493  mDebounceCounter++; // New format still stable -- keep counting
494  else
495  mDebounceCounter = 0; // Input changed again -- start over
496  }
497 
498  return true;
499  } // else if video format changed
500  else
501  return true;
502 
503 } // CheckForValidInput
504 
505 
507 {
508  NTV2VideoFormat videoFormat (NTV2_FORMAT_UNKNOWN);
509  NTV2_ASSERT (mNTV2Card.IsOpen ());
510  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
511 
512  switch (mInputSource)
513  {
515  break; // indicates no source is currently selected
516 
517  default:
518  videoFormat = mNTV2Card.GetInputVideoFormat (mInputSource);
519  break;
520  }
521 
522  return videoFormat;
523 
524 } // GetVideoFormatFromInputSource
525 
526 
528 {
529  if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
530  {
532  mNTV2Card.GetHDMIInputColor (hdmiColor, mChannel);
533  return hdmiColor;
534  }
535 
537 }
538 
539 
541 {
542  bool is3Gb (false);
543 
544  mNTV2Card.GetSDIInput3GbPresent (is3Gb, ::NTV2InputSourceToChannel (inputSource));
545 
546  return is3Gb;
547 } // IsInput3Gb
548 
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5050
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:1462
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:3805
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
static uint64_t GetPid()
Definition: process.cpp:35
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
Capture (input) mode, which writes into device SDRAM.
Definition: ntv2enums.h:1245
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)
#define false
uint32_t ULWord
Definition: ajatypes.h:236
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:1359
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:5394
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:489
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:7042
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:100
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:1283
NTV2VideoFormat GetVideoFormatFromInputSource(void)
NTV2Crosspoint NTV2InputSourceToChannelSpec(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Crosspoint value.
Definition: ntv2utils.cpp:5002
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:6749
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:226
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:1362
virtual NTV2DeviceID GetDeviceID(void)
UWord NTV2DeviceGetNumVideoInputs(const NTV2DeviceID inDeviceID)
#define FGNOTE(_expr_)
Declares the AJAProcess 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:1264
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:1286
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:234
ULWord GetRasterWidth(void) const
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1361
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:3800
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:727
UWord GetDeviceIndex(void) const
NTV2OutputXptID GetSDIInputOutputXptFromChannel(const NTV2Channel inSDIInput, const bool inIsDS2=false)
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1285
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.
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3681
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5026
NTV2StreamGrabber(QObject *pInParentObject=NULL)
Constructs me.
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:225
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.