How to gst_element_release_request_pad?

killerrats koreysjunkmail at gmail.com
Mon Oct 24 23:49:14 UTC 2016


I Have Unlinked the pad but for some reason it says I can't find the pad that
I assigned to each tee I on the pipeline? I am successfully blocking the
vtee and atee. If you need the full file look  testingPurpose.h
<http://www.planetkorey.com/tmp/testingPurpose.h>  


///// -------------- PIPELINE ------------- ///////////// 
                 - - - - q1 - - - rtph264depay - - - - h264parse - - - -
vtee - - \ 
               /                                                                                              
q3- - - - \   avimux - - appsink 
source --                                                                                                      
q4 - -/ 
               \ - - - - q2 - - - rtpmp4gdepay - - - aacparse - - - faad - -
- atee - -/ 


/ ------------------------ METHOD ---------------------- / 
void SetupRecPipeline()
{
	_videoData.Rec = gst_bin_new("rec");

	_videoData.mux = gst_element_factory_make("avimux","avimux");	
	_videoData.q3 = gst_element_factory_make("queue","video-queueRec");
	_videoData.q4 = gst_element_factory_make("queue","audio-queueRec");
	_videoData.appsink = gst_element_factory_make ("appsink", "appsink");
	g_object_set(GST_OBJECT(_videoData.appsink),"emit-signals",TRUE,NULL);

	Console::WriteLine("Adding Elements to Mux Container");

gst_bin_add_many(GST_BIN(_videoData.Rec),_videoData.q3,_videoData.q4,_videoData.mux,_videoData.appsink,NULL);
}
/ ------------------------ METHOD ---------------------- / 
gboolean LinkRecPipeline()
{
	GstPad* OverallSrcpad,* OverallSinkpad;
	// Request source pads from tee and sink pads from bin
	_videoData.SourcePadVideoQ3ToMux =
gst_element_get_static_pad(_videoData.q3,"src");
	_videoData.SinkPadVideoQ3ToMux =
gst_element_get_request_pad(_videoData.mux,"video_00");

gst_pad_link(_videoData.SourcePadVideoQ3ToMux,_videoData.SinkPadVideoQ3ToMux);

	_videoData.SourcePadAudioQ4ToMux =
gst_element_get_static_pad(_videoData.q4,"src");
	_videoData.SinkPadAudioQ4ToMux =
gst_element_get_request_pad(_videoData.mux,"audio_00");

gst_pad_link(_videoData.SourcePadAudioQ4ToMux,_videoData.SinkPadAudioQ4ToMux);
		
	gst_bin_add(GST_BIN(_videoData.srcPipeline),_videoData.Rec);
		
	std::cout << std::endl << "linked record pipeline" << std::endl;
	// Create ghost pads on the bin and link to queues
	GstPad* sinkpad;
	sinkpad = gst_element_get_static_pad(_videoData.q3, "sink");
	gst_element_add_pad(_videoData.Rec, gst_ghost_pad_new("videosink",
sinkpad));
	gst_object_unref(GST_OBJECT(sinkpad));
						
	sinkpad = gst_element_get_static_pad(_videoData.q4, "sink");
	gst_element_add_pad(_videoData.Rec, gst_ghost_pad_new("audiosink",
sinkpad));
	gst_object_unref(GST_OBJECT(sinkpad));
		
	gst_element_set_state(_videoData.Rec, GST_STATE_PAUSED);
		
	std::cout << std::endl << "rec pipeline to pause state" << std::endl;
	// set the new bin to PAUSE to preroll
		
	// Request source pads from tee and sink pads from bin
	
	_videoData.vtee = gst_bin_get_by_name (GST_BIN(_videoData.srcPipeline),
"videotee");
	_videoData.SourcePadVideoVTeeToQ3 =
gst_element_get_request_pad(_videoData.vtee, "src_0");
	_videoData.SinkPadVideoVTeeQ3 = gst_element_get_static_pad(_videoData.Rec,
"videosink");
	gst_pad_link(_videoData.SourcePadVideoVTeeToQ3,
_videoData.SinkPadVideoVTeeQ3);
	
	_videoData.atee = gst_bin_get_by_name (GST_BIN(_videoData.srcPipeline),
"audiotee");
	_videoData.SourcePadAudioATeeToQ4 =
gst_element_get_request_pad(_videoData.atee, "src_0");
	_videoData.SinkPadAudioATeeToQ4 =
gst_element_get_static_pad(_videoData.Rec, "audiosink");
	gst_pad_link(_videoData.SourcePadAudioATeeToQ4,
_videoData.SinkPadAudioATeeToQ4);
				
	if(!elementLinking(_videoData.mux,_videoData.appsink,"\nFailed Link mux to
appsink\n"))
		return false;

	return TRUE;
}
/ ------------------------ METHOD ---------------------- / 
static GstPadProbeReturn
event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
	GMainLoop *loop = (GMainLoop *)user_data;
	GstElement *next;
	GstElement* temp;
	GstPad* srcpad,*sinkpad;

	if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_DATA (info)) != GST_EVENT_EOS)
	return GST_PAD_PROBE_PASS;

	gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

	std::cout << std::endl << "Removed Blocked Probe in mux"<< std::endl;
	
	//g_print ("Switching from '%s' to '%s'..\n", GST_OBJECT_NAME (cur_effect),
		//GST_OBJECT_NAME (next));

	g_print("\nSwitching\n");
	
	if(gst_pad_unlink(_videoData.SourcePadVideoVTeeToQ3,
_videoData.SinkPadVideoVTeeQ3))
		Console::WriteLine("Unlinked VTee q3");
	if(gst_pad_unlink(_videoData.SourcePadAudioATeeToQ4,
_videoData.SinkPadAudioATeeToQ4))
		Console::WriteLine("Unlinked ATee q4");

