AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
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 "ntv2utils.h"
11 #if defined (INCLUDE_AJACC)
14  using namespace std;
15 #endif
16 
17 #define NTV2_NUM_IMAGES (10)
18 
19 // Convenience macros for EZ logging:
20 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
21 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
22 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
23 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
24 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
25 
26 static QMutex gMutex;
27 
28 
30  : QThread (parent),
31  mRestart (true),
32  mAbort (false),
33  mCheckFor4K (false),
34  mDeinterlace (true),
35  mbFixedReference (false),
36  mBoardNumber (0),
37  mDeviceID (DEVICE_ID_NOTFOUND),
38  mChannel (NTV2_MAX_NUM_CHANNELS),
39  mNumChannels (0),
40  mTsi (false),
41  mCurrentVideoFormat (NTV2_FORMAT_UNKNOWN),
42  mCurrentColorSpace (NTV2_LHIHDMIColorSpaceYCbCr),
43  mLastVideoFormat (NTV2_FORMAT_UNKNOWN),
44  mDebounceCounter (0),
45  mFormatIsProgressive (true),
46  mInputSource (NTV2_NUM_INPUTSOURCES),
47  mFrameBufferFormat (NTV2_FBF_ARGB),
48  mDoMultiChannel (false),
49  mbWithAudio (false),
50  mAudioOutput (AJA_NULL),
51  mAudioDevice (AJA_NULL),
52  mNumAudioChannels (0),
53  mAudioSystem (NTV2_AUDIOSYSTEM_1),
54  mTimeCodeSource (NTV2_TCINDEX_INVALID)
55 {
57 } // constructor
58 
59 
61 {
62  mAbort = true;
63  while (isRunning())
64  ; // Wait for grabber thread to finish
65 
67 
68  if (mAudioOutput)
69  delete mAudioOutput;
70 
71 } // destructor
72 
73 
75 {
76  if (inInputSource != mInputSource)
77  {
78  qDebug() << "## DEBUG: NTV2FrameGrabber::SetInputSource" << ::NTV2InputSourceToString (inInputSource).c_str ();
79  gMutex.lock();
80  mInputSource = inInputSource;
81  mRestart = true;
82  gMutex.unlock();
83  }
84 
85 } // SetInputSource
86 
87 
88 void NTV2FrameGrabber::SetDeviceIndex (const UWord inDeviceIndex)
89 {
90  if (inDeviceIndex != mBoardNumber)
91  {
92  gMutex.lock();
93  mBoardNumber = inDeviceIndex;
94  mRestart = true;
95  gMutex.unlock();
96  }
97 } // SetDeviceIndex
98 
99 
101 {
102  if (inTCIndex != mTimeCodeSource)
103  {
104  gMutex.lock();
105  mTimeCodeSource = inTCIndex;
106  mRestart = true;
107  gMutex.unlock();
108  }
109 } // SetTimeCodeSource
110 
111 
113 {
114  gMutex.lock();
115  const UWord result (mBoardNumber);
116  gMutex.unlock();
117  return result;
118 }
119 
120 
121 #if defined (INCLUDE_AJACC)
122  #if 0
123  static const UWord gTest [15][32] =
124  // 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
125  // 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
126  /*01*/ {{0x250C, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
127  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2510},
128  /*02*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
129  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
130  /*03*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
131  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
132  /*04*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
133  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
134  /*05*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
135  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
136  /*06*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
137  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
138  /*07*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
139  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
140  /*08*/ {0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
141  0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
142  /*09*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
143  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
144  /*10*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
145  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
146  /*11*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
147  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
148  /*12*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
149  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
150  /*13*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
151  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
152  /*14*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
153  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
154  /*15*/ {0x2514, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
155  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2518}};
156  #endif // 0
157 #endif // defined (INCLUDE_AJACC)
158 
159 
160 void NTV2FrameGrabber::ClearCaptionBuffer (const bool inNotifyClients)
161 {
162  #if defined (INCLUDE_AJACC)
163  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
164  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
165  mScreenBuffer [row-1][col-1] = 0x0020; // gTest[row-1][col-1];
166  if (inNotifyClients)
167  emit captionScreenChanged (&mScreenBuffer[0][0]);
168  #else
169  (void) inNotifyClients;
170  #endif
171 }
172 
173 
175 {
176  #if defined (INCLUDE_AJACC)
177  NTV2_ASSERT (mNTV2Card.IsOpen ());
178  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
179 
180  if (mNTV2Card.features().CanDoCustomAnc())
181  {
182  bool gotCaptionPacket (false);
183  CaptionData captionData; // The two byte pairs (one pair per field) our 608 decoder is looking for
184  ostringstream oss; // DEBUG
185 
186  // See what's in the AUTOCIRCULATE_TRANSFER's F1 & F2 anc buffers...
187  AJAAncillaryList ancPacketsF1, ancPacketsF2;
188  ancPacketsF1.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCBuffer.GetHostPointer (), mTransferStruct.acANCBuffer.GetByteCount ());
189  ancPacketsF2.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCField2Buffer.GetHostPointer (), mTransferStruct.acANCField2Buffer.GetByteCount ());
190  ancPacketsF1.ParseAllAncillaryData ();
191  ancPacketsF2.ParseAllAncillaryData ();
192 
194  {
196  if (ancCEA708DataIn.GetPayloadData () && ancCEA708DataIn.GetPayloadByteCount ())
197  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA708DataIn.GetPayloadData (), ancCEA708DataIn.GetPayloadByteCount ()) : false;
198  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA708 packet(s)";
199  }
201  {
203  if (ancCEA608DataIn.GetPayloadData () && ancCEA608DataIn.GetPayloadByteCount ())
204  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA608DataIn.GetPayloadData (), ancCEA608DataIn.GetPayloadByteCount ()) : false;
205  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA608 packet(s)";
206  }
208  {
210  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
211  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f1_char1, captionData.f1_char2, captionData.bGotField1Data)))
212  gotCaptionPacket = true;
213  //if (gotCaptionPacket) oss << "Using F1 AJAAnc EIA608 packet(s)";
214  }
216  {
218  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
219  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f2_char1, captionData.f2_char2, captionData.bGotField2Data)))
220  gotCaptionPacket = true;
221  //if (gotCaptionPacket) oss << "Using F2 AJAAnc EIA608 packet(s)";
222  }
223 
224  if (NTV2_IS_HD_VIDEO_FORMAT (mCurrentVideoFormat))
225  {
226  if (gotCaptionPacket && m708Decoder && m708Decoder->ParseSMPTE334AncPacket ())
227  captionData = m708Decoder->GetCC608CaptionData (); // Extract the 608 caption byte pairs
228  } // else if HD
229 
230  // Sorry, we only handle 608 captions -- nothing else.
231  // The 608 decoder does the rest. It expects to be called once per frame (to implement flashing characters and roll-up).
232  // Pass the caption byte pairs to it for processing (even if captionData.HasData returns false)...
233  if (m608Decoder)
234  m608Decoder->ProcessNew608FrameData (captionData);
235  //if (!oss.str ().empty ()) cerr << oss.str () << endl; // DEBUG DEBUG DEBUG DEBUG
236  //if (captionData.HasData ()) cerr << captionData << endl;
237  } // if able to use Anc buffers
238  #endif // defined (INCLUDE_AJACC)
239 } // GrabCaptions
240 
241 
242 void NTV2FrameGrabber::changeCaptionChannel (int inNewCaptionChannelId)
243 {
244  #if defined (INCLUDE_AJACC)
245  const NTV2Line21Channel chosenCaptionChannel (static_cast <NTV2Line21Channel> (inNewCaptionChannelId));
246 
247  if (!m608Decoder && IsValidLine21Channel (chosenCaptionChannel))
248  {
249  NTV2_ASSERT (!m708Decoder);
250  if (CNTV2CaptionDecoder608::Create (m608Decoder) && CNTV2CaptionDecoder708::Create (m708Decoder))
251  {
252  m608Decoder->SubscribeChangeNotification (Caption608Changed, this);
253  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
254  ClearCaptionBuffer (true);
255  }
256  else
257  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
258  }
259  else if (m608Decoder)
260  {
261  NTV2_ASSERT (m708Decoder);
262  if (!IsValidLine21Channel (chosenCaptionChannel))
263  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
264  else if (m608Decoder->GetDisplayChannel () != chosenCaptionChannel)
265  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
266  ClearCaptionBuffer (true);
267  }
268  #else
269  (void) inNewCaptionChannelId;
270  #endif // defined (INCLUDE_AJACC)
271 } // changeCaptionChannel
272 
273 
275 {
276  // Set up 2 images to ping-pong between capture and display...
277  QImage * images [NTV2_NUM_IMAGES];
278  ULWord framesCaptured (0);
279  FGNOTE("Thread started");
280 
281  // Initialize images
282  for (int i(0); i < NTV2_NUM_IMAGES; i++)
283  images[i] = new QImage(QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y, QImage::Format_RGB32);
284 
285  // Make sure all Bidirectionals are set to Inputs.
286  if (mNTV2Card.Open(mBoardNumber))
287  {
288  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
289  {
290  // We have not acquired the board continue until something changes...
291  qDebug ("Could not acquire board number %d", GetDeviceIndex());
292  mNTV2Card.Close ();
293  mDeviceID = DEVICE_ID_NOTFOUND;
294  }
295  else
296  {
297  mNTV2Card.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
298  mNTV2Card.SetEveryFrameServices (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
299 
300  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDI connectors...
301  {
302  bool waitForInput = false;
303  for (unsigned offset(0); offset < 8; offset++)
304  {
305  mNTV2Card.EnableChannel (NTV2Channel(offset));
306  bool outputEnabled;
307  mNTV2Card.GetSDITransmitEnable (NTV2Channel(offset), outputEnabled);
308  if (outputEnabled)
309  {
310  waitForInput = true;
311  mNTV2Card.SetSDITransmitEnable (NTV2Channel(offset), false);
312  }
313  }
314  // Only if we had to change an output to input do we need to wait.
315  if (waitForInput)
316  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // ...and give the device some time to lock to a signal
317  }
318  }
319  }
320 
321  while (true)
322  {
323  if (mAbort)
324  break;
325 
326  if (!NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
327  {
328  // No input chosen, so display banner...
329  if (NTV2_IS_VALID_CHANNEL(mChannel))
331  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
332  currentImage->load (":/resources/splash.png");
333  emit newStatusString ("");
334  emit newFrame (*currentImage, true);
335  AJATime::Sleep(200);
336  continue;
337  }
338 
339  if (mRestart)
340  {
341  gMutex.lock();
343  if (mNTV2Card.IsOpen())
344  {
345  if (!mDoMultiChannel)
346  {
348  mNTV2Card.SetEveryFrameServices (mSavedTaskMode);
349  }
350  mNTV2Card.Close();
351  mDeviceID = DEVICE_ID_NOTFOUND;
352  }
353  gMutex.unlock();
354 
355  if (mNTV2Card.Open(mBoardNumber))
356  {
357  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
358  {
359  // Haven't acquired the device --- continue til other app releases it...
360  qDebug() << mNTV2Card.GetDisplayName().c_str() << "is busy";
361  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
362  currentImage->fill(Qt::lightGray);
363  QString status (QString("%1 is busy").arg(mNTV2Card.GetDisplayName().c_str()));
364  emit newStatusString(status);
365  emit newFrame(*currentImage, true);
366  mNTV2Card.Close();
367  mDeviceID = DEVICE_ID_NOTFOUND;
368  AJATime::Sleep(500);
369  continue;
370  }
371 
372  mNTV2Card.GetEveryFrameServices(mSavedTaskMode); // Save the current state before we change it
373  mNTV2Card.SetEveryFrameServices(NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
374 
375  mDeviceID = mNTV2Card.GetDeviceID();
376  if (mNTV2Card.features().CanDoMultiFormat())
377  mNTV2Card.SetMultiFormatMode(true);
378 
379  if (!mNTV2Card.IsDeviceReady(false))
380  {
381  qDebug() << mNTV2Card.GetDisplayName().c_str() << "not ready";
382  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
383  currentImage->fill(Qt::lightGray);
384  QString status (QString("%1 is not ready").arg(mNTV2Card.GetDisplayName().c_str()));
385  emit newStatusString(status);
386  emit newFrame(*currentImage, true);
387  AJATime::Sleep(1000); // Keep the UI responsive while waiting for device to become ready
388  }
389  else if (!mNTV2Card.features().GetNumCSCs())
390  {
391  qDebug() << mNTV2Card.GetDisplayName().c_str() << "has no CSCs, won't work with NTV2FrameGrabberthis demo";
392  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
393  currentImage->fill(qRgba(40, 40, 40, 255));
394  QString status (QString("%1 won't work with NTV2QtPreview (no CSCs)").arg(mNTV2Card.GetDisplayName().c_str()));
395  emit newStatusString(status);
396  emit newFrame(*currentImage, true);
397  AJATime::Sleep(1000); // Keep the UI responsive while waiting for device to become ready
398  }
399  else if (SetupInput())
400  {
401  mTransferStruct.acANCBuffer.Allocate (mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
402  mTransferStruct.acANCField2Buffer.Allocate(mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
403  const ULWord acOptions(AUTOCIRCULATE_WITH_RP188 | (mTransferStruct.acANCBuffer.IsNULL() && mTransferStruct.acANCField2Buffer.IsNULL() ? 0 : AUTOCIRCULATE_WITH_ANC));
404  gMutex.lock();
406  ULWord numFrameBuffersAvailable = (mNTV2Card.DeviceGetNumberFrameBuffers() - mNTV2Card.features().GetNumAudioSystems());
407  ULWord startFrameBuffer = (numFrameBuffersAvailable / mNTV2Card.features().GetNumFrameStores()) * ULWord(mChannel);
408  mNTV2Card.AutoCirculateInitForInput (mChannel, 0, ::NTV2ChannelToAudioSystem(mChannel),
409  acOptions, 1, startFrameBuffer, startFrameBuffer+7);
410  gMutex.unlock();
411  SetupAudio();
412  if (mAudioOutput)
413  mAudioDevice = mAudioOutput->start();
414 
415  // Start AutoCirculate...
416  mNTV2Card.SetLTCInputEnable(true);
417  mNTV2Card.SetRP188SourceFilter (mChannel, 0); // 0=LTC 1=VITC1 2=VITC2
418  mNTV2Card.AutoCirculateStart(mChannel);
419 
420  for (int i(0); i < NTV2_NUM_IMAGES; i++)
421  {
422  delete images[i];
423  images[i] = new QImage (mFrameDimensions.Width(), mFrameDimensions.Height(), QImage::Format_RGB32);
424  }
425 
426  framesCaptured = 0;
427  mRestart = false;
428  } // if board set up ok
429  else
430  AJATime::Sleep(1000); // This keeps the UI responsive if/while this channel has no input
431  } // if board opened ok
432  else
433  {
434  qDebug() << "## WARNING: Open failed for device " << GetDeviceIndex ();
435  AJATime::Sleep(200);
436  continue;
437  }
438 
439  emit newStatusString(::NTV2InputSourceToString (mInputSource, true).c_str());
440  } // if mRestart
441 
442  if (!CheckForValidInput() && NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
443  {
444  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
445  currentImage->fill(qRgba(40, 40, 40, 255));
446  QString status (QString("%1: No Detected Input").arg(::NTV2InputSourceToString(mInputSource, true).c_str()));
447  emit newStatusString(status);
448  emit newFrame(*currentImage, true);
449  AJATime::Sleep(200);
450  continue;
451  }
452 
453  AUTOCIRCULATE_STATUS acStatus;
454  mNTV2Card.AutoCirculateGetStatus (mChannel, acStatus);
455  if (acStatus.acState == NTV2_AUTOCIRCULATE_RUNNING && acStatus.acBufferLevel > 1)
456  {
457  QImage * currentImage (images [framesCaptured % NTV2_NUM_IMAGES]);
458  NTV2TimeCodeList tcValues;
459 
460  #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
461  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->sizeInBytes()));
462  #else
463  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->byteCount()));
464  #endif
465  mNTV2Card.AutoCirculateTransfer (mChannel, mTransferStruct);
466  if (!mFormatIsProgressive && mDeinterlace)
467  {
468  // Eliminate field flicker by copying even lines to odd lines...
469  // (a very lame de-interlace technique)
470  if (currentImage->height() == int(mFrameDimensions.Height()) && currentImage->width() == int(mFrameDimensions.Width()))
471  for (ULWord line (0); line < mFrameDimensions.Height(); line += 2)
472  ::memcpy (currentImage->scanLine (int(line) + 1), currentImage->scanLine(int(line)), mFrameDimensions.Width() * 4);
473  }
474  GrabCaptions();
475  mTimeCode.clear ();
476  if (mTransferStruct.acTransferStatus.acFrameStamp.GetInputTimeCodes(tcValues) && size_t(mTimeCodeSource) < tcValues.size())
477  {
478  CRP188 tc (tcValues.at(mTimeCodeSource));
479  if (!tcValues.at (mTimeCodeSource).IsValid())
480  {
481  // If the requested timecode was invalid, check for embedded LTC
482  if (NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
483  tc.SetRP188 (tcValues.at (::NTV2InputSourceToTimecodeIndex (mInputSource, true)));
484  }
485  tc.GetRP188Str (mTimeCode);
486  }
487 
488  QString outString (::NTV2InputSourceToString (mInputSource, true).c_str());
489  outString.append (" ");
490  outString.append (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
491  outString.append (" ");
492  outString.append (mTimeCode.c_str());
493 
494  emit newStatusString (outString);
495 
496  emit newFrame (*currentImage, (framesCaptured == 0) ? true : false);
497  if (mbWithAudio && mTransferStruct.acAudioBuffer)
498  OutputAudio (mTransferStruct.acAudioBuffer, mTransferStruct.acTransferStatus.acAudioTransferSize);
499 
500  framesCaptured++;
501  } // if running and at least one frame ready to transfer
502  else
503  mNTV2Card.WaitForInputVerticalInterrupt (mChannel);
504  } // loop til break
505 
506  if (mNTV2Card.IsOpen ())
507  {
508  gMutex.lock();
510  if (!mDoMultiChannel)
511  {
512  mNTV2Card.ReleaseStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())); // Release the device
513  mNTV2Card.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
514  }
515  gMutex.unlock();
516  }
517 
518  for (int i(0); i < NTV2_NUM_IMAGES; i++)
519  delete images[i];
520 
521  FGNOTE("Thread completed, will exit for device" << mNTV2Card.GetDisplayName() << " input source " << ::NTV2InputSourceToString(mInputSource));
522 
523 } // run
524 
525 
527 {
528  if (!mNTV2Card.IsOpen())
529  return false;
530  if (mDeviceID == DEVICE_ID_NOTFOUND)
531  return false;
532 
533  mChannel = ::NTV2InputSourceToChannel(mInputSource);
534  if (mChannel == NTV2_CHANNEL_INVALID)
535  mChannel = NTV2_CHANNEL1;
536  mTimeCodeSource = ::NTV2InputSourceToTimecodeIndex(mInputSource);
537 
538  bool waitForInput(false);
539  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDIs...
540  for (unsigned offset(0); offset < 4; offset++)
541  {
542  mNTV2Card.EnableChannel(NTV2Channel(mChannel + offset));
543  bool outputEnabled;
544  mNTV2Card.GetSDITransmitEnable (NTV2Channel(mChannel + offset), outputEnabled);
545  if (outputEnabled)
546  {
547  waitForInput = true;
548  mNTV2Card.SetSDITransmitEnable (NTV2Channel(mChannel + offset), false);
549  }
550  }
551 
552  // Only if we had to change an output to input do we need to wait.
553  if (waitForInput)
554  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // Give the device ~10 fields/frames to lock to a signal
555 
556  mCurrentVideoFormat = GetVideoFormatFromInputSource();
557  mCurrentColorSpace = GetColorSpaceFromInputSource();
558  mFrameDimensions.Set (QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y);
559  if (!NTV2_IS_VALID_VIDEO_FORMAT(mCurrentVideoFormat))
560  return false; // No video!
561 
562  mNTV2Card.SetVideoFormat (mCurrentVideoFormat, false, false, mChannel);
564  mNTV2Card.GetVANCMode (vm, mChannel);
565  const NTV2FormatDescriptor fd (mCurrentVideoFormat, mFrameBufferFormat, vm);
566  mFrameDimensions.Set (fd.GetRasterWidth(), fd.GetRasterHeight());
567  const QString vfString (::NTV2VideoFormatToString(mCurrentVideoFormat).c_str());
568  qDebug() << "## DEBUG: mInputSource=" << mChannel << ", mCurrentVideoFormat=" << vfString << ", width=" << mFrameDimensions.Width() << ", height=" << mFrameDimensions.Height();
569 
570  mFormatIsProgressive = IsProgressivePicture(mCurrentVideoFormat);
571  if (!mbFixedReference)
573 
574  if (NTV2_INPUT_SOURCE_IS_SDI(mInputSource))
575  {
576  mNumChannels = 0;
577  mTsi = false;
578 
579  bool is6g(false), is12g(false);
580  mNTV2Card.GetSDIInput6GPresent(is6g, mChannel);
581  mNTV2Card.GetSDIInput12GPresent(is12g, mChannel);
582 
583  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
584  {
585  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel), ::GetSDIInputOutputXptFromChannel(mChannel));
586  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel), ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
587  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
588  mNTV2Card.EnableChannel(mChannel);
589  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel, IsInput3Gb(mInputSource) ? true : false);
590  }
591  else for (unsigned offset(0); offset < 4; offset++)
592  {
593  mNumChannels++;
594  mNTV2Card.Connect (::GetCSCInputXptFromChannel (NTV2Channel(mChannel + offset)), ::GetSDIInputOutputXptFromChannel(NTV2Channel(mChannel + offset)));
595  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (NTV2Channel(mChannel + offset)), ::GetCSCOutputXptFromChannel(NTV2Channel(mChannel + offset), false/*isKey*/, true/*isRGB*/));
596  mNTV2Card.SetFrameBufferFormat (NTV2Channel(mChannel + offset), mFrameBufferFormat);
597  mNTV2Card.EnableChannel (NTV2Channel(mChannel + offset));
598  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel + offset, IsInput3Gb(mInputSource) ? true : false);
599  if (!NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat))
600  break;
601  mNTV2Card.Set4kSquaresEnable(true, NTV2_CHANNEL1);
602  }
603  }
604  else if (mInputSource == NTV2_INPUTSOURCE_ANALOG1)
605  {
606  mNumChannels = 0;
607  mTsi = false;
608  //mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
609 
611  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(NTV2_CHANNEL1), ::GetCSCOutputXptFromChannel(NTV2_CHANNEL1, false/*isKey*/, true/*isRGB*/));
612  mNTV2Card.SetFrameBufferFormat(NTV2_CHANNEL1, mFrameBufferFormat);
613  if (!mbFixedReference)
615  mChannel = NTV2_CHANNEL1;
616  mNumChannels = 1;
617  }
618  else if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
619  {
620  mNumChannels = 0;
621  mTsi = false;
622 
623  if (!mbFixedReference)
624  mNTV2Card.SetReference(::NTV2InputSourceToReferenceSource(mInputSource));
625 
626  // configure hdmi with 2.0 support
627  if (mNTV2Card.features().CanDo12gRouting())
628  {
629  mNumChannels = 1;
630  mNTV2Card.EnableChannel(mChannel);
631  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
632  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
633  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
634  {
635  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel),
636  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
637  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
638  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
639  }
640  else
641  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
642  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
643  }
644  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && !mNTV2Card.features().CanDoHDMIQuadRasterConversion())
645  {
646  // Set two sample interleave
647  mChannel = NTV2_CHANNEL1;
648  mNTV2Card.SetTsiFrameEnable(true, NTV2_CHANNEL1);
649 
650  for (NTV2Channel channel (NTV2_CHANNEL1); channel < NTV2_CHANNEL3; channel = NTV2Channel(channel+1))
651  {
652  mNTV2Card.EnableChannel(channel);
653  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
654  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
655  }
656 
657  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
658  {
659  mNTV2Card.Connect (NTV2_XptCSC1VidInput,
660  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
661  mNTV2Card.Connect (NTV2_XptCSC2VidInput,
662  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
663  mNTV2Card.Connect (NTV2_XptCSC3VidInput,
664  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
665  mNTV2Card.Connect (NTV2_XptCSC4VidInput,
666  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
667 
672  }
673  else
674  {
675  mNTV2Card.Connect (NTV2_Xpt425Mux1AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
676  mNTV2Card.Connect (NTV2_Xpt425Mux1BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
677  mNTV2Card.Connect (NTV2_Xpt425Mux2AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
678  mNTV2Card.Connect (NTV2_Xpt425Mux2BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
679  }
680 
685 
686  mNumChannels = 2;
687  mTsi = true;
688  } // if 4K and can't do HDMI quad raster conversion
689  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && mNTV2Card.features().CanDoHDMIQuadRasterConversion())
690  {
691  mNumChannels = 0;
692  mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
693  for (NTV2Channel channel(NTV2_CHANNEL1); channel < NTV2_CHANNEL5; channel = NTV2Channel(channel+1))
694  {
695  mNumChannels++;
696  mNTV2Card.EnableChannel(channel);
697  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
698  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
699  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
700  {
701  mNTV2Card.Connect (::GetCSCInputXptFromChannel(channel),
702  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
703  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(channel),
704  ::GetCSCOutputXptFromChannel (channel, false/*isKey*/, true/*isRGB*/));
705  }
706  else
707  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(channel),
708  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
709  } // loop once for each channel (4 times for 4K/UHD)
710  } // else if 4K and can do HDMI quad raster conversion
711  else
712  {
713  mNumChannels = 1;
714  mNTV2Card.EnableChannel(mChannel);
715  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
716  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
717  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
718  {
719  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel),
720  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
721  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
722  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
723  }
724  else
725  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
726  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
727  } // else not 4K
728 
729  // configure the qrc if present
730  if (mNTV2Card.features().GetHDMIVersion() == 2)
732  }
733  else
734  qDebug () << "## DEBUG: NTV2FrameGrabber::SetupInput: Bad mInputSource switch value " << ::NTV2InputSourceToChannelSpec (mInputSource);
735 
736  return true;
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 
768  if ((mCurrentVideoFormat != videoFormat) || (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  return true;
791  } // if video format changed
792 
793  return true;
794 
795 } // CheckForValidInput
796 
797 
799 {
800  if (!mNTV2Card.IsOpen())
801  return NTV2_FORMAT_UNKNOWN;
802  if (mDeviceID == DEVICE_ID_NOTFOUND)
803  return NTV2_FORMAT_UNKNOWN;
804 
806  if (NTV2_INPUT_SOURCE_IS_SDI(mInputSource))
807  {
808  bool is6g (false), is12g(false);
809  NTV2Channel channel (::NTV2InputSourceToChannel(mInputSource));
810  mNTV2Card.GetSDIInput6GPresent(is6g, channel);
811  mNTV2Card.GetSDIInput12GPresent(is12g, channel);
812  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
813  {
814  videoFormat = mNTV2Card.GetInputVideoFormat(mInputSource);
815  return videoFormat;
816  }
817  }
818 
819  switch (mInputSource)
820  {
823  {
824  const ULWord ndx (::GetIndexForNTV2InputSource(mInputSource));
825  videoFormat = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 0));
826  NTV2Standard videoStandard (::GetNTV2StandardFromVideoFormat(videoFormat));
827  if (mCheckFor4K && (videoStandard == NTV2_STANDARD_1080p))
828  {
829  NTV2VideoFormat videoFormatNext (mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 1)));
830  if (videoFormatNext == videoFormat)
831  {
832  videoFormatNext = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 2));
833  if (videoFormatNext == videoFormat)
834  {
835  videoFormatNext = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 3));
836  if (videoFormatNext == videoFormat)
838  }
839  }
840  }
841  }
842  break;
843 
845  break; // indicates no source is currently selected
846 
847  default:
848  videoFormat = mNTV2Card.GetInputVideoFormat(mInputSource);
849  break;
850  }
851  return videoFormat;
852 
853 } // GetVideoFormatFromInputSource
854 
855 
857 {
858  if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
859  {
861  mNTV2Card.GetHDMIInputColor (hdmiColor, mChannel);
862  return hdmiColor;
863  }
865 }
866 
867 
869 {
870  bool is3Gb(false);
871  mNTV2Card.GetSDIInput3GbPresent (is3Gb, ::NTV2InputSourceToChannel(inputSource));
872  return is3Gb;
873 } // IsInput3Gb
874 
875 
877 {
878  if (!mNTV2Card.IsOpen())
879  return;
880  if (mDeviceID == DEVICE_ID_NOTFOUND)
881  return;
882 
883  mTransferStruct.acAudioBuffer.Allocate(NTV2_AUDIOSIZE_MAX); // Reserve space for largest audio packet/frame
884  if (mAudioOutput)
885  {
886  delete mAudioOutput;
887  mAudioOutput = AJA_NULL;
888  }
889 
890  NTV2AudioSource audioSource (NTV2_AUDIO_EMBEDDED);
891  if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
892  audioSource = NTV2_AUDIO_HDMI;
893  else if (NTV2_INPUT_SOURCE_IS_ANALOG(mInputSource))
894  audioSource = NTV2_AUDIO_ANALOG;
895 
896  // Set up AJA device audio...
897  mNumAudioChannels = mNTV2Card.features().GetMaxAudioChannels();
898  mAudioSystem = ::NTV2ChannelToAudioSystem(mChannel);
899  mNTV2Card.SetAudioSystemInputSource (mAudioSystem, audioSource, ::NTV2InputSourceToEmbeddedAudioInput(mInputSource));
900  mNTV2Card.SetNumberAudioChannels (mNumAudioChannels, mAudioSystem);
901  mNTV2Card.SetAudioRate (NTV2_AUDIO_48K, mAudioSystem);
902  mNTV2Card.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
903 
904  // Set up Qt's audio output...
905 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
906  mFormat.setSampleRate(48000);
907  mFormat.setChannelCount(2);
908  mFormat.setSampleSize(16);
909  mFormat.setCodec("audio/pcm");
910  mFormat.setByteOrder(QAudioFormat::LittleEndian);
911  mFormat.setSampleType(QAudioFormat::SignedInt);
912 #else
913  mFormat.setSampleRate(48000);
914  mFormat.setChannelCount(2);
915  mFormat.setSampleFormat(QAudioFormat::Int16);
916 #endif
917 
918 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
919  QAudioDeviceInfo audioDeviceInfo (QAudioDeviceInfo::defaultOutputDevice());
920  if (audioDeviceInfo.isFormatSupported(mFormat))
921  mAudioOutput = new QAudioOutput (mFormat, AJA_NULL);
922 #else
923  QAudioDevice deviceInfo (QMediaDevices::defaultAudioOutput());
924  if (deviceInfo.isFormatSupported(mFormat))
925  mAudioOutput = new QAudioSink(deviceInfo, mFormat, AJA_NULL);
926 #endif
927 } // SetupAudio
928 
929 
930 void NTV2FrameGrabber::OutputAudio (ULWord * pInOutBuffer, const ULWord inNumValidBytes)
931 {
932  const ULWord nBytesPerAJASample (4); // AJA devices provide four bytes per channel per sample
933  unsigned channel (0); // Current channel being processed
934  UWord qtSampleNdx (0); // Which Qt audio sample is being processed
935  const ULWord totalSamples (inNumValidBytes / mNumAudioChannels); // Total number of audio samples to process, regardless of channel count
936  const ULWord totalAjaSamples (inNumValidBytes / nBytesPerAJASample); // Total number of AJA-device-provided audio samples, one sample per channel
937  UWord * pQtAudioBuffer (reinterpret_cast<UWord*>(pInOutBuffer)); // Qt-centric pointer to the audio buffer (2-bytes per channel per sample)
938 
939  //
940  // Walk through the audio buffer channel by channel:
941  // 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...
942  // and copy samples from channels 0 and 1 up to the front of the buffer...
943  // 0 1 0 1 0 1 0 1 0 1 0 1 ...etc..
944  //
945  for (unsigned ajaSampleNdx(0); ajaSampleNdx < totalAjaSamples; ajaSampleNdx++)
946  {
947  if (channel < 2)
948  {
949  pQtAudioBuffer [qtSampleNdx] = pInOutBuffer [ajaSampleNdx] >> 16; // Also discard the least significant 16 bits of each sample
950  qtSampleNdx++;
951  } // if channel 0 or 1
952 
953  channel++;
954  if (channel == mNumAudioChannels)
955  channel = 0;
956  } // for each channel for each sample
957 
958  if (mAudioDevice)
959  mAudioDevice->write (reinterpret_cast<const char*>(pQtAudioBuffer), totalSamples);
960 
961 } // OutputAudio
962 
963 
964 #if defined (INCLUDE_AJACC)
965  void NTV2FrameGrabber::Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo)
966  {
967  NTV2FrameGrabber * pFG (reinterpret_cast <NTV2FrameGrabber *> (pInstance));
968  if (pFG)
969  pFG->caption608Changed (inChangeInfo);
970  }
971 
972  void NTV2FrameGrabber::caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo)
973  {
974  NTV2Line21Attributes attrs;
975  bool changed (false);
976  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
977  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
978  {
979  ushort utf16Char (m608Decoder ? m608Decoder->GetOnAirUTF16CharacterWithAttributes (row, col, attrs) : 0x0020);
980  if (!utf16Char)
981  utf16Char = 0x0020;
982  if (utf16Char != mScreenBuffer [row-1][col-1])
983  {
984  mScreenBuffer [row-1][col-1] = utf16Char;
985  changed = true;
986  }
987  }
988  if (changed)
989  emit captionScreenChanged (&mScreenBuffer[0][0]);
990  }
991 #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:5083
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:2833
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5107
NTV2FrameGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2framegrabber.cpp:112
NTV2_FBF_ARGB
@ NTV2_FBF_ARGB
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:215
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:1337
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
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3631
NTV2_AUDIO_BUFFER_BIG
@ NTV2_AUDIO_BUFFER_BIG
Definition: ntv2enums.h:1894
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:5155
NTV2FrameGrabber::SetupInput
bool SetupInput(void)
Configures my AJA device for capture.
Definition: ntv2framegrabber.cpp:526
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1334
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6096
NTV2_ASSERT
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:508
NTV2_XptCSC4VidInput
@ NTV2_XptCSC4VidInput
Definition: ntv2enums.h:2746
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:1905
NTV2FrameGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2framegrabber.cpp:798
ancillarylist.h
Declares the AJAAncillaryList class.
NTV2_Xpt425Mux2AYUV
@ NTV2_Xpt425Mux2AYUV
Definition: ntv2enums.h:2628
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3850
NTV2InputSourceToEmbeddedAudioInput
NTV2EmbeddedAudioInput NTV2InputSourceToEmbeddedAudioInput(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2EmbeddedAudioInput value.
Definition: ntv2utils.cpp:4937
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:8017
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:2630
NTV2FormatDescriptor::GetRasterHeight
ULWord GetRasterHeight(const bool inVisibleOnly=false) const
Definition: ntv2formatdescriptor.h:176
NTV2_REFERENCE_ANALOG_INPUT1
@ NTV2_REFERENCE_ANALOG_INPUT1
Specifies the Analog In 1 connector.
Definition: ntv2enums.h:1435
gMutex
static QMutex gMutex
Definition: ntv2framegrabber.cpp:26
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:1647
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3634
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:256
FGNOTE
#define FGNOTE(_expr_)
Definition: ntv2framegrabber.cpp:23
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1336
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:2740
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:3955
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:1195
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:2836
NTV2_CHANNEL_INVALID
@ NTV2_CHANNEL_INVALID
Definition: ntv2enums.h:1345
NTV2FrameDimensions::Set
NTV2FrameDimensions & Set(const ULWord inWidth, const ULWord inHeight)
Sets my dimension values.
Definition: ntv2publicinterface.h:5695
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:769
IsProgressivePicture
bool IsProgressivePicture(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5451
NTV2_CHANNEL4
@ NTV2_CHANNEL4
Specifies channel or Frame Store 4 (or the 4th item).
Definition: ntv2enums.h:1339
AUTOCIRCULATE_STATUS::acState
NTV2AutoCirculateState acState
Current AutoCirculate state.
Definition: ntv2publicinterface.h:7196
NTV2_CHANNEL5
@ NTV2_CHANNEL5
Specifies channel or Frame Store 5 (or the 5th item).
Definition: ntv2enums.h:1340
GetIndexForNTV2InputSource
ULWord GetIndexForNTV2InputSource(const NTV2InputSource inValue)
Definition: ntv2utils.cpp:5334
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:1246
AUTOCIRCULATE_WITH_ANC
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
Definition: ntv2publicinterface.h:5528
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:1251
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:5059
CNTV2Card::DeviceGetNumberFrameBuffers
virtual ULWord DeviceGetNumberFrameBuffers(const NTV2FrameGeometry inFrameGeometry, const NTV2FrameBufferFormat inFBFormat)
Definition: ntv2card.cpp:447
NTV2_XptCSC3VidRGB
@ NTV2_XptCSC3VidRGB
Definition: ntv2enums.h:2570
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7258
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:2724
NTV2FrameGrabber::ClearCaptionBuffer
void ClearCaptionBuffer(const bool inSignalClients=(0))
Definition: ntv2framegrabber.cpp:160
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:156
NTV2_XptCSC4VidRGB
@ NTV2_XptCSC4VidRGB
Definition: ntv2enums.h:2573
NTV2_MAX_NUM_CHANNELS
@ NTV2_MAX_NUM_CHANNELS
Definition: ntv2enums.h:1344
NTV2Buffer::IsNULL
bool IsNULL(void) const
Definition: ntv2publicinterface.h:6118
ULWord
uint32_t ULWord
Definition: ajatypes.h:255
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7193
NTV2FrameGrabber::SetupAudio
void SetupAudio(void)
Performs audio configuration.
Definition: ntv2framegrabber.cpp:876
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:17
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:2116
NTV2_INPUTSOURCE_INVALID
@ NTV2_INPUTSOURCE_INVALID
The invalid video input.
Definition: ntv2enums.h:1259
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:3904
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:1255
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:1338
NTV2_STANDARD_1080p
@ NTV2_STANDARD_1080p
Identifies SMPTE HD 1080p.
Definition: ntv2enums.h:162
UWord
uint16_t UWord
Definition: ajatypes.h:253
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:1266
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1434
GetNTV2InputSourceForIndex
NTV2InputSource GetNTV2InputSourceForIndex(const ULWord inIndex0, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5284
NTV2_XptCSC3VidInput
@ NTV2_XptCSC3VidInput
Definition: ntv2enums.h:2744
ntv2utils.h
Declares numerous NTV2 utility functions.
NTV2FrameGrabber::NTV2FrameGrabber
NTV2FrameGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2framegrabber.cpp:29
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6793
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1263
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:2729
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:723
NTV2_XptAnalogIn
@ NTV2_XptAnalogIn
Definition: ntv2enums.h:2533
CNTV2CaptionDecoder608::Create
static bool Create(CNTV2CaptionDecoder608Ptr &outEncoder)
Creates a new CNTV2CaptionEncoder608 instance.
NTV2_XptFrameBuffer1DS2Input
@ NTV2_XptFrameBuffer1DS2Input
Definition: ntv2enums.h:2725
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1312
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:1260
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:2624
NTV2_Xpt425Mux1BYUV
@ NTV2_Xpt425Mux1BYUV
Definition: ntv2enums.h:2626
AUTOCIRCULATE_TRANSFER_STATUS::acFrameStamp
FRAME_STAMP acFrameStamp
Frame stamp for the transferred frame.
Definition: ntv2publicinterface.h:7920
AUTOCIRCULATE_TRANSFER::acANCField2Buffer
NTV2Buffer acANCField2Buffer
The host "Field 2" ancillary data buffer. This field is owned by the client application,...
Definition: ntv2publicinterface.h:8039
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:7206
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:3750
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:199
AUTOCIRCULATE_TRANSFER::acTransferStatus
AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
Contains status information that's valid after CNTV2Card::AutoCirculateTransfer returns,...
Definition: ntv2publicinterface.h:8054
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1348
NTV2_VANCMODE_INVALID
@ NTV2_VANCMODE_INVALID
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3755
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:930
NTV2Buffer::GetHostPointer
void * GetHostPointer(void) const
Definition: ntv2publicinterface.h:6079
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1244
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:521
NTV2_AUDIO_HDMI
@ NTV2_AUDIO_HDMI
Obtain audio samples from the device HDMI input, if available.
Definition: ntv2enums.h:1985
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:274
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3633
AJAAncillaryDataType_Cea708
#define AJAAncillaryDataType_Cea708
Definition: ancillarydata.h:1639
NTV2_XptFrameBuffer2Input
@ NTV2_XptFrameBuffer2Input
Definition: ntv2enums.h:2726
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:5522
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:1225
NTV2FrameGrabber::GrabCaptions
void GrabCaptions(void)
Performs caption data extraction & decoding.
Definition: ntv2framegrabber.cpp:174
NTV2FrameGrabber::SetInputSource
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
Definition: ntv2framegrabber.cpp:74
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:868
NTV2_AUDIO_EMBEDDED
@ NTV2_AUDIO_EMBEDDED
Obtain audio samples from the audio that's embedded in the video HANC.
Definition: ntv2enums.h:1982
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:6871
NTV2_XptCSC2VidRGB
@ NTV2_XptCSC2VidRGB
Definition: ntv2enums.h:2526
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:3934
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:407
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:88
NTV2_XptCSC1VidRGB
@ NTV2_XptCSC1VidRGB
Definition: ntv2enums.h:2511
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:1265
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:7921
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:1984
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:3956
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:1264
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:1223
NTV2FrameGrabber::SetTimeCodeSource
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
Definition: ntv2framegrabber.cpp:100
NTV2_XptFrameBuffer2DS2Input
@ NTV2_XptFrameBuffer2DS2Input
Definition: ntv2enums.h:2727
NTV2AudioSource
NTV2AudioSource
This enum value determines/states where an audio system will obtain its audio samples.
Definition: ntv2enums.h:1980
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:4929
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:8028
NTV2_XptCSC2VidInput
@ NTV2_XptCSC2VidInput
Definition: ntv2enums.h:2742
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:92
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:2834
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:711
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:227
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:2835
NTV2FrameGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2framegrabber.cpp:856
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:60