event->accept();
}
-void CaptureWinGL::setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info)
+void CaptureWinGL::updateFrameInfo()
{
- // Set (TODO: move to capture-win)
- m_frameInfo.frameHeight = height;
- m_frameInfo.frameWidth = width;
- m_frameInfo.format = format;
- m_frameInfo.planeData[0] = data;
- m_frameInfo.planeData[1] = data2;
- m_frameInfo.info = info;
-
// Get/copy (TODO: remove CaptureWinGLEngine and use direct or use pointer)
#ifdef HAVE_QTGL
m_videoSurface.setFrame(m_frameInfo.frameWidth, m_frameInfo.frameHeight,
if (width > 0 && height > 0) {
setMaximumSize(width, height);
- resizeGL(width, height);
+ resizeGL(width, height); // TODO: necessary? Always called by resizeEvent()
}
}
CaptureWinGL();
~CaptureWinGL();
- void setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info);
void stop();
bool hasNativeFormat(__u32 format);
static bool isSupported();
protected:
void resizeEvent(QResizeEvent *event);
+ void updateFrameInfo();
private:
#ifdef HAVE_QTGL
paintFrame();
}
-void CaptureWinQt::setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info)
+void CaptureWinQt::updateFrameInfo()
{
- // Set (TODO: move to capture-win)
- m_frameInfo.frameHeight = height;
- m_frameInfo.frameWidth = width;
- m_frameInfo.format = format;
- m_frameInfo.planeData[0] = data;
- m_frameInfo.planeData[1] = data2;
- m_frameInfo.info = info;
-
// Get/copy (TODO: use direct?)
m_data = m_frameInfo.planeData[0];
CaptureWinQt();
~CaptureWinQt();
- void setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info);
-
void stop();
bool hasNativeFormat(__u32 format);
static bool isSupported() { return true; }
protected:
void resizeEvent(QResizeEvent *event);
+ void updateFrameInfo();
private:
bool findNativeFormat(__u32 format, QImage::Format &dstFmt);
CropMethod CaptureWin::m_cropMethod = QV4L2_CROP_NONE;
CaptureWin::CaptureWin() :
- m_curWidth(-1),
- m_curHeight(-1)
+ m_curWinWidth(-1),
+ m_curWinHeight(-1)
{
setWindowTitle("V4L2 Capture");
m_hotkeyClose = new QShortcut(Qt::CTRL+Qt::Key_W, this);
delete m_hotkeyScaleReset;
}
+void CaptureWin::setFrame(int width, int height, __u32 format,
+ unsigned char *data, unsigned char *data2, const QString &info)
+{
+ m_frameInfo.frameHeight = height;
+ m_frameInfo.frameWidth = width;
+ m_frameInfo.format = format;
+ m_frameInfo.planeData[0] = data;
+ m_frameInfo.planeData[1] = data2;
+ m_frameInfo.info = info;
+
+ updateFrameInfo();
+}
+
void CaptureWin::buildWindow(QWidget *videoSurface)
{
int l, t, r, b;
showNormal();
// Force resize even if no size change
- int w = m_curWidth;
- int h = m_curHeight;
- m_curWidth = -1;
- m_curHeight = -1;
+ int w = m_curWinWidth;
+ int h = m_curWinHeight;
+ m_curWinWidth = -1;
+ m_curWinHeight = -1;
resize(w, h);
}
{
if (!enable) {
QSize margins = getMargins();
- QWidget::setMinimumSize(m_curWidth + margins.width(), m_curHeight + margins.height());
+ QWidget::setMinimumSize(m_curWinWidth + margins.width(), m_curWinHeight + margins.height());
} else {
QWidget::setMinimumSize(MIN_WIN_SIZE_WIDTH, MIN_WIN_SIZE_HEIGHT);
}
// Dont resize window if the frame size is the same in
// the event the window has been paused when beeing resized.
- if (width == m_curWidth && height == m_curHeight)
+ if (width == m_curWinWidth && height == m_curWinHeight)
return;
- m_curWidth = width;
- m_curHeight = height;
+ m_curWinWidth = width;
+ m_curWinHeight = height;
QSize margins = getMargins();
h = margins.height() - cropHeight(width, height) * 2 + actualFrameHeight(height);
* @param data The frame data.
* @param info A string containing capture information.
*/
- virtual void setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info) = 0;
+ void setFrame(int width, int height, __u32 format,
+ unsigned char *data, unsigned char *data2, const QString &info);
/**
* @brief Called when the capture stream is stopped.
struct frameInfoStruct m_frameInfo;
/**
+ * @brief Update frame information to renderer.
+ *
+ * @note Must be implemented by derived render dependent classes.
+ */
+ virtual void updateFrameInfo() = 0;
+
+ /**
* @brief Determines if scaling is to be applied to video frame.
*/
static bool m_enableScaling;
static CropMethod m_cropMethod;
QShortcut *m_hotkeyClose;
QShortcut *m_hotkeyScaleReset;
- int m_curWidth;
- int m_curHeight;
+ int m_curWinWidth;
+ int m_curWinHeight;
};
#endif