From 53978f47703d734a7838997033e4aedd9f920a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 10 Mar 2016 00:52:06 +0100 Subject: [PATCH] Add GStreamer 1.0 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- config.h.in | 3 +++ kaffeine/configure.in.in | 21 ++++++++++++---- .../player-parts/gstreamer-part/Makefile.am | 2 +- .../gstreamer-part/gstreamer_part.cpp | 13 +++++++++- .../src/player-parts/gstreamer-part/timer.cpp | 16 ++++++++++-- .../src/player-parts/gstreamer-part/video.cpp | 25 ++++++++++++++++++- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/config.h.in b/config.h.in index 88dc36a..1afeb9a 100644 --- a/config.h.in +++ b/config.h.in @@ -24,6 +24,9 @@ /* DVB headers installed */ #undef HAVE_DVB +/* Defined if GStreamer is 1.x */ +#undef HAVE_GSTREAMER_1 + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H diff --git a/kaffeine/configure.in.in b/kaffeine/configure.in.in index 1d84afe..fab9603 100644 --- a/kaffeine/configure.in.in +++ b/kaffeine/configure.in.in @@ -200,19 +200,30 @@ LIB_GSTREAMER="" if test "$with_gstreamer" != "no" ; then AC_MSG_CHECKING([for GStreamer]) - if "$PKG_CONFIG" --exists "gstreamer-0.10 gstreamer-plugins-base-0.10"; then + if "$PKG_CONFIG" --exists "gstreamer-1.0 gstreamer-plugins-base-1.0"; then with_gstreamer=yes - CFLAGS_GSTREAMER=`"$PKG_CONFIG" --cflags gstreamer-0.10 gstreamer-plugins-base-0.10` - LIB_GSTREAMER=`"$PKG_CONFIG" --libs gstreamer-0.10 gstreamer-plugins-base-0.10` + CFLAGS_GSTREAMER=`"$PKG_CONFIG" --cflags gstreamer-1.0 gstreamer-plugins-base-1.0` + LIB_GSTREAMER=`"$PKG_CONFIG" --libs gstreamer-1.0 gstreamer-plugins-base-1.0` + LIB_GSTOVERLAY='-lgstvideo-1.0' + AC_DEFINE(HAVE_GSTREAMER_1, 1, [Defined if GStreamer is 1.x]) AC_MSG_RESULT([yes]) else - with_gstreamer=no - AC_MSG_RESULT([no]) + if "$PKG_CONFIG" --exists "gstreamer-0.10 gstreamer-plugins-base-0.10"; then + with_gstreamer=yes + CFLAGS_GSTREAMER=`"$PKG_CONFIG" --cflags gstreamer-0.10 gstreamer-plugins-base-0.10` + LIB_GSTREAMER=`"$PKG_CONFIG" --libs gstreamer-0.10 gstreamer-plugins-base-0.10` + LIB_GSTOVERLAY='-lgstinterfaces-0.10' + AC_MSG_RESULT([yes]) + else + with_gstreamer=no + AC_MSG_RESULT([no]) + fi fi fi AC_SUBST([CFLAGS_GSTREAMER]) AC_SUBST([LIB_GSTREAMER]) +AC_SUBST([LIB_GSTOVERLAY]) AM_CONDITIONAL([with_gstreamer], [test "$with_gstreamer" = "yes"]) diff --git a/kaffeine/src/player-parts/gstreamer-part/Makefile.am b/kaffeine/src/player-parts/gstreamer-part/Makefile.am index d10ddca..16cbbbd 100644 --- a/kaffeine/src/player-parts/gstreamer-part/Makefile.am +++ b/kaffeine/src/player-parts/gstreamer-part/Makefile.am @@ -8,7 +8,7 @@ noinst_HEADERS = gstreamer_part.h timer.h video.h videosettings.h gstreamerconf libgstreamerpart_la_SOURCES = gstreamer_part.cpp video.cpp timer.cpp videosettings.cpp gstreamerconfig.cpp libgstreamerpart_la_LIBADD = $(LIB_TDEPARTS) $(LIB_TDEFILE) ../kaffeine-part/libkaffeinepart.la -libgstreamerpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(LIB_QT) -lDCOP $(KDE_PLUGIN) $(LIB_TDEPARTS) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEIO) $(LIB_GSTREAMER) -lgstinterfaces-0.10 $(all_libraries) -avoid-version -no-undefined +libgstreamerpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(LIB_QT) -lDCOP $(KDE_PLUGIN) $(LIB_TDEPARTS) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEIO) $(LIB_GSTREAMER) $(LIB_GSTOVERLAY) $(all_libraries) -avoid-version -no-undefined # this is where the desktop file will go partdesktopdir = $(kde_servicesdir) diff --git a/kaffeine/src/player-parts/gstreamer-part/gstreamer_part.cpp b/kaffeine/src/player-parts/gstreamer-part/gstreamer_part.cpp index b76e363..f9ed207 100644 --- a/kaffeine/src/player-parts/gstreamer-part/gstreamer_part.cpp +++ b/kaffeine/src/player-parts/gstreamer-part/gstreamer_part.cpp @@ -38,6 +38,7 @@ #include #include +#include "config.h" #include "gstreamer_part.h" #include "gstreamer_part.moc" #include "playlistimport.h" @@ -764,10 +765,20 @@ bool GStreamerPart::initGStreamer() kdDebug() << "GStreamerPart: Found GStreamer version "<data); +#else name = GST_PLUGIN_FEATURE_NAME(factories->data); +#endif cat = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(factories->data)); // kdDebug() << "GStreamerPart: Found plugin: " << name << " - Category: " << cat << endl; if ( cat == "Visualization" ) diff --git a/kaffeine/src/player-parts/gstreamer-part/timer.cpp b/kaffeine/src/player-parts/gstreamer-part/timer.cpp index 04be9b7..7ef268d 100644 --- a/kaffeine/src/player-parts/gstreamer-part/timer.cpp +++ b/kaffeine/src/player-parts/gstreamer-part/timer.cpp @@ -132,12 +132,24 @@ void Timer::slotUpdate() if ( !m_play ) return; - if ( gst_element_query_duration( m_play, &fmt, &t ) ) { + if ( gst_element_query_duration( m_play, +#ifdef HAVE_GSTREAMER_1 + fmt, +#else + &fmt, +#endif + &t ) ) { m_len = t; m_slider->setMaxValue( m_len / GST_SECOND ); } - if ( !gst_element_query_position( m_play, &fmt, &t ) ) + if ( !gst_element_query_position( m_play, +#ifdef HAVE_GSTREAMER_1 + fmt, +#else + &fmt, +#endif + &t ) ) return; m_pos = t; diff --git a/kaffeine/src/player-parts/gstreamer-part/video.cpp b/kaffeine/src/player-parts/gstreamer-part/video.cpp index ecca253..dee1d14 100644 --- a/kaffeine/src/player-parts/gstreamer-part/video.cpp +++ b/kaffeine/src/player-parts/gstreamer-part/video.cpp @@ -34,7 +34,11 @@ #include #include +#ifdef HAVE_GSTREAMER_1 +#include +#else #include +#endif #include "video.h" @@ -67,9 +71,15 @@ void VideoWindow::setPlaybin( GstElement *play ) VideoWindow::~VideoWindow() { +#ifdef HAVE_GSTREAMER_1 + if ( m_element && GST_IS_VIDEO_OVERLAY(m_element) ) { + gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY(m_element), 0 ); + } +#else if ( m_element && GST_IS_X_OVERLAY(m_element) ) { gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(m_element), 0 ); } +#endif gst_object_unref( GST_OBJECT(m_element) ); kdDebug() << "VideoWindow: destructed" << endl; @@ -80,10 +90,17 @@ VideoWindow::~VideoWindow() void VideoWindow::refresh() { /* expose overlay */ +#ifdef HAVE_GSTREAMER_1 + if ( m_element && GST_IS_VIDEO_OVERLAY(m_element) ) { + gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY (m_element), winId() ); + gst_video_overlay_expose( GST_VIDEO_OVERLAY (m_element) ); + } +#else if ( m_element && GST_IS_X_OVERLAY(m_element) ) { gst_x_overlay_set_xwindow_id( GST_X_OVERLAY (m_element), winId() ); gst_x_overlay_expose( GST_X_OVERLAY (m_element) ); } +#endif } @@ -165,7 +182,13 @@ void VideoWindow::newState() if ( !g_strcasecmp(val->value_nick, "video") ) { GstCaps *caps; g_object_get( info, "object", &pad, NULL ); - if ( (caps=gst_pad_get_negotiated_caps(pad)) ) { + if ( +#ifdef HAVE_GSTREAMER_1 + (caps=gst_pad_get_current_caps(pad)) +#else + (caps=gst_pad_get_negotiated_caps(pad)) +#endif + ) { newCapsset( caps ); gst_caps_unref (caps); return;