summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2013-05-28 11:39:52 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-05-28 11:46:42 +0200
commitd4a146e2c84746ab0b194dc17970c4188ce1edc8 (patch)
tree475c3c17ac0a6d32499e9a215272b1ea142c5fee
parent86927b60bb86370d69cc37e3054594068bfd120e (diff)
Port Mirage plugin to GStreamer 1.0
-rw-r--r--README12
-rw-r--r--build/m4/extensions/mirage.m48
-rw-r--r--src/Mirage/libmirageaudio/gst-mirageaudio.c39
3 files changed, 35 insertions, 24 deletions
diff --git a/README b/README
index 8c5e53d..25eca5c 100644
--- a/README
+++ b/README
@@ -47,9 +47,9 @@ LastfmFingerprint
glib-2.0
fftw3f
samplerate
- gstreamer-0.10 >= 0.10.15
- gstreamer-base-0.10 >= 0.10.15
- gstreamer-plugins-base-0.10 >= 0.10.15
+ gstreamer-1.0 >= 1.0
+ gstreamer-base-1.0 >= 1.0
+ gstreamer-plugins-base-1.0 >= 1.0
LCD
LCDProc
@@ -61,9 +61,9 @@ Mirage:
glib-2.0
fftw3f
samplerate
- gstreamer-0.10 >= 0.10.15
- gstreamer-base-0.10 >= 0.10.15
- gstreamer-plugins-base-0.10 >= 0.10.15
+ gstreamer-1.0 >= 1.0
+ gstreamer-base-1.0 >= 1.0
+ gstreamer-plugins-base-1.0 >= 1.0
Telepathy
empathy >= 2.27.91
diff --git a/build/m4/extensions/mirage.m4 b/build/m4/extensions/mirage.m4
index 689fb80..b172353 100644
--- a/build/m4/extensions/mirage.m4
+++ b/build/m4/extensions/mirage.m4
@@ -14,11 +14,11 @@ AC_DEFUN([BCE_MIRAGE],
[samplerate],
[The samplerate library was not found. Please install it or disable the Mirage extension by passing --disable-mirage])
- GSTREAMER_REQUIRED_VERSION=0.10.15
+ GSTREAMER_REQUIRED_VERSION=1.0
BCE_CHECK_EXTENSION_DEP([Mirage], [GSTREAMER],
- [gstreamer-0.10 >= $GSTREAMER_REQUIRED_VERSION
- gstreamer-base-0.10 >= $GSTREAMER_REQUIRED_VERSION
- gstreamer-plugins-base-0.10 >= $GSTREAMER_REQUIRED_VERSION],
+ [gstreamer-1.0 >= $GSTREAMER_REQUIRED_VERSION
+ gstreamer-base-1.0 >= $GSTREAMER_REQUIRED_VERSION
+ gstreamer-plugins-base-1.0 >= $GSTREAMER_REQUIRED_VERSION],
[GStreamer >= $GSTREAMER_REQUIRED_VERSION not found. Please install it or disable the Mirage extension by passing --disable-mirage])
if test "x$enable_Mirage" = "xtry" \
diff --git a/src/Mirage/libmirageaudio/gst-mirageaudio.c b/src/Mirage/libmirageaudio/gst-mirageaudio.c
index 3e6071d..292ba74 100644
--- a/src/Mirage/libmirageaudio/gst-mirageaudio.c
+++ b/src/Mirage/libmirageaudio/gst-mirageaudio.c
@@ -23,10 +23,12 @@
#include <math.h>
#include <string.h>
#include <time.h>
+#include <stdlib.h>
#include <glib.h>
#include <fftw3.h>
#include <gst/gst.h>
+#include <gst/audio/audio.h>
#include <samplerate.h>
#include "gst-mirageaudio.h"
@@ -89,21 +91,21 @@ void toc()
}
static void
-mirageaudio_cb_newpad(GstElement *decodebin, GstPad *pad, gboolean last, MirageAudio *ma)
+mirageaudio_cb_newpad(GstElement *decodebin, GstPad *pad, MirageAudio *ma)
{
GstCaps *caps;
GstStructure *str;
GstPad *audiopad;
// only link once
- audiopad = gst_element_get_pad(ma->audio, "sink");
+ audiopad = gst_element_get_static_pad(ma->audio, "sink");
if (GST_PAD_IS_LINKED(audiopad)) {
g_object_unref(audiopad);
return;
}
// check media type
- caps = gst_pad_get_caps(pad);
+ caps = gst_pad_get_current_caps(pad);
str = gst_caps_get_structure(caps, 0);
if (!g_strrstr(gst_structure_get_name(str), "audio")) {
@@ -126,17 +128,20 @@ mirageaudio_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, Mi
gint i;
gint j;
gint fill;
+ GstMapInfo map;
// if data continues to flow/EOS is not yet processed
if (ma->quit)
return;
// exit on empty buffer
- if (buffer->size <= 0)
+ if (gst_buffer_get_size (buffer) <= 0)
return;
+ if (!gst_buffer_map (buffer, &map, GST_MAP_READ))
+ return;
- ma->src_data.data_in = (float*)GST_BUFFER_DATA(buffer);
- ma->src_data.input_frames = GST_BUFFER_SIZE(buffer)/sizeof(float);
+ ma->src_data.data_in = (float*)map.data;
+ ma->src_data.input_frames = map.size/sizeof(float);
do {
// set end of input flag if necessary
@@ -152,8 +157,10 @@ mirageaudio_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, Mi
g_print("libmirageaudio: SRC Error - %s\n", src_strerror(err));
}
// return if no output
- if (ma->src_data.output_frames_gen == 0)
+ if (ma->src_data.output_frames_gen == 0) {
+ gst_buffer_unmap (buffer, &map);
return;
+ }
buffersamples = ma->src_data.output_frames_gen;
bufferpos = 0;
@@ -202,6 +209,7 @@ mirageaudio_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, Mi
g_print("libmirageaudio: EOS Message sent\n");
gst_object_unref(bus);
ma->quit = TRUE;
+ gst_buffer_unmap (buffer, &map);
return;
}
@@ -218,6 +226,8 @@ mirageaudio_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, Mi
} while (ma->src_data.input_frames > 0);
+ gst_buffer_unmap (buffer, &map);
+
return;
}
@@ -279,7 +289,7 @@ mirageaudio_initgstreamer(MirageAudio *ma, const gchar *file)
src = gst_element_factory_make("filesrc", "source");
g_object_set(G_OBJECT(src), "location", file, NULL);
dec = gst_element_factory_make("decodebin", "decoder");
- g_signal_connect(dec, "new-decoded-pad", G_CALLBACK(mirageaudio_cb_newpad), ma);
+ g_signal_connect(dec, "pad-added", G_CALLBACK(mirageaudio_cb_newpad), ma);
gst_bin_add_many(GST_BIN(ma->pipeline), src, dec, NULL);
gst_element_link(src, dec);
@@ -287,8 +297,8 @@ mirageaudio_initgstreamer(MirageAudio *ma, const gchar *file)
ma->audio = gst_bin_new("audio");
audioconvert = gst_element_factory_make("audioconvert", "conv");
- filter_float = gst_caps_new_simple("audio/x-raw-float",
- "width", G_TYPE_INT, 32,
+ filter_float = gst_caps_new_simple("audio/x-raw",
+ "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
NULL);
cfilt_float = gst_element_factory_make("capsfilter", "cfilt_float");
g_object_set(G_OBJECT(cfilt_float), "caps", filter_float, NULL);
@@ -296,7 +306,8 @@ mirageaudio_initgstreamer(MirageAudio *ma, const gchar *file)
audioresample = gst_element_factory_make("audioresample", "resample");
- filter_resample = gst_caps_new_simple("audio/x-raw-float",
+ filter_resample = gst_caps_new_simple("audio/x-raw",
+ "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
"channels", G_TYPE_INT, 1,
NULL);
cfilt_resample = gst_element_factory_make("capsfilter", "cfilt_resample");
@@ -316,7 +327,7 @@ mirageaudio_initgstreamer(MirageAudio *ma, const gchar *file)
audioresample, cfilt_resample,
sink, NULL);
- audiopad = gst_element_get_pad(audioconvert, "sink");
+ audiopad = gst_element_get_static_pad(audioconvert, "sink");
gst_element_add_pad(ma->audio,
gst_ghost_pad_new("sink", audiopad));
gst_object_unref(audiopad);
@@ -332,8 +343,8 @@ mirageaudio_initgstreamer(MirageAudio *ma, const gchar *file)
gst_element_get_state(ma->pipeline, NULL, NULL, max_wait);
}
- GstPad *pad = gst_element_get_pad(sink, "sink");
- GstCaps *caps = gst_pad_get_negotiated_caps(pad);
+ GstPad *pad = gst_element_get_static_pad(sink, "sink");
+ GstCaps *caps = gst_pad_get_current_caps(pad);
if (GST_IS_CAPS(caps)) {
GstStructure *str = gst_caps_get_structure(caps, 0);
gst_structure_get_int(str, "rate", &ma->filerate);