50 lines
1.9 KiB
C
50 lines
1.9 KiB
C
#include <gst/gst.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
GMainLoop *loop;
|
|
GstElement *rx, *tx;
|
|
GstElement *rx_tap, *rx_jitterbuffer, *rx_depay, *rx_opusdec, *rx_resample, *rx_sink;
|
|
|
|
gst_init (&argc, &argv);
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
rx = gst_pipeline_new ("rx");
|
|
rx_tap = gst_element_factory_make("udpsrc", "rx-tap");
|
|
rx_jitterbuffer = gst_element_factory_make("rtpjitterbuffer", "rx-jitterbuffer");
|
|
rx_depay = gst_element_factory_make("rtpopusdepay", "rx-depay");
|
|
rx_opusdec = gst_element_factory_make("opusdec", "rx-opusdec");
|
|
rx_resample = gst_element_factory_make("audioresample", "rx-audioresample");
|
|
rx_sink = gst_element_factory_make("autoaudiosink", "rx-sink");
|
|
|
|
if (!rx || !rx_tap || !rx_jitterbuffer || !rx_depay || !rx_opusdec || !rx_resample || !rx_sink) {
|
|
g_printerr ("One element could not be created. Exiting.\n");
|
|
return -1;
|
|
}
|
|
|
|
g_object_set(G_OBJECT (rx_tap), "port", 5000, NULL);
|
|
g_object_set(G_OBJECT (rx_tap), "caps", gst_caps_new_simple("application/x-rtp", "media", G_TYPE_STRING, "audio", NULL), NULL);
|
|
|
|
g_object_set(G_OBJECT (rx_jitterbuffer), "do-lost", TRUE, NULL);
|
|
g_object_set(G_OBJECT (rx_jitterbuffer), "do-retransmission", FALSE, NULL);
|
|
g_object_set(G_OBJECT (rx_jitterbuffer), "latency", 50, NULL);
|
|
|
|
g_object_set(G_OBJECT (rx_opusdec), "plc", TRUE, NULL);
|
|
g_object_set(G_OBJECT (rx_opusdec), "use-inband-fec", FALSE, NULL);
|
|
|
|
gst_bin_add_many (GST_BIN (rx), rx_tap, rx_jitterbuffer, rx_depay, rx_opusdec, rx_resample, rx_sink, NULL);
|
|
gst_element_link_many (rx_tap, rx_jitterbuffer, rx_depay, rx_opusdec, rx_resample, rx_sink, NULL);
|
|
|
|
gst_element_set_state (rx, GST_STATE_PLAYING);
|
|
|
|
g_print ("Running...\n");
|
|
g_main_loop_run (loop);
|
|
|
|
g_print ("Returned, stopping playback\n");
|
|
gst_element_set_state (rx, GST_STATE_NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (rx));
|
|
g_main_loop_unref (loop);
|
|
|
|
return 0;
|
|
}
|