Skip to content

Instantly share code, notes, and snippets.

@pioz
Created May 6, 2011 00:14
Show Gist options
  • Select an option

  • Save pioz/958229 to your computer and use it in GitHub Desktop.

Select an option

Save pioz/958229 to your computer and use it in GitHub Desktop.
Gstreamer 'hello world' multimedia player
#include <glib.h>
#include <gst/gst.h>
// Compile with: gcc hello.c `pkg-config gstreamer-0.10 --libs --cflags`
static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg))
{
case GST_MESSAGE_EOS:
g_print ("End of stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:
g_print ("Error\n");
g_main_loop_quit (loop);
break;
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline;
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_element_factory_make ("playbin", "pioz streaming fuck yeah pipeline");
g_object_set (G_OBJECT (pipeline), "uri", "http://shoutcast.unitedradio.it:1101/", NULL);
//g_object_set (G_OBJECT (pipeline), "uri", "file:///home/pioz/Desktop/acdc.mp3", NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment