port to new audio caps

This commit is contained in:
Wim Taymans 2011-08-19 18:07:58 +02:00
parent 8ab84f0f8a
commit 957043ad0a
3 changed files with 42 additions and 39 deletions

View file

@ -58,11 +58,8 @@ static GstStaticPadTemplate mad_src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, " GST_STATIC_CAPS ("audio/x-raw, "
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " "format = (string) " GST_AUDIO_NE (S32) ", "
"signed = (boolean) true, "
"width = (int) 32, "
"depth = (int) 32, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, " "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]") "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 /* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */ * can be gotten for streaminfo */
caps = gst_caps_new_simple ("audio/x-raw-int", caps = gst_caps_new_simple ("audio/x-raw",
"endianness", G_TYPE_INT, G_BYTE_ORDER, "format", G_TYPE_STRING, GST_AUDIO_NE (S32),
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 32,
"depth", G_TYPE_INT, 32,
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL); "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL);
gst_pad_set_caps (mad->srcpad, caps); gst_pad_set_caps (mad->srcpad, caps);

View file

@ -1,8 +1,10 @@
plugin_LTLIBRARIES = libgstsid.la plugin_LTLIBRARIES = libgstsid.la
libgstsid_la_SOURCES = gstsiddec.cc libgstsid_la_SOURCES = gstsiddec.cc
libgstsid_la_CXXFLAGS = $(GST_BASE_CFLAGS) $(GST_CXXFLAGS) $(SIDPLAY_CFLAGS) libgstsid_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
libgstsid_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(SIDPLAY_LIBS) $(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_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstsid_la_LIBTOOLFLAGS = --tag=disable-static libgstsid_la_LIBTOOLFLAGS = --tag=disable-static

View file

@ -45,6 +45,7 @@
#endif #endif
#include <string.h> #include <string.h>
#include <gst/audio/audio.h>
#include "gstsiddec.h" #include "gstsiddec.h"
#define DEFAULT_TUNE 0 #define DEFAULT_TUNE 0
@ -76,14 +77,13 @@ static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-sid") 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", static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, " GST_STATIC_CAPS ("audio/x-raw, "
"endianness = (int) BYTE_ORDER, " "format = (string) " FORMATS ", "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]") "rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
); );
@ -279,12 +279,12 @@ static gboolean
siddec_negotiate (GstSidDec * siddec) siddec_negotiate (GstSidDec * siddec)
{ {
GstCaps *allowed; GstCaps *allowed;
gboolean sign = TRUE;
gint width = 16, depth = 16;
GstStructure *structure; GstStructure *structure;
int rate = 44100; int rate = 44100;
int channels = 1; int channels = 1;
GstCaps *caps; GstCaps *caps;
const gchar *str;
GstAudioFormat format;
allowed = gst_pad_get_allowed_caps (siddec->srcpad); allowed = gst_pad_get_allowed_caps (siddec->srcpad);
if (!allowed) if (!allowed)
@ -294,31 +294,39 @@ siddec_negotiate (GstSidDec * siddec)
structure = gst_caps_get_structure (allowed, 0); structure = gst_caps_get_structure (allowed, 0);
gst_structure_get_int (structure, "width", &width); str = gst_structure_get_string (structure, "format");
gst_structure_get_int (structure, "depth", &depth); if (str == NULL)
goto invalid_format;
if (width && depth && width != depth) format = gst_audio_format_from_string (str);
goto wrong_width; switch (format) {
case GST_AUDIO_FORMAT_S8:
width = width | depth; siddec->config->bitsPerSample = 8;
if (width) { siddec->config->sampleFormat = SIDEMU_SIGNED_PCM;
siddec->config->bitsPerSample = width; 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); gst_structure_get_int (structure, "rate", &rate);
siddec->config->frequency = rate; siddec->config->frequency = rate;
gst_structure_get_int (structure, "channels", &channels); gst_structure_get_int (structure, "channels", &channels);
siddec->config->channels = channels; siddec->config->channels = channels;
siddec->config->sampleFormat = caps = gst_caps_new_simple ("audio/x-raw",
(sign ? SIDEMU_SIGNED_PCM : SIDEMU_UNSIGNED_PCM); "format", G_TYPE_STRING, gst_audio_format_to_string (format),
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,
"rate", G_TYPE_INT, siddec->config->frequency, "rate", G_TYPE_INT, siddec->config->frequency,
"channels", G_TYPE_INT, siddec->config->channels, NULL); "channels", G_TYPE_INT, siddec->config->channels, NULL);
gst_pad_set_caps (siddec->srcpad, caps); gst_pad_set_caps (siddec->srcpad, caps);
@ -334,10 +342,9 @@ nothing_allowed:
GST_DEBUG_OBJECT (siddec, "could not get allowed caps"); GST_DEBUG_OBJECT (siddec, "could not get allowed caps");
return FALSE; return FALSE;
} }
wrong_width: invalid_format:
{ {
GST_DEBUG_OBJECT (siddec, "width %d and depth %d are different", GST_DEBUG_OBJECT (siddec, "invalid audio caps");
width, depth);
return FALSE; return FALSE;
} }
} }