Created
December 5, 2015 14:09
-
-
Save yashi/926c3999b2c9cb005741 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; | |
GstElement *src; | |
gst_init(&argc, &argv); | |
mainloop = g_main_loop_new(NULL, FALSE); | |
pipeline = gst_parse_launch("filesrc name=mysrc location=a.txt ! fdsink", &error); | |
bus = gst_element_get_bus(pipeline); | |
gst_bus_add_watch(bus, on_message, mainloop); | |
src = gst_bin_get_by_name(GST_BIN(pipeline), "mysrc"); | |
if (src) { | |
g_print("name: %s\n", gst_element_get_name(src)); | |
g_object_unref(src); | |
} | |
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