AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
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 "ntv2task.h"
27 #include "ntv2rp188.h"
28 #include "ajabase/common/types.h"
29 #include "ajabase/system/process.h"
30 #if defined (INCLUDE_AJACC)
33 #endif // INCLUDE_AJACC
34 
35 #define QTPREVIEW_WIDGET_X (960)
36 #define QTPREVIEW_WIDGET_Y (540)
37 
38 
39 
46 class NTV2FrameGrabber : public QThread
47 {
48  Q_OBJECT
49 
50  // Instance Methods
51  public:
56  NTV2FrameGrabber (QObject * pInParentObject = NULL);
57 
58  virtual ~NTV2FrameGrabber ();
59 
64  void SetInputSource (const NTV2InputSource inInputSource);
65 
70  inline void SetWithAudio (const bool inWithAudio) {mbWithAudio = inWithAudio; mRestart = true;}
71 
76  void SetDeviceIndex (const UWord inDeviceIndex);
77 
78  void SetTimeCodeSource (const NTV2TCIndex inTCSource);
79 
80  UWord GetDeviceIndex (void) const;
81 
86  inline void CheckFor4kInput (const bool inCheckFor4K) {mCheckFor4K = inCheckFor4K;}
87 
92  inline void SetDeinterlaceNonProgressiveVideo (const bool inDeinterlace) {mDeinterlace = inDeinterlace;}
93 
94  inline bool GetDeinterlaceNonProgressiveVideo (void) const {return mDeinterlace;}
95 
96  void SetFixedReference(bool fixed) {mbFixedReference = fixed;}
97 
98  protected:
99  void ClearCaptionBuffer (const bool inSignalClients = false);
100  void GrabCaptions (void);
101 
102 
103  signals:
110  void newFrame (const QImage &inImage, const bool inClear);
111 
116  void newStatusString (const QString & inStatus);
117 
122  void captionScreenChanged (const ushort * pInScreen);
123 
124  private slots:
125  void changeCaptionChannel (int id);
126 
127 
128  protected:
129  virtual void run (void);
130 
131  bool SetupInput (void);
132  void StopAutoCirculate (void);
133  void SetupAudio (void);
134 
150  void OutputAudio (ULWord * pInOutAudioBuffer, const ULWord inNumValidBytes);
151 
152  bool CheckForValidInput (void);
153 
156 
157  bool IsInput3Gb (const NTV2InputSource inputSource);
158 
159  // Instance Data
160  private:
161  bool mRestart;
162  bool mAbort;
163  bool mCheckFor4K;
164  bool mDeinterlace;
165  bool mbFixedReference;
166 
167  CNTV2Card mNTV2Card;
168  UWord mBoardNumber;
169  NTV2DeviceID mDeviceID;
170  NTV2Channel mChannel;
171  ULWord mNumChannels;
172  bool mTsi;
173  NTV2VideoFormat mCurrentVideoFormat;
174  NTV2LHIHDMIColorSpace mCurrentColorSpace;
175  NTV2VideoFormat mLastVideoFormat;
176  ULWord mDebounceCounter;
177  bool mFormatIsProgressive;
178  NTV2InputSource mInputSource;
179  NTV2FrameDimensions mFrameDimensions;
180  NTV2FrameBufferFormat mFrameBufferFormat;
181  AUTOCIRCULATE_TRANSFER mTransferStruct;
182  NTV2EveryFrameTaskMode mSavedTaskMode;
183  bool mDoMultiChannel;
184 
185  bool mbWithAudio;
186 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
187  QAudioOutput * mAudioOutput;
188 #else
189  QAudioSink * mAudioOutput;
190 #endif
191  QAudioFormat mFormat;
192  QIODevice * mAudioDevice;
193  ULWord mNumAudioChannels;
194  NTV2AudioSystem mAudioSystem;
195 
196  std::string mTimeCode;
197  NTV2TCIndex mTimeCodeSource;
198  #if defined (INCLUDE_AJACC)
199  CNTV2CaptionDecoder608Ptr m608Decoder;
200  CNTV2CaptionDecoder708Ptr m708Decoder;
201  ushort mScreenBuffer [15][32];
202 
203  static void Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo);
204  void caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo);
205  #endif // defined (INCLUDE_AJACC)
206 
207 }; // class NTV2FrameGrabber
208 
209 
210 #endif // NTV2FRAMEGRABBER_H
NTV2FrameGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2framegrabber.cpp:115
NTV2FrameGrabber::SetDeinterlaceNonProgressiveVideo
void SetDeinterlaceNonProgressiveVideo(const bool inDeinterlace)
Enables or disables deinterlacing of non-progressive video.
Definition: ntv2framegrabber.h:92
NTV2FrameDimensions
Describes the horizontal and vertical size dimensions of a raster, bitmap, frame or image.
Definition: ntv2publicinterface.h:5632
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3592
types.h
Declares common types used in the ajabase library.
NULL
#define NULL
Definition: ntv2caption608types.h:19
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 Frame Store. They're also commonly used to i...
Definition: ntv2enums.h:1305
AJARefPtr< CNTV2CaptionDecoder608 >
ntv2task.h
Declares the CNTV2Task class (deprecated).
NTV2FrameGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2framegrabber.cpp:764
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:207
NTV2FrameGrabber::CheckFor4kInput
void CheckFor4kInput(const bool inCheckFor4K)
Enables or disables checking for 4K/UHD video (on devices that supported 4K/UHD).
Definition: ntv2framegrabber.h:86
NTV2FrameGrabber::CheckForValidInput
bool CheckForValidInput(void)
Definition: ntv2framegrabber.cpp:722
NTV2Caption608ChangeInfo
This class is used to respond to dynamic events that occur during CEA-608 caption decoding.
Definition: ntv2caption608types.h:779
process.h
Declares the AJAProcess class.
NTV2FrameGrabber::SetWithAudio
void SetWithAudio(const bool inWithAudio)
Enables or disables host audio playback.
Definition: ntv2framegrabber.h:70
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
NTV2FrameGrabber::SetupAudio
void SetupAudio(void)
Performs audio configuration.
Definition: ntv2framegrabber.cpp:831
NTV2FrameGrabber::captionScreenChanged
void captionScreenChanged(const ushort *pInScreen)
This is signaled (called) when my caption screen buffer changes.
ntv2card.h
Declares the CNTV2Card class.
NTV2TCIndex
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3865
ntv2captiondecoder708.h
Declares the CNTV2CaptionDecoder708 class.
UWord
uint16_t UWord
Definition: ajatypes.h:244
ntv2enums.h
Enumerations for controlling NTV2 devices.
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:7904
NTV2FrameGrabber::NTV2FrameGrabber
NTV2FrameGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2framegrabber.cpp:31
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:262
NTV2FrameGrabber::newStatusString
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
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:884
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1221
NTV2FrameGrabber::ClearCaptionBuffer
void ClearCaptionBuffer(const bool inSignalClients=false)
Definition: ntv2framegrabber.cpp:163
NTV2FrameGrabber::run
virtual void run(void)
My thread function.
Definition: ntv2framegrabber.cpp:277
NTV2FrameGrabber
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
Definition: ntv2framegrabber.h:46
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
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.
NTV2FrameGrabber::IsInput3Gb
bool IsInput3Gb(const NTV2InputSource inputSource)
Definition: ntv2framegrabber.cpp:821
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
ntv2rp188.h
Declares the CRP188 class. See SMPTE RP188 standard for details.
NTV2EveryFrameTaskMode
NTV2EveryFrameTaskMode
Describes the task mode state. See also: Sharing AJA Devices With Other Applications.
Definition: ntv2publicinterface.h:4257
NTV2FrameGrabber::StopAutoCirculate
void StopAutoCirculate(void)
Stops capturing.
Definition: ntv2framegrabber.cpp:706
NTV2FrameGrabber::SetDeviceIndex
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
Definition: ntv2framegrabber.cpp:91
NTV2FrameGrabber::SetFixedReference
void SetFixedReference(bool fixed)
Definition: ntv2framegrabber.h:96
NTV2AudioSystem
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information.
Definition: ntv2enums.h:3809
NTV2FrameGrabber::SetTimeCodeSource
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
Definition: ntv2framegrabber.cpp:103
ntv2captiondecoder608.h
Declares the CNTV2CaptionDecoder608 class.
NTV2FrameGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2framegrabber.cpp:808
NTV2FrameGrabber::~NTV2FrameGrabber
virtual ~NTV2FrameGrabber()
My destructor.
Definition: ntv2framegrabber.cpp:63