summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-10-09 12:10:23 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-10-23 23:46:28 +0200
commite96f5ed674e1a18c7b8880bfae27a21a8274c329 (patch)
tree5246a5d93d9cc540cfbcb71f18336ed5600416d6
parent6729c341120f7111c5b91acde89601e5cb23eb83 (diff)
Add GStreamer 1.0 supportgst-1.0
This commit adds GStreamer 1.0 support. As the changes compared to GStreamer 0.10 are minor (only 2 functions to modify), I've kept support for both versions. GStreamer 1.0 support can be enabled using --with-audio=gstreamer1
-rw-r--r--configure.ac17
-rw-r--r--gtk/spice-audio.c4
-rw-r--r--gtk/spice-gstaudio.c43
3 files changed, 58 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index f47ee20..91633e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -288,7 +288,7 @@ AS_IF([test "x$have_phodav" = "xyes"],
AC_DEFINE(USE_PHODAV, [1], [Define if supporting phodav]))
AC_ARG_WITH([audio],
- AS_HELP_STRING([--with-audio=@<:@gstreamer/pulse/auto/no@:>@], [Select audio backend @<:@default=auto@:>@]),
+ AS_HELP_STRING([--with-audio=@<:@gstreamer/gstreamer1/pulse/auto/no@:>@], [Select audio backend @<:@default=auto@:>@]),
[],
[with_audio="auto"])
@@ -297,7 +297,7 @@ AS_IF([test "x$with_audio" = "xauto"], [
])
case "$with_audio" in
- gstreamer|pulse|no*)
+ gstreamer|gstreamer1|pulse|no*)
;;
*) AC_MSG_ERROR(Unsupported audio backend)
esac
@@ -326,7 +326,18 @@ AS_IF([test "x$have_gst" = "xyes"],
[AC_MSG_ERROR([GStreamer requested but not found])
])
])
-AM_CONDITIONAL([WITH_GSTAUDIO], [test "x$have_gst" = "xyes"])
+
+AS_IF([test "x$with_audio" = "xgstreamer1"],
+ [PKG_CHECK_MODULES(GST, gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-audio-1.0, [have_gst1=yes], [have_gst1=no])],
+ [have_gst1=no])
+
+AS_IF([test "x$have_gst1" = "xyes"],
+ [AC_DEFINE([WITH_GST1AUDIO], 1, [Have GStreamer 1.0?])],
+ [AS_IF([test "x$with_audio" = "xgstreamer1"],
+ [AC_MSG_ERROR([GStreamer 1.0 requested but not found])
+ ])
+])
+AM_CONDITIONAL([WITH_GSTAUDIO], [test "x$have_gst" = "xyes" -o "x$have_gst1" = "xyes"])
AC_SUBST(GST_CFLAGS)
AC_SUBST(GST_LIBS)
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index dbd3a8b..34c1b69 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -47,7 +47,7 @@
#ifdef WITH_PULSE
#include "spice-pulse.h"
#endif
-#ifdef WITH_GSTAUDIO
+#if defined(WITH_GSTAUDIO) || defined(WITH_GST1AUDIO)
#include "spice-gstaudio.h"
#endif
@@ -219,7 +219,7 @@ SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
#ifdef WITH_PULSE
self = SPICE_AUDIO(spice_pulse_new(session, context, name));
#endif
-#ifdef WITH_GSTAUDIO
+#if defined(WITH_GSTAUDIO) || defined(WITH_GST1AUDIO)
self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
#endif
if (!self)
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index faa0c74..fb76dfb 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -21,9 +21,13 @@
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
-#include <gst/app/gstappbuffer.h>
#include <gst/app/gstappsink.h>
+#ifdef WITH_GST1AUDIO
+#include <gst/audio/streamvolume.h>
+#else
+#include <gst/app/gstappbuffer.h>
#include <gst/interfaces/streamvolume.h>
+#endif
#include "spice-gstaudio.h"
#include "spice-common.h"
@@ -155,6 +159,38 @@ static gboolean record_bus_cb(GstBus *bus, GstMessage *msg, gpointer data)
g_return_val_if_fail(p != NULL, FALSE);
switch (GST_MESSAGE_TYPE(msg)) {
+#ifdef WITH_GST1AUDIO
+ case GST_MESSAGE_APPLICATION: {
+ GstSample *s;
+ GstBuffer *buffer;
+ GstMapInfo mapping;
+
+ s = gst_app_sink_pull_sample(GST_APP_SINK(p->record.sink));
+ if (!s) {
+ if (!gst_app_sink_is_eos(GST_APP_SINK(p->record.sink)))
+ g_warning("eos not reached, but can't pull new sample");
+ return TRUE;
+ }
+
+ buffer = gst_sample_get_buffer(s);
+ if (!buffer) {
+ if (!gst_app_sink_is_eos(GST_APP_SINK(p->record.sink)))
+ g_warning("eos not reached, but can't pull new buffer");
+ return TRUE;
+ }
+ if (!gst_buffer_map(buffer, &mapping, GST_MAP_READ)) {
+ return TRUE;
+ }
+
+ spice_record_send_data(SPICE_RECORD_CHANNEL(p->rchannel),
+ /* FIXME: server side doesn't care about ts?
+ what is the unit? ms apparently */
+ mapping.data, mapping.size, 0);
+ gst_buffer_unmap(buffer, &mapping);
+ gst_sample_unref(s);
+ break;
+ }
+#else
case GST_MESSAGE_APPLICATION: {
GstBuffer *b;
@@ -171,6 +207,7 @@ static gboolean record_bus_cb(GstBus *bus, GstMessage *msg, gpointer data)
GST_BUFFER_DATA(b), GST_BUFFER_SIZE(b), 0);
break;
}
+#endif
default:
break;
}
@@ -356,7 +393,11 @@ static void playback_data(SpicePlaybackChannel *channel,
g_return_if_fail(p != NULL);
audio = g_memdup(audio, size); /* TODO: try to avoid memory copy */
+#ifdef WITH_GST1AUDIO
+ buf = gst_buffer_new_wrapped(audio, size);
+#else
buf = gst_app_buffer_new(audio, size, g_free, audio);
+#endif
gst_app_src_push_buffer(GST_APP_SRC(p->playback.src), buf);
}