From 5d3721983396f4a144c3a51e0621dae600fdb540 Mon Sep 17 00:00:00 2001 From: Vasilis Liaskovitis Date: Tue, 26 Apr 2016 18:32:03 +0200 Subject: [PATCH] Refactoring VideoImpl VideoImpl now creates the backend pipeline (queue->videoconvert->...->appsink) Separate subclasses build a different frontend of the pipeline depending on the type of video stream (uri, webcam , shared memory) that attaches to the backend pipeline. - VideoUridecodeBin: front-end for video file / uri - VideoV4l2SrcBin: front-end for webcam (at the moment only works with /dev/video*files, tested only on Ubuntu 14.04) - VideoShmSrcBin: front-end for Shared memory / socket (used to work, currently has problems) Code is still hacky, needs work. --- MainWindow.cpp | 23 +- MainWindow.h | 3 +- Paint.cpp | 23 +- Paint.h | 8 +- VideoImpl.cpp | 446 +------------------------------------- VideoImpl.h | 189 ++++++++++++---- VideoShmSrcImpl.cpp | 118 ++++++++++ VideoShmSrcImpl.h | 73 +++++++ VideoUriDecodeBinImpl.cpp | 260 ++++++++++++++++++++++ VideoUriDecodeBinImpl.h | 66 ++++++ VideoV4l2SrcImpl.cpp | 82 +++++++ VideoV4l2SrcImpl.h | 65 ++++++ mapmap.pro | 6 + 13 files changed, 870 insertions(+), 492 deletions(-) create mode 100644 VideoShmSrcImpl.cpp create mode 100644 VideoShmSrcImpl.h create mode 100644 VideoUriDecodeBinImpl.cpp create mode 100644 VideoUriDecodeBinImpl.h create mode 100644 VideoV4l2SrcImpl.cpp create mode 100644 VideoV4l2SrcImpl.h diff --git a/MainWindow.cpp b/MainWindow.cpp index 6eb8860..d892f69 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -446,7 +446,7 @@ void MainWindow::importMedia() // Check if file is image or not // according to file extension if (!fileName.isEmpty()) { - if (MM::IMAGE_FILES_FILTER.contains(QFileInfo(fileName).suffix(), Qt::CaseInsensitive)) + if (!QFileInfo(fileName).suffix().isEmpty() && MM::IMAGE_FILES_FILTER.contains(QFileInfo(fileName).suffix(), Qt::CaseInsensitive)) importMediaFile(fileName, true); else importMediaFile(fileName, false); @@ -833,7 +833,7 @@ bool MainWindow::clearProject() } uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, - bool isImage, bool live, double rate) + bool isImage, VideoType type, double rate) { // Cannot create image with already existing id. if (Paint::getUidAllocator().exists(paintId)) @@ -842,14 +842,14 @@ uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, else { // Check if file exists before - if (! fileExists(uri)) - uri = locateMediaFile(uri, isImage); + //if (! fileExists(uri)) + //uri = locateMediaFile(uri, isImage); Texture* tex = 0; if (isImage) tex = new Image(uri, paintId); else { - tex = new Video(uri, live, rate, paintId); + tex = new Video(uri, type, rate, paintId); } // Create new image with corresponding ID. @@ -2273,14 +2273,19 @@ bool MainWindow::importMediaFile(const QString &fileName, bool isImage) { QFile file(fileName); QDir currentDir; + VideoType type = VIDEO_URI; if (!fileSupported(fileName, isImage)) return false; - bool live = false; + if (fileName.contains(QString("/dev/video"))) { + type = VIDEO_WEBCAM; + } + if (!file.open(QIODevice::ReadOnly)) { - if (file.isSequential()) - live = true; + if (file.isSequential()) { + type = VIDEO_SHMSRC; + } else { QMessageBox::warning(this, tr("MapMap Project"), tr("Cannot read file %1:\n%2.") @@ -2293,7 +2298,7 @@ bool MainWindow::importMediaFile(const QString &fileName, bool isImage) QApplication::setOverrideCursor(Qt::WaitCursor); // Add media file to model. - uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, isImage, live); + uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, isImage, type); // Initialize position (center). QSharedPointer