aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/LVideoSurface.cpp46
-rw-r--r--src-qt5/core/libLumina/LVideoSurface.h15
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp37
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.h4
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp6
5 files changed, 70 insertions, 38 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;
};
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index 4d695ab4..40d2d544 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -23,17 +23,20 @@ MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){
terminate_thread = false;
UpdateIcons(); //Set all the icons in the dialog
SetupConnections();
- player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
- surface = new LVideoSurface();
+ player = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
+ surface = new LVideoSurface(this);
player->setVideoOutput(surface);
+ player->setMuted(true);
+ connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration(QMediaPlayer::MediaStatus)));
+ connect(surface, SIGNAL(frameReceived(QPixmap)), this, SLOT(stopVideo(QPixmap)));
INFO = 0;
}
MainUI::~MainUI(){
terminate_thread = true;
+ surface->deleteLater();
+ player->deleteLater();
this->close();
- delete surface;
- delete player;
}
//=============
@@ -92,15 +95,12 @@ void MainUI::LoadFile(QString path, QString type){
ui->label_file_icon->setPixmap( pix.scaledToHeight(64) );
ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
//qDebug() << " - done with image";
- }/*else if(INFO->isVideo()){
+ }else if(INFO->isVideo()){
player->setMedia(QUrl("file://"+INFO->absoluteFilePath()));
player->play();
- player->setPosition(player->duration() / 2);
- connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(stopVideo(QImage)));
+ player->pause();
//Pixmap set when video is loaded in stopVideo
- //ui->label_file_icon->setPixmap( QPixmap::fromImage(surface->frameImage()).scaledToHeight(64) );
- //ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
- }*/else{
+ }else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
//Now verify the tab is available in the widget
@@ -117,7 +117,7 @@ void MainUI::LoadFile(QString path, QString type){
}
//Now load the special XDG desktop info
qDebug() << "Check XDG Info:" << type;
- qDebug() << INFO->isDesktopFile() << type;
+ //qDebug() << INFO->isDesktopFile() << type;
if(INFO->isDesktopFile() || !type.isEmpty()){
if(INFO->XDG()->type == XDGDesktop::APP){
@@ -310,12 +310,17 @@ void MainUI::getXdgCommand(QString prev){
xdgvaluechanged();
}
-/*void MainUI::stopVideo(QImage img) {
- static bool flag = true;
- if(flag) { player->setPosition(player->duration() / 2); flag = false;}
+void MainUI::stopVideo(QPixmap img) {
+ ui->label_file_icon->setPixmap( img.scaledToHeight(64) );
player->pause();
- ui->label_file_icon->setPixmap( QPixmap::fromImage( img.scaledToHeight(64) ));
-}*/
+}
+
+void MainUI::setDuration(QMediaPlayer::MediaStatus status) {
+ if(status == QMediaPlayer::BufferedMedia) {
+ player->setPosition(player->duration() / 2);
+ player->play();
+ }
+}
void MainUI::on_tool_xdg_getDir_clicked(){
//Find a directory
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
index e1f37425..5ce7b01a 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
@@ -37,6 +37,7 @@ private:
LFileInfo *INFO;
LVideoSurface *surface;
QMediaPlayer *player;
+ bool flag;
bool canwrite;
bool terminate_thread; //flag for terminating the GetDirSize task
@@ -53,7 +54,8 @@ private slots:
//UI Buttons
void on_push_close_clicked();
void on_push_save_clicked();
- //void stopVideo(QImage);
+ void stopVideo(QPixmap);
+ void setDuration(QMediaPlayer::MediaStatus);
void getXdgCommand(QString prev = "");
//void on_tool_xdg_getCommand_clicked(QString prev = "");
void on_tool_xdg_getDir_clicked();
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
index ee76a8dc..d0ecdecf 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
@@ -18,7 +18,7 @@ struct vFrame {
public:
QString getCodec();
- void goto(int timeInSeconds);
+ void skipTo(int timeInSeconds);
void readVideoFrame();
void getScaledVideoFrame(int scaledSize, vFrame& vFrame);
@@ -35,14 +35,12 @@ public:
private:
-
bool readVideoPacket();
bool getVideoPacket();
void scaleVideo(int scaledSize, int& scaledWidth, int& scaledHeight);
void createVFrame(AVFrame *vFrame, quint8 *frameBuffer, int width, int height);
void calculateDimensions(int size);
- void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage&
-image);
+ void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& image);
QString getMimeType(const QString& videoFile);
QString getExtension(const QString& videoFilename);
bgstack15