Advertisement
herrpaco

identity_not_linked

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