AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2streamgrabber.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef NTV2STREAMGRABBER_H
9 #define NTV2STREAMGRABBER_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 #include <QtMultimedia>
20 #include "ntv2card.h"
21 #include "ntv2enums.h"
22 #include "ntv2task.h"
23 #include "ntv2rp188.h"
24 #include "ajabase/common/types.h"
25 #include "ajabase/system/process.h"
26 #if defined (INCLUDE_AJACC)
29 #endif // INCLUDE_AJACC
30 
31 #define STREAMPREVIEW_WIDGET_X (960)
32 #define STREAMPREVIEW_WIDGET_Y (540)
33 
34 
35 
42 class NTV2StreamGrabber : public QThread
43 {
44  Q_OBJECT
45 
46  // Instance Methods
47  public:
52  NTV2StreamGrabber (QObject * pInParentObject = NULL);
53 
54  virtual ~NTV2StreamGrabber ();
55 
60  void SetInputSource (const NTV2InputSource inInputSource);
61 
66  inline void SetWithAudio (const bool inWithAudio) {mbWithAudio = inWithAudio; mRestart = true;}
67 
72  void SetDeviceIndex (const UWord inDeviceIndex);
73 
74  void SetTimeCodeSource (const NTV2TCIndex inTCSource);
75 
76  UWord GetDeviceIndex (void) const;
77 
82  inline void CheckFor4kInput (const bool inCheckFor4K) {mCheckFor4K = inCheckFor4K;}
83 
88  inline void SetDeinterlaceNonProgressiveVideo (const bool inDeinterlace) {mDeinterlace = inDeinterlace;}
89 
90  inline bool GetDeinterlaceNonProgressiveVideo (void) const {return mDeinterlace;}
91 
92  void SetFixedReference(bool fixed) {mbFixedReference = fixed;}
93 
94  protected:
95  void ClearCaptionBuffer (const bool inSignalClients = false);
96  void GrabCaptions (void);
97 
98 
99  signals:
106  void newFrame (const QImage &inImage, const bool inClear);
107 
112  void newStatusString (const QString & inStatus);
113 
118  void captionScreenChanged (const ushort * pInScreen);
119 
120  private slots:
121  void changeCaptionChannel (int id);
122 
123 
124  protected:
125  virtual void run (void);
126 
127  bool SetupInput (void);
128  void StopAutoCirculate (void);
129  void SetupAudio (void);
130 
146  void OutputAudio (ULWord * pInOutAudioBuffer, const ULWord inNumValidBytes);
147 
148  bool CheckForValidInput (void);
149 
152 
153  bool IsInput3Gb (const NTV2InputSource inputSource);
154 
155  // Instance Data
156  private:
157  bool mRestart;
158  bool mAbort;
159  bool mCheckFor4K;
160  bool mDeinterlace;
161  bool mbFixedReference;
162 
163  CNTV2Card mNTV2Card;
164  UWord mBoardNumber;
165  NTV2DeviceID mDeviceID;
166  NTV2Channel mChannel;
167  ULWord mNumChannels;
168  bool mTsi;
169  NTV2VideoFormat mCurrentVideoFormat;
170  NTV2LHIHDMIColorSpace mCurrentColorSpace;
171  NTV2VideoFormat mLastVideoFormat;
172  ULWord mDebounceCounter;
173  bool mFormatIsProgressive;
174  NTV2InputSource mInputSource;
175  NTV2FrameDimensions mFrameDimensions;
176  NTV2FrameBufferFormat mFrameBufferFormat;
177  AUTOCIRCULATE_TRANSFER mTransferStruct;
178  NTV2EveryFrameTaskMode mSavedTaskMode;
179  bool mDoMultiChannel;
180 
181  bool mbWithAudio;
182  QAudioOutput * mAudioOutput;
183  QAudioFormat mFormat;
184  QIODevice * mAudioDevice;
185  ULWord mNumAudioChannels;
186  NTV2AudioSystem mAudioSystem;
187 
188  std::string mTimeCode;
189  NTV2TCIndex mTimeCodeSource;
190  #if defined (INCLUDE_AJACC)
191  CNTV2CaptionDecoder608Ptr m608Decoder;
192  CNTV2CaptionDecoder708Ptr m708Decoder;
193  ushort mScreenBuffer [15][32];
194 
195  static void Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo);
196  void caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo);
197  #endif // defined (INCLUDE_AJACC)
198 
199 }; // class NTV2StreamGrabber
200 
201 
202 #endif // NTV2STREAMGRABBER_H
NTV2StreamGrabber::newStatusString
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
NTV2StreamGrabber::SetupAudio
void SetupAudio(void)
Performs audio configuration.
Definition: ntv2streamgrabber.cpp:871
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
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).
NTV2StreamGrabber::SetWithAudio
void SetWithAudio(const bool inWithAudio)
Enables or disables host audio playback.
Definition: ntv2streamgrabber.h:66
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
NTV2StreamGrabber::SetupInput
bool SetupInput(void)
Configures my AJA device for capture.
Definition: ntv2streamgrabber.cpp:487
NTV2StreamGrabber::run
virtual void run(void)
My thread function.
Definition: ntv2streamgrabber.cpp:277
NTV2Caption608ChangeInfo
This class is used to respond to dynamic events that occur during CEA-608 caption decoding.
Definition: ntv2caption608types.h:779
NTV2StreamGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2streamgrabber.cpp:848
process.h
Declares the AJAProcess class.
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
NTV2StreamGrabber::SetFixedReference
void SetFixedReference(bool fixed)
Definition: ntv2streamgrabber.h:92
NTV2StreamGrabber::StopAutoCirculate
void StopAutoCirculate(void)
Stops capturing.
Definition: ntv2streamgrabber.cpp:731
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
NTV2StreamGrabber::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.
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:262
NTV2StreamGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2streamgrabber.cpp:115
NTV2StreamGrabber::ClearCaptionBuffer
void ClearCaptionBuffer(const bool inSignalClients=false)
Definition: ntv2streamgrabber.cpp:163
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1221
NTV2StreamGrabber::SetInputSource
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
Definition: ntv2streamgrabber.cpp:77
NTV2StreamGrabber::GrabCaptions
void GrabCaptions(void)
Performs caption data extraction & decoding.
Definition: ntv2streamgrabber.cpp:177
NTV2StreamGrabber
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
Definition: ntv2streamgrabber.h:42
NTV2StreamGrabber::~NTV2StreamGrabber
virtual ~NTV2StreamGrabber()
My destructor.
Definition: ntv2streamgrabber.cpp:63
NTV2StreamGrabber::NTV2StreamGrabber
NTV2StreamGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2streamgrabber.cpp:31
NTV2StreamGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2streamgrabber.cpp:803
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
NTV2StreamGrabber::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: ntv2streamgrabber.cpp:912
NTV2StreamGrabber::SetDeinterlaceNonProgressiveVideo
void SetDeinterlaceNonProgressiveVideo(const bool inDeinterlace)
Enables or disables deinterlacing of non-progressive video.
Definition: ntv2streamgrabber.h:88
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
NTV2StreamGrabber::CheckFor4kInput
void CheckFor4kInput(const bool inCheckFor4K)
Enables or disables checking for 4K/UHD video (on devices that supported 4K/UHD).
Definition: ntv2streamgrabber.h:82
NTV2StreamGrabber::IsInput3Gb
bool IsInput3Gb(const NTV2InputSource inputSource)
Definition: ntv2streamgrabber.cpp:861
NTV2StreamGrabber::captionScreenChanged
void captionScreenChanged(const ushort *pInScreen)
This is signaled (called) when my caption screen buffer changes.
NTV2AudioSystem
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information.
Definition: ntv2enums.h:3809
NTV2StreamGrabber::CheckForValidInput
bool CheckForValidInput(void)
Definition: ntv2streamgrabber.cpp:747
ntv2captiondecoder608.h
Declares the CNTV2CaptionDecoder608 class.
NTV2StreamGrabber::SetTimeCodeSource
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
Definition: ntv2streamgrabber.cpp:103
NTV2StreamGrabber::SetDeviceIndex
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
Definition: ntv2streamgrabber.cpp:91