Commit b144bc6c authored by David Schleef's avatar David Schleef

Merge CAPS branch

Original commit message from CVS:
Merge CAPS branch
parent 2309d726
......@@ -12,78 +12,27 @@ struct probe_context {
gint total_ls;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
};
static void
print_caps (GstCaps *caps)
{
if (caps == NULL) return;
if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") ||
!strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo"))
{
GstProps *props = caps->properties;
GList *walk;
/* ugly hack, but ok for now. If needed, fix by individual strcmp */
g_print (" %s:\n", gst_caps_get_mime (caps) + 18);
if (props == NULL) {
g_print (" none\n");
return;
}
walk = props->properties;
while (walk) {
GstPropsEntry *entry = (GstPropsEntry *) walk->data;
const gchar *name;
const gchar *str_val;
gint int_val;
GstPropsType type;
name = gst_props_entry_get_name (entry);
type = gst_props_entry_get_props_type (entry);
switch (type) {
case GST_PROPS_STRING_TYPE:
gst_props_entry_get_string (entry, &str_val);
g_print (" %s='%s'\n", name, str_val);
break;
case GST_PROPS_INT_TYPE:
gst_props_entry_get_int (entry, &int_val);
g_print (" %s=%d\n", name, int_val);
break;
default:
break;
}
walk = g_list_next (walk);
}
}
else {
g_print (" unkown caps type\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" %s\n", s);
g_free (s);
}
static void
print_format (GstCaps *caps)
{
g_print (" format:\n");
if (!caps || caps->properties == NULL) {
g_print (" unkown\n");
return;
}
if (!strcmp (gst_caps_get_mime (caps), "audio/raw")) {
gint channels;
gint rate;
gst_caps_get_int (caps, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate);
g_print (" channels: %d\n", channels);
g_print (" rate: %d\n", rate);
}
else {
g_print (" unkown format\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" format: %s\n", s);
g_free (s);
}
static void
......
......@@ -38,36 +38,34 @@ static GstElementDetails gst_arts_details = {
};
GST_PAD_TEMPLATE_FACTORY ( sink_temp,
static GstStaticPadTemplate sink_temp =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"arts_sample",
"audio/x-raw-int",
"depth", GST_PROPS_INT (16),
"width", GST_PROPS_INT (16),
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (2),
"endianness", GST_PROPS_INT (G_BYTE_ORDER)
GST_STATIC_CAPS ( "audio/x-raw-int, "
"depth = (int) 16, "
"width = (int) 16, "
"signed = (boolean) true, "
"channels = (int) 2, "
"endianness = (int) byte_order"
)
)
);
GST_PAD_TEMPLATE_FACTORY ( src_temp,
static GstStaticPadTemplate src_temp =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"arts_sample",
"audio/x-raw-int",
"depth", GST_PROPS_INT (16),
"width", GST_PROPS_INT (16),
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (2),
"rate", GST_PROPS_INT (44100),
"endianness", GST_PROPS_INT (G_BYTE_ORDER)
GST_STATIC_CAPS ("audio/x-raw-int, "
"depth = (int) 16, "
"width = (int) 16, "
"signed = (boolean) true, "
"channels = (int) 2, "
"rate = (int) 44100, "
"endianness = (int) byte_order"
)
)
);
enum {
ARG_0,
......@@ -112,9 +110,9 @@ gst_arts_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_temp));
gst_static_pad_template_get (&sink_temp));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_temp));
gst_static_pad_template_get (&src_temp));
gst_element_class_set_details (element_class, &gst_arts_details);
}
......@@ -133,10 +131,12 @@ gst_arts_class_init (GstARTSClass *klass)
static void
gst_arts_init (GstARTS *arts)
{
arts->sinkpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(sink_temp),"sink");
arts->sinkpad = gst_pad_new_from_template(
gst_element_get_pad_template (GST_ELEMENT (arts), "sink"), "sink");
gst_element_add_pad(GST_ELEMENT(arts),arts->sinkpad);
arts->srcpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(src_temp),"src");
arts->srcpad = gst_pad_new_from_template(
gst_element_get_pad_template (GST_ELEMENT (arts), "src"), "src");
gst_element_add_pad(GST_ELEMENT(arts),arts->srcpad);
gst_element_set_loop_function (GST_ELEMENT (arts), gst_arts_loop);
......
......@@ -24,6 +24,7 @@
#include "config.h"
#endif
#include "gstartsdsink.h"
#include <gst/audio/audio.h>
/* elementfactory information */
static GstElementDetails artsdsink_details = {
......@@ -45,31 +46,12 @@ enum {
ARG_NAME,
};
GST_PAD_TEMPLATE_FACTORY (sink_factory,
"sink", /* the name of the pads */
GST_PAD_SINK, /* type of the pad */
GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */
GST_CAPS_NEW (
"artsdsink_sink", /* the name of the caps */
"audio/x-raw-int", /* the mime type of the caps */
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (FALSE),
"width", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"depth", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
)
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
);
static void gst_artsdsink_base_init (gpointer g_class);
......@@ -80,7 +62,7 @@ static gboolean gst_artsdsink_open_audio (GstArtsdsink *sink);
static void gst_artsdsink_close_audio (GstArtsdsink *sink);
static GstElementStateReturn gst_artsdsink_change_state (GstElement *element);
static gboolean gst_artsdsink_sync_parms (GstArtsdsink *artsdsink);
static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, const GstCaps *caps);
static void gst_artsdsink_chain (GstPad *pad, GstData *_data);
static void gst_artsdsink_set_property (GObject *object, guint prop_id,
......@@ -118,7 +100,8 @@ gst_artsdsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &artsdsink_details);
}
......@@ -151,7 +134,7 @@ static void
gst_artsdsink_init(GstArtsdsink *artsdsink)
{
artsdsink->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_element_get_pad_template (GST_ELEMENT (artsdsink), "sink"), "sink");
gst_element_add_pad(GST_ELEMENT(artsdsink), artsdsink->sinkpad);
gst_pad_set_chain_function(artsdsink->sinkpad, gst_artsdsink_chain);
gst_pad_set_link_function(artsdsink->sinkpad, gst_artsdsink_link);
......@@ -175,19 +158,16 @@ gst_artsdsink_sync_parms (GstArtsdsink *artsdsink)
}
static GstPadLinkReturn
gst_artsdsink_link (GstPad *pad, GstCaps *caps)
gst_artsdsink_link (GstPad *pad, const GstCaps *caps)
{
GstArtsdsink *artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));
GstStructure *structure;
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
gst_caps_get (caps,
"rate", &artsdsink->frequency,
"depth", &artsdsink->depth,
"signed", &artsdsink->signd,
"channels", &artsdsink->channels,
NULL);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &artsdsink->frequency);
gst_structure_get_int (structure, "depth", &artsdsink->depth);
gst_structure_get_int (structure, "signed", &artsdsink->signd);
gst_structure_get_int (structure, "channels", &artsdsink->channels);
if (gst_artsdsink_sync_parms (artsdsink))
return GST_PAD_LINK_OK;
......
......@@ -50,42 +50,34 @@ enum {
};
/* added a src factory function to force audio/raw MIME type */
GST_PAD_TEMPLATE_FACTORY (afparse_src_factory,
static GstStaticPadTemplate afparse_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"audiofile_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (TRUE), GST_PROPS_BOOLEAN (FALSE)),
"width", GST_PROPS_INT_RANGE (8, 16),
"depth", GST_PROPS_INT_RANGE (8, 16),
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"signed = (boolean) { true, false }, "
"buffer-frames = (int) [ 1, MAX ]"
)
)
);
GST_PAD_TEMPLATE_FACTORY (afparse_sink_factory,
static GstStaticPadTemplate afparse_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"afparse_sink_aiff",
"audio/x-aiff",
NULL
),
GST_CAPS_NEW (
"afparse_sink_wav",
"audio/x-wav",
NULL
),
GST_CAPS_NEW (
"afparse_sink_snd",
"audio/x-au",
NULL
GST_STATIC_CAPS (
"audio/x-aiff; "
"audio/x-wav; "
"audio/x-au"
)
)
);
static void gst_afparse_base_init (gpointer g_class);
static void gst_afparse_class_init(GstAFParseClass *klass);
......@@ -131,8 +123,10 @@ gst_afparse_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afparse_src_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afparse_sink_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&afparse_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&afparse_sink_factory));
gst_element_class_set_details (element_class, &afparse_details);
}
......@@ -154,10 +148,12 @@ gst_afparse_class_init (GstAFParseClass *klass)
static void
gst_afparse_init (GstAFParse *afparse)
{
afparse->srcpad = gst_pad_new_from_template (afparse_src_factory (), "src");
afparse->srcpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (afparse), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);
afparse->sinkpad = gst_pad_new_from_template (afparse_sink_factory (), "sink");
afparse->sinkpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (afparse), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);
......@@ -191,7 +187,6 @@ gst_afparse_loop(GstElement *element)
{
GstAFParse *afparse;
GstBuffer *buf;
GstBufferPool *bufpool;
gint numframes = 0, frames_to_bytes, frames_per_read, bytes_per_read;
guint8 *data;
gboolean bypass_afread = TRUE;
......@@ -230,7 +225,6 @@ gst_afparse_loop(GstElement *element)
frames_per_read = afparse->frames_per_read;
bytes_per_read = frames_per_read * frames_to_bytes;
bufpool = gst_buffer_pool_get_default (bytes_per_read, 8);
afSeekFrame(afparse->file, AF_DEFAULT_TRACK, 0);
if (bypass_afread){
......@@ -269,7 +263,7 @@ gst_afparse_loop(GstElement *element)
}
else {
do {
buf = gst_buffer_new_from_pool (bufpool, 0, 0);
buf = gst_buffer_new_and_alloc (bytes_per_read);
GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
data = GST_BUFFER_DATA(buf);
numframes = afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
......@@ -290,7 +284,6 @@ gst_afparse_loop(GstElement *element)
while (TRUE);
}
gst_afparse_close_file (afparse);
gst_buffer_pool_unref(bufpool);
gst_bytestream_destroy ((GstByteStream*) afparse->vfile->closure);
......@@ -389,17 +382,15 @@ gst_afparse_open_file (GstAFParse *afparse)
/* set caps on src */
/*FIXME: add all the possible formats, especially float ! */
gst_pad_try_set_caps (afparse->srcpad,
GST_CAPS_NEW (
"af_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */
"signed", GST_PROPS_BOOLEAN (afparse->is_signed),
"width", GST_PROPS_INT (afparse->width),
"depth", GST_PROPS_INT (afparse->width),
"rate", GST_PROPS_INT (afparse->rate),
"channels", GST_PROPS_INT (afparse->channels)
)
);
gst_caps_new_simple (
"audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, afparse->is_signed,
"width", G_TYPE_INT, afparse->width,
"depth", G_TYPE_INT, afparse->width,
"rate", G_TYPE_INT, afparse->rate,
"channels", G_TYPE_INT, afparse->channels,
NULL));
GST_FLAG_SET (afparse, GST_AFPARSE_OPEN);
......
......@@ -52,22 +52,19 @@ enum {
/* added a sink factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
GST_PAD_TEMPLATE_FACTORY (afsink_sink_factory,
static GstStaticPadTemplate afsink_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"audiofile_sink",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"width", GST_PROPS_INT_RANGE (8, 16),
"depth", GST_PROPS_INT_RANGE (8, 16),
"rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"signed = (boolean) { true, false }, "
"buffer-frames = (int) [ 1, MAX ]"
)
);
......@@ -143,7 +140,8 @@ gst_afsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afsink_sink_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&afsink_sink_factory));
gst_element_class_set_details (element_class, &afsink_details);
}
......@@ -188,7 +186,7 @@ gst_afsink_init (GstAFSink *afsink)
/* GstPad *pad; this is now done in the struct */
afsink->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (afsink_sink_factory), "sink");
gst_element_get_pad_template (GST_ELEMENT (afsink), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afsink), afsink->sinkpad);
gst_pad_set_chain_function (afsink->sinkpad, gst_afsink_chain);
......@@ -284,7 +282,8 @@ static gboolean
gst_afsink_open_file (GstAFSink *sink)
{
AFfilesetup outfilesetup;
GstCaps *caps;
const GstCaps *caps;
GstStructure *structure;
int sample_format; /* audiofile's sample format, look in audiofile.h */
int byte_order = 0; /* audiofile's byte order defines */
......@@ -301,22 +300,18 @@ gst_afsink_open_file (GstAFSink *sink)
*/
/* get the audio parameters */
caps = NULL;
g_return_val_if_fail (GST_IS_PAD (sink->sinkpad), FALSE);
caps = GST_PAD_CAPS (sink->sinkpad);
if (caps == NULL)
{
/* FIXME : Please change this to a better warning method ! */
printf ("WARNING: gstafsink chain : Could not get caps of pad !\n");
}
else
{
gst_caps_get_int (caps, "channels", &sink->channels);
gst_caps_get_int (caps, "width", &sink->width);
gst_caps_get_int (caps, "rate", &sink->rate);
gst_caps_get_boolean (caps, "signed", &sink->is_signed);
gst_caps_get_int (caps, "endianness", &sink->endianness_data);
if (caps == NULL) {
g_critical ("gstafsink chain : Could not get caps of pad !\n");
} else {
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &sink->channels);
gst_structure_get_int (structure, "width", &sink->width);
gst_structure_get_int (structure, "rate", &sink->rate);
gst_structure_get_boolean (structure, "signed", &sink->is_signed);
gst_structure_get_int (structure, "endianness", &sink->endianness_data);
}
GST_DEBUG ("channels %d, width %d, rate %d, signed %s",
sink->channels, sink->width, sink->rate,
......
......@@ -51,22 +51,19 @@ enum {
/* added a src factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
GST_PAD_TEMPLATE_FACTORY (afsrc_src_factory,
static GstStaticPadTemplate afsrc_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"audiofile_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"width", GST_PROPS_INT_RANGE (8, 16),
"depth", GST_PROPS_INT_RANGE (8, 16),
"rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"signed = (boolean) { true, false }, "
"buffer-frames = (int) [ 1, MAX ]"
)
);
......@@ -142,7 +139,8 @@ gst_afsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afsrc_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&afsrc_src_factory));
gst_element_class_set_details (element_class, &afsrc_details);
}
......@@ -178,7 +176,8 @@ static void
gst_afsrc_init (GstAFSrc *afsrc)
{
/* no need for a template, caps are set based on file, right ? */
afsrc->srcpad = gst_pad_new_from_template (afsrc_src_factory (), "src");
afsrc->srcpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (afsrc), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afsrc), afsrc->srcpad);
gst_pad_set_get_function (afsrc->srcpad, gst_afsrc_get);
......@@ -342,17 +341,14 @@ gst_afsrc_open_file (GstAFSrc *src)
/* set caps on src */
/*FIXME: add all the possible formats, especially float ! */
gst_pad_try_set_caps (src->srcpad,
GST_CAPS_NEW (
"af_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */
"signed", GST_PROPS_BOOLEAN (src->is_signed),
"width", GST_PROPS_INT (src->width),
"depth", GST_PROPS_INT (src->width),
"rate", GST_PROPS_INT (src->rate),
"channels", GST_PROPS_INT (src->channels)
)
);
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, src->is_signed,
"width", G_TYPE_INT, src->width,
"depth", G_TYPE_INT, src->width,
"rate", G_TYPE_INT, src->rate,
"channels", G_TYPE_INT, src->channels,
NULL));
GST_FLAG_SET (src, GST_AFSRC_OPEN);
......
......@@ -25,8 +25,6 @@
#include "gstgsmdec.h"
static GstPadTemplate *gsmdec_src_template, *gsmdec_sink_template;
/* elementfactory information */
GstElementDetails gst_gsmdec_details = {
"GSM audio decoder",
......@@ -51,7 +49,7 @@ static void gst_gsmdec_class_init (GstGSMDec *klass);
static void gst_gsmdec_init (GstGSMDec *gsmdec);
static void gst_gsmdec_chain (GstPad *pad, GstData *_data);
static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
/*static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 }; */
......@@ -77,39 +75,43 @@ gst_gsmdec_get_type(void) {
return gsmdec_type;
}
GST_CAPS_FACTORY (gsm_caps_factory,
GST_CAPS_NEW (
"gsm_gsm",
"audio/x-gsm",
"rate", GST_PROPS_INT_RANGE (1000, 48000),
"channels", GST_PROPS_INT (1)
)
)
GST_CAPS_FACTORY (raw_caps_factory,
GST_CAPS_NEW (
"gsm_raw",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (1000, 48000),
"channels", GST_PROPS_INT (1)
static GstStaticPadTemplate gsmdec_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-gsm, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) 1"
)
);
static GstStaticPadTemplate gsmdec_src_template =
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, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) 1"
)
)
);
static void
gst_gsmdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gsmdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, gsm_caps_factory(), NULL);
gsmdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, raw_caps_factory(), NULL);
gst_element_class_add_pad_template (element_class, gsmdec_sink_template);
gst_element_class_add_pad_template (element_class, gsmdec_src_template);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gsmdec_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gsmdec_src_template));
gst_element_class_set_details (element_class, &gst_gsmdec_details);
}
......@@ -129,12 +131,14 @@ gst_gsmdec_init (GstGSMDec *gsmdec)
GST_DEBUG ("gst_gsmdec_init: initializing");
/* create the sink and src pads */
gsmdec->sinkpad = gst_pad_new_from_template (gsmdec_sink_template, "sink");
gsmdec->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gsmdec_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain);
gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_sinkconnect);
gsmdec->srcpad = gst_pad_new_from_template (gsmdec_src_template, "src");
gsmdec->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gsmdec_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
......@@ -142,29 +146,26 @@ gst_gsmdec_init (GstGSMDec *gsmdec)
}
static GstPadLinkReturn
gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps)
gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstGSMDec *gsmdec;
gint rate;
GstStructure *structure;
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;