aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LVideoSurface.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-11-04 19:28:17 +0000
committerWeblate <noreply@weblate.org>2017-11-04 19:28:17 +0000
commit7787f617656751ee7e0a58c813d0bfd5757c5c97 (patch)
tree48aa053bbd4fda9c64f89a061a2f442c860ab13d /src-qt5/core/libLumina/LVideoSurface.cpp
parentTranslated using Weblate (Lithuanian) (diff)
parentMerge pull request #497 from a-stjohn/patch-1 (diff)
downloadlumina-7787f617656751ee7e0a58c813d0bfd5757c5c97.tar.gz
lumina-7787f617656751ee7e0a58c813d0bfd5757c5c97.tar.bz2
lumina-7787f617656751ee7e0a58c813d0bfd5757c5c97.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/libLumina/LVideoSurface.cpp')
-rw-r--r--src-qt5/core/libLumina/LVideoSurface.cpp60
1 files changed, 60 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..3aaa81f0
--- /dev/null
+++ b/src-qt5/core/libLumina/LVideoSurface.cpp
@@ -0,0 +1,60 @@
+#include "LVideoSurface.h"
+#include <QDebug>
+
+LVideoSurface::LVideoSurface(QObject *parent) : QAbstractVideoSurface(parent) {
+ frameImage = QPixmap();
+ entered = false;
+}
+
+bool LVideoSurface::present(const QVideoFrame &frame) {
+ //qDebug() << surfaceFormat().frameSize() << frame.size();
+ if(!frameImage.isNull() && !entered) {
+ emit frameReceived(frameImage);
+ return true;
+ }
+
+ if(frame.isValid()) {
+ //qDebug() << "Recording Frame";
+ //qDebug() << surfaceFormat().frameSize() << frame.size();
+ QVideoFrame icon(frame);
+ icon.map(QAbstractVideoBuffer::ReadOnly);
+ QImage img(icon.bits(), icon.width(), icon.height(), icon.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat()));
+
+ if((frameImage.isNull() && !entered) or entered)
+ 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;
+}
+
+void LVideoSurface::stop() {
+ QAbstractVideoSurface::stop();
+}
+
+void LVideoSurface::switchRollOver() {
+ entered = !entered;
+}
+
+bool LVideoSurface::start(const QVideoSurfaceFormat &format) {
+ const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
+ const QSize size = format.frameSize();
+
+ //QVideoSurfaceFormat newFormat = format;
+ //Shrink the frames passed through the format to a smaller, thumbnail appropriate size and increase the frame rate
+ //newFormat.setFrameSize(258,258);
+ //newFormat.setFrameRate(90);
+
+ if (imageFormat != QImage::Format_Invalid && !size.isEmpty())
+ QAbstractVideoSurface::start(format);
+
+ return (imageFormat != QImage::Format_Invalid && !size.isEmpty());
+}
bgstack15