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

Tim Müller t.i.m at zen.co.uk
Fri Sep 1 12:42:12 CEST 2006


On Fri, 2006-09-01 at 12:24 +0200, Alfred E. Heggestad wrote:

> the gst_caps_get_structure() returns a valid pointer, however the
> gst_structure_get_int() both return FALSE..
> 
> when dumping the caps I get:
>
>   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?

Those are the template caps, which is what you get when the real caps
haven't been set yet. Caps negotiation will take place when data flow
happens, so you should check again then. The easiest way is to wait
until the pipeline has reached PAUSED state and only then check the
stream-info.

Alternatively, you can extract this information at the sink when the
first buffer arrives (it should have the caps set on the buffer, check
GST_BUFFER_CAPS(), and fakesink's sink pad should also have caps set on
it then).


> 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

That's because the "width" field is fixed already, there's only one
possibility.

Hope this helps.

 Cheers
  -Tim






More information about the gstreamer-devel mailing list