diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2013-05-28 11:48:08 +0200 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-05-28 11:48:08 +0200 |
commit | 88cbafe258a788f300568e17f13c08dfdbfff043 (patch) | |
tree | d2ba9af5ab4c3ea4617f3b2f8272dbe3976a6b11 | |
parent | d4a146e2c84746ab0b194dc17970c4188ce1edc8 (diff) |
Port LastfmFingerprint plugin to GStreamer 1.0
4 files changed, 28 insertions, 23 deletions
diff --git a/build/m4/extensions/lastfmfingerprint.m4 b/build/m4/extensions/lastfmfingerprint.m4 index 9ab0c53..21a6549 100644 --- a/build/m4/extensions/lastfmfingerprint.m4 +++ b/build/m4/extensions/lastfmfingerprint.m4 @@ -19,11 +19,11 @@ AC_DEFUN([BCE_LASTFMFINGERPRINT], [banshee-lastfm], [banshee-lastfm was not found. Please install it or disable the LastfmFingerprint extension by passing --disable-lastfmfingerprint]) - GSTREAMER_REQUIRED_VERSION=0.10.15 + GSTREAMER_REQUIRED_VERSION=1.0 BCE_CHECK_EXTENSION_DEP([LastfmFingerprint], [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 LastfmFingerprint extension by passing --disable-lastfmfingerprint]) if test "x$enable_LastfmFingerprint" = "xtry" \ diff --git a/src/LastfmFingerprint/liblastfmfpbridge/gst-lastfmfpbridge.cpp b/src/LastfmFingerprint/liblastfmfpbridge/gst-lastfmfpbridge.cpp index 12268c1..c197b36 100644 --- a/src/LastfmFingerprint/liblastfmfpbridge/gst-lastfmfpbridge.cpp +++ b/src/LastfmFingerprint/liblastfmfpbridge/gst-lastfmfpbridge.cpp @@ -25,6 +25,9 @@ #include <glib.h> #include <gst/gst.h> +#include <gst/audio/audio.h> + +#include <stdlib.h> #include "gst-lastfmfpbridge.h" @@ -60,21 +63,21 @@ struct LastfmfpAudio { }; static void -Lastfmfp_cb_newpad(GstElement *decodebin, GstPad *pad, gboolean last, LastfmfpAudio *ma) +Lastfmfp_cb_newpad(GstElement *decodebin, GstPad *pad, LastfmfpAudio *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")) { @@ -107,17 +110,22 @@ Lastfmfp_getVersion (LastfmfpAudio *ma) static void Lastfmfp_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, LastfmfpAudio *ma) { + 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->data_in = (short*)GST_BUFFER_DATA(buffer); + ma->data_in = (short*)map.data; //ma->num_samples = (size_t)(GST_BUFFER_OFFSET_END (buffer) - GST_BUFFER_OFFSET (buffer)); - ma->num_samples = (size_t)(GST_BUFFER_SIZE (buffer) / sizeof(guint16)); + ma->num_samples = (size_t)(map.size / sizeof(guint16)); //printf("caps: %s\n", gst_caps_to_string(GST_BUFFER_CAPS(buffer))); //printf(" offset : %llu size: %llu \n", (unsigned long long)GST_BUFFER_OFFSET (buffer), (unsigned long long)GST_BUFFER_OFFSET_END (buffer)); @@ -133,10 +141,9 @@ Lastfmfp_cb_have_data(GstElement *element, GstBuffer *buffer, GstPad *pad, Lastf g_print("libLastfmfp: EOS Message sent\n"); gst_object_unref(bus); ma->quit = TRUE; - return; - } - + + gst_buffer_unmap (buffer, &map); return; } @@ -173,7 +180,7 @@ Lastfmfp_initgstreamer(LastfmfpAudio *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(Lastfmfp_cb_newpad), ma); + g_signal_connect(dec, "pad-added", G_CALLBACK(Lastfmfp_cb_newpad), ma); gst_bin_add_many(GST_BIN(ma->pipeline), src, dec, NULL); gst_element_link(src, dec); @@ -181,11 +188,8 @@ Lastfmfp_initgstreamer(LastfmfpAudio *ma, const gchar *file) ma->audio = gst_bin_new("audio"); audioconvert = gst_element_factory_make("audioconvert", "conv"); - filter_short = gst_caps_new_simple("audio/x-raw-int", - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, 1234,//BYTE_ORDER, //1234, - "signed", G_TYPE_BOOLEAN, TRUE, + filter_short = gst_caps_new_simple("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE(S16), NULL); cfilt_short = gst_element_factory_make("capsfilter", "cfilt_short"); g_object_set(G_OBJECT(cfilt_short), "caps", filter_short, NULL); @@ -202,7 +206,7 @@ Lastfmfp_initgstreamer(LastfmfpAudio *ma, const gchar *file) gst_element_link_many(audioconvert, cfilt_short, 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); @@ -218,8 +222,8 @@ Lastfmfp_initgstreamer(LastfmfpAudio *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); diff --git a/src/LastfmFingerprint/liblastfmfpbridge/lastfmfpbridgetest.cpp b/src/LastfmFingerprint/liblastfmfpbridge/lastfmfpbridgetest.cpp index 66ab448..487443e 100644 --- a/src/LastfmFingerprint/liblastfmfpbridge/lastfmfpbridgetest.cpp +++ b/src/LastfmFingerprint/liblastfmfpbridge/lastfmfpbridgetest.cpp @@ -21,6 +21,7 @@ */ #include <gst/gst.h> +#include <stdio.h> #include "gst-lastfmfpbridge.h" diff --git a/src/LastfmFingerprint/liblastfmfpbridge/liblastfmfpbridge.cproj b/src/LastfmFingerprint/liblastfmfpbridge/liblastfmfpbridge.cproj index a6871d5..d6375ad 100644 --- a/src/LastfmFingerprint/liblastfmfpbridge/liblastfmfpbridge.cproj +++ b/src/LastfmFingerprint/liblastfmfpbridge/liblastfmfpbridge.cproj @@ -21,7 +21,7 @@ <CompileTarget>SharedLibrary</CompileTarget> <Includes> <Includes> - <Include>/usr/include/gstreamer-0.10</Include> + <Include>/usr/include/gstreamer-1.0</Include> <Include>/usr/include/glib-2.0</Include> <Include>/usr/lib/glib-2.0/include</Include> <Include>/usr/include/libxml2</Include> |