10 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) 22 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_) 23 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_) 24 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_) 25 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_) 26 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_) 33 : QDialog (parent, flags)
35 if (objectName ().isEmpty ())
36 setObjectName (QString::fromUtf8 (
"Dialog"));
38 mBoardChoiceCombo =
new QComboBox;
41 mInputButtonGroup =
new QButtonGroup ();
43 for (
unsigned ndx (0); ndx < 8; ndx++)
45 for (
unsigned ndx (0); ndx < 4; ndx++)
51 mWithAudioCheckBox =
new QCheckBox (
"With Audio",
this);
52 mCheckFor4kCheckBox =
new QCheckBox (
"Check for 4K Input",
this);
53 mCheckFixedReference =
new QCheckBox (
"Fixed Reference",
this);
60 mFrameGrabber->
SetDeviceIndex (mBoardChoiceCombo->currentIndex ());
63 QVBoxLayout * layout (
new QVBoxLayout);
64 layout->addWidget (mBoardChoiceCombo);
65 layout->addWidget (mVideoPreviewWidget);
67 #if defined (INCLUDE_AJACC) 68 QVBoxLayout * bottomLeftLayout (
new QVBoxLayout);
69 bottomLeftLayout->setContentsMargins (0, 0, 0, 0);
71 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
72 bottomLeftLayout->addWidget (iter.next());
74 bottomLeftLayout->addWidget (mWithAudioCheckBox);
75 bottomLeftLayout->addWidget (mCheckFor4kCheckBox);
76 bottomLeftLayout->addStretch (1);
78 QVBoxLayout * bottomRightLayout (
new QVBoxLayout);
79 bottomRightLayout->setContentsMargins (0, 0, 0, 0);
81 mCaptionButtonGroup =
new QButtonGroup ();
83 for (
unsigned ndx (1); ndx <= 8; ndx++)
84 mCaptionButtonGroup->addButton (
new QRadioButton (QString (
"%1%2").arg (
string (ndx < 5 ?
"CC" :
"TXT").c_str(),
string (1,
char ((ndx < 5 ? ndx : ndx - 4) +
'0')).c_str())),
88 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext (); )
89 bottomRightLayout->addWidget (iter.next());
91 QHBoxLayout * bottomLayout (
new QHBoxLayout);
92 bottomLayout->setContentsMargins (0, 0, 0, 0);
94 bottomLayout->addLayout (bottomLeftLayout);
95 bottomLayout->addLayout (bottomRightLayout);
96 layout->addLayout (bottomLayout);
97 #else // !defined (INCLUDE_AJACC) 98 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
99 layout->addWidget (iter.next());
100 layout->addWidget (mWithAudioCheckBox);
101 layout->addWidget (mCheckFor4kCheckBox);
102 layout->addWidget (mCheckFixedReference);
103 #endif // !defined (INCLUDE_AJACC) 105 layout->addStretch (1);
108 connect (mBoardChoiceCombo, SIGNAL(currentIndexChanged(
int)),
this, SLOT(RequestDeviceChange(
const int)));
109 connect (mInputButtonGroup, SIGNAL(idReleased(
int)),
this, SLOT(inputChanged(
int)));
110 connect (mWithAudioCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(withAudioChanged(
int)));
111 connect (mCheckFixedReference, SIGNAL(toggled(
bool)),
this, SLOT(fixedRefChanged(
bool)));
112 connect (mCheckFor4kCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(checkFor4kChanged(
int)));
113 connect (mFrameGrabber, SIGNAL(newFrame(
const QImage&,
bool)), mVideoPreviewWidget, SLOT(updateFrame(
const QImage &,
bool)));
114 connect (mFrameGrabber, SIGNAL(newStatusString(
const QString)), mVideoPreviewWidget, SLOT(updateStatusString(
const QString)));
115 #if defined (INCLUDE_AJACC) 116 connect (mFrameGrabber, SIGNAL (captionScreenChanged (
const ushort *)), mVideoPreviewWidget, SLOT (updateCaptionScreen (
const ushort *)));
117 connect (mCaptionButtonGroup, SIGNAL (buttonReleased (
int)), mFrameGrabber, SLOT (changeCaptionChannel (
int)));
118 #endif // defined (INCLUDE_AJACC) 121 mFrameGrabber->start ();
122 mTimerID = startTimer (100);
133 delete mFrameGrabber;
138 void NTV2QtPreview::RequestDeviceChange (
const int inDeviceIndexNum)
143 FGNOTE(
"Device changed to " << inDeviceIndexNum);
148 void NTV2QtPreview::inputChanged (
int inputRadioButtonId)
154 {
FGNOTE(
"No device at " << mBoardChoiceCombo->currentIndex());
return;}
166 else FGWARN(
"input source " << inputRadioButtonId <<
" unsupported by device");
171 void NTV2QtPreview::withAudioChanged (
int state)
173 mFrameGrabber->
SetWithAudio (state == Qt::Checked ?
true :
false);
178 void NTV2QtPreview::fixedRefChanged (
bool checked)
185 void NTV2QtPreview::checkFor4kChanged (
int state)
192 void NTV2QtPreview::updateInputs (
void)
194 CNTV2Card ntv2Card (mBoardChoiceCombo->currentIndex());
195 if (ntv2Card.IsOpen())
197 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
199 QRadioButton * pButton (reinterpret_cast<QRadioButton*>(iter.next()));
203 const bool hasInputSource (ntv2Card.features().CanDoInputSource(inputSource));
204 const string videoFormatStr (hasInputSource ? ::
NTV2VideoFormatToString(ntv2Card.GetInputVideoFormat(inputSource)) :
"");
205 const QString buttonLabel (QString(
"%1 %2").arg(::
NTV2InputSourceToString(inputSource,
true).c_str(), videoFormatStr.empty() ?
"No Detected Input" : videoFormatStr.c_str()));
206 pButton->setText(buttonLabel);
207 pButton->setEnabled(hasInputSource);
210 #if defined (INCLUDE_AJACC) 212 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext(); )
213 iter.next()->setEnabled(hasCustomAnc);
214 #endif // defined (INCLUDE_AJACC) 219 void NTV2QtPreview::timerEvent (QTimerEvent * event)
221 if (event->timerId() == mTimerID)
224 QWidget::timerEvent(event);
228 void NTV2QtPreview::devicesChanged (
void)
234 mBoardChoiceCombo->clear();
235 for (
ULWord ndx(0); ndx < 100; ndx++)
239 mBoardChoiceCombo->addItem(tr(device.
GetDisplayName().c_str()), QVariant());
241 {mBoardChoiceCombo->addItem(tr(
"No Devices Found"));
break;}
245 mBoardChoiceCombo->setCurrentIndex(0);
249 void NTV2QtPreview::PnpCallback (
AJAPnpMessage inMessage,
void * pUserData)
254 NTV2QtPreview * pMainWindow (reinterpret_cast<NTV2QtPreview*>(pUserData));
255 pMainWindow->devicesChanged();
Specifies SDI input/output kinds.
I am a QDialog that displays whatever video is present on the SDI inputs of an AJA device...
void SetFixedReference(bool fixed)
I interrogate and control an AJA video/audio capture/playout device.
Declares the AJADebug class.
virtual AJAStatus Uninstall()
Uninstalls any previously-installed callback notifier.
Specifies HDMI input/output kinds.
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). ...
virtual class DeviceCapabilities & features(void)
bool CanDoInputSource(const NTV2InputSource inSrc)
bool CanDoCustomAnc(void)
#define QTPREVIEW_WIDGET_Y
NTV2QtPreview(QWidget *parent=NULL, Qt::WindowFlags flags=Qt::WindowFlags())
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
virtual bool IsOpen(void) const
Specifies analog input/output kinds.
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Header file for NTV2QtPreview demo application. Demonstrates how to capture audio/video from NTV2-bas...
NTV2InputSource GetNTV2InputSourceForIndex(const ULWord inIndex0, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
static bool GetDeviceAtIndex(const ULWord inDeviceIndexNumber, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device having the given zero-bas...
void SetWithAudio(const bool inWithAudio)
Enables or disables host audio playback.
NTV2InputSource
Identifies a specific video input source.
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Declares numerous NTV2 utility functions.
QListIterator< QAbstractButton * > QButtonIterator
#define QTPREVIEW_WIDGET_X
virtual AJAStatus Install(AJAPnpCallback pInCallback, void *inRefCon=NULL, uint32_t inDeviceMask=0xFFFFFFFF)
Installs the given plug & play notification callback function, replacing any callback function that m...
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Identifies the 1st SDI video input.