summaryrefslogtreecommitdiffstats
path: root/gst/speed
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2003-12-05 10:04:56 +0000
committerDavid Schleef <ds@schleef.org>2003-12-05 10:04:56 +0000
commit9be5abd7cf58a87c9bf7568eed0137577494a92c (patch)
tree96a826f91a27394d2f01fe2fc46e69cd50e5322f /gst/speed
parentc03ed5262a96a0b0cac881ffd8a04210b0bd4fee (diff)
downloadgst-plugins-bad-9be5abd7cf58a87c9bf7568eed0137577494a92c.tar.gz
gst-plugins-bad-9be5abd7cf58a87c9bf7568eed0137577494a92c.tar.bz2
gst-plugins-bad-9be5abd7cf58a87c9bf7568eed0137577494a92c.zip
convert to new caps
Original commit message from CVS: convert to new caps
Diffstat (limited to 'gst/speed')
-rw-r--r--gst/speed/gstspeed.c104
1 files changed, 48 insertions, 56 deletions
diff --git a/gst/speed/gstspeed.c b/gst/speed/gstspeed.c
index a8894075..a8fa40f7 100644
--- a/gst/speed/gstspeed.c
+++ b/gst/speed/gstspeed.c
@@ -55,39 +55,27 @@ enum {
ARG_SPEED
};
-static GstPadTemplate*
-speed_sink_factory (void)
-{
- static GstPadTemplate *template = NULL;
-
- if (!template) {
- template = gst_pad_template_new
- ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
- GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
- gst_caps_new ("sink_float", "audio/x-raw-float",
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)),
- NULL);
- }
- return template;
-}
+static GstStaticPadTemplate gst_speed_sink_template =
+GST_STATIC_PAD_TEMPLATE (
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
+ )
+);
-static GstPadTemplate*
-speed_src_factory (void)
-{
- static GstPadTemplate *template = NULL;
-
- if (!template)
- template = gst_pad_template_new
- ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float",
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS),
- gst_caps_new ("src_int", "audio/x-raw-int",
- GST_AUDIO_INT_PAD_TEMPLATE_PROPS)),
- NULL);
-
- return template;
-}
+static GstStaticPadTemplate gst_speed_src_template =
+GST_STATIC_PAD_TEMPLATE (
+ "src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
+ )
+);
static GstBufferPool*
speed_sink_get_bufferpool (GstPad *pad)
@@ -106,7 +94,7 @@ static void speed_init (GstSpeed *filter);
static void speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static gboolean speed_parse_caps (GstSpeed *filter, GstCaps *caps);
+static gboolean speed_parse_caps (GstSpeed *filter, const GstCaps2 *caps);
static void speed_loop (GstElement *element);
@@ -114,7 +102,7 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
static GstPadLinkReturn
-speed_link (GstPad *pad, GstCaps *caps)
+speed_link (GstPad *pad, const GstCaps2 *caps)
{
GstSpeed *filter;
GstPad *otherpad;
@@ -124,41 +112,41 @@ speed_link (GstPad *pad, GstCaps *caps)
g_return_val_if_fail (GST_IS_SPEED (filter), GST_PAD_LINK_REFUSED);
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
- if (GST_CAPS_IS_FIXED (caps)) {
- if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED;
+ if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED;
- return gst_pad_try_set_caps(otherpad, caps);
- }
-
- return GST_PAD_LINK_DELAYED;
+ return gst_pad_try_set_caps(otherpad, caps);
}
static gboolean
-speed_parse_caps (GstSpeed *filter, GstCaps *caps)
+speed_parse_caps (GstSpeed *filter, const GstCaps2 *caps)
{
const gchar *mimetype;
+ GstStructure *structure;
+ gboolean ret;
g_return_val_if_fail(filter != NULL, FALSE);
g_return_val_if_fail(caps != NULL, FALSE);
- gst_caps_get_int (caps, "rate", &filter->rate);
- gst_caps_get_int (caps, "channels", &filter->channels);
- gst_caps_get_int (caps, "width", &filter->width);
- gst_caps_get_int (caps, "endianness", &filter->endianness);
- gst_caps_get_int (caps, "buffer-frames", &filter->buffer_frames);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+
+ ret = gst_structure_get_int (structure, "rate", &filter->rate);
+ ret &= gst_structure_get_int (structure, "channels", &filter->channels);
+ ret &= gst_structure_get_int (structure, "width", &filter->width);
+ ret &= gst_structure_get_int (structure, "endianness", &filter->endianness);
+ ret &= gst_structure_get_int (structure, "buffer-frames", &filter->buffer_frames);
- mimetype = gst_caps_get_mime (caps);
+ mimetype = gst_structure_get_name (structure);
- if (! strncmp(mimetype, "audio/x-raw-int", 15)) {
+ if (strcmp(mimetype, "audio/x-raw-int") == 0) {
filter->format = GST_SPEED_FORMAT_INT;
- gst_caps_get_int (caps, "depth", &filter->depth);
- gst_caps_get_boolean (caps, "signed", &filter->is_signed);
- } else if (! strncmp(mimetype, "audio/x-raw-float", 17)) {
+ ret &= gst_structure_get_int (structure, "depth", &filter->depth);
+ ret &= gst_structure_get_boolean (structure, "signed", &filter->is_signed);
+ } else if (strcmp(mimetype, "audio/x-raw-float") == 0) {
filter->format = GST_SPEED_FORMAT_FLOAT;
} else {
return FALSE;
}
- return TRUE;
+ return ret;
}
@@ -190,8 +178,10 @@ speed_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &speed_details);
- gst_element_class_add_pad_template (element_class, speed_src_factory ());
- gst_element_class_add_pad_template (element_class, speed_sink_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_speed_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_speed_sink_template));
}
static void
speed_class_init (GstSpeedClass *klass)
@@ -211,12 +201,14 @@ speed_class_init (GstSpeedClass *klass)
static void
speed_init (GstSpeed *filter)
{
- filter->sinkpad = gst_pad_new_from_template(speed_sink_factory (), "sink");
+ filter->sinkpad = gst_pad_new_from_template(
+ gst_static_pad_template_get (&gst_speed_sink_template), "sink");
gst_pad_set_link_function(filter->sinkpad, speed_link);
gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
gst_pad_set_bufferpool_function (filter->sinkpad, speed_sink_get_bufferpool);
- filter->srcpad = gst_pad_new_from_template(speed_src_factory (), "src");
+ filter->srcpad = gst_pad_new_from_template(
+ gst_static_pad_template_get (&gst_speed_src_template), "src");
gst_pad_set_link_function(filter->srcpad, speed_link);
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);