AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
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.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
119  mNTV2Card.SetEveryFrameServices (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.SetEveryFrameServices (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.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
186  mNTV2Card.SetEveryFrameServices (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.SetEveryFrameServices (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 (::GetFrameBufferInputXptFromChannel (mChannel), ::GetCSCOutputXptFromChannel ((inputChannel), false/*isKey*/, true/*isRGB*/));
404  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
405  }
406  else
407  {
408  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (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 (::GetFrameBufferInputXptFromChannel (mChannel),
429  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
430  }
431  else
432  {
433  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (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 
NTV2StreamGrabber::newStatusString
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
CNTV2Card::SetSDIInLevelBtoLevelAConversion
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).
Definition: ntv2register.cpp:4283
CNTV2Card::StreamBufferQueue
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
NTV2InputSourceToReferenceSource
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5081
ntv2streamgrabber.h
Header file for the NTV2StreamGrabber class.
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
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5105
NTV2_FBF_ARGB
@ NTV2_FBF_ARGB
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:212
GetSDIInputOutputXptFromChannel
NTV2OutputXptID GetSDIInputOutputXptFromChannel(const NTV2Channel inSDIInput, const bool inIsDS2=false)
Definition: ntv2signalrouter.cpp:893
NTV2StreamBuffer::mBufferCookie
ULWord64 mBufferCookie
Buffer User cookie.
Definition: ntv2publicinterface.h:8738
NTV2StreamChannel
Definition: ntv2publicinterface.h:8669
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or Frame Store 2 (or the 2nd item).
Definition: ntv2enums.h:1308
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
ancillarydata_cea608_line21.h
Declares the AJAAncillaryData_Cea608_line21 class.
ntv2devicefeatures.h
Declares device capability functions.
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3597
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1305
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:5993
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6066
NTV2_ASSERT
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:506
NTV2Buffer::Deallocate
bool Deallocate(void)
Deallocates my user-space storage (if I own it – i.e. from a prior call to Allocate).
Definition: ntv2publicinterface.cpp:1664
ancillarylist.h
Declares the AJAAncillaryList class.
NTV2DeviceCanDoMultiFormat
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:4065
GetFrameBufferInputXptFromChannel
NTV2InputXptID GetFrameBufferInputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsBInput=false)
Definition: ntv2signalrouter.cpp:762
NTV2FormatDescriptor::GetRasterHeight
ULWord GetRasterHeight(const bool inVisibleOnly=false) const
Definition: ntv2formatdescriptor.h:170
NTV2StreamGrabber::SetupInput
bool SetupInput(void)
Configures my AJA device for capture.
Definition: ntv2streamgrabber.cpp:354
NTV2Buffer::Allocate
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
Definition: ntv2publicinterface.cpp:1630
NTV2DeviceGetNumCSCs
UWord NTV2DeviceGetNumCSCs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10042
CNTV2Card::StreamChannelRelease
virtual ULWord StreamChannelRelease(const NTV2Channel inChannel)
Release a stream. Releases all buffers remaining in the queue.
Definition: ntv2stream.cpp:19
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3600
CNTV2Card::GetVANCMode
virtual bool GetVANCMode(NTV2VANCMode &outVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Retrieves the current VANC mode for the given FrameStore.
Definition: ntv2register.cpp:2728
PULWord
uint32_t * PULWord
Definition: ajatypes.h:254
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=(!(0)), NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1812
CNTV2Card::SetSDITransmitEnable
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
Definition: ntv2register.cpp:3796
CNTV2Card::GetSDITransmitEnable
virtual bool GetSDITransmitEnable(const NTV2Channel inChannel, bool &outEnabled)
Answers whether or not the specified SDI connector is currently acting as a transmitter (i....
Definition: ntv2register.cpp:3817
NTV2StreamGrabber::run
virtual void run(void)
My thread function.
Definition: ntv2streamgrabber.cpp:99
NTV2_CHANNEL_INVALID
@ NTV2_CHANNEL_INVALID
Definition: ntv2enums.h:1316
NTV2FrameDimensions::Set
NTV2FrameDimensions & Set(const ULWord inWidth, const ULWord inHeight)
Sets my dimension values.
Definition: ntv2publicinterface.h:5694
IsProgressivePicture
bool IsProgressivePicture(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5423
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::DMABufferUnlockAll
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
Definition: ntv2dma.cpp:457
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:86
NTV2InputSourceToChannelSpec
NTV2Crosspoint NTV2InputSourceToChannelSpec(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Crosspoint value.
Definition: ntv2utils.cpp:5057
NTV2StreamGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2streamgrabber.cpp:534
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7215
NTV2_FORMAT_1080p_5994_B
@ NTV2_FORMAT_1080p_5994_B
Definition: ntv2enums.h:529
ULWord
uint32_t ULWord
Definition: ajatypes.h:253
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
CNTV2Card::StreamChannelStart
virtual ULWord StreamChannelStart(const NTV2Channel inChannel, NTV2StreamChannel &status)
Start a stream. Put the stream is the active state to start processing queued buffers....
Definition: ntv2stream.cpp:27
gMutex
static QMutex gMutex
Definition: ntv2streamgrabber.cpp:28
NTV2DeviceHasBiDirectionalSDI
bool NTV2DeviceHasBiDirectionalSDI(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:6454
CNTV2Card::SetMode
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.
Definition: ntv2register.cpp:1607
GetCSCOutputXptFromChannel
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
Definition: ntv2signalrouter.cpp:819
AJAProcess::GetPid
static uint64_t GetPid()
Definition: process.cpp:35
FGNOTE
#define FGNOTE(_expr_)
Definition: ntv2streamgrabber.cpp:25
NTV2DeviceGetNumVideoInputs
UWord NTV2DeviceGetNumVideoInputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:11923
UWord
uint16_t UWord
Definition: ajatypes.h:251
NTV2_IS_VALID_INPUT_SOURCE
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1243
NTV2_FBF_8BIT_YCBCR
@ NTV2_FBF_8BIT_YCBCR
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:211
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1404
ntv2utils.h
Declares numerous NTV2 utility functions.
NTV2_FORMAT_1080p_5000_B
@ NTV2_FORMAT_1080p_5000_B
Definition: ntv2enums.h:528
NTV2StreamGrabber::newFrame
void newFrame(const QImage &inImage, const bool inClear)
This is signaled (called) when a new frame has been captured and is available for display.
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1240
GetCSCInputXptFromChannel
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
Definition: ntv2signalrouter.cpp:775
CNTV2Card::StreamBufferRelease
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
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1284
NTV2StreamGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2streamgrabber.cpp:90
NTV2_NUM_INPUTSOURCES
@ NTV2_NUM_INPUTSOURCES
Definition: ntv2enums.h:1237
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
NTV2_FORMAT_1080p_6000_A
@ NTV2_FORMAT_1080p_6000_A
Definition: ntv2enums.h:535
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
NTV2VANCMode
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3716
NTV2_VANCMODE_INVALID
@ NTV2_VANCMODE_INVALID
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3721
NTV2Buffer::GetHostAddress
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
Definition: ntv2publicinterface.cpp:1686
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1221
NTV2StreamGrabber::SetInputSource
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
Definition: ntv2streamgrabber.cpp:64
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
CNTV2Card::Connect
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).
Definition: ntv2regroute.cpp:87
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3599
CNTV2Card::StreamChannelWait
virtual ULWord StreamChannelWait(const NTV2Channel inChannel, NTV2StreamChannel &status)
Wait for any stream event. Returns for any state or buffer change.
Definition: ntv2stream.cpp:59
false
#define false
Definition: ntv2devicefeatures.h:25
ntv2democommon.h
This file contains some structures, constants, classes and functions that are used in some of the dem...
NTV2StreamGrabber::~NTV2StreamGrabber
virtual ~NTV2StreamGrabber()
My destructor.
Definition: ntv2streamgrabber.cpp:53
NTV2StreamGrabber::NTV2StreamGrabber
NTV2StreamGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2streamgrabber.cpp:31
NTV2_MODE_CAPTURE
@ NTV2_MODE_CAPTURE
Capture (input) mode, which writes into device SDRAM.
Definition: ntv2enums.h:1202
std
Definition: json.hpp:5362
NTV2StreamGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2streamgrabber.cpp:513
NTV2_FORMAT_1080p_5000_A
@ NTV2_FORMAT_1080p_5000_A
Definition: ntv2enums.h:533
CNTV2MacDriverInterface::AcquireStreamForApplicationWithReference
virtual bool AcquireStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::AcquireStreamForApplication useful for process g...
Definition: ntv2macdriverinterface.cpp:551
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
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
NTV2_FORMAT_1080p_6000_B
@ NTV2_FORMAT_1080p_6000_B
Definition: ntv2enums.h:530
STREAMPREVIEW_WIDGET_Y
#define STREAMPREVIEW_WIDGET_Y
Definition: ntv2streamgrabber.h:31
true
#define true
Definition: ntv2devicefeatures.h:26
NTV2_STREAM_STATUS_SUCCESS
#define NTV2_STREAM_STATUS_SUCCESS
Used in NTV2Stream success.
Definition: ntv2publicinterface.h:8660
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:381
CNTV2Card::StreamChannelInitialize
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
NTV2_FORMAT_1080p_5994_A
@ NTV2_FORMAT_1080p_5994_A
Definition: ntv2enums.h:534
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
GetInputSourceOutputXpt
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
Definition: ntv2signalrouter.cpp:865
NTV2_INPUT_SOURCE_IS_SDI
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1242
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
NTV2StreamGrabber::IsInput3Gb
bool IsInput3Gb(const NTV2InputSource inputSource)
Definition: ntv2streamgrabber.cpp:547
NTV2StreamGrabber::StopStream
void StopStream(void)
Stops capturing.
Definition: ntv2streamgrabber.cpp:447
CNTV2MacDriverInterface::ReleaseStreamForApplicationWithReference
virtual bool ReleaseStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::ReleaseStreamForApplication useful for process g...
Definition: ntv2macdriverinterface.cpp:589
NTV2StreamGrabber::CheckForValidInput
bool CheckForValidInput(void)
Definition: ntv2streamgrabber.cpp:457
NTV2StreamBuffer
Definition: ntv2publicinterface.h:8729
NTV2StreamBuffer::mStatus
ULWord mStatus
Action status.
Definition: ntv2publicinterface.h:8733
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2097
CNTV2DriverInterface::Open
virtual bool Open(const UWord inDeviceIndex)
Opens a local/physical AJA device so it can be monitored/controlled.
Definition: ntv2driverinterface.cpp:131
DEVICE_ID_NOTFOUND
@ DEVICE_ID_NOTFOUND
Invalid or "not found".
Definition: ntv2enums.h:90
CNTV2Card::GetSDIInput3GbPresent
virtual bool GetSDIInput3GbPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3614
NTV2_NUM_IMAGES
#define NTV2_NUM_IMAGES
Definition: ntv2streamgrabber.cpp:19
NTV2_IS_VALID_VIDEO_FORMAT
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:688
CNTV2DriverInterface::Close
virtual bool Close(void)
Closes me, releasing host resources that may have been allocated in a previous Open call.
Definition: ntv2driverinterface.cpp:199
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM: Device is configured by controlling application(s), with minimal driver involvement.
Definition: ntv2publicinterface.h:4292
NTV2StreamGrabber::SetDeviceIndex
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
Definition: ntv2streamgrabber.cpp:78
STREAMPREVIEW_WIDGET_X
#define STREAMPREVIEW_WIDGET_X
Definition: ntv2streamgrabber.h:30