Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gst/gst.h>
- static GstPad *videosrc_blockpad;
- static GstElement *videosrc, *videosink, *pipeline, *identity;
- static GstPadProbeReturn pad_probe_videosrc_cb(GstPad * videosrc_pad, GstPadProbeInfo * info, gpointer user_data){
- /* unlink videotestsrc from ximagesink */
- gst_element_set_state(videosink, GST_STATE_NULL);
- /* adding the identity */
- identity = gst_element_factory_make("identity", NULL);
- gst_bin_add(GST_BIN(pipeline), identity);
- /* inserting the text overlay */
- gst_element_link_many(videosrc, identity, videosink, NULL);
- GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL ,"identity");
- /* Setting new linked elements to GST_STATE_PLAYING */
- gst_element_set_state(videosink, GST_STATE_PLAYING);
- gst_element_set_state(identity, GST_STATE_PLAYING);
- gst_debug_set_threshold_from_string ("*:5", TRUE);
- /* This removes the blocking probe of videotestsrc:src */
- return GST_PAD_PROBE_REMOVE;
- }
- static gboolean timeout_cb (gpointer user_data){
- gst_pad_add_probe (videosrc_blockpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_probe_videosrc_cb, user_data, NULL);
- return FALSE;
- }
- int main (int argc, char **argv){
- GMainLoop *loop;
- /* init GStreamer */
- gst_init (&argc, &argv);
- loop = g_main_loop_new (NULL, FALSE);
- videosrc = gst_element_factory_make("videotestsrc", NULL);
- videosrc_blockpad = gst_element_get_static_pad(videosrc, "src");
- videosink = gst_element_factory_make("ximagesink", NULL);
- pipeline = gst_pipeline_new("pipeline");
- gst_bin_add_many(GST_BIN(pipeline), videosrc, videosink, NULL);
- gst_element_link_many(videosrc, videosink, NULL);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
- g_timeout_add_seconds (5, timeout_cb, loop);
- g_main_loop_run (loop);
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement