5 GST_PLAY_FLAG_VIS = (1 << 3) /* Enable rendering of visualizations when there is no video stream. */
8 /* Return TRUE if this is a Visualization element */
9 static gboolean filter_vis_features (GstPluginFeature *feature, gpointer data) {
10 GstElementFactory *factory;
12 if (!GST_IS_ELEMENT_FACTORY (feature))
14 factory = GST_ELEMENT_FACTORY (feature);
15 if (!g_strrstr (gst_element_factory_get_klass (factory), "Visualization"))
21 int main(int argc, char *argv[]) {
22 GstElement *pipeline, *vis_plugin;
26 GstElementFactory *selected_factory = NULL;
29 /* Initialize GStreamer */
30 gst_init (&argc, &argv);
32 /* Get a list of all visualization plugins */
33 list = gst_registry_feature_filter (gst_registry_get (), filter_vis_features, FALSE, NULL);
35 /* Print their names */
36 g_print("Available visualization plugins:\n");
37 for (walk = list; walk != NULL; walk = g_list_next (walk)) {
39 GstElementFactory *factory;
41 factory = GST_ELEMENT_FACTORY (walk->data);
42 name = gst_element_factory_get_longname (factory);
43 g_print(" %s\n", name);
45 if (selected_factory == NULL || g_str_has_prefix (name, "GOOM")) {
46 selected_factory = factory;
50 /* Don't use the factory if it's still empty */
51 /* e.g. no visualization plugins found */
52 if (!selected_factory) {
53 g_print ("No visualization plugins found!\n");
57 /* We have now selected a factory for the visualization element */
58 g_print ("Selected '%s'\n", gst_element_factory_get_longname (selected_factory));
59 vis_plugin = gst_element_factory_create (selected_factory, NULL);
63 /* Build the pipeline */
64 pipeline = gst_parse_launch ("playbin uri=http://radio.hbr1.com:19800/ambient.ogg", NULL);
66 /* Set the visualization flag */
67 g_object_get (pipeline, "flags", &flags, NULL);
68 flags |= GST_PLAY_FLAG_VIS;
69 g_object_set (pipeline, "flags", flags, NULL);
71 /* set vis plugin for playbin2 */
72 g_object_set (pipeline, "vis-plugin", vis_plugin, NULL);
75 gst_element_set_state (pipeline, GST_STATE_PLAYING);
77 /* Wait until error or EOS */
78 bus = gst_element_get_bus (pipeline);
79 msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
83 gst_message_unref (msg);
84 gst_plugin_feature_list_free (list);
85 gst_object_unref (bus);
86 gst_element_set_state (pipeline, GST_STATE_NULL);
87 gst_object_unref (pipeline);