Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gst/gst.h>
- static GstPad *audiosrc_blockpad;
- static GstElement *videosrc, *videosink, *pipeline, *textoverlay, *audiosrc, *audiosink;
- 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);
- gst_bin_remove(GST_BIN(pipeline), videosink);
- /* adding the textoverlay */
- textoverlay = gst_element_factory_make("textoverlay", NULL);
- g_object_set(G_OBJECT (textoverlay), "text", "Hello World!", NULL);
- gst_bin_add_many(GST_BIN(pipeline), textoverlay, videosink, NULL);
- /* inserting the text overlay */
- gst_element_link_many(videosrc, textoverlay, videosink, NULL);
- gst_element_set_state(textoverlay, GST_STATE_PLAYING);
- gst_element_set_state(videosink, GST_STATE_PLAYING);
- //gst_debug_set_threshold_from_string ("*:5", TRUE);
- return GST_PAD_PROBE_REMOVE;
- }
- static GstPadProbeReturn pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data){
- /* remove audio */
- gst_element_set_state(audiosink, GST_STATE_NULL);
- gst_bin_remove(GST_BIN(pipeline), audiosink);
- gst_pad_add_probe (gst_element_get_static_pad(videosrc, "src"), GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_probe_videosrc_cb, user_data, NULL);
- GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL ,"usecase2-b");
- return GST_PAD_PROBE_OK;
- }
- static gboolean timeout_cb (gpointer user_data){
- GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL ,"usecase2-a");
- gst_pad_add_probe (audiosrc_blockpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_probe_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);
- videosink = gst_element_factory_make("ximagesink", NULL);
- audiosrc = gst_element_factory_make("audiotestsrc", NULL);
- audiosink = gst_element_factory_make("pulsesink", NULL);
- /* We must set provide-clock to FALSE, otherwise, ximagesink loses its clock and freezes */
- g_object_set(G_OBJECT (audiosink), "provide-clock", FALSE, NULL);
- audiosrc_blockpad = gst_element_get_static_pad(audiosrc, "src");
- pipeline = gst_pipeline_new("pipeline");
- gst_bin_add_many(GST_BIN(pipeline), audiosink, audiosrc, videosrc, videosink, NULL);
- gst_element_link_many(videosrc, videosink, NULL);
- gst_element_link_many(audiosrc, audiosink, 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