Tee pipeline stall on pause

Forzaferrarileo leonardo.ferroro at gmail.com
Fri Jan 9 08:46:54 PST 2015


mmm , i don't know why but gist broke the code. 

that's the right code ( the lines mentioned by you were a problem of gist )

#include <cstdio>
#include <gst/gst.h>
#include <unistd.h>

GstElement *bin, // the containing all the elements
	*pipeline,    
	*src,  
	*tee,
	*q1,*q2,
	*filesink,
	*sink,
	*rtph264,
	*mp4mux,
	*encoder,
	*h264parse;

GstBus *bus; //the bus element te transport messages from/to the pipeline


int main (int argc, char** argv) {

	gst_init (NULL, NULL);


	GstMessage *msg;
	GstCaps *caps;
	GstPadTemplate *tee_src_pad_template;
	GstPad *tee_q1_pad, *tee_q2_pad;
	GstPad *q1_pad, *q2_pad ;


 	pipeline = gst_pipeline_new ("video_pipeline");

 	/* create the bus for the pipeline */
 	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));

	bin = gst_bin_new ("record bin");
 
	//initializing elements
	src = gst_element_factory_make ("videotestsrc", "src");
	sink = gst_element_factory_make ("autovideosink", "udp sink");
	filesink = gst_element_factory_make ("filesink", "filesink");
	tee = gst_element_factory_make ("tee", "tee");
	q1 = gst_element_factory_make ("queue", "queueone");
	q2 = gst_element_factory_make ("queue", "queuetwo");
	rtph264 = gst_element_factory_make("videoconvert","rtph264pay");
	encoder = gst_element_factory_make("x264enc","encoder");
	mp4mux = gst_element_factory_make("mp4mux","mux");
	h264parse = gst_element_factory_make("h264parse","parse");

	//g_object_set(src, "bitrate", 6000000, NULL);
	g_object_set(rtph264, "config-interval", 1, NULL);
	g_object_set(rtph264, "pt" , 96, NULL);
	//g_object_set(sink, "host", "192.168.1.100" /*ip.c_str()*/ , NULL);
	//g_object_set(sink, "port", 5000, NULL);
	g_object_set(filesink, "location", "test.mp4", NULL);

	/* Add the elements to the pipeline prior to linking them */ 
	gst_bin_add_many(GST_BIN(pipeline), src, tee, q1, sink, q2,
filesink,rtph264,encoder,mp4mux,h264parse, NULL);

	/* Specify caps for the csp-filter (modify this if your hardware requires)
*/
	caps = gst_caps_new_simple("video/x-raw",
		"width", G_TYPE_INT, 1280,
		"height", G_TYPE_INT, 720,
		"framerate", GST_TYPE_FRACTION, 30, 1,NULL);

	/* link the tee element */ 
	gst_element_link_filtered(src, tee, caps);

	/* Manually link the Tee, which has "Request" pads */
	tee_src_pad_template = gst_element_class_get_pad_template
(GST_ELEMENT_GET_CLASS (tee), "src_%u");
 
	/* Obtaining request pads for the tee elements*/
	tee_q1_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL,
NULL);
	g_print ("Obtained request pad %s for q1 branch.\n", gst_pad_get_name
(tee_q1_pad));
	q1_pad = gst_element_get_static_pad (q1, "sink");

	tee_q2_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL,
NULL);
	g_print ("Obtained request pad %s for q2 branch.\n", gst_pad_get_name
(tee_q2_pad));
	q2_pad = gst_element_get_static_pad (q2, "sink");

	/* Link the tee to the queue 1 */
	gst_pad_link(tee_q1_pad, q1_pad);
 	gst_pad_link(tee_q2_pad, q2_pad);

	gst_object_unref (q1_pad);
	gst_object_unref (q2_pad);

	/* Link the first sink */
	gst_element_link_many(q1, rtph264, sink, NULL);

	gst_element_link_many(q2, encoder , h264parse, mp4mux , filesink, NULL);

	gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);

	bus = gst_element_get_bus (pipeline);
	msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR );

	gst_element_release_request_pad (tee, tee_q1_pad);
	gst_element_release_request_pad (tee, tee_q2_pad);
	gst_object_unref (tee_q1_pad);
	gst_object_unref (tee_q2_pad);

	gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);

	gst_object_unref(GST_OBJECT(pipeline));

	return 0;

}



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Tee-pipeline-stall-on-pause-tp4670157p4670200.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list