From ad83c4a0d55e0820e3504b9d2bbb7503ff61db1c Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 9 Mar 2004 21:29:56 +0000 Subject: [PATCH] ext/alsa/gstalsa.c: Add fixate function. (bug #135719) Original commit message from CVS: * ext/alsa/gstalsa.c: (gst_alsa_request_new_pad), (gst_alsa_fixate): Add fixate function. (bug #135719) * ext/alsa/gstalsa.h: * ext/alsa/gstalsasink.c: (gst_alsa_sink_init): --- ChangeLog | 7 +++++++ ext/alsa/gstalsa.c | 28 ++++++++++++++++++++++++++++ ext/alsa/gstalsa.h | 2 ++ ext/alsa/gstalsasink.c | 1 + 4 files changed, 38 insertions(+) diff --git a/ChangeLog b/ChangeLog index 147d7b0..dd12ad8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-03-09 David Schleef + + * ext/alsa/gstalsa.c: (gst_alsa_request_new_pad), + (gst_alsa_fixate): Add fixate function. (bug #135719) + * ext/alsa/gstalsa.h: + * ext/alsa/gstalsasink.c: (gst_alsa_sink_init): + 2004-03-09 Benjamin Otte * ext/mikmod/gstmikmod.c: (gst_mikmod_init), (gst_mikmod_loop), diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index bf99c37..6f4facb 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -332,6 +332,7 @@ found_track: gst_pad_set_link_function (this->pad[track], gst_alsa_link); gst_pad_set_getcaps_function (this->pad[track], gst_alsa_get_caps); + gst_pad_set_fixate_function (this->pad[track], gst_alsa_fixate); gst_element_add_pad (GST_ELEMENT (this), this->pad[track]); @@ -612,6 +613,33 @@ gst_alsa_get_caps (GstPad *pad) } } +GstCaps * +gst_alsa_fixate (GstPad *pad, const GstCaps *caps) +{ + GstCaps *newcaps; + GstStructure *structure; + + newcaps = gst_caps_new_full (gst_structure_copy(gst_caps_get_structure (caps, 0)), NULL); + structure = gst_caps_get_structure (newcaps, 0); + + if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) { + return newcaps; + } + if (gst_caps_structure_fixate_field_nearest_int (structure, "depth", 16)) { + return newcaps; + } + if (gst_caps_structure_fixate_field_nearest_int (structure, "width", 16)) { + return newcaps; + } + if (gst_caps_structure_fixate_field_nearest_int (structure, "channels", 2)) { + return newcaps; + } + + gst_caps_free (newcaps); + + return NULL; +} + /* Negotiates the caps */ GstPadLinkReturn gst_alsa_link (GstPad *pad, const GstCaps *caps) diff --git a/ext/alsa/gstalsa.h b/ext/alsa/gstalsa.h index d610732..496c401 100644 --- a/ext/alsa/gstalsa.h +++ b/ext/alsa/gstalsa.h @@ -175,6 +175,8 @@ void gst_alsa_set_eos (GstAlsa * this); GstPadLinkReturn gst_alsa_link (GstPad * pad, const GstCaps * caps); GstCaps * gst_alsa_get_caps (GstPad * pad); +GstCaps * gst_alsa_fixate (GstPad * pad, + const GstCaps * caps); GstCaps * gst_alsa_caps (snd_pcm_format_t format, gint rate, gint channels); diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index d454167..254c708 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -145,6 +145,7 @@ gst_alsa_sink_init (GstAlsaSink *sink) this->pad[0] = gst_pad_new_from_template (gst_alsa_sink_pad_factory (), "sink"); gst_pad_set_link_function (this->pad[0], gst_alsa_link); gst_pad_set_getcaps_function (this->pad[0], gst_alsa_get_caps); + gst_pad_set_fixate_function (this->pad[0], gst_alsa_fixate); gst_element_add_pad (GST_ELEMENT (this), this->pad[0]); this->clock = gst_alsa_clock_new ("alsasinkclock", gst_alsa_sink_get_time, this); -- 2.7.4