diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-04 09:52:01 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-04 09:52:01 -0400 |
commit | 15d8dac497768350ea429d6c6682ed9723d0464c (patch) | |
tree | b6238a9d934b8aca88122306fa1f90f06cc394fe /src-qt5/core/libLumina | |
parent | Finish up the auto archive/extract within lumina-archiver (with JT) (diff) | |
parent | Further lumina-fm changes for video thumbnails (diff) | |
download | lumina-15d8dac497768350ea429d6c6682ed9723d0464c.tar.gz lumina-15d8dac497768350ea429d6c6682ed9723d0464c.tar.bz2 lumina-15d8dac497768350ea429d6c6682ed9723d0464c.zip |
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.cpp | 58 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.h | 21 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.pri | 9 |
3 files changed, 88 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/LVideoSurface.cpp b/src-qt5/core/libLumina/LVideoSurface.cpp new file mode 100644 index 00000000..895a3a32 --- /dev/null +++ b/src-qt5/core/libLumina/LVideoSurface.cpp @@ -0,0 +1,58 @@ +#include "LVideoSurface.h" +#include <QDebug> + +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); + 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); + return true; + } + return false; +} + +QList<QVideoFrame::PixelFormat> LVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const { + Q_UNUSED(type); + 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 new file mode 100644 index 00000000..42a140d9 --- /dev/null +++ b/src-qt5/core/libLumina/LVideoSurface.h @@ -0,0 +1,21 @@ +#include <QAbstractVideoSurface> +#include <QVideoSurfaceFormat> +#include <QPixmap> +#include <QDebug> + +class LVideoSurface : public QAbstractVideoSurface { + Q_OBJECT + + public: + LVideoSurface(QObject *parent=0); + virtual bool present(const QVideoFrame&); + virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const; + /*virtual QList<QVidebool isFormatSupported(const QVideoSurfaceFormat &format) const; + bool start(const QVideoSurfaceFormat &format); + void stop();*/ + signals: + void frameReceived(QPixmap); + private: + QPixmap frameImage; + //QImage::Format imageFormat; +}; diff --git a/src-qt5/core/libLumina/LVideoSurface.pri b/src-qt5/core/libLumina/LVideoSurface.pri new file mode 100644 index 00000000..469b8c93 --- /dev/null +++ b/src-qt5/core/libLumina/LVideoSurface.pri @@ -0,0 +1,9 @@ +QT *= multimedia + +HEADERS *= $${PWD}/LVideoSurface.h +SOURCES *= $${PWD}/LVideoSurface.cpp + +INCLUDEPATH *= ${PWD} + +#Now the other dependendies of it +#include(LUtils.pri) |