13 #if defined (INCLUDE_AJACC)
19 #define NTV2_NUM_IMAGES (10)
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_)
37 mbFixedReference (
false),
47 mFormatIsProgressive (
true),
50 mDoMultiChannel (
false),
54 mNumAudioChannels (0),
79 if (inInputSource != mInputSource)
83 mInputSource = inInputSource;
93 if (inDeviceIndex != mBoardNumber)
96 mBoardNumber = inDeviceIndex;
105 if (inTCIndex != mTimeCodeSource)
108 mTimeCodeSource = inTCIndex;
118 const UWord result (mBoardNumber);
124 #if defined (INCLUDE_AJACC)
126 static const UWord gTest [15][32] =
129 {{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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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}};
160 #endif // defined (INCLUDE_AJACC)
165 #if defined (INCLUDE_AJACC)
168 mScreenBuffer [row-1][col-1] = 0x0020;
172 (void) inNotifyClients;
179 #if defined (INCLUDE_AJACC)
185 bool gotCaptionPacket (
false);
199 if (ancCEA708DataIn.
GetPayloadData () && ancCEA708DataIn.GetPayloadByteCount ())
200 gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA708DataIn.
GetPayloadData (), ancCEA708DataIn.GetPayloadByteCount ()) :
false;
206 if (ancCEA608DataIn.
GetPayloadData () && ancCEA608DataIn.GetPayloadByteCount ())
207 gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA608DataIn.
GetPayloadData (), ancCEA608DataIn.GetPayloadByteCount ()) :
false;
215 gotCaptionPacket =
true;
223 gotCaptionPacket =
true;
229 if (gotCaptionPacket && m708Decoder && m708Decoder->ParseSMPTE334AncPacket ())
230 captionData = m708Decoder->GetCC608CaptionData ();
237 m608Decoder->ProcessNew608FrameData (captionData);
241 #endif // defined (INCLUDE_AJACC)
245 void NTV2StreamGrabber::changeCaptionChannel (
int inNewCaptionChannelId)
247 #if defined (INCLUDE_AJACC)
255 m608Decoder->SubscribeChangeNotification (Caption608Changed,
this);
256 m608Decoder->SetDisplayChannel (chosenCaptionChannel);
262 else if (m608Decoder)
267 else if (m608Decoder->GetDisplayChannel () != chosenCaptionChannel)
268 m608Decoder->SetDisplayChannel (chosenCaptionChannel);
272 (void) inNewCaptionChannelId;
273 #endif // defined (INCLUDE_AJACC)
281 ULWord framesCaptured (0);
291 if (mNTV2Card.
Open(mBoardNumber))
307 bool waitForInput =
false;
308 for (
unsigned offset (0); offset < 8; offset++)
334 QImage * currentImage = images [0];
335 currentImage->load (
":/resources/splash.png");
337 emit
newFrame (*currentImage,
true);
347 if (mNTV2Card.IsOpen ())
350 if (!mDoMultiChannel)
360 if (mNTV2Card.
Open(mBoardNumber))
365 qDebug() <<
"Could not acquire board number " <<
GetDeviceIndex();
381 qDebug (
"Device not ready");
402 images[i] =
new QImage ((uchar*)mTransferStruct.
acVideoBuffer.
GetHostAddress(i), mFrameDimensions.Width (), mFrameDimensions.Height (), QImage::Format_RGB32);
408 QImage * currentImage (images [0]);
419 qDebug() <<
"## WARNING: Open failed for device " <<
GetDeviceIndex ();
429 QImage * currentImage (images [0]);
430 currentImage->fill (qRgba (40, 40, 40, 255));
434 emit
newFrame (*currentImage,
true);
439 if (mNTV2Card.IsOpen())
441 QImage * currentImage (images [0]);
444 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
452 outString.append (
" ");
457 emit
newFrame (*currentImage, (framesCaptured == 0) ?
true :
false);
465 if (mNTV2Card.IsOpen ())
469 if (!mDoMultiChannel)
489 bool validInput (
false);
499 bool waitForInput(
false);
501 for (
unsigned offset (0); offset < 4; offset++)
524 switch (mCurrentVideoFormat)
538 mNTV2Card.
SetVideoFormat (mCurrentVideoFormat,
false,
false, mChannel);
544 qDebug() <<
"## DEBUG: mInputSource=" << mChannel <<
", mCurrentVideoFormat=" << vfString <<
", width=" << mFrameDimensions.Width() <<
", height=" << mFrameDimensions.Height();
547 if (!mbFixedReference)
555 for (
unsigned offset (0); offset < 1; offset++)
602 if (!mbFixedReference)
612 if (!mbFixedReference)
733 if (mNTV2Card.IsOpen ())
737 bool tsiEnable(
false);
768 mCurrentVideoFormat = videoFormat;
771 else if ((mCurrentVideoFormat != videoFormat) ||
772 (mCurrentColorSpace != colorSpace))
774 if (mDebounceCounter == 0)
777 mLastVideoFormat = videoFormat;
780 else if (mDebounceCounter == 6)
784 mCurrentVideoFormat = videoFormat;
785 mDebounceCounter = 0;
789 if (mLastVideoFormat == videoFormat)
792 mDebounceCounter = 0;
809 switch (mInputSource)
821 if (videoFormatNext == videoFormat)
824 if (videoFormatNext == videoFormat)
827 if (videoFormatNext == videoFormat)
898 mFormat.setSampleRate (48000);
899 mFormat.setChannelCount (2);
900 mFormat.setSampleSize (16);
901 mFormat.setCodec (
"audio/pcm");
902 mFormat.setByteOrder (QAudioFormat::LittleEndian);
903 mFormat.setSampleType (QAudioFormat::SignedInt);
905 QAudioDeviceInfo audioDeviceInfo (QAudioDeviceInfo::defaultOutputDevice ());
906 if (audioDeviceInfo.isFormatSupported (mFormat))
907 mAudioOutput =
new QAudioOutput (mFormat,
AJA_NULL);
914 const ULWord nBytesPerAJASample (4);
915 unsigned channel (0);
916 UWord qtSampleNdx (0);
917 const ULWord totalSamples (inNumValidBytes / mNumAudioChannels);
918 const ULWord totalAjaSamples (inNumValidBytes / nBytesPerAJASample);
919 UWord * pQtAudioBuffer (
reinterpret_cast <UWord *
> (pInOutBuffer));
928 for (
unsigned ajaSampleNdx = 0; ajaSampleNdx < totalAjaSamples; ajaSampleNdx++)
932 pQtAudioBuffer [qtSampleNdx] = pInOutBuffer [ajaSampleNdx] >> 16;
937 if (channel == mNumAudioChannels)
942 mAudioDevice->write (
reinterpret_cast <const char *
> (pQtAudioBuffer), totalSamples);
947 #if defined (INCLUDE_AJACC)
952 pFG->caption608Changed (inChangeInfo);
958 bool changed (
false);
962 ushort utf16Char (m608Decoder ? m608Decoder->GetOnAirUTF16CharacterWithAttributes (row, col, attrs) : 0x0020);
965 if (utf16Char != mScreenBuffer [row-1][col-1])
967 mScreenBuffer [row-1][col-1] = utf16Char;
974 #endif // defined (INCLUDE_AJACC)