kamoso/kamoso-2.0.2-libqt-gstreamer-1.2.0.patch

275 lines
12 KiB
Diff
Raw Permalink Normal View History

commit b85e8c187b4eabf9765bc05348f6232ba32c9493
Author: Andreas Cord-Landwehr <cordlandwehr@kde.org>
Date: Fri Aug 29 16:51:30 2014 +0200
Porting to GStreamer-1.0 API and QtGStreamer-1.2
This is the first iteration of a porting patch to upgrade Kamoso to work with GStreamer-1.x (in particular, 0.10 is deprecated and unmaintained by upstream). The patch in its current version does the following:
* update the cmake find module to find the new version of gstreamer and qtgstreamer
* fixes compilation with the new version
I am quite sure that further changes at the pipelines are necessary to make it work at runtime, yet an area where I do not have much experience (hence, all these people you get the review request :)
In the big picture, I would like to have Kamoso ported asap, since with Artikulate a first KDE application switched to the new QtGStreamer version and the continiuous integration system can only support one qtgstreamer version for all. Also, it would be good to have all KDE applications ready for QtGStreamer-1.2 with the KDE SC 4.14 release to allow distros to upgrade all in one step.
REVIEW: 118979
From 48b4129cc4009aad0a013df8535b89f98554b1e9 Mon Sep 17 00:00:00 2001
From: Andreas Cord-Landwehr <cordlandwehr@kde.org>
Date: Wed, 25 Jun 2014 23:24:08 +0200
Subject: [PATCH] Porting patch for GStreamer-1.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d6bfb1..83b2025 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,8 +6,8 @@ find_package(KDE4 REQUIRED)
find_package(Kipi REQUIRED)
find_package(Phonon REQUIRED)
find_package(GLIB2 REQUIRED)
-find_package(GStreamer REQUIRED)
-find_package(QtGStreamer REQUIRED)
+find_package(GStreamer 1.0.0)
+find_package(QtGStreamer 1.1.90 REQUIRED)
macro_optional_find_package(Nepomuk)
macro_log_feature(NEPOMUK_FOUND "Nepomuk" "Handles all kinds of metadata on the KDE desktop to provide a semantic desktop" "http://nepomuk.kde.org/" FALSE "" "STRONGLY_RECOMMENDED: Nepomuk is used to provide metadata on objects like files, emails etc. to provide a semantic desktop.")
@@ -15,6 +15,10 @@ macro_bool_to_01(NEPOMUK_FOUND HAVE_NEPOMUK)
macro_display_feature_log()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(
+ ${QTGSTREAMER_INCLUDE_DIR}
+)
+
add_subdirectory(src)
add_subdirectory(icons)
add_subdirectory(doc)
diff --git a/cmake/FindGStreamer.cmake b/cmake/FindGStreamer.cmake
index a1b6e33..bebcf00 100644
--- a/cmake/FindGStreamer.cmake
+++ b/cmake/FindGStreamer.cmake
@@ -15,40 +15,38 @@
# TODO: Other versions --> GSTREAMER_X_Y_FOUND (Example: GSTREAMER_0_8_FOUND and GSTREAMER_0_10_FOUND etc)
-IF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
+IF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY)
# in cache already
SET(GStreamer_FIND_QUIETLY TRUE)
-ELSE (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
+ELSE (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY)
SET(GStreamer_FIND_QUIETLY FALSE)
-ENDIF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
+ENDIF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY)
+SET(GSTREAMER_API_VERSION 1.0)
IF (NOT WIN32)
FIND_PACKAGE(PkgConfig REQUIRED)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
# don't make this check required - otherwise you can't use macro_optional_find_package on this one
- PKG_CHECK_MODULES(PKG_GSTREAMER gstreamer-0.10)
+ PKG_CHECK_MODULES(PKG_GSTREAMER gstreamer-${GSTREAMER_API_VERSION})
SET(GSTREAMER_VERSION ${PKG_GSTREAMER_VERSION})
SET(GSTREAMER_DEFINITIONS ${PKG_GSTREAMER_CFLAGS})
ENDIF (NOT WIN32)
+MESSAGE(STATUS "Found GStreamer package: ${PKG_GSTREAMER_VERSION}")
+
FIND_PATH(GSTREAMER_INCLUDE_DIR gst/gst.h
PATHS
${PKG_GSTREAMER_INCLUDE_DIRS}
- PATH_SUFFIXES gstreamer-0.10
- )
-
-FIND_LIBRARY(GSTREAMER_LIBRARIES NAMES gstreamer-0.10
- PATHS
- ${PKG_GSTREAMER_LIBRARY_DIRS}
+ PATH_SUFFIXES gstreamer-${GSTREAMER_API_VERSION}
)
-FIND_LIBRARY(GSTREAMER_BASE_LIBRARY NAMES gstbase-0.10
+FIND_LIBRARY(GSTREAMER_LIBRARIES NAMES gstreamer-${GSTREAMER_API_VERSION}
PATHS
${PKG_GSTREAMER_LIBRARY_DIRS}
)
-FIND_LIBRARY(GSTREAMER_INTERFACE_LIBRARY NAMES gstinterfaces-0.10
+FIND_LIBRARY(GSTREAMER_BASE_LIBRARY NAMES gstbase-${GSTREAMER_API_VERSION}
PATHS
${PKG_GSTREAMER_LIBRARY_DIRS}
)
@@ -63,12 +61,7 @@ ELSE (GSTREAMER_LIBRARIES)
MESSAGE(STATUS "GStreamer: WARNING: library not found")
ENDIF (GSTREAMER_LIBRARIES)
-IF (GSTREAMER_INTERFACE_LIBRARY)
-ELSE (GSTREAMER_INTERFACE_LIBRARY)
- MESSAGE(STATUS "GStreamer: WARNING: interface library not found")
-ENDIF (GSTREAMER_INTERFACE_LIBRARY)
-
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer DEFAULT_MSG GSTREAMER_LIBRARIES GSTREAMER_INCLUDE_DIR GSTREAMER_BASE_LIBRARY GSTREAMER_INTERFACE_LIBRARY)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer DEFAULT_MSG GSTREAMER_LIBRARIES GSTREAMER_INCLUDE_DIR GSTREAMER_BASE_LIBRARY)
-MARK_AS_ADVANCED(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY GSTREAMER_INTERFACE_LIBRARY)
+MARK_AS_ADVANCED(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY)
diff --git a/src/webcamwidget.cpp b/src/webcamwidget.cpp
index 62b7831..ba1160f 100644
--- a/src/webcamwidget.cpp
+++ b/src/webcamwidget.cpp
@@ -55,8 +55,9 @@
#include <QGst/Structure>
#include <QGst/Clock>
#include <QGst/Init>
-#include <QGst/XOverlay>
+#include <QGst/VideoOverlay>
#include <QGst/Message>
+#include <QGst/Memory>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <QGst/Bus>
@@ -130,8 +131,7 @@ void WebcamWidget::playFile(const Device &device)
QByteArray pipe = basicPipe();
//Set the right colorspace to convert to QImage
- pipe += " ! ffmpegcolorspace ! "
- GST_VIDEO_CAPS_xRGB_HOST_ENDIAN
+ pipe += " ! videoconvert"
" ! fakesink name=fakesink";
kDebug() << "================ PIPELINE ================";
@@ -157,7 +157,7 @@ void WebcamWidget::playFile(const Device &device)
setVideoSettings();
kDebug() << "================ Capabilities ================";
- kDebug() << d->m_pipeline->getElementByName("v4l2src")->getStaticPad("src")->caps()->toString();
+// kDebug() << d->m_pipeline->getElementByName("v4l2src")->getStaticPad("src")->currentCaps()->toString(); //commented out for now: src-pad returns null
d->m_pipeline->setState(QGst::StatePlaying);
}
@@ -179,34 +179,51 @@ bool WebcamWidget::takePhoto(const KUrl &dest)
}
kDebug() << dest;
d->destination = dest;
+ if (!d->m_bin) {
+ return false;
+ }
d->m_bin->getElementByName("fakesink")->setProperty("signal-handoffs", true);
QGlib::connect(d->m_bin->getElementByName("fakesink"), "handoff", this, &WebcamWidget::photoGstCallback);
return true;
}
//This code has been borrowed from the Qt Multimedia project.
-void WebcamWidget::photoGstCallback(QGst::BufferPtr buffer, QGst::PadPtr)
+void WebcamWidget::photoGstCallback(QGst::BufferPtr buffer, QGst::PadPtr pad)
{
kDebug();
QImage img;
- QGst::CapsPtr caps = buffer->caps();
+ QGst::CapsPtr caps = pad->currentCaps();
const QGst::StructurePtr structure = caps->internalStructure(0);
int width, height;
+ QString format;
+ format = structure.data()->value("format").get<QString>();
width = structure.data()->value("width").get<int>();
height = structure.data()->value("height").get<int>();
kDebug() << "We've got a caps in here";
kDebug() << "Size: " << width << "x" << height;
kDebug() << "Name: " << structure.data()->name();
+ kDebug() << "Format: " << format;
- if (qstrcmp(structure.data()->name().toLatin1(), "video/x-raw-yuv") == 0) {
+ if (format == "YUV") {
QGst::Fourcc fourcc = structure->value("format").get<QGst::Fourcc>();
kDebug() << "fourcc: " << fourcc.value.as_integer;
if (fourcc.value.as_integer == QGst::Fourcc("I420").value.as_integer) {
img = QImage(width/2, height/2, QImage::Format_RGB32);
- const uchar *data = (const uchar *)buffer->data();
+ QGst::MemoryPtr memory;
+ QGst::MapInfo info;
+ memory = buffer->getMemory(0);
+ if (!memory) {
+ kError() << "Could not get memory for buffer.";
+ return;
+ }
+ if (!memory->map(info, QGst::MapRead)) {
+ kError() << "Could not map memory buffer.";
+ return;
+ }
+ const uchar *data = (const uchar *)info.data();
for (int y=0; y<height; y+=2) {
const uchar *yLine = data + y*width;
@@ -225,6 +242,7 @@ void WebcamWidget::photoGstCallback(QGst::BufferPtr buffer, QGst::PadPtr)
img.setPixel(x/2,y/2,qRgb(r,g,b));
}
}
+ memory->unmap(info);
} else {
kDebug() << "Not I420";
}
@@ -240,11 +258,23 @@ void WebcamWidget::photoGstCallback(QGst::BufferPtr buffer, QGst::PadPtr)
format = QImage::Format_RGB32;
if (format != QImage::Format_Invalid) {
- img = QImage((const uchar *)buffer->data(),
+ QGst::MemoryPtr memory;
+ QGst::MapInfo info;
+ memory = buffer->getMemory(0);
+ if (!memory) {
+ kError() << "Could not get memory for buffer.";
+ return;
+ }
+ if (!memory->map(info, QGst::MapRead)) {
+ kError() << "Could not map memory buffer.";
+ return;
+ }
+ img = QImage((const uchar *)info.data(),
width,
height,
format);
img.bits(); //detach
+ memory->unmap(info);
}
}
@@ -285,7 +315,7 @@ void WebcamWidget::recordVideo(bool sound)
//Get the audio from alsa
" ! mux. autoaudiosrc "
//Sound type and quality
- " ! audio/x-raw-int,rate=48000,channels=2,depth=16 "
+ " ! audio/x-raw,rate=48000,channels=2,depth=16 "
//Encode sound as vorbis
" ! queue ! audioconvert ! queue "
" ! vorbisenc "
@@ -368,11 +398,11 @@ QByteArray WebcamWidget::basicPipe()
//Accepted capabilities
pipe +=
- " ! ffmpegcolorspace"
- " ! video/x-raw-yuv, width=640, height=480, framerate=15/1;"
- " video/x-raw-yuv, width=640, height=480, framerate=24/1;"
- " video/x-raw-yuv, width=640, height=480, framerate=30/1;"
- " video/x-raw-yuv, width=352, height=288, framerate=15/1"
+ " ! videoconvert"
+ " ! video/x-raw, format=RGB, width=640, height=480, framerate=15/1;"
+ " video/x-raw, format=RGB, width=640, height=480, framerate=24/1;"
+ " video/x-raw, format=RGB, width=640, height=480, framerate=30/1;"
+ " video/x-raw, format=RGB, width=352, height=288, framerate=15/1"
//Basic plug-in for video controls
" ! gamma name=gamma"
@@ -424,7 +454,7 @@ void WebcamWidget::activeAspectRatio()
{
QGst::BinPtr sink = d->m_bin->getElementByName("videosink").staticCast<QGst::Bin>();
- QGlib::RefPointer<QGst::XOverlay> over = sink->getElementByInterface<QGst::XOverlay>();
+ QGlib::RefPointer<QGst::VideoOverlay> over = sink->getElementByInterface<QGst::VideoOverlay>();
if (over->findProperty("force-aspect-ratio")) {
kDebug() << "Setting aspect ratio";