#endif
}
-void CaptureWinGL::resizeEvent(QResizeEvent *event)
-{
- QSize margins = getMargins();
-#ifdef ENABLE_GL
- m_videoSurface.setSize(width() - margins.width(), height() - margins.height());
-#endif
- event->accept();
-}
-
void CaptureWinGL::setFrame(int width, int height, __u32 format, unsigned char *data, const QString &info)
{
#ifdef ENABLE_GL
checkError("InitializeGL");
}
-void CaptureWinGLEngine::setSize(int width, int height)
-{
- QSize sizedFrame = CaptureWin::scaleFrameSize(QSize(width, height), QSize(m_frameWidth, m_frameHeight));
-
- width = sizedFrame.width();
- height = sizedFrame.height();
-
- if (width > 0 && height > 0) {
- setMaximumSize(width, height);
- resizeGL(width, height);
- }
-}
void CaptureWinGLEngine::resizeGL(int width, int height)
{
- glViewport(0, 0, width, height);
+ // Resizing is disabled by setting viewport equal to frame size
+ glViewport(0, 0, m_frameWidth, m_frameHeight);
}
void CaptureWinGLEngine::setFrame(int width, int height, __u32 format, unsigned char *data)
m_frameWidth = width;
m_frameHeight = height;
m_frameFormat = format;
+
+ QGLWidget::setMaximumSize(m_frameWidth, m_frameHeight);
}
m_frameData = data;
#include "qv4l2.h"
#include "capture-win.h"
-#include <QBoxLayout>
-#include <QResizeEvent>
-
#ifdef ENABLE_GL
#define GL_GLEXT_PROTOTYPES
#include <QGLWidget>
void stop();
void setFrame(int width, int height, __u32 format, unsigned char *data);
bool hasNativeFormat(__u32 format);
- void setSize(int width, int height);
protected:
void paintGL();
bool hasNativeFormat(__u32 format);
static bool isSupported();
- protected:
- void resizeEvent(QResizeEvent *event);
-
-private:
#ifdef ENABLE_GL
CaptureWinGLEngine m_videoSurface;
#endif
CaptureWinQt::CaptureWinQt() :
m_frame(new QImage(0, 0, QImage::Format_Invalid))
{
+
CaptureWin::buildWindow(&m_videoSurface);
- m_scaledFrame.setWidth(0);
- m_scaledFrame.setHeight(0);
}
CaptureWinQt::~CaptureWinQt()
delete m_frame;
}
-void CaptureWinQt::resizeEvent(QResizeEvent *event)
-{
- if (m_frame->bits() == NULL)
- return;
-
- QPixmap img = QPixmap::fromImage(*m_frame);
- m_scaledFrame = scaleFrameSize(QSize(m_videoSurface.width(), m_videoSurface.height()),
- QSize(m_frame->width(), m_frame->height()));
- img = img.scaled(m_scaledFrame.width(), m_scaledFrame.height(), Qt::IgnoreAspectRatio);
- m_videoSurface.setPixmap(img);
- QWidget::resizeEvent(event);
-}
-
void CaptureWinQt::setFrame(int width, int height, __u32 format, unsigned char *data, const QString &info)
{
QImage::Format dstFmt;
if (m_frame->width() != width || m_frame->height() != height || m_frame->format() != dstFmt) {
delete m_frame;
m_frame = new QImage(width, height, dstFmt);
- m_scaledFrame = scaleFrameSize(QSize(m_videoSurface.width(), m_videoSurface.height()),
- QSize(m_frame->width(), m_frame->height()));
}
if (data == NULL || !supported)
memcpy(m_frame->bits(), data, m_frame->numBytes());
m_information.setText(info);
-
- QPixmap img = QPixmap::fromImage(*m_frame);
- img = img.scaled(m_scaledFrame.width(), m_scaledFrame.height(), Qt::IgnoreAspectRatio);
-
- m_videoSurface.setPixmap(img);
+ m_videoSurface.setPixmap(QPixmap::fromImage(*m_frame));
}
bool CaptureWinQt::hasNativeFormat(__u32 format)
#include <QLabel>
#include <QImage>
-#include <QResizeEvent>
class CaptureWinQt : public CaptureWin
{
bool hasNativeFormat(__u32 format);
static bool isSupported() { return true; }
-protected:
- void resizeEvent(QResizeEvent *event);
-
private:
bool findNativeFormat(__u32 format, QImage::Format &dstFmt);
QImage *m_frame;
QLabel m_videoSurface;
- QSize m_scaledFrame;
};
#endif
#define MIN_WIN_SIZE_HEIGHT 120
bool CaptureWin::m_enableScaling = true;
-double CaptureWin::m_pixelAspectRatio = 1.0;
CaptureWin::CaptureWin() :
m_curWidth(-1),
resize(w, h);
}
-int CaptureWin::actualFrameWidth(int width)
-{
- if (m_enableScaling)
- return (int)((double)width * m_pixelAspectRatio);
- else
- return width;
-}
-
QSize CaptureWin::getMargins()
{
int l, t, r, b;
delete event;
}
-void CaptureWin::setPixelAspectRatio(double ratio)
-{
- m_pixelAspectRatio = ratio;
- QResizeEvent *event = new QResizeEvent(QSize(width(), height()), QSize(width(), height()));
- QCoreApplication::sendEvent(this, event);
- delete event;
-}
-
void CaptureWin::resize(int width, int height)
{
// Dont resize window if the frame size is the same in
m_curHeight = height;
QSize margins = getMargins();
- width = actualFrameWidth(width) + margins.width();
+ width += margins.width();
height += margins.height();
QDesktopWidget *screen = QApplication::desktop();
QSize CaptureWin::scaleFrameSize(QSize window, QSize frame)
{
- int actualFrameWidth;
+ int actualFrameWidth = frame.width();;
int actualFrameHeight = frame.height();
if (!m_enableScaling) {
window.setWidth(frame.width());
window.setHeight(frame.height());
- actualFrameWidth = frame.width();
- } else {
- actualFrameWidth = CaptureWin::actualFrameWidth(frame.width());
}
double newW, newH;
static bool isSupported() { return false; }
void enableScaling(bool enable);
- void setPixelAspectRatio(double ratio);
static QSize scaleFrameSize(QSize window, QSize frame);
- public slots:
+public slots:
void resetSize();
protected:
*/
static bool m_enableScaling;
- /**
- * @note Aspect ratio it taken care of by scaling, frame size is for square pixels only!
- */
- static double m_pixelAspectRatio;
-
signals:
void close();
m_tvStandard(NULL),
m_qryStandard(NULL),
m_videoTimings(NULL),
- m_pixelAspectRatio(NULL),
m_qryTimings(NULL),
m_freq(NULL),
m_vidCapFormats(NULL),
connect(m_qryTimings, SIGNAL(clicked()), SLOT(qryTimingsClicked()));
}
- if (!isRadio() && !isVbi()) {
- m_pixelAspectRatio = new QComboBox(parent);
- m_pixelAspectRatio->addItem("Autodetect");
- m_pixelAspectRatio->addItem("Square");
- m_pixelAspectRatio->addItem("NTSC/PAL-M/PAL-60");
- m_pixelAspectRatio->addItem("NTSC/PAL-M/PAL-60, Anamorphic");
- m_pixelAspectRatio->addItem("PAL/SECAM");
- m_pixelAspectRatio->addItem("PAL/SECAM, Anamorphic");
-
- addLabel("Pixel Aspect Ratio");
- addWidget(m_pixelAspectRatio);
- connect(m_pixelAspectRatio, SIGNAL(activated(int)), SIGNAL(pixelAspectRatioChanged()));
- }
-
if (m_tuner.capability) {
QDoubleValidator *val;
double factor = (m_tuner.capability & V4L2_TUNER_CAP_LOW) ? 16 : 16000;
updateFrameInterval();
}
-double GeneralTab::getPixelAspectRatio()
-{
- if (m_pixelAspectRatio->currentText().compare("Autodetect") == 0) {
- v4l2_cropcap ratio;
- ratio.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(VIDIOC_CROPCAP, &ratio) < 0)
- return 1.0;
-
- return (double)ratio.pixelaspect.denominator / ratio.pixelaspect.numerator;
- }
- if (m_pixelAspectRatio->currentText().compare("NTSC/PAL-M/PAL-60") == 0)
- return 10.0/11.0;
- if (m_pixelAspectRatio->currentText().compare("NTSC/PAL-M/PAL-60, Anamorphic") == 0)
- return 40.0/33.0;
- if (m_pixelAspectRatio->currentText().compare("PAL/SECAM") == 0)
- return 12.0/11.0;
- if (m_pixelAspectRatio->currentText().compare("PAL/SECAM, Anamorphic") == 0)
- return 16.0/11.0;
- return 1.0;
-}
-
void GeneralTab::updateFrameInterval()
{
v4l2_frmivalenum frmival;
void setAudioDeviceBufferSize(int size);
int getAudioDeviceBufferSize();
bool hasAlsaAudio();
- double getPixelAspectRatio();
bool get_interval(struct v4l2_fract &interval);
int width() const { return m_width; }
int height() const { return m_height; }
signals:
void audioDeviceChanged();
- void pixelAspectRatioChanged();
private slots:
void inputChanged(int);
QComboBox *m_tvStandard;
QPushButton *m_qryStandard;
QComboBox *m_videoTimings;
- QComboBox *m_pixelAspectRatio;
QPushButton *m_qryTimings;
QLineEdit *m_freq;
QComboBox *m_freqTable;
m_saveRawAct->setChecked(false);
connect(m_saveRawAct, SIGNAL(toggled(bool)), this, SLOT(saveRaw(bool)));
- m_showFramesAct = new QAction(QIcon(":/video-television.png"), "&Show Frames", this);
+ m_showFramesAct = new QAction(QIcon(":/video-television.png"), "Show &Frames", this);
m_showFramesAct->setStatusTip("Only show captured frames if set.");
m_showFramesAct->setCheckable(true);
m_showFramesAct->setChecked(true);
toolBar->addSeparator();
toolBar->addAction(quitAct);
- m_scalingAct = new QAction("&Enable Video Scaling", this);
+ m_scalingAct = new QAction("Enable Video Scaling", this);
m_scalingAct->setStatusTip("Scale video frames to match window size if set");
m_scalingAct->setCheckable(true);
m_scalingAct->setChecked(true);
connect(m_scalingAct, SIGNAL(toggled(bool)), this, SLOT(enableScaling(bool)));
- m_resetScalingAct = new QAction("Resize to &Frame Size", this);
+ m_resetScalingAct = new QAction("Resize to Frame Size", this);
m_resetScalingAct->setStatusTip("Resizes the capture window to match frame size");
m_resetScalingAct->setShortcut(Qt::CTRL+Qt::Key_F);
#ifdef HAVE_ALSA
captureMenu->addSeparator();
- m_showAllAudioAct = new QAction("Show All Audio &Devices", this);
+ m_showAllAudioAct = new QAction("Show All Audio Devices", this);
m_showAllAudioAct->setStatusTip("Show all audio input and output devices if set");
m_showAllAudioAct->setCheckable(true);
m_showAllAudioAct->setChecked(false);
captureMenu->addAction(m_showAllAudioAct);
- m_audioBufferAct = new QAction("Set Audio &Buffer Size...", this);
+ m_audioBufferAct = new QAction("Set Audio Buffer Capacity...", this);
m_audioBufferAct->setStatusTip("Set audio buffer capacity in amout of ms than can be stored");
connect(m_audioBufferAct, SIGNAL(triggered()), this, SLOT(setAudioBufferSize()));
captureMenu->addAction(m_audioBufferAct);
newCaptureWin();
+ m_capture->setMinimumSize(150, 50);
+
QWidget *w = new QWidget(m_tabs);
m_genTab = new GeneralTab(device, *this, 4, w);
}
#endif
- connect(m_genTab, SIGNAL(pixelAspectRatioChanged()), this, SLOT(updatePixelAspectRatio()));
m_tabs->addTab(w, "General");
addTabs();
if (caps() & (V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE)) {
break;
}
- m_capture->setPixelAspectRatio(1.0);
m_capture->enableScaling(m_scalingAct->isChecked());
connect(m_capture, SIGNAL(close()), this, SLOT(closeCaptureWin()));
connect(m_resetScalingAct, SIGNAL(triggered()), m_capture, SLOT(resetSize()));
m_capture->enableScaling(enable);
}
-void ApplicationWindow::updatePixelAspectRatio()
-{
- if (m_capture != NULL && m_genTab != NULL)
- m_capture->setPixelAspectRatio(m_genTab->getPixelAspectRatio());
-}
-
void ApplicationWindow::startAudio()
{
#ifdef HAVE_ALSA
m_vbiTab->slicedFormat(fmt.fmt.sliced);
m_vbiSize = fmt.fmt.sliced.io_size;
m_frameData = new unsigned char[m_vbiSize];
- updatePixelAspectRatio();
if (startCapture(m_vbiSize)) {
m_capNotifier = new QSocketNotifier(fd(), QSocketNotifier::Read, m_tabs);
connect(m_capNotifier, SIGNAL(activated(int)), this, SLOT(capVbiFrame()));
m_capSrcFormat = copy;
}
- updatePixelAspectRatio();
m_capture->resize(dstPix.width, dstPix.height);
// Ensure that the initial image is large enough for native 32 bit per pixel formats
if (dstPix.pixelformat == V4L2_PIX_FMT_RGB32 || dstPix.pixelformat == V4L2_PIX_FMT_BGR32)
void openRawFile(const QString &s);
void rejectedRawFile();
void setAudioBufferSize();
- void enableScaling(bool enable);
- void updatePixelAspectRatio();
void about();
void updateStandard();
void updateFreq();
void updateFreqChannel();
- bool showFrames();
GeneralTab *m_genTab;
VbiTab *m_vbiTab;
QAction *m_useGLAct;
QAction *m_showAllAudioAct;
QAction *m_audioBufferAct;
- QAction *m_scalingAct;
- QAction *m_resetScalingAct;
QString m_filename;
QSignalMapper *m_sigMapper;
QTabWidget *m_tabs;
WidgetMap m_widgetMap;
ClassMap m_classMap;
bool m_haveExtendedUserCtrls;
+ bool m_showFrames;
int m_vbiSize;
unsigned m_vbiWidth;
unsigned m_vbiHeight;