[libdmapsharing] Port to GStreamer 1.0
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Port to GStreamer 1.0
- Date: Fri, 30 Nov 2012 04:32:28 +0000 (UTC)
commit a164c8da85650e53481b0fb5d5acbbcfb644ae28
Author: W. Michael Petullo <mike flyn org>
Date: Thu Nov 29 22:32:15 2012 -0600
Port to GStreamer 1.0
Signed-off-by: W. Michael Petullo <mike flyn org>
configure.ac | 6 ++--
libdmapsharing/dmap-gst-input-stream.c | 35 +++++++++++++++++++++------
libdmapsharing/dmap-gst-mp3-input-stream.c | 9 ++++---
libdmapsharing/gst-util.c | 4 +-
tests/Makefile.am | 8 +++---
vala/Makefile.am | 8 +++---
6 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index adda4ef..f8eccc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -318,14 +318,14 @@ PKG_CHECK_MODULES(SOUP_APPLE_REMOTE_APP, libsoup-2.4 >= 2.32.2, ,
dnl Check for GStreamer App, needed for transcoding
dnl gstreamer-plugins-base >= 0.10.23.2 for GNOME Bugzilla #588205 & #587896.
PKG_CHECK_MODULES(GSTREAMERAPP,
- gstreamer-app-0.10
- gstreamer-plugins-base-0.10 >= 0.10.23.2,
+ gstreamer-app-1.0
+ gstreamer-plugins-base-1.0 >= 0.10.23.2,
HAVE_GSTREAMERAPP=yes,
HAVE_GSTREAMERAPP=no)
if test x"$HAVE_GSTREAMERAPP" = "xyes"; then
AC_DEFINE(HAVE_GSTREAMERAPP, 1, [Define if GStreamer App support is enabled])
- GSTLIB=gstreamer-0.10
+ GSTLIB=gstreamer-1.0
AC_SUBST(GSTLIB) # For libdmapsharing-3.0.pc.in.
else
AC_WARN(GStreamer app element not present, transcoding will not be supported.)
diff --git a/libdmapsharing/dmap-gst-input-stream.c b/libdmapsharing/dmap-gst-input-stream.c
index 1318f34..5ebbc0a 100644
--- a/libdmapsharing/dmap-gst-input-stream.c
+++ b/libdmapsharing/dmap-gst-input-stream.c
@@ -23,7 +23,6 @@
#include <string.h>
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
-#include <gst/app/gstappbuffer.h>
#include "dmap-gst-input-stream.h"
#include "dmap-gst-mp3-input-stream.h"
@@ -175,7 +174,10 @@ dmap_gst_input_stream_new_buffer_cb (GstElement * element,
gsize i;
guint8 *ptr;
GTimeVal time;
+ GstSample *sample;
GstBuffer *buffer;
+ GstMemory *memory;
+ GstMapInfo info;
/* FIXME: Is this necessary? I am trying to protect against this
* thread manipulating data after the pipeline has been destroyed.
@@ -191,17 +193,33 @@ dmap_gst_input_stream_new_buffer_cb (GstElement * element,
g_get_current_time (&time);
g_time_val_add (&time, QUEUE_PUSH_WAIT_SECONDS * 1000000);
- buffer = gst_app_sink_pull_buffer (GST_APP_SINK (element));
+ sample = gst_app_sink_pull_sample (GST_APP_SINK (element));
+ if (NULL == sample) {
+ g_warning ("Error getting GStreamer sample");
+ goto _return;
+ }
- if (buffer == NULL) {
+ buffer = gst_sample_get_buffer (sample);
+ if (NULL == buffer) {
g_warning ("Error getting GStreamer buffer");
goto _return;
}
+ memory = gst_buffer_get_memory (buffer, 0);
+ if (NULL == memory) {
+ g_warning ("Error getting GStreamer memory");
+ goto _return;
+ }
+
+ if (gst_memory_map (memory, &info, GST_MAP_READ) == FALSE) {
+ g_warning ("Error mapping GStreamer memory");
+ goto _return;
+ }
+
/* FIXME: this actually allows buffer to grow larger than max. */
if (g_queue_get_length (stream->priv->buffer) +
- GST_BUFFER_SIZE (buffer) > DECODED_BUFFER_SIZE) {
- stream->priv->write_request = GST_BUFFER_SIZE (buffer);
+ info.size > DECODED_BUFFER_SIZE) {
+ stream->priv->write_request = info.size;
if (!g_cond_timed_wait (stream->priv->buffer_write_ready,
stream->priv->buffer_mutex, &time)) {
g_warning
@@ -217,16 +235,17 @@ dmap_gst_input_stream_new_buffer_cb (GstElement * element,
}
if (g_queue_get_length (stream->priv->buffer) +
- GST_BUFFER_SIZE (buffer) <= DECODED_BUFFER_SIZE) {
- ptr = GST_BUFFER_DATA (buffer);
+ info.size <= DECODED_BUFFER_SIZE) {
+ ptr = info.data;
- for (i = 0; i < GST_BUFFER_SIZE (buffer); i++) {
+ for (i = 0; i < info.size; i++) {
g_queue_push_tail (stream->priv->buffer,
GINT_TO_POINTER ((gint) * ptr++));
}
}
gst_buffer_unref (buffer);
+ gst_memory_unmap (memory, &info);
if (g_queue_get_length (stream->priv->buffer)
>= stream->priv->read_request) {
diff --git a/libdmapsharing/dmap-gst-mp3-input-stream.c b/libdmapsharing/dmap-gst-mp3-input-stream.c
index d163095..0ca4dcf 100644
--- a/libdmapsharing/dmap-gst-mp3-input-stream.c
+++ b/libdmapsharing/dmap-gst-mp3-input-stream.c
@@ -88,14 +88,14 @@ dmap_gst_mp3_input_stream_new (GInputStream * src_stream)
g_assert (GST_IS_ELEMENT (stream->priv->src));
stream->priv->decode =
- gst_element_factory_make ("decodebin2", "decode");
+ gst_element_factory_make ("decodebin", "decode");
g_assert (GST_IS_ELEMENT (stream->priv->decode));
stream->priv->convert =
gst_element_factory_make ("audioconvert", "convert");
g_assert (GST_IS_ELEMENT (stream->priv->convert));
- stream->priv->encode = gst_element_factory_make ("lame", "encode");
+ stream->priv->encode = gst_element_factory_make ("lamemp3enc", "encode");
g_assert (GST_IS_ELEMENT (stream->priv->encode));
stream->priv->sink = gst_element_factory_make ("appsink", "sink");
@@ -117,7 +117,8 @@ dmap_gst_mp3_input_stream_new (GInputStream * src_stream)
NULL);
/* quality=9 is important for fast, realtime transcoding: */
- g_object_set (G_OBJECT (stream->priv->encode), "quality", 9, NULL);
+ // FIXME: Causes crash; why?
+ // g_object_set (G_OBJECT (stream->priv->encode), "quality", 9, NULL);
g_object_set (G_OBJECT (stream->priv->encode), "bitrate", 128, NULL);
g_object_set (G_OBJECT (stream->priv->encode), "vbr", 0, NULL);
g_signal_connect (stream->priv->decode, "pad-added",
@@ -129,7 +130,7 @@ dmap_gst_mp3_input_stream_new (GInputStream * src_stream)
GST_APP_MAX_BUFFERS);
gst_app_sink_set_drop (GST_APP_SINK (stream->priv->sink), FALSE);
- g_signal_connect (stream->priv->sink, "new-buffer",
+ g_signal_connect (stream->priv->sink, "new-sample",
G_CALLBACK (dmap_gst_input_stream_new_buffer_cb),
stream);
diff --git a/libdmapsharing/gst-util.c b/libdmapsharing/gst-util.c
index ebff1cb..a36be09 100644
--- a/libdmapsharing/gst-util.c
+++ b/libdmapsharing/gst-util.c
@@ -29,8 +29,8 @@ pads_compatible (GstPad * pad1, GstPad * pad2)
gboolean fnval;
GstCaps *res, *caps1, *caps2;
- caps1 = gst_pad_get_caps (pad1);
- caps2 = gst_pad_get_caps (pad2);
+ caps1 = gst_pad_query_caps (pad1, NULL);
+ caps2 = gst_pad_query_caps (pad2, NULL);
res = gst_caps_intersect (caps1, caps2);
fnval = res && !gst_caps_is_empty (res);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fce91a4..b857c04 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -56,19 +56,19 @@ if MAINTAINER_MODE
BUILT_SOURCES = dacplisten.stamp dpapview.stamp dmapcopy.stamp dmapserve.stamp
dacplisten.stamp: $(dacplisten_VALASOURCES)
- $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
+ $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-1.0 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
touch $@
dpapview.stamp: $(dpapview_VALASOURCES)
- $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gtk+-2.0 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
+ $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gtk+-2.0 --pkg gstreamer-1.0 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
touch $@
dmapcopy.stamp: $(dmapcopy_VALASOURCES)
- $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
+ $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-1.0 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
touch $@
dmapserve.stamp: $(dmapserve_VALASOURCES)
- $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
+ $(VALAC) --vapidir=../vala --pkg gee-0.8 --pkg gstreamer-1.0 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 --pkg avahi-gobject $^ -C
touch $@
endif
diff --git a/vala/Makefile.am b/vala/Makefile.am
index a6645fa..0c0b223 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -16,16 +16,16 @@ libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.gi: libdmapsharin
@mv libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@-uninstalled.gi libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.gi
libdmapsharing- API_VERSION@-daap.vapi: libdmapsharing- API_VERSION@-daap/libdmapsharing- API_VERSION@.gi libdmapsharing- API_VERSION@-daap/libdmapsharing- API_VERSION@.metadata
- $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-0.10 --library libdmapsharing- API_VERSION@-daap libdmapsharing- API_VERSION@-daap/libdmapsharing- API_VERSION@.gi
+ $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-1.0 --library libdmapsharing- API_VERSION@-daap libdmapsharing- API_VERSION@-daap/libdmapsharing- API_VERSION@.gi
libdmapsharing- API_VERSION@-dacp.vapi: libdmapsharing- API_VERSION@-dacp/libdmapsharing- API_VERSION@.gi libdmapsharing- API_VERSION@-dacp/libdmapsharing- API_VERSION@.metadata
- $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-0.10 --library libdmapsharing- API_VERSION@-dacp libdmapsharing- API_VERSION@-dacp/libdmapsharing- API_VERSION@.gi
+ $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-1.0 --library libdmapsharing- API_VERSION@-dacp libdmapsharing- API_VERSION@-dacp/libdmapsharing- API_VERSION@.gi
libdmapsharing- API_VERSION@-dmap.vapi: libdmapsharing- API_VERSION@-dmap/libdmapsharing- API_VERSION@.gi libdmapsharing- API_VERSION@-dmap/libdmapsharing- API_VERSION@.metadata
- $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-0.10 --library libdmapsharing- API_VERSION@-dmap libdmapsharing- API_VERSION@-dmap/libdmapsharing- API_VERSION@.gi
+ $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-1.0 --library libdmapsharing- API_VERSION@-dmap libdmapsharing- API_VERSION@-dmap/libdmapsharing- API_VERSION@.gi
libdmapsharing- API_VERSION@-dpap.vapi: libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.gi libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.metadata
- $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-0.10 --library libdmapsharing- API_VERSION@-dpap libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.gi
+ $(VAPIGEN) --pkg=avahi-gobject --pkg=libsoup-2.4 --pkg=glib-2.0 --pkg=gio-2.0 --pkg=gstreamer-1.0 --library libdmapsharing- API_VERSION@-dpap libdmapsharing- API_VERSION@-dpap/libdmapsharing- API_VERSION@.gi
# NOTE: Sed is used to fix a problem I don't know how to handle in
# vapigen. I have several namespaces (DMAP, DAAP, ...) in libdmapsharing. In
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]