#include #include static gboolean timeoutcall (GMainLoop *loop) { g_main_loop_quit(loop); return FALSE; } 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: { gchar *debug; GError *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("Error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return TRUE; } GstElement *m_pipeline; GstElement *m_datasource; GstElement *m_fakeVideoSink; int main (int argc, char *argv[]) { GMainLoop *loop; GstBus *bus; /* Initialisation */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* Check input arguments */ if (argc != 2) { g_printerr ("Usage: %s \n", argv[0]); return -1; } m_pipeline = gst_pipeline_new ("PIPELINE"); GstElement *subtitles = gst_element_factory_make("subtitleoverlay", "SUBIOVERLAY"); gst_bin_add(GST_BIN(m_pipeline), subtitles); m_datasource = gst_element_make_from_uri(GST_URI_SRC, argv[1], (const char*)NULL); if (!m_datasource) return false; gst_bin_add(GST_BIN(m_pipeline), m_datasource); m_fakeVideoSink = gst_element_factory_make("fakesink", NULL); gst_bin_add(GST_BIN(m_pipeline), m_fakeVideoSink); gst_element_link(m_datasource, m_fakeVideoSink); bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline)); gst_bus_add_watch (bus, bus_call, loop); g_print ("File: %s\n", argv[1]); // g_print ("Setting paused...\n"); // gst_element_set_state (m_pipeline, GST_STATE_PAUSED); // g_print ("Running...\n"); // g_timeout_add(1000, (GSourceFunc)timeoutcall, loop); // g_main_loop_run (loop); /* g_print ("Setting ready...\n"); gst_element_set_state (m_pipeline, GST_STATE_READY); g_print ("Running...\n"); g_timeout_add(1000, (GSourceFunc)timeoutcall, loop); g_main_loop_run (loop); */ g_print ("Setting paused...\n"); gst_element_set_state (m_pipeline, GST_STATE_PAUSED); g_print ("Running...\n"); g_timeout_add(5000, (GSourceFunc)timeoutcall, loop); g_main_loop_run(loop); GstState statee, pending; gst_element_get_state(m_pipeline, &statee, &pending, 1000000000); g_print("STATE state %d %d\n", statee, pending); _gst_debug_bin_to_dot_file (GST_BIN (m_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "gst-frozen-pipeline"); return 0; }