Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gst/gst.h>
- static GstElement *common_pipeline;
- static gboolean bus_cb (GstBus * bus, GstMessage * msg, gpointer user_data)
- {
- GMainLoop *loop = user_data;
- switch (GST_MESSAGE_TYPE (msg)) {
- case GST_MESSAGE_ERROR:{
- GError *err = NULL;
- gchar *dbg;
- gst_message_parse_error (msg, &err, &dbg);
- gst_object_default_error (msg->src, err, dbg);
- g_clear_error (&err);
- g_free (dbg);
- g_main_loop_quit (loop);
- break;
- }
- default:
- break;
- }
- return TRUE;
- }
- int
- main (int argc, char **argv)
- {
- GstElement *v_src1, *v_convert1, *v_queue1, *ip_sink1;
- GstElement *ip_src, *queue, *videosink;
- gst_init(&argc, &argv);
- common_pipeline = gst_pipeline_new("main_pipeline");
- v_src1 = gst_element_factory_make("videotestsrc", "v_src1");
- v_convert1 = gst_element_factory_make("videoconvert", "v_convert1");
- v_queue1 = gst_element_factory_make("queue", "v_queue1");
- ip_sink1 = gst_element_factory_make("interpipesink", "v_source1");
- ip_src = gst_element_factory_make("interpipesrc", "v_sink");
- queue = gst_element_factory_make("queue", "v_queue");
- videosink = gst_element_factory_make("autovideosink", "videosink");
- g_object_set(v_src1,
- "is_live", TRUE,
- NULL);
- g_object_set(ip_sink1,
- "sync", FALSE,
- "async", FALSE,
- NULL);
- g_object_set(ip_src,
- "listen-to", "v_source1",
- "is-live", TRUE,
- "allow-renegotiation", TRUE,
- "stream-sync", 2,
- NULL);
- gst_bin_add_many(GST_BIN(common_pipeline),
- v_src1, v_convert1, v_queue1, ip_sink1,
- ip_src, queue, videosink,
- NULL);
- gst_element_link_many(v_src1, v_convert1, v_queue1, ip_sink1, NULL);
- gst_element_link_many(ip_src, queue, videosink, NULL);
- GMainLoop *loop = g_main_loop_new (NULL, FALSE);
- gst_element_set_state(common_pipeline, GST_STATE_READY);
- GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(common_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "common_pipeline");
- gst_element_set_state(common_pipeline, GST_STATE_PLAYING);
- GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(common_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "common_pipeline_playing");
- gst_bus_add_watch (GST_ELEMENT_BUS (common_pipeline), bus_cb, loop);
- g_main_loop_run (loop);
- gst_element_set_state (common_pipeline, GST_STATE_NULL);
- gst_object_unref (common_pipeline);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement