Created
December 5, 2015 14:31
-
-
Save yashi/252e3fff2c5af3521d99 to your computer and use it in GitHub Desktop.
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 <gst/gst.h> | |
gboolean on_message(GstBus *bus, GstMessage *message, gpointer p) | |
{ | |
GMainLoop *mainloop = p; | |
(void)bus; | |
if ((GST_MESSAGE_TYPE(message) & GST_MESSAGE_EOS)) | |
g_main_loop_quit(mainloop); | |
return TRUE; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
GMainLoop *mainloop; | |
GstElement *pipeline; | |
GError *error = NULL; | |
GstBus *bus; | |
GstIterator *itr; | |
GstElement *elem; | |
GValue val = G_VALUE_INIT; | |
gboolean done = FALSE; | |
gst_init(&argc, &argv); | |
mainloop = g_main_loop_new(NULL, FALSE); | |
pipeline = gst_parse_launch("filesrc location=a.txt ! fdsink", &error); | |
bus = gst_element_get_bus(pipeline); | |
gst_bus_add_watch(bus, on_message, mainloop); | |
itr = gst_bin_iterate_elements(GST_BIN(pipeline)); | |
while (!done) { | |
switch (gst_iterator_next(itr, &val)) { | |
case GST_ITERATOR_OK: | |
elem = g_value_get_object(&val); | |
g_print("name: %s\n", gst_element_get_name(elem)); | |
g_value_unset(&val); | |
break; | |
default: | |
done = TRUE; | |
break; | |
} | |
} | |
gst_element_set_state(pipeline, GST_STATE_PLAYING); | |
g_main_loop_run(mainloop); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment