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.
<pre>
#include <process.h>
#include <string>
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<HANDLE>(_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;
}
</pre>
<div class="signature" style="margin-top:1em;color:#666666;font-size:11px;">
------------------------------
<br/>Gstreamer 1.14.4
<br/>------------------------------
<br/>Windows
</div>
<br/><hr align="left" width="300" />
Sent from the <a href="http://gstreamer-devel.966125.n4.nabble.com/">GStreamer-devel mailing list archive</a> at Nabble.com.<br/>