summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-23 21:56:40 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-23 21:56:40 +0200
commit9edce5658d4574dbd61542a5d13b1fad35f27b64 (patch)
tree2307c6e86d606814b3a13a5f4a65b3cd18c75a49 /src
parentfixed log printf (diff)
getting udp socket file descriptors
Diffstat (limited to 'src')
-rwxr-xr-xsrc/configure4
-rw-r--r--src/sydra.c64
2 files changed, 48 insertions, 20 deletions
diff --git a/src/configure b/src/configure
index 13ddc5d..acb7a20 100755
--- a/src/configure
+++ b/src/configure
@@ -98,8 +98,8 @@ else
COMPILER='clang'
fi
-CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-1.0 gthread-2.0)"
-LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-1.0 gthread-2.0)"
+CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-1.0 gthread-2.0 gio-2.0)"
+LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-1.0 gthread-2.0 gio-2.0)"
rm -f include.mk
rm -f config.h
diff --git a/src/sydra.c b/src/sydra.c
index 43430aa..e751cbe 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -43,6 +43,7 @@
#include <glib.h>
#include <glib-unix.h>
+#include <gio/gio.h>
#include <gst/gst.h>
#include "datatypes.h"
@@ -299,30 +300,37 @@ static gboolean create_media_elements(struct media_elements *me, GstElement* pip
return TRUE;
}
-static gboolean create_udp_elements(options_t* opt, GstElement* pipeline, GstElement* rtp)
+struct udp_elements {
+ GstElement *rtp_video_;
+ GstElement *rtcp_video_;
+ GstElement *rtp_audio_;
+ GstElement *rtcp_audio_;
+};
+
+static gboolean create_udp_elements(options_t* opt, GstElement* pipeline, GstElement* rtp, struct udp_elements *udp)
{
- GstElement *udp_rtp_video = sydra_create_element("udpsink", "udprtpv");
- GstElement *udp_rtcp_video = sydra_create_element("udpsink", "udprtcpv");
- GstElement *udp_rtp_audio = sydra_create_element("udpsink", "udprtpa");
- GstElement *udp_rtcp_audio = sydra_create_element("udpsink", "udprtcpa");
+ udp->rtp_video_ = sydra_create_element("udpsink", "udprtpv");
+ udp->rtcp_video_ = sydra_create_element("udpsink", "udprtcpv");
+ udp->rtp_audio_ = sydra_create_element("udpsink", "udprtpa");
+ udp->rtcp_audio_ = sydra_create_element("udpsink", "udprtcpa");
- if(!udp_rtp_video || !udp_rtcp_video || !udp_rtp_audio || !udp_rtcp_audio)
+ if(!udp->rtp_video_ || !udp->rtcp_video_ || !udp->rtp_audio_ || !udp->rtcp_audio_)
return FALSE;
log_printf(DEBUG, "udp elements created successfully!");
int rtp_port = opt->rtp_port_base_;
- g_object_set(G_OBJECT(udp_rtp_video), "host", opt->rtp_host_, "port", rtp_port++, NULL);
- g_object_set(G_OBJECT(udp_rtcp_video), "host", opt->rtp_host_, "port", rtp_port++, "sync", FALSE, "async", FALSE, NULL);
- g_object_set(G_OBJECT(udp_rtp_audio), "host", opt->rtp_host_, "port", rtp_port++, NULL);
- g_object_set(G_OBJECT(udp_rtcp_audio), "host", opt->rtp_host_, "port", rtp_port++, "sync", FALSE, "async", FALSE, NULL);
+ g_object_set(G_OBJECT(udp->rtp_video_), "host", opt->rtp_host_, "port", rtp_port++, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_video_), "host", opt->rtp_host_, "port", rtp_port++, "sync", FALSE, "async", FALSE, NULL);
+ g_object_set(G_OBJECT(udp->rtp_audio_), "host", opt->rtp_host_, "port", rtp_port++, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_audio_), "host", opt->rtp_host_, "port", rtp_port++, "sync", FALSE, "async", FALSE, NULL);
- gst_bin_add_many(GST_BIN (pipeline), udp_rtp_video, udp_rtcp_video, udp_rtp_audio, udp_rtcp_audio, NULL);
+ gst_bin_add_many(GST_BIN (pipeline), udp->rtp_video_, udp->rtcp_video_, udp->rtp_audio_, udp->rtcp_audio_, NULL);
- if(!sydra_link_static_static(rtp, "send_rtp_src_0", udp_rtp_video, "sink") ||
- !sydra_link_request_static(rtp, "send_rtcp_src_0", udp_rtcp_video, "sink") ||
- !sydra_link_static_static(rtp, "send_rtp_src_1", udp_rtp_audio, "sink") ||
- !sydra_link_request_static(rtp, "send_rtcp_src_1", udp_rtcp_audio, "sink"))
+ if(!sydra_link_static_static(rtp, "send_rtp_src_0", udp->rtp_video_, "sink") ||
+ !sydra_link_request_static(rtp, "send_rtcp_src_0", udp->rtcp_video_, "sink") ||
+ !sydra_link_static_static(rtp, "send_rtp_src_1", udp->rtp_audio_, "sink") ||
+ !sydra_link_request_static(rtp, "send_rtcp_src_1", udp->rtcp_audio_, "sink"))
return FALSE;
log_printf(DEBUG, "udp elements linked successfully!");
@@ -330,6 +338,22 @@ static gboolean create_udp_elements(options_t* opt, GstElement* pipeline, GstEle
return TRUE;
}
+static void get_udp_descriptors(struct udp_elements *udp)
+{
+ GSocket *sock;
+ g_object_get(G_OBJECT(udp->rtp_video_), "used-socket", &sock, NULL);
+ int rtp_video = g_socket_get_fd(sock);
+ g_object_get(G_OBJECT(udp->rtcp_video_), "used-socket", &sock, NULL);
+ int rtcp_video = g_socket_get_fd(sock);
+ g_object_get(G_OBJECT(udp->rtp_audio_), "used-socket", &sock, NULL);
+ int rtp_audio = g_socket_get_fd(sock);
+ g_object_get(G_OBJECT(udp->rtcp_audio_), "used-socket", &sock, NULL);
+ int rtcp_audio = g_socket_get_fd(sock);
+
+ log_printf(DEBUG, "UDP file descriptors: video RTP=%d RTCP=%d, audio RTP=%d RTCP=%d",
+ rtp_video, rtcp_video, rtp_audio, rtcp_audio);
+}
+
static gboolean create_preview_elements(const char* preview_bin_desc, GstElement* pipeline, GstElement* tee)
{
GstElement *qr = sydra_create_element("queue", NULL);
@@ -417,7 +441,7 @@ static gboolean create_recorder_elements(options_t* opt, GstElement* pipeline, s
return TRUE;
}
-static GstElement* create_pipeline(options_t* opt)
+static GstElement* create_pipeline(options_t* opt, struct udp_elements *udp)
{
GstElement *pipeline = gst_pipeline_new ("sydra");
if(!pipeline) {
@@ -438,7 +462,7 @@ static GstElement* create_pipeline(options_t* opt)
opt->audio_payloader_, NULL };
if(!create_media_elements(&video, pipeline, rtp, 0) ||
!create_media_elements(&audio, pipeline, rtp, 1) ||
- !create_udp_elements(opt, pipeline, rtp)) {
+ !create_udp_elements(opt, pipeline, rtp, udp)) {
return NULL;
}
@@ -461,7 +485,8 @@ int main_loop(options_t* opt)
{
log_printf(INFO, "entering main loop");
- GstElement *pipeline = create_pipeline(opt);
+ struct udp_elements udp;
+ GstElement *pipeline = create_pipeline(opt, &udp);
if(!pipeline) {
log_printf(ERROR, "creating pipeline failed");
return -1;
@@ -481,6 +506,9 @@ int main_loop(options_t* opt)
log_printf(INFO, "Set State: Paused");
gst_element_set_state(pipeline, GST_STATE_PAUSED);
+
+ get_udp_descriptors(&udp);
+
log_printf(INFO, "Set State: Playing");
gst_element_set_state(pipeline, GST_STATE_PLAYING);