From 957043ad0a1503446d9ef64861d340e018be6220 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 19 Aug 2011 18:07:58 +0200 Subject: [PATCH] port to new audio caps --- ext/mad/gstmad.c | 14 +++------ ext/sidplay/Makefile.am | 6 ++-- ext/sidplay/gstsiddec.cc | 61 ++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index cdba719d99..2fe4853382 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -58,11 +58,8 @@ static GstStaticPadTemplate mad_src_template_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-int, " - "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " - "signed = (boolean) true, " - "width = (int) 32, " - "depth = (int) 32, " + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_AUDIO_NE (S32) ", " "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, " "channels = (int) [ 1, 2 ]") ); @@ -1252,11 +1249,8 @@ gst_mad_check_caps_reset (GstMad * mad) /* we set the caps even when the pad is not connected so they * can be gotten for streaminfo */ - caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "width", G_TYPE_INT, 32, - "depth", G_TYPE_INT, 32, + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (S32), "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL); gst_pad_set_caps (mad->srcpad, caps); diff --git a/ext/sidplay/Makefile.am b/ext/sidplay/Makefile.am index 50f31353ec..60d503071c 100644 --- a/ext/sidplay/Makefile.am +++ b/ext/sidplay/Makefile.am @@ -1,8 +1,10 @@ plugin_LTLIBRARIES = libgstsid.la libgstsid_la_SOURCES = gstsiddec.cc -libgstsid_la_CXXFLAGS = $(GST_BASE_CFLAGS) $(GST_CXXFLAGS) $(SIDPLAY_CFLAGS) -libgstsid_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(SIDPLAY_LIBS) +libgstsid_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \ + $(GST_CXXFLAGS) $(SIDPLAY_CFLAGS) +libgstsid_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(SIDPLAY_LIBS) \ + -lgstaudio-$(GST_MAJORMINOR) libgstsid_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstsid_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/ext/sidplay/gstsiddec.cc b/ext/sidplay/gstsiddec.cc index c4f3b1ec14..78f0067285 100644 --- a/ext/sidplay/gstsiddec.cc +++ b/ext/sidplay/gstsiddec.cc @@ -45,6 +45,7 @@ #endif #include +#include #include "gstsiddec.h" #define DEFAULT_TUNE 0 @@ -76,14 +77,13 @@ static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_CAPS ("audio/x-sid") ); +#define FORMATS "{ S8, U8, "GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)" }" + static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-int, " - "endianness = (int) BYTE_ORDER, " - "signed = (boolean) { true, false }, " - "width = (int) { 8, 16 }, " - "depth = (int) { 8, 16 }, " + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " FORMATS ", " "rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]") ); @@ -279,12 +279,12 @@ static gboolean siddec_negotiate (GstSidDec * siddec) { GstCaps *allowed; - gboolean sign = TRUE; - gint width = 16, depth = 16; GstStructure *structure; int rate = 44100; int channels = 1; GstCaps *caps; + const gchar *str; + GstAudioFormat format; allowed = gst_pad_get_allowed_caps (siddec->srcpad); if (!allowed) @@ -294,31 +294,39 @@ siddec_negotiate (GstSidDec * siddec) structure = gst_caps_get_structure (allowed, 0); - gst_structure_get_int (structure, "width", &width); - gst_structure_get_int (structure, "depth", &depth); + str = gst_structure_get_string (structure, "format"); + if (str == NULL) + goto invalid_format; - if (width && depth && width != depth) - goto wrong_width; - - width = width | depth; - if (width) { - siddec->config->bitsPerSample = width; + format = gst_audio_format_from_string (str); + switch (format) { + case GST_AUDIO_FORMAT_S8: + siddec->config->bitsPerSample = 8; + siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; + break; + case GST_AUDIO_FORMAT_U8: + siddec->config->bitsPerSample = 8; + siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM; + break; + case GST_AUDIO_FORMAT_S16: + siddec->config->bitsPerSample = 16; + siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; + break; + case GST_AUDIO_FORMAT_U16: + siddec->config->bitsPerSample = 16; + siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM; + break; + default: + goto invalid_format; } - gst_structure_get_boolean (structure, "signed", &sign); gst_structure_get_int (structure, "rate", &rate); siddec->config->frequency = rate; gst_structure_get_int (structure, "channels", &channels); siddec->config->channels = channels; - siddec->config->sampleFormat = - (sign ? SIDEMU_SIGNED_PCM : SIDEMU_UNSIGNED_PCM); - - caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, sign, - "width", G_TYPE_INT, siddec->config->bitsPerSample, - "depth", G_TYPE_INT, siddec->config->bitsPerSample, + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, gst_audio_format_to_string (format), "rate", G_TYPE_INT, siddec->config->frequency, "channels", G_TYPE_INT, siddec->config->channels, NULL); gst_pad_set_caps (siddec->srcpad, caps); @@ -334,10 +342,9 @@ nothing_allowed: GST_DEBUG_OBJECT (siddec, "could not get allowed caps"); return FALSE; } -wrong_width: +invalid_format: { - GST_DEBUG_OBJECT (siddec, "width %d and depth %d are different", - width, depth); + GST_DEBUG_OBJECT (siddec, "invalid audio caps"); return FALSE; } }