Skip to content

Instantly share code, notes, and snippets.

@yashi
Created December 5, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashi/e029db46e16b0194bb7e to your computer and use it in GitHub Desktop.
Save yashi/e029db46e16b0194bb7e to your computer and use it in GitHub Desktop.
#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;
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);
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