Last active
August 8, 2019 12:33
-
-
Save hnwfs/99cff330994dc753d61814e40bf7e757 to your computer and use it in GitHub Desktop.
Szentkorona online radio player v 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <glib.h> | |
#include <gst/gst.h> | |
// compile: | |
// | |
// gcc main.c -o netradio_01 `pkg-config gstreamer-1.0 --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", NULL); | |
g_object_set(G_OBJECT(pipeline), "uri", "http://radio.szentkoronaradio.com:8048", 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