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

Tim Müller t.i.m at zen.co.uk
Fri Sep 1 11:39:53 CEST 2006


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);
  }

Cheers
 -Tim






More information about the gstreamer-devel mailing list