[gst-devel] SOLVED - Adding new tee src%d to a running pipeline...

Nathanael D. Noblet nathanael at gnat.ca
Wed Jul 28 19:06:21 CEST 2010


So because I couldn't find the answer to these questions with google, 
I'm answering how I got it working for those that come afterwards...

================================================================
// Attaching a new branch to a running pipe...
================================================================
bin = gst_bin_new ("recording_bin");

filesink  = gst_element_factory_make ("filesink",  "filesink");
filequeue = gst_element_factory_make ("queue2",    "filequeue");

// Build the new branch bin...
g_object_set (G_OBJECT (filesink), "location", current_dir, NULL);

gst_bin_add_many(GST_BIN(bin),filequeue,filesink,NULL);
gst_element_link(filequeue,filesink);

sinkpad = gst_element_get_static_pad(filequeue,"sink");
gst_element_add_pad(bin,gst_ghost_pad_new("sink",sinkpad));
gst_object_unref(GST_OBJECT(sinkpad));

// set the new bin to PAUSE to preroll?
gst_element_set_state(bin, GST_STATE_PAUSED);

// get regular pipeline pre-existing tee element
tee = gst_bin_get_by_name (GST_BIN(pipeline),"tee");

sinkpad         = gst_element_get_pad(bin,"sink");
srcpad          = gst_element_get_request_pad(tee,"src2");

gst_pad_set_blocked(srcpad,TRUE);

// the main pipeline becomes paused (because the new one is paused)
gst_bin_add(GST_BIN(pipeline), bin);
gst_pad_link(srcpad,sinkpad);
gst_pad_set_blocked(srcpad,FALSE);

// set to PLAYING
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);

================================================================
// To detach ...
================================================================
bin     = gst_bin_get_by_name(GST_BIN(pipeline), "recording_bin");
tee     = gst_bin_get_by_name(GST_BIN(pipeline), "tee");
srcpad  = gst_element_get_pad(tee,"src2");
sinkpad = gst_element_get_pad(bin,"sink");

gst_pad_set_blocked(srcpad,TRUE);
gst_pad_unlink(srcpad,sinkpad);
gst_pad_set_blocked(srcpad,FALSE);
gst_element_remove_pad(tee,srcpad);
gst_bin_remove(GST_BIN(pipeline),bin);




More information about the gstreamer-devel mailing list