[gst-devel] playbin: get sample rate and channels in current stream

Alfred E. Heggestad aeh at db.org
Fri Sep 1 12:24:23 CEST 2006


Tim Müller wrote:
> On Fri, 2006-09-01 at 11:25 +0200, Alfred E. Heggestad wrote:
> 
> Hi Alfred,
> 
>> now, what I am not able to understand is how can I get the samplerate
>> and number of channels for the current stream??? I was able to get
>> the type and caps from the "stream-info" property, but not samplerate..
>> if you can give me some hints of how to get samplerate and channels
>> I would be very grateful.
> 
> You should be able to get that from the caps with something like:
> 
>   GstStructure *s;
>   gint rate, channels;
> 
>   s = gst_caps_get_structure (caps, 0);
>   if (gst_structure_get_int (s, "rate", &rate) &&
>       gst_structure_get_int (s, "channels", &channels)) {
>     g_print ("%d channels @ %d Hz\n", channels, rate);
>   }
> 

thanks for the hint.

the gst_caps_get_structure() returns a valid pointer, however the
gst_structure_get_int() both return FALSE..

when dumping the caps I get:

		g_print (" caps: %s\n", gst_caps_to_string(caps));


  caps: audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, 
width=(int)32, depth=(int)32, rate=(int){ 8000, 11025, 12000, 16000, 
22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]



..which I guess indicates the ranges of e.g. rate/channels..
any way of getting the current value?


also, if I try to get the "width" it returns the correct value:


		if (gst_structure_get_int (s, "width", &width))
			g_print ("width: %d\n", width);

width: 32



/alfred





More information about the gstreamer-devel mailing list