AJA NTV2 SDK  18.1.0.2262
NTV2 SDK 18.1.0.2262
ntv2framegrabber.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef NTV2FRAMEGRABBER_H
9 #define NTV2FRAMEGRABBER_H
10 
11 #include <QBasicTimer>
12 #include <QtCore>
13 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
14  #include <QtWidgets>
15 #else
16  #include <QtGui>
17 #endif
18 #include <QThread>
19 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
20 #include <QtMultimedia>
21 #else
22 #include <QAudioOutput>
23 #endif
24 #include "ntv2card.h"
25 #include "ntv2enums.h"
26 #include "ntv2rp188.h"
27 #include "ajabase/common/types.h"
28 #include "ajabase/system/process.h"
29 #if defined (INCLUDE_AJACC)
32 #endif // INCLUDE_AJACC
33 
34 #define QTPREVIEW_WIDGET_X (960)
35 #define QTPREVIEW_WIDGET_Y (540)
36 
37 
38 
45 class NTV2FrameGrabber : public QThread
46 {
47  Q_OBJECT
48 
49  // Instance Methods
50  public:
55  NTV2FrameGrabber (QObject * pInParentObject = NULL);
56 
57  virtual ~NTV2FrameGrabber ();
58 
63  void SetInputSource (const NTV2InputSource inInputSource);
64 
69  inline void SetWithAudio (const bool inWithAudio) {mbWithAudio = inWithAudio; mRestart = true;}
70 
75  void SetDeviceIndex (const UWord inDeviceIndex);
76 
77  void SetTimeCodeSource (const NTV2TCIndex inTCSource);
78 
79  UWord GetDeviceIndex (void) const;
80 
85  inline void CheckFor4kInput (const bool inCheckFor4K) {mCheckFor4K = inCheckFor4K;}
86 
91  inline void SetDeinterlaceNonProgressiveVideo (const bool inDeinterlace) {mDeinterlace = inDeinterlace;}
92 
93  inline bool GetDeinterlaceNonProgressiveVideo (void) const {return mDeinterlace;}
94 
95  void SetFixedReference(bool fixed) {mbFixedReference = fixed;}
96 
97  protected:
98  void ClearCaptionBuffer (const bool inSignalClients = false);
99  void GrabCaptions (void);
100 
101 
102  signals:
109  void newFrame (const QImage &inImage, const bool inClear);
110 
115  void newStatusString (const QString & inStatus);
116 
121  void captionScreenChanged (const ushort * pInScreen);
122 
123  private slots:
124  void changeCaptionChannel (int id);
125 
126 
127  protected:
128  virtual void run (void);
129 
130  bool SetupInput (void);
131  void StopAutoCirculate (void);
132  void SetupAudio (void);
133 
149  void OutputAudio (ULWord * pInOutAudioBuffer, const ULWord inNumValidBytes);
150 
151  bool CheckForValidInput (void);
152 
155 
156  bool IsInput3Gb (const NTV2InputSource inputSource);
157 
158  // Instance Data
159  private:
160  bool mRestart;
161  bool mAbort;
162  bool mCheckFor4K;
163  bool mDeinterlace;
164  bool mbFixedReference;
165 
166  CNTV2Card mNTV2Card;
167  UWord mBoardNumber;
168  NTV2DeviceID mDeviceID;
169  NTV2Channel mChannel;
170  ULWord mNumChannels;
171  bool mTsi;
172  NTV2VideoFormat mCurrentVideoFormat;
173  NTV2LHIHDMIColorSpace mCurrentColorSpace;
174  NTV2VideoFormat mLastVideoFormat;
175  ULWord mDebounceCounter;
176  bool mFormatIsProgressive;
177  NTV2InputSource mInputSource;
178  NTV2FrameSize mFrameDimensions;
179  NTV2PixelFormat mFrameBufferFormat;
180  AUTOCIRCULATE_TRANSFER mTransferStruct;
181  NTV2TaskMode mSavedTaskMode;
182  bool mDoMultiChannel;
183 
184  bool mbWithAudio;
185 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
186  QAudioOutput * mAudioOutput;
187 #else
188  QAudioSink * mAudioOutput;
189 #endif
190  QAudioFormat mFormat;
191  QIODevice * mAudioDevice;
192  ULWord mNumAudioChannels;
193  NTV2AudioSystem mAudioSystem;
194 
195  std::string mTimeCode;
196  NTV2TCIndex mTimeCodeSource;
197  #if defined (INCLUDE_AJACC)
198  CNTV2CaptionDecoder608Ptr m608Decoder;
199  CNTV2CaptionDecoder708Ptr m708Decoder;
200  ushort mScreenBuffer [15][32];
201 
202  static void Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo);
203  void caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo);
204  #endif // defined (INCLUDE_AJACC)
205 
206 }; // class NTV2FrameGrabber
207 
208 
209 #endif // NTV2FRAMEGRABBER_H
virtual void run(void)
My thread function.
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3898
Declares common types used in the ajabase library.
This class is used to respond to dynamic events that occur during CEA-608 caption decoding...
#define NULL
void SetFixedReference(bool fixed)
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:221
NTV2TaskMode
Describes the task mode state. See also: NTV2 Device Sharing.
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
void CheckFor4kInput(const bool inCheckFor4K)
Enables or disables checking for 4K/UHD video (on devices that supported 4K/UHD). ...
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
void ClearCaptionBuffer(const bool inSignalClients=(0))
uint32_t ULWord
Definition: ajatypes.h:236
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1359
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3954
bool IsInput3Gb(const NTV2InputSource inputSource)
bool GetDeinterlaceNonProgressiveVideo(void) const
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
Enumerations for controlling NTV2 devices.
UWord GetDeviceIndex(void) const
Declares the CNTV2CaptionDecoder708 class.
Declares the CRP188 class. See SMPTE RP188 standard for details.
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
NTV2VideoFormat GetVideoFormatFromInputSource(void)
void SetWithAudio(const bool inWithAudio)
Enables or disables host audio playback.
void GrabCaptions(void)
Performs caption data extraction & decoding.
void newFrame(const QImage &inImage, const bool inClear)
This is signaled (called) when a new frame has been captured and is available for display...
Declares the AJAProcess class.
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1264
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
bool CheckForValidInput(void)
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
bool SetupInput(void)
Configures my AJA device for capture.
void SetupAudio(void)
Performs audio configuration.
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Describes the horizontal and vertical size dimensions of a raster, bitmap, frame or image...
void StopAutoCirculate(void)
Stops capturing.
uint16_t UWord
Definition: ajatypes.h:234
void SetDeinterlaceNonProgressiveVideo(const bool inDeinterlace)
Enables or disables deinterlacing of non-progressive video.
void captionScreenChanged(const ushort *pInScreen)
This is signaled (called) when my caption screen buffer changes.
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
Declares the CNTV2Card class.
NTV2FrameGrabber(QObject *pInParentObject=NULL)
Constructs me.
Declares the CNTV2CaptionDecoder608 class.
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...
virtual ~NTV2FrameGrabber()
My destructor.
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3681