- commit
- 8b5fc7fc258daead8e93481c4e4946b785fcafd5
- parent
- e632dd73e5d285da613c3b606484c60bf3c1f04d
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2010-11-01 23:43
file structure
Diffstat
| A | expermients/gs.c | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | xiRetimer | 0 |
2 files changed, 58 insertions, 0 deletions
diff --git a/expermients/gs.c b/expermients/gs.c
@@ -0,0 +1,58 @@
-1 1 #include <gst/gst.h>
-1 2 #include <stdbool.h>
-1 3
-1 4 static GMainLoop *loop;
-1 5
-1 6 static gboolean bus_call(GstBus *bus, GstMessage *msg, void *user_data)
-1 7 {
-1 8 switch (GST_MESSAGE_TYPE(msg)) {
-1 9 case GST_MESSAGE_EOS: {
-1 10 g_message("End-of-stream");
-1 11 g_main_loop_quit(loop);
-1 12 break;
-1 13 }
-1 14 case GST_MESSAGE_ERROR: {
-1 15 GError *err;
-1 16 gst_message_parse_error(msg, &err, NULL);
-1 17 g_error("%s", err->message);
-1 18 g_error_free(err);
-1 19
-1 20 g_main_loop_quit(loop);
-1 21 break;
-1 22 }
-1 23 default:
-1 24 break;
-1 25 }
-1 26
-1 27 return true;
-1 28 }
-1 29
-1 30 static void play_uri(const char *uri)
-1 31 {
-1 32 GstElement *pipeline;
-1 33 GstBus *bus;
-1 34
-1 35 loop = g_main_loop_new(NULL, FALSE);
-1 36 pipeline = gst_element_factory_make("playbin", "player");
-1 37
-1 38 if (uri)
-1 39 g_object_set(G_OBJECT(pipeline), "uri", uri, NULL);
-1 40
-1 41 bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-1 42 gst_bus_add_watch(bus, bus_call, NULL);
-1 43 gst_object_unref(bus);
-1 44
-1 45 gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
-1 46
-1 47 g_main_loop_run(loop);
-1 48
-1 49 gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
-1 50 gst_object_unref(GST_OBJECT(pipeline));
-1 51 }
-1 52
-1 53 int main(int argc, char *argv[])
-1 54 {
-1 55 gst_init(&argc, &argv);
-1 56 play_uri(argv[1]);
-1 57 return 0;
-1 58 }