Advertisement
herrpaco

identity-linked

Nov 17th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.12 KB | None | 0 0
  1. #include <gst/gst.h>
  2.  
  3. static GstPad *videosrc_blockpad;
  4. static GstElement *videosrc, *videosink, *pipeline, *identity;
  5.  
  6. static GstPadProbeReturn pad_probe_videosrc_cb(GstPad * videosrc_pad, GstPadProbeInfo * info, gpointer user_data){
  7.    
  8.     /* unlink videotestsrc from ximagesink */
  9.     gst_element_set_state(videosink, GST_STATE_NULL);
  10.     gst_bin_remove(GST_BIN(pipeline), videosink);
  11.    
  12.     /* adding the identity */
  13.     identity = gst_element_factory_make("identity", NULL);
  14.     gst_bin_add_many(GST_BIN(pipeline), identity, videosink, NULL);
  15.    
  16.     /* inserting the text overlay */
  17.     gst_element_link_many(videosrc, identity, videosink, NULL);
  18.    
  19.     GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL ,"identity-linked");
  20.    
  21.     /* Setting new linked elements to GST_STATE_PLAYING */
  22.     gst_element_set_state(videosink, GST_STATE_PLAYING);
  23.     gst_element_set_state(identity, GST_STATE_PLAYING);
  24.    
  25.     gst_debug_set_threshold_from_string ("*:5", TRUE);
  26.    
  27.     /* This removes the blocking probe of videotestsrc:src */
  28.     return GST_PAD_PROBE_REMOVE;
  29. }
  30.  
  31. static gboolean timeout_cb (gpointer user_data){
  32.    
  33.     gst_pad_add_probe (videosrc_blockpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_probe_videosrc_cb, user_data, NULL);
  34.     return FALSE;
  35. }
  36.  
  37. int main (int argc, char **argv){
  38.     GMainLoop *loop;
  39.    
  40.     /* init GStreamer */
  41.     gst_init (&argc, &argv);
  42.     loop = g_main_loop_new (NULL, FALSE);
  43.    
  44.     videosrc = gst_element_factory_make("videotestsrc", NULL);
  45.     videosrc_blockpad = gst_element_get_static_pad(videosrc, "src");
  46.    
  47.     videosink = gst_element_factory_make("ximagesink", NULL);
  48.    
  49.     pipeline = gst_pipeline_new("pipeline");
  50.    
  51.     gst_bin_add_many(GST_BIN(pipeline), videosrc, videosink, NULL);
  52.    
  53.     gst_element_link_many(videosrc, videosink, NULL);
  54.    
  55.     gst_element_set_state(pipeline, GST_STATE_PLAYING);
  56.    
  57.     g_timeout_add_seconds (5, timeout_cb, loop);
  58.    
  59.     g_main_loop_run (loop);
  60.    
  61.     gst_element_set_state (pipeline, GST_STATE_NULL);
  62.    
  63.     gst_object_unref (pipeline);
  64.    
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement