rendered paste body/*
* gcc -Wall -o probe probe.c `pkg-config --cflags --libs gstreamer-0.10`
*
*/
#include <gst/gst.h>
int
main (int argc, char **argv)
{
const GValue *val;
GstElement *element;
GstCaps *caps;
GstPad *pad;
gst_init (&argc, &argv);
element = gst_element_factory_make ("alsasrc", "alsasrc");
/* must set proper device to get precise caps */
g_object_set (element, "device", "hw:0", NULL);
/* open device (so caps are probed) */
gst_element_set_state (element, GST_STATE_READY);
pad = gst_element_get_pad (element, "src");
caps = gst_pad_get_caps (pad);
gst_object_unref (pad);
val = gst_structure_get_value (gst_caps_get_structure (caps, 0), "rate");
g_assert (val != NULL);
if (G_VALUE_HOLDS_INT (val)) {
g_print ("Supported sample rate = %d\n", g_value_get_int (val));
} else if (GST_VALUE_HOLDS_INT_RANGE (val)) {
g_print ("Supported sample rate = %d - %d\n",
gst_value_get_int_range_min (val),
gst_value_get_int_range_max (val));
} else if (GST_VALUE_HOLDS_LIST (val)) {
const GValue *listval;
guint i, num;
num = gst_value_list_get_size (val);
for (i = 0; i < num; ++i) {
listval = gst_value_list_get_value (val, i);
g_print ("supported sample rate %02u/%02u = %d\n",
i, num, g_value_get_int (listval));
}
}
/* and get rid */
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (element);
return 0;
}