diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-03 18:36:51 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-03 18:36:51 -0400 |
commit | 3005f7ab6b19cabf423b85ec7c3845d840c7cb18 (patch) | |
tree | aed60a1f70a13d09be3733449420564f6ae32349 /src-qt5/core | |
parent | add libav video thumbnail code back to project (diff) | |
download | lumina-3005f7ab6b19cabf423b85ec7c3845d840c7cb18.tar.gz lumina-3005f7ab6b19cabf423b85ec7c3845d840c7cb18.tar.bz2 lumina-3005f7ab6b19cabf423b85ec7c3845d840c7cb18.zip |
Reworked the VideoSurface subclass
Diffstat (limited to 'src-qt5/core')
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.cpp | 46 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.h | 15 |
2 files changed, 44 insertions, 17 deletions
diff --git a/src-qt5/core/libLumina/LVideoSurface.cpp b/src-qt5/core/libLumina/LVideoSurface.cpp index 6adec5d2..895a3a32 100644 --- a/src-qt5/core/libLumina/LVideoSurface.cpp +++ b/src-qt5/core/libLumina/LVideoSurface.cpp @@ -1,27 +1,29 @@ #include "LVideoSurface.h" #include <QDebug> -LVideoSurface::LVideoSurface() : QAbstractVideoSurface() { - recording = 0; - frameImage = QImage(); -} - -QImage LVideoSurface::currentFrame() { - return frameImage; +LVideoSurface::LVideoSurface(QObject *parent) : QAbstractVideoSurface(parent) { + frameImage = QPixmap(); } bool LVideoSurface::present(const QVideoFrame &frame) { + if(!frameImage.isNull()) { + emit frameReceived(frameImage); + return true; + } + if(frame.isValid()) { qDebug() << "Recording Frame" << frame.pixelFormat(); QVideoFrame icon(frame); icon.map(QAbstractVideoBuffer::ReadOnly); - frameImage = QImage(icon.bits(), icon.width(), icon.height(), icon.bytesPerLine(), QImage::Format_ARGB32_Premultiplied); + QImage img(icon.bits(), icon.width(), icon.height(), icon.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); + + if(frameImage.isNull()) + frameImage = QPixmap::fromImage(img.copy(img.rect())); + icon.unmap(); emit frameReceived(frameImage); - if(recording++ == 2) ready = true; return true; } - ready = false; return false; } @@ -30,3 +32,27 @@ QList<QVideoFrame::PixelFormat> LVideoSurface::supportedPixelFormats(QAbstractVi return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_ARGB32 << QVideoFrame::Format_RGB32 << QVideoFrame::Format_RGB24 << QVideoFrame::Format_RGB565 << QVideoFrame::Format_RGB555 << QVideoFrame::Format_BGRA32 << QVideoFrame::Format_BGR32; } + +/*bool VideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const { + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + return imageFormat != QImage::Format_Invalid && !size.isEmpty() && format.handleType() == QAbstractVideoBuffer::NoHandle; +} + +void VideoSurface::stop() { + QAbstractVideoSurface::stop(); +} + +bool VideoSurface::start(const QVideoSurfaceFormat &format) { + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { + this->imageFormat = imageFormat; + QAbstractVideoSurface::start(format); + return true; + } else { + return false; + } +}*/ diff --git a/src-qt5/core/libLumina/LVideoSurface.h b/src-qt5/core/libLumina/LVideoSurface.h index adb4611d..42a140d9 100644 --- a/src-qt5/core/libLumina/LVideoSurface.h +++ b/src-qt5/core/libLumina/LVideoSurface.h @@ -1,20 +1,21 @@ #include <QAbstractVideoSurface> #include <QVideoSurfaceFormat> +#include <QPixmap> #include <QDebug> class LVideoSurface : public QAbstractVideoSurface { Q_OBJECT public: - LVideoSurface(); + LVideoSurface(QObject *parent=0); virtual bool present(const QVideoFrame&); virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const; - QImage currentFrame(); - bool frameReady(); + /*virtual QList<QVidebool isFormatSupported(const QVideoSurfaceFormat &format) const; + bool start(const QVideoSurfaceFormat &format); + void stop();*/ signals: - void frameReceived(QImage); + void frameReceived(QPixmap); private: - int recording; - QImage frameImage; - bool ready; + QPixmap frameImage; + //QImage::Format imageFormat; }; |