diff options
author | David Schleef <ds@schleef.org> | 2003-12-09 09:27:44 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2003-12-09 09:27:44 +0000 |
commit | dc48c15d6cba08cfbd483a32ed5bafbc713bd8ae (patch) | |
tree | a2dff914fdc56bd883c29b813690217fb85ddf85 /gst/passthrough/gstpassthrough.c | |
parent | 6e632b821c61ff7e757a5ab8b2c34786b7408daa (diff) | |
download | gst-plugins-bad-dc48c15d6cba08cfbd483a32ed5bafbc713bd8ae.tar.gz gst-plugins-bad-dc48c15d6cba08cfbd483a32ed5bafbc713bd8ae.tar.bz2 gst-plugins-bad-dc48c15d6cba08cfbd483a32ed5bafbc713bd8ae.zip |
Convert to new caps
Original commit message from CVS:
Convert to new caps
Diffstat (limited to 'gst/passthrough/gstpassthrough.c')
-rw-r--r-- | gst/passthrough/gstpassthrough.c | 90 |
1 files changed, 41 insertions, 49 deletions
diff --git a/gst/passthrough/gstpassthrough.c b/gst/passthrough/gstpassthrough.c index 9942a758..4f0b1a1d 100644 --- a/gst/passthrough/gstpassthrough.c +++ b/gst/passthrough/gstpassthrough.c @@ -50,39 +50,27 @@ enum { ARG_SILENT }; -static GstPadTemplate* -passthrough_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 GstPadTemplate* -passthrough_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-float", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS)), - NULL); - - return template; -} +static GstStaticPadTemplate passthrough_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 GstStaticPadTemplate passthrough_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 void passthrough_class_init (GstPassthroughClass *klass); static void passthrough_base_init (GstPassthroughClass *klass); @@ -91,7 +79,7 @@ static void passthrough_init (GstPassthrough *filter); static void passthrough_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void passthrough_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static GstPadLinkReturn passthrough_connect_sink (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn passthrough_connect_sink (GstPad *pad, const GstCaps2 *caps); static void passthrough_chain (GstPad *pad, GstData *_data); static void inline passthrough_fast_float_chain (gfloat* data, guint numsamples); @@ -111,10 +99,11 @@ passthrough_get_bufferpool (GstPad *pad) } static GstPadLinkReturn -passthrough_connect_sink (GstPad *pad, GstCaps *caps) +passthrough_connect_sink (GstPad *pad, const GstCaps2 *caps) { const gchar *mimetype; GstPassthrough *filter; + GstStructure *structure; g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED); g_return_val_if_fail (caps != NULL, GST_PAD_LINK_DELAYED); @@ -123,18 +112,19 @@ passthrough_connect_sink (GstPad *pad, GstCaps *caps) g_return_val_if_fail (filter != NULL, GST_PAD_LINK_REFUSED); g_return_val_if_fail (GST_IS_PASSTHROUGH (filter), GST_PAD_LINK_REFUSED); - mimetype = gst_caps_get_mime(caps); + structure = gst_caps2_get_nth_cap (caps, 0); - 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); + mimetype = gst_structure_get_name (structure); + gst_structure_get_int (structure, "rate", &filter->rate); + gst_structure_get_int (structure, "channels", &filter->channels); + gst_structure_get_int (structure, "width", &filter->width); + gst_structure_get_int (structure, "endianness", &filter->endianness); if (strcmp (mimetype, "audio/x-raw-int") == 0) { filter->format = GST_PASSTHROUGH_FORMAT_INT; - gst_caps_get_int (caps, "depth", &filter->depth); - gst_caps_get_boolean (caps, "signed", &filter->is_signed); + gst_structure_get_int (structure, "depth", &filter->depth); + gst_structure_get_boolean (structure, "signed", &filter->is_signed); if (! filter->silent) { g_print ("Passthrough : channels %d, rate %d\n", filter->channels, filter->rate); @@ -150,9 +140,7 @@ passthrough_connect_sink (GstPad *pad, GstCaps *caps) } } - if (GST_CAPS_IS_FIXED (caps)) - return gst_pad_try_set_caps (filter->srcpad, caps); - return GST_PAD_LINK_DELAYED; + return gst_pad_try_set_caps (filter->srcpad, caps); } GType @@ -182,8 +170,10 @@ passthrough_base_init (GstPassthroughClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_pad_template (element_class, passthrough_src_factory ()); - gst_element_class_add_pad_template (element_class, passthrough_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&passthrough_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&passthrough_sink_template)); gst_element_class_set_details (element_class, &passthrough_details); } @@ -209,9 +199,11 @@ passthrough_class_init (GstPassthroughClass *klass) static void passthrough_init (GstPassthrough *filter) { - filter->srcpad = gst_pad_new_from_template (passthrough_src_factory (),"src"); + filter->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&passthrough_src_template), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); - filter->sinkpad = gst_pad_new_from_template (passthrough_sink_factory (),"sink"); + filter->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&passthrough_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_pad_set_link_function (filter->sinkpad, passthrough_connect_sink); |