if(gst_pad_unlink(_videoData.SourcePadVideoQ3ToMux,_videoData.SinkPadVideoQ3ToMux))
		Console::WriteLine("Unlinked q3 to mux");

if(gst_pad_unlink(_videoData.SourcePadAudioQ4ToMux,_videoData.SinkPadAudioQ4ToMux))
		Console::WriteLine("Unlinked q4 mux");
	if(gst_element_unlinkBool(_videoData.mux,_videoData.appsink))
		Console::WriteLine("Unlinked mux to appsink");
	

gst_element_release_request_pad(_videoData.vtee,_videoData.SourcePadVideoVTeeToQ3);

gst_element_release_request_pad(_videoData.atee,_videoData.SourcePadAudioATeeToQ4);

gst_element_release_request_pad(_videoData.q3,_videoData.SourcePadVideoQ3ToMux);

gst_element_release_request_pad(_videoData.q4,_videoData.SourcePadAudioQ4ToMux);

	gst_pad_set_active(_videoData.SourcePadVideoVTeeToQ3,FALSE);
	gst_pad_set_active(_videoData.SinkPadVideoVTeeQ3,FALSE);
	gst_pad_set_active(_videoData.SourcePadAudioATeeToQ4,FALSE);
	gst_pad_set_active(_videoData.SinkPadAudioATeeToQ4,FALSE);

	gst_element_remove_pad(_videoData.vtee,_videoData.SourcePadVideoVTeeToQ3);
	gst_element_remove_pad(_videoData.atee,_videoData.SourcePadAudioATeeToQ4);	
	gst_element_remove_pad(_videoData.q3,_videoData.SourcePadVideoQ3ToMux);	
	gst_element_remove_pad(_videoData.q4,_videoData.SourcePadAudioQ4ToMux);
	
	g_print("\nsetting state NULL\n");
	gst_element_set_state (_videoData.mux, GST_STATE_NULL);
	gst_element_set_state (_videoData.q3, GST_STATE_NULL);
	gst_element_set_state (_videoData.q4, GST_STATE_NULL);
	gst_element_set_state (_videoData.appsink, GST_STATE_NULL);
	gst_element_set_state (_videoData.Rec, GST_STATE_NULL);

	gst_bin_remove (GST_BIN (_videoData.Rec), _videoData.q3);
	gst_bin_remove (GST_BIN (_videoData.Rec), _videoData.q4);
	gst_bin_remove (GST_BIN (_videoData.Rec), _videoData.mux);
	gst_bin_remove (GST_BIN (_videoData.Rec), _videoData.appsink);
	gst_bin_remove (GST_BIN (_videoData.srcPipeline), _videoData.Rec);

	SetupRecPipeline();
	LinkRecPipeline();

	gst_pad_set_active(_videoData.SourcePadVideoVTeeToQ3,TRUE);
	gst_pad_set_active(_videoData.SinkPadVideoVTeeQ3,TRUE);
	gst_pad_set_active(_videoData.SourcePadAudioATeeToQ4,TRUE);
	gst_pad_set_active(_videoData.SinkPadAudioATeeToQ4,TRUE);

	CheckStateChange(gst_element_set_state (_videoData.Rec,
GST_STATE_PLAYING));
	
	return GST_PAD_PROBE_OK;
}
/ ------------------------ METHOD ---------------------- / 
static GstPadProbeReturn
pad_probe_cb_block (GstPad * pad, GstPadProbeInfo * info, gpointer
user_data)
{
	GstPad *srcpad;

	GST_DEBUG_OBJECT (pad, "pad is blocked now");
	g_print("\nBlocked Now\n");
	/* remove the probe first */
	//gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));
	
	send_eos_element = _videoData.mux;
	
	// install new probe for EOS 
	srcpad = gst_element_get_static_pad(_videoData.appsink, "sink");
	muxID = gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
event_probe_cb, user_data, NULL);
	gst_object_unref(srcpad);
	/* push EOS into the element, the probe will be fired when the
	* EOS leaves the effect and it has thus drained all of its data */
	//sinkpad = gst_element_get_static_pad (send_eos_element, "sink");
	//gst_pad_send_event (_videoData.SinkPadVideoVTeeQ3, gst_event_new_eos ());
	//gst_object_unref (_videoData.SinkPadVideoVTeeQ3);
	//g_print("\nsending eos \n");
	gst_element_send_event(_videoData.Rec,gst_event_new_eos());

	return GST_PAD_PROBE_OK;
}
/ ------------------------ METHOD ---------------------- / 
static GstPadProbeReturn
pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
	GstPad *srcpad;

	GST_DEBUG_OBJECT (pad, "pad is blocked now");
	g_print("\nBlocked Now\n");
	/* remove the probe first */
	//gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));	
	
	std::cout << std::endl << " Blocking Video" << std::endl;
	vID = gst_pad_add_probe (BlockVideoPad,
GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
      pad_probe_cb_block, user_data, NULL);
	//gst_pad_remove_probe(BlockVideoPad,vID);
		
	return GST_PAD_PROBE_OK;
}



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-gst-element-release-request-pad-tp4680208.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list