|
#include <gst/gst.h> |
|
|
|
static GMainLoop *loop; |
|
|
|
int main (int argc, char *argv[]) { |
|
|
|
GstElement *pipeline, *udpsrc, *rtpL2depay, *audioconvert, *wavenc, *filesink; |
|
|
|
gst_init (&argc, &argv); |
|
loop = g_main_loop_new (NULL, FALSE); |
|
|
|
pipeline = gst_pipeline_new ("pipeline"); |
|
udpsrc = gst_element_factory_make ("udpsrc", NULL); |
|
rtpL2depay = gst_element_factory_make ("rtpL24depay", NULL); |
|
audioconvert = gst_element_factory_make ("audioconvert", NULL); |
|
wavenc = gst_element_factory_make("wavenc", NULL); |
|
filesink = gst_element_factory_make ("filesink", NULL); |
|
|
|
g_object_set(G_OBJECT(udpsrc), |
|
"address", "192.168.1.3", /* UDP IP Address */ |
|
"port", 4343, /* UDP port */ |
|
NULL); |
|
|
|
g_object_set (G_OBJECT (udpsrc), "caps", |
|
gst_caps_new_simple ("application/x-rtp", |
|
"channels", G_TYPE_INT, 2, |
|
"format", G_TYPE_STRING, "S16LE", |
|
"media", G_TYPE_STRING, "audio", |
|
"payload", G_TYPE_INT, 96, |
|
"clock-rate", G_TYPE_INT, 44100, |
|
"encoding-name", G_TYPE_STRING, "L24", |
|
NULL), NULL); |
|
|
|
g_object_set(G_OBJECT(filesink), "location", "capture.wave", NULL); |
|
|
|
gst_bin_add_many (GST_BIN (pipeline), udpsrc, rtpL2depay, audioconvert, wavenc, filesink, NULL); |
|
gst_element_link_many (udpsrc, rtpL2depay, audioconvert, wavenc, filesink, NULL); |
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
g_main_loop_run (loop); |
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL); |
|
gst_object_unref (GST_OBJECT (pipeline)); |
|
g_main_loop_unref (loop); |
|
|
|
return 0; |
|
} |