AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
ntv2framegrabber.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include <ostream>
8 #include "ntv2framegrabber.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  mCheckFor4K (false),
36  mDeinterlace (true),
37  mbFixedReference (false),
38  mBoardNumber (0),
39  mDeviceID (DEVICE_ID_NOTFOUND),
40  mChannel (NTV2_MAX_NUM_CHANNELS),
41  mNumChannels (0),
42  mTsi (false),
43  mCurrentVideoFormat (NTV2_FORMAT_UNKNOWN),
44  mCurrentColorSpace (NTV2_LHIHDMIColorSpaceYCbCr),
45  mLastVideoFormat (NTV2_FORMAT_UNKNOWN),
46  mDebounceCounter (0),
47  mFormatIsProgressive (true),
48  mInputSource (NTV2_NUM_INPUTSOURCES),
49  mFrameBufferFormat (NTV2_FBF_ARGB),
50  mDoMultiChannel (false),
51  mbWithAudio (false),
52  mAudioOutput (AJA_NULL),
53  mAudioDevice (AJA_NULL),
54  mNumAudioChannels (0),
55  mAudioSystem (NTV2_AUDIOSYSTEM_1),
56  mTimeCodeSource (NTV2_TCINDEX_INVALID)
57 {
59 
60 } // constructor
61 
62 
64 {
65  mAbort = true;
66  while (isRunning ())
67  ; // Wait for grabber thread to finish
68 
70 
71  if (mAudioOutput)
72  delete mAudioOutput;
73 
74 } // destructor
75 
76 
78 {
79  if (inInputSource != mInputSource)
80  {
81  qDebug() << "## DEBUG: NTV2FrameGrabber::SetInputSource" << ::NTV2InputSourceToString (inInputSource).c_str ();
82  gMutex.lock ();
83  mInputSource = inInputSource;
84  mRestart = true;
85  gMutex.unlock ();
86  }
87 
88 } // SetInputSource
89 
90 
91 void NTV2FrameGrabber::SetDeviceIndex (const UWord inDeviceIndex)
92 {
93  if (inDeviceIndex != mBoardNumber)
94  {
95  gMutex.lock ();
96  mBoardNumber = inDeviceIndex;
97  mRestart = true;
98  gMutex.unlock ();
99  }
100 } // SetDeviceIndex
101 
102 
104 {
105  if (inTCIndex != mTimeCodeSource)
106  {
107  gMutex.lock ();
108  mTimeCodeSource = inTCIndex;
109  mRestart = true;
110  gMutex.unlock ();
111  }
112 } // SetTimeCodeSource
113 
114 
116 {
117  gMutex.lock ();
118  const UWord result (mBoardNumber);
119  gMutex.unlock ();
120  return result;
121 }
122 
123 
124 #if defined (INCLUDE_AJACC)
125  #if 0
126  static const UWord gTest [15][32] =
127  // 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
128  // 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
129  /*01*/ {{0x250C, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
130  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2510},
131  /*02*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
132  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
133  /*03*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
134  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
135  /*04*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
136  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
137  /*05*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
138  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
139  /*06*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
140  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
141  /*07*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
142  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
143  /*08*/ {0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
144  0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
145  /*09*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
146  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
147  /*10*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
148  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
149  /*11*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
150  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
151  /*12*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
152  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
153  /*13*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
154  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
155  /*14*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
156  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
157  /*15*/ {0x2514, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
158  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2518}};
159  #endif // 0
160 #endif // defined (INCLUDE_AJACC)
161 
162 
163 void NTV2FrameGrabber::ClearCaptionBuffer (const bool inNotifyClients)
164 {
165  #if defined (INCLUDE_AJACC)
166  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
167  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
168  mScreenBuffer [row-1][col-1] = 0x0020; // gTest[row-1][col-1];
169  if (inNotifyClients)
170  emit captionScreenChanged (&mScreenBuffer[0][0]);
171  #else
172  (void) inNotifyClients;
173  #endif
174 }
175 
176 
178 {
179  #if defined (INCLUDE_AJACC)
180  NTV2_ASSERT (mNTV2Card.IsOpen ());
181  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
182 
183  if (mNTV2Card.features().CanDoCustomAnc())
184  {
185  bool gotCaptionPacket (false);
186  CaptionData captionData; // The two byte pairs (one pair per field) our 608 decoder is looking for
187  ostringstream oss; // DEBUG
188 
189  // See what's in the AUTOCIRCULATE_TRANSFER's F1 & F2 anc buffers...
190  AJAAncillaryList ancPacketsF1, ancPacketsF2;
191  ancPacketsF1.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCBuffer.GetHostPointer (), mTransferStruct.acANCBuffer.GetByteCount ());
192  ancPacketsF2.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCField2Buffer.GetHostPointer (), mTransferStruct.acANCField2Buffer.GetByteCount ());
193  ancPacketsF1.ParseAllAncillaryData ();
194  ancPacketsF2.ParseAllAncillaryData ();
195 
197  {
199  if (ancCEA708DataIn.GetPayloadData () && ancCEA708DataIn.GetPayloadByteCount ())
200  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA708DataIn.GetPayloadData (), ancCEA708DataIn.GetPayloadByteCount ()) : false;
201  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA708 packet(s)";
202  }
204  {
206  if (ancCEA608DataIn.GetPayloadData () && ancCEA608DataIn.GetPayloadByteCount ())
207  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA608DataIn.GetPayloadData (), ancCEA608DataIn.GetPayloadByteCount ()) : false;
208  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA608 packet(s)";
209  }
211  {
213  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
214  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f1_char1, captionData.f1_char2, captionData.bGotField1Data)))
215  gotCaptionPacket = true;
216  //if (gotCaptionPacket) oss << "Using F1 AJAAnc EIA608 packet(s)";
217  }
219  {
221  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
222  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f2_char1, captionData.f2_char2, captionData.bGotField2Data)))
223  gotCaptionPacket = true;
224  //if (gotCaptionPacket) oss << "Using F2 AJAAnc EIA608 packet(s)";
225  }
226 
227  if (NTV2_IS_HD_VIDEO_FORMAT (mCurrentVideoFormat))
228  {
229  if (gotCaptionPacket && m708Decoder && m708Decoder->ParseSMPTE334AncPacket ())
230  captionData = m708Decoder->GetCC608CaptionData (); // Extract the 608 caption byte pairs
231  } // else if HD
232 
233  // Sorry, we only handle 608 captions -- nothing else.
234  // The 608 decoder does the rest. It expects to be called once per frame (to implement flashing characters and roll-up).
235  // Pass the caption byte pairs to it for processing (even if captionData.HasData returns false)...
236  if (m608Decoder)
237  m608Decoder->ProcessNew608FrameData (captionData);
238  //if (!oss.str ().empty ()) cerr << oss.str () << endl; // DEBUG DEBUG DEBUG DEBUG
239  //if (captionData.HasData ()) cerr << captionData << endl;
240  } // if able to use Anc buffers
241  #endif // defined (INCLUDE_AJACC)
242 } // GrabCaptions
243 
244 
245 void NTV2FrameGrabber::changeCaptionChannel (int inNewCaptionChannelId)
246 {
247  #if defined (INCLUDE_AJACC)
248  const NTV2Line21Channel chosenCaptionChannel (static_cast <NTV2Line21Channel> (inNewCaptionChannelId));
249 
250  if (!m608Decoder && IsValidLine21Channel (chosenCaptionChannel))
251  {
252  NTV2_ASSERT (!m708Decoder);
253  if (CNTV2CaptionDecoder608::Create (m608Decoder) && CNTV2CaptionDecoder708::Create (m708Decoder))
254  {
255  m608Decoder->SubscribeChangeNotification (Caption608Changed, this);
256  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
257  ClearCaptionBuffer (true);
258  }
259  else
260  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
261  }
262  else if (m608Decoder)
263  {
264  NTV2_ASSERT (m708Decoder);
265  if (!IsValidLine21Channel (chosenCaptionChannel))
266  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
267  else if (m608Decoder->GetDisplayChannel () != chosenCaptionChannel)
268  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
269  ClearCaptionBuffer (true);
270  }
271  #else
272  (void) inNewCaptionChannelId;
273  #endif // defined (INCLUDE_AJACC)
274 } // changeCaptionChannel
275 
276 
278 {
279  // Set up 2 images to ping-pong between capture and display...
280  QImage * images [NTV2_NUM_IMAGES];
281  ULWord framesCaptured (0);
282  FGNOTE("Thread started");
283 
284  // initialize images
285  for (int i = 0; i < NTV2_NUM_IMAGES; i++)
286  {
287  images[i] = new QImage(QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y, QImage::Format_RGB32);
288  }
289 
290  // Make sure all Bidirectionals are set to Inputs.
291  if (mNTV2Card.Open(mBoardNumber))
292  {
293  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
294  {
295  // We have not acquired the board continue until something changes...
296  qDebug ("Could not acquire board number %d", GetDeviceIndex());
297  mNTV2Card.Close ();
298  mDeviceID = DEVICE_ID_NOTFOUND;
299  }
300  else
301  {
302  mNTV2Card.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
303  mNTV2Card.SetEveryFrameServices (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
304 
305  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDI connectors...
306  {
307  bool waitForInput = false;
308  for (unsigned offset (0); offset < 8; offset++)
309  {
310  mNTV2Card.EnableChannel (NTV2Channel(offset));
311  bool outputEnabled;
312  mNTV2Card.GetSDITransmitEnable (NTV2Channel(offset), outputEnabled);
313  if (outputEnabled)
314  {
315  waitForInput = true;
316  mNTV2Card.SetSDITransmitEnable (NTV2Channel(offset), false);
317  }
318  }
319  // Only if we had to change an output to input do we need to wait.
320  if (waitForInput)
321  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // ...and give the device some time to lock to a signal
322  }
323  }
324  }
325 
326  while (true)
327  {
328  if (mAbort)
329  break;
330 
331  if (!NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
332  {
333  // No input chosen, so display banner...
334  if (NTV2_IS_VALID_CHANNEL(mChannel))
335  {
337  }
338  QImage * currentImage = images [framesCaptured % NTV2_NUM_IMAGES];
339  currentImage->load (":/resources/splash.png");
340  emit newStatusString ("");
341  emit newFrame (*currentImage, true);
342  AJATime::Sleep(200);
343  continue;
344  }
345 
346  if (mRestart)
347  {
348  gMutex.lock ();
350  if (mNTV2Card.IsOpen ())
351  {
352  if (!mDoMultiChannel)
353  {
355  mNTV2Card.SetEveryFrameServices (mSavedTaskMode);
356  }
357  mNTV2Card.Close ();
358  mDeviceID = DEVICE_ID_NOTFOUND;
359  }
360  gMutex.unlock ();
361 
362  if (mNTV2Card.Open(mBoardNumber))
363  {
364  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
365  {
366  //We have not acquired the board continue until something changes
367  qDebug() << "Could not acquire board number " << GetDeviceIndex();
368  mNTV2Card.Close ();
369  mDeviceID = DEVICE_ID_NOTFOUND;
370  AJATime::Sleep(500);
371  continue;
372  }
373 
374  mNTV2Card.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
375  mNTV2Card.SetEveryFrameServices (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
376 
377  mDeviceID = mNTV2Card.GetDeviceID ();
378  if (mNTV2Card.features().CanDoMultiFormat())
379  mNTV2Card.SetMultiFormatMode (true);
380 
381  if (!mNTV2Card.IsDeviceReady (false))
382  {
383  qDebug ("Device not ready");
384  AJATime::Sleep(1000); // Keep the UI responsive while waiting for device to become ready
385  }
386  else if (SetupInput ())
387  {
388  mTransferStruct.acANCBuffer.Allocate (mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
389  mTransferStruct.acANCField2Buffer.Allocate(mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
390  const ULWord acOptions(AUTOCIRCULATE_WITH_RP188 | (mTransferStruct.acANCBuffer.IsNULL() && mTransferStruct.acANCField2Buffer.IsNULL() ? 0 : AUTOCIRCULATE_WITH_ANC));
391  gMutex.lock ();
393  ULWord numFrameBuffersAvailable = (mNTV2Card.DeviceGetNumberFrameBuffers() - mNTV2Card.features().GetNumAudioSystems());
394  ULWord startFrameBuffer = (numFrameBuffersAvailable / mNTV2Card.features().GetNumFrameStores()) * ULWord(mChannel);
395  mNTV2Card.AutoCirculateInitForInput (mChannel, 0, ::NTV2ChannelToAudioSystem(mChannel),
396  acOptions, 1, startFrameBuffer, startFrameBuffer+7);
397  gMutex.unlock ();
398  SetupAudio ();
399  if (mAudioOutput)
400  mAudioDevice = mAudioOutput->start ();
401 
402  // Start AutoCirculate...
403  mNTV2Card.SetLTCInputEnable (true);
404  mNTV2Card.SetRP188SourceFilter (mChannel, 0); // 0=LTC 1=VITC1 2=VITC2
405  mNTV2Card.AutoCirculateStart (mChannel);
406 
407  for (int i = 0; i < NTV2_NUM_IMAGES; i++)
408  {
409  delete images[i];
410  images[i] = new QImage (mFrameDimensions.Width (), mFrameDimensions.Height (), QImage::Format_RGB32);
411  }
412 
413  framesCaptured = 0;
414  mRestart = false;
415  } // if board set up ok
416  else
417  AJATime::Sleep(1000); // This keeps the UI responsive if/while this channel has no input
418  } // if board opened ok
419  else
420  {
421  qDebug() << "## WARNING: Open failed for device " << GetDeviceIndex ();
422  AJATime::Sleep(200);
423  continue;
424  }
425 
426  emit newStatusString (::NTV2InputSourceToString (mInputSource, true).c_str());
427  } // if mRestart
428 
429  if (CheckForValidInput () == false && NTV2_IS_VALID_INPUT_SOURCE (mInputSource))
430  {
431  QImage * currentImage (images [framesCaptured % NTV2_NUM_IMAGES]);
432  currentImage->fill (qRgba (40, 40, 40, 255));
433 
434  QString status (QString("%1: No Detected Input").arg(::NTV2InputSourceToString(mInputSource, true).c_str()));
435  emit newStatusString (status);
436  emit newFrame (*currentImage, true);
437  AJATime::Sleep(200);
438  continue;
439  }
440 
441  AUTOCIRCULATE_STATUS acStatus;
442  mNTV2Card.AutoCirculateGetStatus (mChannel, acStatus);
443  if (acStatus.acState == NTV2_AUTOCIRCULATE_RUNNING && acStatus.acBufferLevel > 1)
444  {
445  QImage * currentImage (images [framesCaptured % NTV2_NUM_IMAGES]);
446  NTV2TimeCodeList tcValues;
447 
448  #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
449  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->sizeInBytes()));
450  #else
451  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->byteCount()));
452  #endif
453  mNTV2Card.AutoCirculateTransfer (mChannel, mTransferStruct);
454  if (!mFormatIsProgressive && mDeinterlace)
455  {
456  // Eliminate field flicker by copying even lines to odd lines...
457  // (a very lame de-interlace technique)
458  if (currentImage->height() == int(mFrameDimensions.Height()) && currentImage->width() == int(mFrameDimensions.Width()))
459  for (ULWord line (0); line < mFrameDimensions.Height(); line += 2)
460  ::memcpy (currentImage->scanLine (int(line) + 1), currentImage->scanLine(int(line)), mFrameDimensions.Width() * 4);
461  }
462  GrabCaptions();
463  mTimeCode.clear ();
464  if (mTransferStruct.acTransferStatus.acFrameStamp.GetInputTimeCodes(tcValues) && size_t(mTimeCodeSource) < tcValues.size())
465  {
466  CRP188 tc (tcValues.at(mTimeCodeSource));
467  if (!tcValues.at (mTimeCodeSource).IsValid())
468  {
469  // If the requested timecode was invalid, check for embedded LTC
470  if (NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
471  tc.SetRP188 (tcValues.at (::NTV2InputSourceToTimecodeIndex (mInputSource, true)));
472  }
473  tc.GetRP188Str (mTimeCode);
474  }
475 
476  QString outString (::NTV2InputSourceToString (mInputSource, true).c_str());
477  outString.append (" ");
478  outString.append (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
479  outString.append (" ");
480  outString.append (mTimeCode.c_str());
481 
482  emit newStatusString (outString);
483 
484  emit newFrame (*currentImage, (framesCaptured == 0) ? true : false);
485  if (mbWithAudio && mTransferStruct.acAudioBuffer)
486  OutputAudio (mTransferStruct.acAudioBuffer, mTransferStruct.acTransferStatus.acAudioTransferSize);
487 
488  framesCaptured++;
489  } // if running and at least one frame ready to transfer
490  else
491  mNTV2Card.WaitForInputVerticalInterrupt (mChannel);
492  } // loop til break
493 
494  if (mNTV2Card.IsOpen ())
495  {
496  gMutex.lock ();
498  if (!mDoMultiChannel)
499  {
500  mNTV2Card.ReleaseStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())); // Release the device
501  mNTV2Card.SetEveryFrameServices (mSavedTaskMode); // Restore prior task mode
502  }
503  gMutex.unlock ();
504  }
505 
506  for (int i = 0; i < NTV2_NUM_IMAGES; i++)
507  delete images[i];
508 
509  FGNOTE("Thread completed, will exit for device" << mNTV2Card.GetDisplayName() << " input source " << ::NTV2InputSourceToString(mInputSource));
510 
511 } // run
512 
513 
515 {
516  bool validInput (false);
517 
518  NTV2_ASSERT (mNTV2Card.IsOpen ());
519  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
520 
521  mChannel = ::NTV2InputSourceToChannel (mInputSource);
522  if(mChannel == NTV2_CHANNEL_INVALID)
523  mChannel = NTV2_CHANNEL1;
524  mTimeCodeSource = ::NTV2InputSourceToTimecodeIndex (mInputSource);
525 
526  bool waitForInput(false);
527  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDIs...
528  for (unsigned offset (0); offset < 4; offset++)
529  {
530  mNTV2Card.EnableChannel (NTV2Channel(mChannel+offset));
531  bool outputEnabled;
532  mNTV2Card.GetSDITransmitEnable (NTV2Channel(mChannel+offset), outputEnabled);
533  if (outputEnabled)
534  {
535  waitForInput = true;
536  mNTV2Card.SetSDITransmitEnable (NTV2Channel(mChannel+offset), false);
537  }
538  }
539 
540  // Only if we had to change an output to input do we need to wait.
541  if (waitForInput)
542  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // Give the device ~10 fields/frames to lock to a signal
543 
544  mCurrentVideoFormat = GetVideoFormatFromInputSource ();
545  mCurrentColorSpace = GetColorSpaceFromInputSource ();
546  mFrameDimensions.Set (QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y);
547 
548  if (NTV2_IS_VALID_VIDEO_FORMAT (mCurrentVideoFormat))
549  {
550  validInput = true;
551  mNTV2Card.SetVideoFormat (mCurrentVideoFormat, false, false, mChannel);
553  mNTV2Card.GetVANCMode(vm, mChannel);
554  const NTV2FormatDescriptor fd(mCurrentVideoFormat, mFrameBufferFormat, vm);
555  mFrameDimensions.Set (fd.GetRasterWidth(), fd.GetRasterHeight());
556  const QString vfString (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
557  qDebug() << "## DEBUG: mInputSource=" << mChannel << ", mCurrentVideoFormat=" << vfString << ", width=" << mFrameDimensions.Width() << ", height=" << mFrameDimensions.Height();
558 
559  mFormatIsProgressive = IsProgressivePicture (mCurrentVideoFormat);
560  if (!mbFixedReference)
562 
563  if (NTV2_INPUT_SOURCE_IS_SDI (mInputSource))
564  {
565  mNumChannels = 0;
566  mTsi = false;
567 
568  bool is6g;
569  bool is12g;
570  mNTV2Card.GetSDIInput6GPresent(is6g, mChannel);
571  mNTV2Card.GetSDIInput12GPresent(is12g, mChannel);
572 
573  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
574  {
576  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (NTV2Channel (mChannel)), ::GetCSCOutputXptFromChannel (NTV2Channel (mChannel), false/*isKey*/, true/*isRGB*/));
577  mNTV2Card.SetFrameBufferFormat (NTV2Channel (mChannel), mFrameBufferFormat);
578  mNTV2Card.EnableChannel (NTV2Channel (mChannel));
579  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel, IsInput3Gb (mInputSource) ? true : false);
580  }
581  else
582  {
583  for (unsigned offset (0); offset < 4; offset++)
584  {
585  mNumChannels++;
586  mNTV2Card.Connect (::GetCSCInputXptFromChannel (NTV2Channel (mChannel + offset)), ::GetSDIInputOutputXptFromChannel (NTV2Channel (mChannel + offset)));
587  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (NTV2Channel (mChannel + offset)), ::GetCSCOutputXptFromChannel (NTV2Channel (mChannel + offset), false/*isKey*/, true/*isRGB*/));
588  mNTV2Card.SetFrameBufferFormat (NTV2Channel (mChannel + offset), mFrameBufferFormat);
589  mNTV2Card.EnableChannel (NTV2Channel (mChannel + offset));
590  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel + offset, IsInput3Gb (mInputSource) ? true : false);
591  if (!NTV2_IS_4K_VIDEO_FORMAT (mCurrentVideoFormat))
592  break;
593  mNTV2Card.Set4kSquaresEnable(true, NTV2_CHANNEL1);
594  }
595  }
596  }
597  else if (mInputSource == NTV2_INPUTSOURCE_ANALOG1)
598  {
599  mNumChannels = 0;
600  mTsi = false;
601  //mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
602 
604  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (NTV2_CHANNEL1), ::GetCSCOutputXptFromChannel (NTV2_CHANNEL1, false/*isKey*/, true/*isRGB*/));
605  mNTV2Card.SetFrameBufferFormat (NTV2_CHANNEL1, mFrameBufferFormat);
606  if (!mbFixedReference)
608  mChannel = NTV2_CHANNEL1;
609  mNumChannels = 1;
610  }
611  else if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
612  {
613  mNumChannels = 0;
614  mTsi = false;
615 
616  if (!mbFixedReference)
617  mNTV2Card.SetReference (::NTV2InputSourceToReferenceSource(mInputSource));
618 
619  // configure hdmi with 2.0 support
620  if (mNTV2Card.features().CanDo12gRouting())
621  {
622  mNumChannels = 1;
623  mNTV2Card.EnableChannel (mChannel);
624  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
625  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
626  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
627  {
628  mNTV2Card.Connect (::GetCSCInputXptFromChannel (mChannel),
629  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
630  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (mChannel),
631  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
632  }
633  else
634  {
635  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (mChannel),
636  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
637  }
638  }
639  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && !mNTV2Card.features().CanDoHDMIQuadRasterConversion())
640  {
641  // Set two sample interleave
642  mChannel = NTV2_CHANNEL1;
643  mNTV2Card.SetTsiFrameEnable(true, NTV2_CHANNEL1);
644 
645  for (NTV2Channel channel (NTV2_CHANNEL1); channel < NTV2_CHANNEL3; channel = NTV2Channel(channel+1))
646  {
647  mNTV2Card.EnableChannel (channel);
648  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
649  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
650  }
651 
652  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
653  {
654  mNTV2Card.Connect (NTV2_XptCSC1VidInput,
655  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
656  mNTV2Card.Connect (NTV2_XptCSC2VidInput,
657  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
658  mNTV2Card.Connect (NTV2_XptCSC3VidInput,
659  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
660  mNTV2Card.Connect (NTV2_XptCSC4VidInput,
661  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
662 
667  }
668  else
669  {
670  mNTV2Card.Connect (NTV2_Xpt425Mux1AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
671  mNTV2Card.Connect (NTV2_Xpt425Mux1BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
672  mNTV2Card.Connect (NTV2_Xpt425Mux2AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
673  mNTV2Card.Connect (NTV2_Xpt425Mux2BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
674  }
675 
680 
681  mNumChannels = 2;
682  mTsi = true;
683  } // if 4K and can't do HDMI quad raster conversion
684  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && mNTV2Card.features().CanDoHDMIQuadRasterConversion())
685  {
686  mNumChannels = 0;
687  mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
688  for (NTV2Channel channel (NTV2_CHANNEL1); channel < NTV2_CHANNEL5; channel = NTV2Channel(channel+1))
689  {
690  mNumChannels++;
691  mNTV2Card.EnableChannel (channel);
692  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
693  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
694  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
695  {
696  mNTV2Card.Connect (::GetCSCInputXptFromChannel (channel),
697  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
698  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (channel),
699  ::GetCSCOutputXptFromChannel (channel, false/*isKey*/, true/*isRGB*/));
700  }
701  else
702  {
703  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (channel),
704  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
705  }
706  } // loop once for each channel (4 times for 4K/UHD)
707  } // else if 4K and can do HDMI quad raster conversion
708  else
709  {
710  mNumChannels = 1;
711  mNTV2Card.EnableChannel (mChannel);
712  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
713  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
714  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
715  {
716  mNTV2Card.Connect (::GetCSCInputXptFromChannel (mChannel),
717  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
718  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (mChannel),
719  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
720  }
721  else
722  {
723  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (mChannel),
724  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
725  }
726  } // else not 4K
727 
728  // configure the qrc if present
729  if (mNTV2Card.features().GetHDMIVersion() == 2)
731  }
732  else
733  qDebug () << "## DEBUG: NTV2FrameGrabber::SetupInput: Bad mInputSource switch value " << ::NTV2InputSourceToChannelSpec (mInputSource);
734  } // if video format not unknown
735 
736  return validInput;
737 
738 } // SetupInput
739 
740 
742 {
743  if (mNTV2Card.IsOpen ())
744  {
745  mNTV2Card.AutoCirculateStop (mChannel);
746 
747  bool tsiEnable(false);
748  mNTV2Card.GetTsiFrameEnable (tsiEnable, NTV2_CHANNEL1);
749  for (ULWord i(0); i < (tsiEnable ? 2 : mNumChannels); i++)
750  mNTV2Card.SetMode (NTV2Channel(mChannel + i), NTV2_MODE_DISPLAY);
751  }
752  ClearCaptionBuffer (true);
753 
754 } // StopAutoCirculate
755 
756 
758 {
761 
762  if (videoFormat == NTV2_FORMAT_UNKNOWN)
763  {
764  mCurrentVideoFormat = videoFormat;
765  return false;
766  } // if no video or unknown format
767  else if ((mCurrentVideoFormat != videoFormat) ||
768  (mCurrentColorSpace != colorSpace))
769  {
770  if (mDebounceCounter == 0)
771  {
772  // Check to see if the video input has stabilized...
773  mLastVideoFormat = videoFormat;
774  mDebounceCounter++;
775  }
776  else if (mDebounceCounter == 6)
777  {
778  // The new format is stable -- restart autocirculate...
779  mRestart = true;
780  mCurrentVideoFormat = videoFormat;
781  mDebounceCounter = 0;
782  }
783  else
784  {
785  if (mLastVideoFormat == videoFormat)
786  mDebounceCounter++; // New format still stable -- keep counting
787  else
788  mDebounceCounter = 0; // Input changed again -- start over
789  }
790 
791  return true;
792  } // else if video format changed
793  else
794  return true;
795 
796 } // CheckForValidInput
797 
798 
800 {
801  NTV2VideoFormat videoFormat (NTV2_FORMAT_UNKNOWN);
802  NTV2_ASSERT (mNTV2Card.IsOpen ());
803  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
804 
805  if (NTV2_INPUT_SOURCE_IS_SDI(mInputSource))
806  {
807  bool is6g;
808  bool is12g;
809  NTV2Channel channel = ::NTV2InputSourceToChannel (mInputSource);
810  mNTV2Card.GetSDIInput6GPresent(is6g, channel);
811  mNTV2Card.GetSDIInput12GPresent(is12g, channel);
812 
813  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
814  {
815  videoFormat = mNTV2Card.GetInputVideoFormat (mInputSource);
816  return videoFormat;
817  }
818  }
819 
820  switch (mInputSource)
821  {
824  {
825  const ULWord ndx (::GetIndexForNTV2InputSource (mInputSource));
826  videoFormat = mNTV2Card.GetInputVideoFormat (::GetNTV2InputSourceForIndex (ndx + 0));
827  NTV2Standard videoStandard (::GetNTV2StandardFromVideoFormat (videoFormat));
828  if (mCheckFor4K && (videoStandard == NTV2_STANDARD_1080p))
829  {
830  NTV2VideoFormat videoFormatNext (mNTV2Card.GetInputVideoFormat (::GetNTV2InputSourceForIndex (ndx + 1)));
831  if (videoFormatNext == videoFormat)
832  {
833  videoFormatNext = mNTV2Card.GetInputVideoFormat (::GetNTV2InputSourceForIndex (ndx + 2));
834  if (videoFormatNext == videoFormat)
835  {
836  videoFormatNext = mNTV2Card.GetInputVideoFormat (::GetNTV2InputSourceForIndex (ndx + 3));
837  if (videoFormatNext == videoFormat)
838  CNTV2DemoCommon::Get4KInputFormat (videoFormat);
839  }
840  }
841  }
842  }
843  break;
844 
846  break; // indicates no source is currently selected
847 
848  default:
849  videoFormat = mNTV2Card.GetInputVideoFormat (mInputSource);
850  break;
851  }
852 
853  return videoFormat;
854 
855 } // GetVideoFormatFromInputSource
856 
857 
859 {
860  if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
861  {
863  mNTV2Card.GetHDMIInputColor (hdmiColor, mChannel);
864  return hdmiColor;
865  }
866 
868 }
869 
870 
872 {
873  bool is3Gb (false);
874 
875  mNTV2Card.GetSDIInput3GbPresent (is3Gb, ::NTV2InputSourceToChannel (inputSource));
876 
877  return is3Gb;
878 } // IsInput3Gb
879 
880 
882 {
883  NTV2_ASSERT (mNTV2Card.IsOpen ());
884  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
885 
886  mTransferStruct.acAudioBuffer.Allocate (NTV2_AUDIOSIZE_MAX); // Reserve space for largest audio packet/frame
887  if (mAudioOutput)
888  {
889  delete mAudioOutput;
890  mAudioOutput = AJA_NULL;
891  }
892 
893  NTV2AudioSource audioSource (NTV2_AUDIO_EMBEDDED);
894  if (NTV2_INPUT_SOURCE_IS_HDMI (mInputSource))
895  audioSource = NTV2_AUDIO_HDMI;
896  else if (NTV2_INPUT_SOURCE_IS_ANALOG (mInputSource))
897  audioSource = NTV2_AUDIO_ANALOG;
898 
899  // Set up AJA device audio...
900  mNumAudioChannels = mNTV2Card.features().GetMaxAudioChannels();
901  mAudioSystem = ::NTV2ChannelToAudioSystem (mChannel);
902  mNTV2Card.SetAudioSystemInputSource (mAudioSystem, audioSource, ::NTV2InputSourceToEmbeddedAudioInput (mInputSource));
903  mNTV2Card.SetNumberAudioChannels (mNumAudioChannels, mAudioSystem);
904  mNTV2Card.SetAudioRate (NTV2_AUDIO_48K, mAudioSystem);
905  mNTV2Card.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
906 
907  // Set up Qt's audio output...
908 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
909  mFormat.setSampleRate (48000);
910  mFormat.setChannelCount (2);
911  mFormat.setSampleSize (16);
912  mFormat.setCodec ("audio/pcm");
913  mFormat.setByteOrder (QAudioFormat::LittleEndian);
914  mFormat.setSampleType (QAudioFormat::SignedInt);
915 #else
916  mFormat.setSampleRate (48000);
917  mFormat.setChannelCount (2);
918  mFormat.setSampleFormat (QAudioFormat::Int16);
919 #endif
920 
921 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
922  QAudioDeviceInfo audioDeviceInfo (QAudioDeviceInfo::defaultOutputDevice ());
923  if (audioDeviceInfo.isFormatSupported (mFormat))
924  mAudioOutput = new QAudioOutput (mFormat, AJA_NULL);
925 #else
926  QAudioDevice deviceInfo (QMediaDevices::defaultAudioOutput());
927  if (deviceInfo.isFormatSupported (mFormat))
928  mAudioOutput = new QAudioSink(deviceInfo, mFormat, AJA_NULL);
929 #endif
930 
931 } // SetupAudio
932 
933 
934 void NTV2FrameGrabber::OutputAudio (ULWord * pInOutBuffer, const ULWord inNumValidBytes)
935 {
936  const ULWord nBytesPerAJASample (4); // AJA devices provide four bytes per channel per sample
937  unsigned channel (0); // Current channel being processed
938  UWord qtSampleNdx (0); // Which Qt audio sample is being processed
939  const ULWord totalSamples (inNumValidBytes / mNumAudioChannels); // Total number of audio samples to process, regardless of channel count
940  const ULWord totalAjaSamples (inNumValidBytes / nBytesPerAJASample); // Total number of AJA-device-provided audio samples, one sample per channel
941  UWord * pQtAudioBuffer (reinterpret_cast <UWord *> (pInOutBuffer)); // Qt-centric pointer to the audio buffer (2-bytes per channel per sample)
942 
943  //
944  // Walk through the audio buffer channel by channel:
945  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 ...etc...
946  // and copy samples from channels 0 and 1 up to the front of the buffer...
947  // 0 1 0 1 0 1 0 1 0 1 0 1 ...etc..
948  //
949 
950  for (unsigned ajaSampleNdx = 0; ajaSampleNdx < totalAjaSamples; ajaSampleNdx++)
951  {
952  if (channel < 2)
953  {
954  pQtAudioBuffer [qtSampleNdx] = pInOutBuffer [ajaSampleNdx] >> 16; // Also discard the least significant 16 bits of each sample
955  qtSampleNdx++;
956  } // if channel 0 or 1
957 
958  channel++;
959  if (channel == mNumAudioChannels)
960  channel = 0;
961  } // for each channel for each sample
962 
963  if (mAudioDevice)
964  mAudioDevice->write (reinterpret_cast <const char *> (pQtAudioBuffer), totalSamples);
965 
966 } // OutputAudio
967 
968 
969 #if defined (INCLUDE_AJACC)
970  void NTV2FrameGrabber::Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo)
971  {
972  NTV2FrameGrabber * pFG (reinterpret_cast <NTV2FrameGrabber *> (pInstance));
973  if (pFG)
974  pFG->caption608Changed (inChangeInfo);
975  }
976 
977  void NTV2FrameGrabber::caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo)
978  {
979  NTV2Line21Attributes attrs;
980  bool changed (false);
981  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
982  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
983  {
984  ushort utf16Char (m608Decoder ? m608Decoder->GetOnAirUTF16CharacterWithAttributes (row, col, attrs) : 0x0020);
985  if (!utf16Char)
986  utf16Char = 0x0020;
987  if (utf16Char != mScreenBuffer [row-1][col-1])
988  {
989  mScreenBuffer [row-1][col-1] = utf16Char;
990  changed = true;
991  }
992  }
993  if (changed)
994  emit captionScreenChanged (&mScreenBuffer[0][0]);
995  }
996 #endif // defined (INCLUDE_AJACC)
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
NTV2InputSourceToReferenceSource
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5081
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
NTV2_Xpt425Mux1AInput
@ NTV2_Xpt425Mux1AInput
Definition: ntv2enums.h:2802
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5105
NTV2FrameGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2framegrabber.cpp:115
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
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or Frame Store 2 (or the 2nd item).
Definition: ntv2enums.h:1308
CNTV2CaptionDecoder708::Create
static bool Create(CNTV2CaptionDecoder708Ptr &outDecoder)
Creates a new CNTV2CaptionEncoder708 instance.
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.
CNTV2Card::Set4kSquaresEnable
virtual bool Set4kSquaresEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 "2K quadrants" mode for the given FrameStore bank on the device....
Definition: ntv2register.cpp:1238
NTV2_CC608_MinCol
const UWord NTV2_CC608_MinCol(1)
The minimum column index number (located at the left edge of the screen).
CaptionData::f2_char1
UByte f2_char1
Caption Byte 1 of Field 2.
Definition: ntv2caption608types.h:662
ntv2devicefeatures.h
Declares device capability functions.
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3597
NTV2_AUDIO_BUFFER_BIG
@ NTV2_AUDIO_BUFFER_BIG
Definition: ntv2enums.h:1864
AJAAncillaryData_Cea608::GetCEA608Bytes
virtual AJAStatus GetCEA608Bytes(uint8_t &outByte1, uint8_t &outByte2, bool &outIsValid) const
Answers with the CEA608 payload bytes.
Definition: ancillarydata_cea608.cpp:89
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2InputSourceToTimecodeIndex
NTV2TimecodeIndex NTV2InputSourceToTimecodeIndex(const NTV2InputSource inInputSource, const bool inEmbeddedLTC=false)
Converts a given NTV2InputSource to its equivalent NTV2TimecodeIndex value.
Definition: ntv2utils.cpp:5153
NTV2FrameGrabber::SetupInput
bool SetupInput(void)
Configures my AJA device for capture.
Definition: ntv2framegrabber.cpp:514
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1305
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6066
NTV2_ASSERT
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:506
NTV2_XptCSC4VidInput
@ NTV2_XptCSC4VidInput
Definition: ntv2enums.h:2715
AJAAncillaryData_Cea608_Line21
This class handles "analog" (Line 21) based CEA-608 caption data packets.
Definition: ancillarydata_cea608_line21.h:27
CNTV2Card::WaitForInputVerticalInterrupt
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
Definition: ntv2subscriptions.cpp:149
NTV2_AUDIO_48K
@ NTV2_AUDIO_48K
Definition: ntv2enums.h:1875
NTV2FrameGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2framegrabber.cpp:799
ancillarylist.h
Declares the AJAAncillaryList class.
NTV2_Xpt425Mux2AYUV
@ NTV2_Xpt425Mux2AYUV
Definition: ntv2enums.h:2597
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3816
NTV2InputSourceToEmbeddedAudioInput
NTV2EmbeddedAudioInput NTV2InputSourceToEmbeddedAudioInput(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2EmbeddedAudioInput value.
Definition: ntv2utils.cpp:4935
AUTOCIRCULATE_TRANSFER::acAudioBuffer
NTV2Buffer acAudioBuffer
The host audio buffer. This field is owned by the client application, and thus is responsible for all...
Definition: ntv2publicinterface.h:7984
AJAAncillaryList::CountAncillaryDataWithType
virtual uint32_t CountAncillaryDataWithType(const AJAAncDataType inMatchType) const
Answers with the number of AJAAncillaryData objects having the given type.
Definition: ancillarylist.cpp:222
GetFrameBufferInputXptFromChannel
NTV2InputXptID GetFrameBufferInputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsBInput=false)
Definition: ntv2signalrouter.cpp:762
CNTV2Card::GetSDIInput12GPresent
virtual bool GetSDIInput12GPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3638
CNTV2Card::AutoCirculateInitForInput
virtual bool AutoCirculateInitForInput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate ingest, designating a contiguous block of frame buffers on the ...
Definition: ntv2autocirculate.cpp:221
AJAAncillaryList::ParseAllAncillaryData
virtual AJAStatus ParseAllAncillaryData(void)
Sends a "ParsePayloadData" command to all of my AJAAncillaryData objects.
Definition: ancillarylist.cpp:205
NTV2_Xpt425Mux2BYUV
@ NTV2_Xpt425Mux2BYUV
Definition: ntv2enums.h:2599
NTV2FormatDescriptor::GetRasterHeight
ULWord GetRasterHeight(const bool inVisibleOnly=false) const
Definition: ntv2formatdescriptor.h:170
NTV2_REFERENCE_ANALOG_INPUT1
@ NTV2_REFERENCE_ANALOG_INPUT1
Specifies the Analog In 1 connector.
Definition: ntv2enums.h:1405
gMutex
static QMutex gMutex
Definition: ntv2framegrabber.cpp:28
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
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
FGNOTE
#define FGNOTE(_expr_)
Definition: ntv2framegrabber.cpp:25
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
CaptionData::f1_char2
UByte f1_char2
Caption Byte 2 of Field 1.
Definition: ntv2caption608types.h:659
NTV2_XptCSC1VidInput
@ NTV2_XptCSC1VidInput
Definition: ntv2enums.h:2709
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
AJAAncillaryList::GetAncillaryDataWithType
virtual AJAAncillaryData * GetAncillaryDataWithType(const AJAAncDataType inMatchType, const uint32_t inIndex=0) const
Answers with the AJAAncillaryData object having the given type and index.
Definition: ancillarylist.cpp:238
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
NTV2FrameGrabber::CheckForValidInput
bool CheckForValidInput(void)
Definition: ntv2framegrabber.cpp:757
NTV2_HDMI_V2_HDSD_BIDIRECTIONAL
@ NTV2_HDMI_V2_HDSD_BIDIRECTIONAL
Definition: ntv2enums.h:3921
CNTV2DemoCommon::Get4KInputFormat
static bool Get4KInputFormat(NTV2VideoFormat &inOutVideoFormat)
Given a video format, if all 4 inputs are the same and promotable to 4K, this function does the promo...
Definition: ntv2democommon.cpp:1088
AJAAncillaryList
I am an ordered collection of AJAAncillaryData instances which represent one or more SMPTE 291 data p...
Definition: ancillarylist.h:64
NTV2_Xpt425Mux2BInput
@ NTV2_Xpt425Mux2BInput
Definition: ntv2enums.h:2805
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
CNTV2Card::SetAudioSystemInputSource
virtual bool SetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedInput)
Sets the audio source for the given NTV2AudioSystem on the device.
Definition: ntv2audio.cpp:485
NTV2_IS_4K_VIDEO_FORMAT
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:746
IsProgressivePicture
bool IsProgressivePicture(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5423
NTV2_CHANNEL4
@ NTV2_CHANNEL4
Specifies channel or Frame Store 4 (or the 4th item).
Definition: ntv2enums.h:1310
AUTOCIRCULATE_STATUS::acState
NTV2AutoCirculateState acState
Current AutoCirculate state.
Definition: ntv2publicinterface.h:7163
NTV2_CHANNEL5
@ NTV2_CHANNEL5
Specifies channel or Frame Store 5 (or the 5th item).
Definition: ntv2enums.h:1311
GetIndexForNTV2InputSource
ULWord GetIndexForNTV2InputSource(const NTV2InputSource inValue)
Definition: ntv2utils.cpp:5306
CNTV2Card::GetSDIInput6GPresent
virtual bool GetSDIInput6GPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3626
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:141
NTV2_INPUTSOURCE_ANALOG1
@ NTV2_INPUTSOURCE_ANALOG1
Identifies the first analog video input.
Definition: ntv2enums.h:1223
AUTOCIRCULATE_WITH_ANC
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
Definition: ntv2publicinterface.h:5527
NTV2Caption608ChangeInfo
This class is used to respond to dynamic events that occur during CEA-608 caption decoding.
Definition: ntv2caption608types.h:779
NTV2_INPUTSOURCE_SDI1
@ NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1228
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
CNTV2Card::DeviceGetNumberFrameBuffers
virtual ULWord DeviceGetNumberFrameBuffers(const NTV2FrameGeometry inFrameGeometry, const NTV2FrameBufferFormat inFBFormat)
Definition: ntv2card.cpp:448
NTV2_XptCSC3VidRGB
@ NTV2_XptCSC3VidRGB
Definition: ntv2enums.h:2539
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7215
CNTV2Card::SetRP188SourceFilter
virtual bool SetRP188SourceFilter(const NTV2Channel inSDIInput, const UWord inFilterValue)
Sets the RP188 DBB filter for the given SDI input.
Definition: ntv2register.cpp:2533
NTV2_XptFrameBuffer1Input
@ NTV2_XptFrameBuffer1Input
Definition: ntv2enums.h:2693
NTV2FrameGrabber::ClearCaptionBuffer
void ClearCaptionBuffer(const bool inSignalClients=(0))
Definition: ntv2framegrabber.cpp:163
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:153
NTV2_XptCSC4VidRGB
@ NTV2_XptCSC4VidRGB
Definition: ntv2enums.h:2542
NTV2_MAX_NUM_CHANNELS
@ NTV2_MAX_NUM_CHANNELS
Definition: ntv2enums.h:1315
NTV2Buffer::IsNULL
bool IsNULL(void) const
Definition: ntv2publicinterface.h:6088
ULWord
uint32_t ULWord
Definition: ajatypes.h:253
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7160
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2FrameGrabber::SetupAudio
void SetupAudio(void)
Performs audio configuration.
Definition: ntv2framegrabber.cpp:881
AJAAncillaryData
I am the principal class that stores a single SMPTE-291 SDI ancillary data packet OR the digitized co...
Definition: ancillarydata.h:552
NTV2FrameGrabber::captionScreenChanged
void captionScreenChanged(const ushort *pInScreen)
This is signaled (called) when my caption screen buffer changes.
NTV2_NUM_IMAGES
#define NTV2_NUM_IMAGES
Definition: ntv2framegrabber.cpp:19
AJAAncillaryData::GetPayloadData
virtual const uint8_t * GetPayloadData(void) const
Definition: ancillarydata.h:801
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
FRAME_STAMP::GetInputTimeCodes
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Returns all RP188 timecodes associated with the frame in NTV2TCIndex order.
Definition: ntv2publicinterface.cpp:2095
AJAAncillaryData_Cea608_Line21::ParsePayloadData
virtual AJAStatus ParsePayloadData(void)
Parses out (interprets) the "local" ancillary data from my payload data.
Definition: ancillarydata_cea608_line21.cpp:83
NTV2TCIndex
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3870
IsValidLine21Channel
#define IsValidLine21Channel(_chan_)
Definition: ntv2caption608types.h:102
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
NTV2_INPUTSOURCE_SDI5
@ NTV2_INPUTSOURCE_SDI5
Identifies the 5th SDI video input.
Definition: ntv2enums.h:1232
CNTV2Card::SetLTCInputEnable
virtual bool SetLTCInputEnable(const bool inEnable)
Enables or disables the ability for the device to read analog LTC on the reference input connector.
Definition: ntv2register.cpp:3651
NTV2_CHANNEL3
@ NTV2_CHANNEL3
Specifies channel or Frame Store 3 (or the 3rd item).
Definition: ntv2enums.h:1309
NTV2_STANDARD_1080p
@ NTV2_STANDARD_1080p
Identifies SMPTE HD 1080p.
Definition: ntv2enums.h:159
UWord
uint16_t UWord
Definition: ajatypes.h:251
CNTV2Card::AutoCirculateGetStatus
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
Definition: ntv2autocirculate.cpp:646
CRP188::SetRP188
void SetRP188(ULWord ulFrms, ULWord ulSecs, ULWord ulMins, ULWord ulHrs, NTV2FrameRate frameRate, const bool bDropFrame=false, const bool bSMPTE372=false)
Definition: ntv2rp188.cpp:587
NTV2_IS_VALID_INPUT_SOURCE
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1243
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1404
GetNTV2InputSourceForIndex
NTV2InputSource GetNTV2InputSourceForIndex(const ULWord inIndex0, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5268
NTV2_XptCSC3VidInput
@ NTV2_XptCSC3VidInput
Definition: ntv2enums.h:2713
ntv2utils.h
Declares numerous NTV2 utility functions.
NTV2FrameGrabber::NTV2FrameGrabber
NTV2FrameGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2framegrabber.cpp:31
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
QTPREVIEW_WIDGET_Y
#define QTPREVIEW_WIDGET_Y
Definition: ntv2framegrabber.h:36
AJAAncillaryDataType_Cea608_Vanc
#define AJAAncillaryDataType_Cea608_Vanc
Definition: ancillarydata.h:1640
AUTOCIRCULATE_TRANSFER::SetVideoBuffer
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2708
AJA_SUCCESS
#define AJA_SUCCESS(_status_)
Definition: types.h:370
GetCSCInputXptFromChannel
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
Definition: ntv2signalrouter.cpp:775
NTV2_IS_HD_VIDEO_FORMAT
#define NTV2_IS_HD_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:700
NTV2_XptAnalogIn
@ NTV2_XptAnalogIn
Definition: ntv2enums.h:2502
CNTV2CaptionDecoder608::Create
static bool Create(CNTV2CaptionDecoder608Ptr &outEncoder)
Creates a new CNTV2CaptionEncoder608 instance.
NTV2_XptFrameBuffer1DS2Input
@ NTV2_XptFrameBuffer1DS2Input
Definition: ntv2enums.h:2694
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1284
CaptionData::bGotField2Data
bool bGotField2Data
True if Field 2 bytes have been set; otherwise false.
Definition: ntv2caption608types.h:661
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_Xpt425Mux1AYUV
@ NTV2_Xpt425Mux1AYUV
Definition: ntv2enums.h:2593
NTV2_Xpt425Mux1BYUV
@ NTV2_Xpt425Mux1BYUV
Definition: ntv2enums.h:2595
AUTOCIRCULATE_TRANSFER_STATUS::acFrameStamp
FRAME_STAMP acFrameStamp
Frame stamp for the transferred frame.
Definition: ntv2publicinterface.h:7887
AUTOCIRCULATE_TRANSFER::acANCField2Buffer
NTV2Buffer acANCField2Buffer
The host "Field 2" ancillary data buffer. This field is owned by the client application,...
Definition: ntv2publicinterface.h:8006
CNTV2Card::SetTsiFrameEnable
virtual bool SetTsiFrameEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 two-sample interleave (Tsi) frame mode on the device.
Definition: ntv2register.cpp:1311
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
CRP188
Definition: ntv2rp188.h:55
AUTOCIRCULATE_STATUS::acBufferLevel
ULWord acBufferLevel
Number of buffered frames in driver ready to capture or play.
Definition: ntv2publicinterface.h:7173
NTV2_AUDIOSIZE_MAX
#define NTV2_AUDIOSIZE_MAX
Definition: ntv2democommon.h:46
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
NTV2FrameGrabber::newStatusString
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
NTV2VANCMode
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3716
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:197
AUTOCIRCULATE_TRANSFER::acTransferStatus
AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
Contains status information that's valid after CNTV2Card::AutoCirculateTransfer returns,...
Definition: ntv2publicinterface.h:8021
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1319
NTV2_VANCMODE_INVALID
@ NTV2_VANCMODE_INVALID
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3721
NTV2_CC608_MaxCol
const UWord NTV2_CC608_MaxCol(32)
The maximum column index number (located at the right edge of the screen).
NTV2FrameGrabber::OutputAudio
void OutputAudio(ULWord *pInOutAudioBuffer, const ULWord inNumValidBytes)
Writes audio samples for channels 1 and 2 that are in the given audio buffer to my QAudioOutput devic...
Definition: ntv2framegrabber.cpp:934
NTV2Buffer::GetHostPointer
void * GetHostPointer(void) const
Definition: ntv2publicinterface.h:6049
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1221
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
NTV2_AUDIO_HDMI
@ NTV2_AUDIO_HDMI
Obtain audio samples from the device HDMI input, if available.
Definition: ntv2enums.h:1955
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
NTV2FrameGrabber::run
virtual void run(void)
My thread function.
Definition: ntv2framegrabber.cpp:277
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3599
AJAAncillaryDataType_Cea708
#define AJAAncillaryDataType_Cea708
Definition: ancillarydata.h:1639
NTV2_XptFrameBuffer2Input
@ NTV2_XptFrameBuffer2Input
Definition: ntv2enums.h:2695
NTV2FrameGrabber
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
Definition: ntv2framegrabber.h:46
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...
AUTOCIRCULATE_WITH_RP188
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
Definition: ntv2publicinterface.h:5521
AJAAncillaryList::AddReceivedAncillaryData
virtual AJAStatus AddReceivedAncillaryData(const NTV2Buffer &inReceivedData, const uint32_t inFrameNum=0)
Parse "raw" ancillary data bytes received from hardware (ingest) – see SDI Anc Buffer Data Format – i...
Definition: ancillarylist.cpp:542
NTV2_MODE_CAPTURE
@ NTV2_MODE_CAPTURE
Capture (input) mode, which writes into device SDRAM.
Definition: ntv2enums.h:1202
NTV2FrameGrabber::GrabCaptions
void GrabCaptions(void)
Performs caption data extraction & decoding.
Definition: ntv2framegrabber.cpp:177
NTV2FrameGrabber::SetInputSource
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
Definition: ntv2framegrabber.cpp:77
NTV2Line21Channel
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Definition: ntv2caption608types.h:82
NTV2FrameGrabber::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.
std
Definition: json.hpp:5362
NTV2_CC608_MinRow
const UWord NTV2_CC608_MinRow(1)
The minimum row index number (located at the top of the screen).
NTV2FrameGrabber::IsInput3Gb
bool IsInput3Gb(const NTV2InputSource inputSource)
Definition: ntv2framegrabber.cpp:871
NTV2_AUDIO_EMBEDDED
@ NTV2_AUDIO_EMBEDDED
Obtain audio samples from the audio that's embedded in the video HANC.
Definition: ntv2enums.h:1952
CNTV2Card::AutoCirculateTransfer
virtual bool AutoCirculateTransfer(const NTV2Channel inChannel, AUTOCIRCULATE_TRANSFER &transferInfo)
Transfers all or part of a frame as specified in the given AUTOCIRCULATE_TRANSFER object to/from the ...
Definition: ntv2autocirculate.cpp:695
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
NTV2TimeCodeList
std::vector< NTV2_RP188 > NTV2TimeCodeList
An ordered sequence of zero or more NTV2_RP188 structures. An NTV2TCIndex enum value can be used as a...
Definition: ntv2publicinterface.h:6841
NTV2_XptCSC2VidRGB
@ NTV2_XptCSC2VidRGB
Definition: ntv2enums.h:2495
NTV2_AUTOCIRCULATE_RUNNING
@ NTV2_AUTOCIRCULATE_RUNNING
The AutoCirculate channel is running.
Definition: ntv2publicinterface.h:4277
true
#define true
Definition: ntv2devicefeatures.h:26
NTV2_TCINDEX_INVALID
@ NTV2_TCINDEX_INVALID
Definition: ntv2enums.h:3900
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:381
ntv2framegrabber.h
Header file for the NTV2FrameGrabber class.
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
NTV2FrameGrabber::StopAutoCirculate
void StopAutoCirculate(void)
Stops capturing.
Definition: ntv2framegrabber.cpp:741
CNTV2Card::SetHDMIV2Mode
virtual bool SetHDMIV2Mode(const NTV2HDMIV2Mode inMode)
Sets HDMI V2 mode for the device.
Definition: ntv2hdmi.cpp:592
NTV2FrameGrabber::SetDeviceIndex
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
Definition: ntv2framegrabber.cpp:91
NTV2_XptCSC1VidRGB
@ NTV2_XptCSC1VidRGB
Definition: ntv2enums.h:2480
AJAAncillaryDataType_Cea608_Line21
#define AJAAncillaryDataType_Cea608_Line21
Definition: ancillarydata.h:1641
NTV2_INPUT_SOURCE_IS_SDI
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1242
GetNTV2StandardFromVideoFormat
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2277
CNTV2Card::AutoCirculateStart
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
Definition: ntv2autocirculate.cpp:503
CaptionData::bGotField1Data
bool bGotField1Data
True if Field 1 bytes have been set; otherwise false.
Definition: ntv2caption608types.h:657
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
AUTOCIRCULATE_TRANSFER_STATUS::acAudioTransferSize
ULWord acAudioTransferSize
Number of bytes captured into the audio buffer.
Definition: ntv2publicinterface.h:7888
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
NTV2_AUDIO_ANALOG
@ NTV2_AUDIO_ANALOG
Obtain audio samples from the device analog input(s), if available.
Definition: ntv2enums.h:1954
CaptionData
This structure encapsulates all possible CEA-608 caption data bytes that may be associated with a giv...
Definition: ntv2caption608types.h:655
CNTV2Card::SetNumberAudioChannels
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:146
CNTV2Card::SetAudioBufferSize
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device.
Definition: ntv2audio.cpp:249
CaptionData::f2_char2
UByte f2_char2
Caption Byte 2 of Field 2.
Definition: ntv2caption608types.h:663
NTV2_HDMI_V2_4K_CAPTURE
@ NTV2_HDMI_V2_4K_CAPTURE
Definition: ntv2enums.h:3922
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
NTV2_INPUT_SOURCE_IS_ANALOG
#define NTV2_INPUT_SOURCE_IS_ANALOG(_inpSrc_)
Definition: ntv2enums.h:1241
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2097
NTV2_MODE_DISPLAY
@ NTV2_MODE_DISPLAY
Playout (output) mode, which reads from device SDRAM.
Definition: ntv2enums.h:1200
NTV2FrameGrabber::SetTimeCodeSource
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
Definition: ntv2framegrabber.cpp:103
NTV2_XptFrameBuffer2DS2Input
@ NTV2_XptFrameBuffer2DS2Input
Definition: ntv2enums.h:2696
NTV2AudioSource
NTV2AudioSource
This enum value determines/states where an audio system will obtain its audio samples.
Definition: ntv2enums.h:1950
CNTV2Card::GetTsiFrameEnable
virtual bool GetTsiFrameEnable(bool &outIsEnabled, const NTV2Channel inChannel)
Returns the current SMPTE 425 two-sample-interleave frame mode on the device, whether it's enabled or...
Definition: ntv2register.cpp:1404
NTV2ChannelToAudioSystem
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4927
AUTOCIRCULATE_TRANSFER::acANCBuffer
NTV2Buffer acANCBuffer
The host ancillary data buffer. This field is owned by the client application, and thus is responsibl...
Definition: ntv2publicinterface.h:7995
NTV2_XptCSC2VidInput
@ NTV2_XptCSC2VidInput
Definition: ntv2enums.h:2711
CNTV2DriverInterface::Open
virtual bool Open(const UWord inDeviceIndex)
Opens a local/physical AJA device so it can be monitored/controlled.
Definition: ntv2driverinterface.cpp:131
CNTV2Card::AutoCirculateStop
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=(0))
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Definition: ntv2autocirculate.cpp:519
DEVICE_ID_NOTFOUND
@ DEVICE_ID_NOTFOUND
Invalid or "not found".
Definition: ntv2enums.h:90
CNTV2Card::GetSDIInput3GbPresent
virtual bool GetSDIInput3GbPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3614
NTV2_ANCSIZE_MAX
#define NTV2_ANCSIZE_MAX
Definition: ntv2democommon.h:47
NTV2_Xpt425Mux1BInput
@ NTV2_Xpt425Mux1BInput
Definition: ntv2enums.h:2803
CaptionData::f1_char1
UByte f1_char1
Caption Byte 1 of Field 1.
Definition: ntv2caption608types.h:658
NTV2_IS_VALID_VIDEO_FORMAT
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:688
CRP188::GetRP188Str
bool GetRP188Str(std::string &sRP188) const
Definition: ntv2rp188.cpp:918
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
QTPREVIEW_WIDGET_X
#define QTPREVIEW_WIDGET_X
Definition: ntv2framegrabber.h:35
NTV2_Xpt425Mux2AInput
@ NTV2_Xpt425Mux2AInput
Definition: ntv2enums.h:2804
NTV2FrameGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2framegrabber.cpp:858
NTV2_CC608_MaxRow
const UWord NTV2_CC608_MaxRow(15)
The maximum permissible row index number (located at the bottom of the screen).
CNTV2Card::SetAudioRate
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:205
NTV2FrameGrabber::~NTV2FrameGrabber
virtual ~NTV2FrameGrabber()
My destructor.
Definition: ntv2framegrabber.cpp:63