I am using Gstreamer1.0 to extract the rtp packet's payload data into a buffer.
To test this i have created these pipelines (host/client)
host:
gst-launch-1.0 audiotestsrc ! audioconvert ! audio/x-raw,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay ! udpsink host=192.168.151.99 port=5000
client:
gst-launch-1.0 udpsrc port=5000 ! "application/x-rtp,media=(string)audio, clock-rate=(int)44100, width=16, height=16, encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1, channel-positions=(int)1, payload=(int)96" ! rtpL16depay ! audioconvert ! autoaudiosink sync=false
This worked fine in terminal as well as using C++ code. Below is the source code for client in C++.
gint
main (gint argc,
gchar *argv[])
{
GstElement *pipeline, *udp, *sinkcaps, *depay, *conv, *audiosink, *abcd;
GMainLoop *loop;
// init GStreamer
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
// setup pipeline
pipeline = gst_pipeline_new ("pipeline");
udp = gst_element_factory_make("udpsrc", "udp");
g_object_set(G_OBJECT(udp), "port", 5000, NULL);
sinkcaps = gst_element_factory_make("capsfilter", "caps");
g_object_set(sinkcaps, "caps", gst_caps_new_simple("application/x-rtp",
"media", G_TYPE_STRING, "audio",
"clock-rate", G_TYPE_INT, 44100,
"width", G_TYPE_INT, 16,
"height", G_TYPE_INT, 16,
"encoding-name", G_TYPE_STRING, "L16",
"encoding-params", G_TYPE_STRING, "1",
"channels", G_TYPE_INT, 1,
"channel-positions", G_TYPE_INT, 1,
"payload", G_TYPE_INT, 96,NULL), NULL);
depay = gst_element_factory_make("rtpL16depay", "depay");
conv = gst_element_factory_make ("audioconvert", "conv");
audiosink = gst_element_factory_make ("multifilesink", "sink");
g_object_set(G_OBJECT(audiosink), "sync", FALSE, NULL);
gst_bin_add_many (GST_BIN (pipeline), udp, sinkcaps, depay, audiosink, NULL);
if (gst_element_link_many (udp, sinkcaps, depay, conv, audiosink, NULL) != TRUE)
{
return -1;
}
// play
gst_element_set_state (pipeline, GST_STATE_PLAYING);
//Runs a main loop until g_main_loop_quit() is called on the loop.
g_main_loop_run (loop);
// clean up
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
g_main_loop_unref (loop);
return 0;
}
I am getting the audio from speakers for this.
Now I am trying to accomplish the following objective: Dump the rtp payload (only) in sequence in a buffer.
I have tried finding the appropriate element to get the payload data to buffer. The closest I could find is "appsink". For this I have made this following pipeline.
client:
gst-launch-1.0 udpsrc port=5000 ! "application/x-rtp,media=(string)audio, clock-rate=(int)44100, width=16, height=16, encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1, channel-positions=(int)1, payload=(int)96" ! rtpL16depay ! appsink
The pipeline is created successfully but I am not sure where the data is getting dumped and how can I retrieve it?
Thank you any help :)
Aucun commentaire:
Enregistrer un commentaire