create simultaneous & dis-joint pipelines and terminate pipelines independently using timeout

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

create simultaneous & dis-joint pipelines and terminate pipelines independently using timeout

Rohan0993
Hi all,

I am using C++ to create pipelines which are listening to a port and dumping
the data in a separate file.

For eg;
*Pipeline 1:*
gst-launch-1.0 udpsrc port=5000 ! "application/x-rtp,media=(string)audio,
clock-rate=(int)44100, encoding-name=(string)L16,
encoding-params=(string)1, channels=(int)1, channel-positions=(int)1,
payload=(int)96" ! rtpL16depay ! filesink location=/home/rohan/AAA.raw

*Pipeline 2:*
gst-launch-1.0 udpsrc port=5008 ! "application/x-rtp,media=(string)audio,
clock-rate=(int)44100, encoding-name=(string)L16,
encoding-params=(string)1, channels=(int)1, channel-positions=(int)1,
payload=(int)96" ! rtpL16depay ! filesink location=/home/rohan/BBB.raw

now in c++; I am creating these pipeline in 2 threads
The Details of C++ code is given in this stack overflow link.
https://stackoverflow.com/questions/54863923/get-gstreamer-bus-messages-using-non-static-message-handler
<https://stackoverflow.com/questions/54863923/get-gstreamer-bus-messages-using-non-static-message-handler>  

I am stuck with the callback function which prints the bus messages  and
which I have used to terminate the pipelines.

kindly Check the Stack overflow link to read about the issue




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: create simultaneous & dis-joint pipelines and terminate pipelines independently using timeout

killerrats
Administrator
if your using windows you can do it this way. int main() on bottom. Hope this helps! this is not tested but this is what i do in my windows application. should be able to convert it to linux with replacing a few things here and there.
#include 
#include 

class vPipeline
{
	private: 
	std::string cmdLine;
	vPipeline *pPipe;
	GstElement *pipeline;
	GstBus *bus;
		GstMessage *msg;
		GMainLoop *mLoop;
		
	static unsigned int __stdcall TheStartPipeline(void* p_this)
	{
		auto pPipe = (vPipeline*)p_this;
		
		pPipe->startPipe();
		
		return 0;
	}
	static gboolean handle_message(CustomData *data, GstMessage *msg) {

		return TRUE;
	}

	bool startPipe()
	{
		GstStateChangeReturn ret;
		pipeline = gst_parse_launch("",NULL);
		
		this->bus = gst_element_get_bus(this->aRtspPipeline.srcPipeline);
		if (bus == nullptr)
		{
			return false;
		}
		gst_bus_add_signal_watch(this->bus);
		this->aBusWatchSignalId = g_signal_connect(this->bus, "message", G_CALLBACK(handle_message), this->pipeline);
		
		ret = gst_element_set_state(pipeline, GST_STATE_PLAYING);
		if (ret == GST_STATE_CHANGE_FAILURE) {
			g_printerr("Unable to set the pipeline to the playing state.\n");
			gst_object_unref(data.playbin);
			return false;
		}
		
		g_main_loop_run(mLoop);
		
		return true;
	}

	public: 
	vPipeline() 
	{
		this->pPipe = (vPipeline*)this;
	}
	void SetPipelineString(std::string commandLine)
	{
		cmdLine = commandLine;
	}
	void start()
	{
		HANDLE handle =
			reinterpret_cast(_beginthreadex(0, 0, &TheStartPipeline, pPipe, 0, 0));
		CloseHandle(handle);
	}
}

int main()
{
/* Initialize GStreamer */
	gst_init(&argc, &argv);
	
	// command line strings
	std::string cmd1 = "udpsrc port=5000 ! \"application/x-rtp,media=(string)audio,clock-rate=(int)44100, encoding-name=(string)L16,encoding-params=(string)1, channels=(int)1, channel-positions=(int)1,payload=(int)96\" ! rtpL16depay ! filesink location=/home/rohan/AAA.raw"
,cmd2 = "udpsrc port=5008 ! \"application/x-rtp,media=(string)audio,clock-rate=(int)44100, encoding-name=(string)L16,encoding-params=(string)1, channels=(int)1, channel-positions=(int)1,payload=(int)96\" ! rtpL16depay ! filesink location=/home/rohan/BBB.raw";

	// each pipeline
	vPipeline pipe,pipe2;
	
	// pipeline 1
	pipe.SetPipelineString(cmd1);
	pipe.start();
	
	// pipeline 2
	pipe2.SetPipelineString(cmd2);
	pipe2.start();
	
	return 0;
}
------------------------------
Gstreamer 1.14.4
------------------------------
Windows


Sent from the GStreamer-devel mailing list archive at Nabble.com.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
------------------------------
Gstreamer 1.16.2
------------------------------
Windows