summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-24 00:13:53 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-24 00:13:53 +0200
commit71c3b511e3df7619c92a045f6781034191b2004a (patch)
tree143ef3539a1c7941a2621ea9a8638f4a96cc16d7
parentalso listening for packets on IPv6 sockets (diff)
binding to address/port
-rw-r--r--src/options.c21
-rw-r--r--src/options.h2
-rw-r--r--src/sydra.c20
3 files changed, 34 insertions, 9 deletions
diff --git a/src/options.c b/src/options.c
index 1227801..e090bdd 100644
--- a/src/options.c
+++ b/src/options.c
@@ -211,8 +211,10 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-as","--audio-source", opt->audio_src_)
PARSE_STRING_PARAM("-ae","--audio-encoder", opt->audio_enc_)
PARSE_STRING_PARAM("-ap","--audio-payloader", opt->audio_payloader_)
- PARSE_STRING_PARAM("-o","--rtp-host", opt->rtp_host_)
- PARSE_INT_PARAM("-O","--rtp-port-base", opt->rtp_port_base_, 10)
+ PARSE_STRING_PARAM("-a","--rtp-host", opt->rtp_host_)
+ PARSE_INT_PARAM("-o","--rtp-port-base", opt->rtp_port_base_, 10)
+ PARSE_STRING_PARAM("-A","--rtp-addr-local", opt->rtp_addr_local_)
+ PARSE_INT_PARAM("-O","--rtp-port-base-local", opt->rtp_port_base_local_, 10)
PARSE_STRING_PARAM("-V","--videosink", opt->preview_videosink_)
PARSE_STRING_PARAM("-rv","--rec-video-encoder", opt->video_enc_rec_)
PARSE_STRING_PARAM("-ra","--rec-audio-encoder", opt->audio_enc_rec_)
@@ -222,7 +224,8 @@ int options_parse(options_t* opt, int argc, char* argv[])
return i;
}
- if(opt->rtp_port_base_ < 1 || opt->rtp_port_base_ > 65535)
+ if(opt->rtp_port_base_ < 1 || opt->rtp_port_base_ > 65535 ||
+ opt->rtp_port_base_local_ < 1 || opt->rtp_port_base_local_ > 65535)
return -4;
if(opt->debug_) {
@@ -270,6 +273,8 @@ void options_default(options_t* opt)
opt->rtp_host_ = strdup("127.0.0.1");
opt->rtp_port_base_ = 5000;
+ opt->rtp_addr_local_ = NULL;
+ opt->rtp_port_base_local_ = 5000;
opt->preview_videosink_ = NULL;
@@ -311,6 +316,8 @@ void options_clear(options_t* opt)
free(opt->audio_payloader_);
if(opt->rtp_host_)
free(opt->rtp_host_);
+ if(opt->rtp_addr_local_)
+ free(opt->rtp_addr_local_);
if(opt->preview_videosink_)
free(opt->preview_videosink_);
if(opt->video_enc_rec_)
@@ -343,8 +350,10 @@ void options_print_usage()
printf(" [-as|--audio-source pipeline for raw audio (audiotestsrc)\n");
printf(" [-ae|--audio-encoder pipeline for audio encoder (stream)\n");
printf(" [-ap|--audio-payloader audio payloader element (i.e. rptopuspay)\n");
- printf(" [-o|--rtp-host remote host for RTP packets\n");
- printf(" [-O|--rtp-port-base base number for remote ports\n");
+ printf(" [-a|--rtp-host remote host for RTP packets\n");
+ printf(" [-o|--rtp-port-base base number for remote ports\n");
+ printf(" [-A|--rtp-addr-local local address to bind to\n");
+ printf(" [-O|--rtp-port-base-local base number for local ports to bind to\n");
printf(" [-V|--videosink video sink element for local preview (i.e. xvimagesink) - leave empty to disable preview\n");
printf(" [-rv|--rec-video-encoder pipeline for video encoder (recording - leave empty for same as stream)\n");
printf(" [-ra|--rec-audio-encoder pipeline for audio encoder (recording - leave empty for same as stream)\n");
@@ -381,6 +390,8 @@ void options_print(options_t* opt)
printf(" audio_payloader: >>%s<<\n", opt->audio_payloader_);
printf(" rtp_host: >>%s<<\n", opt->rtp_host_);
printf(" rtp_port_base: %d\n", opt->rtp_port_base_);
+ printf(" rtp_addr_local: >>%s<<\n", opt->rtp_addr_local_);
+ printf(" rtp_port_base_local: %d\n", opt->rtp_port_base_local_);
printf(" preview_video_sink: >>%s<<\n", opt->preview_videosink_);
printf(" video_enc_rec: >>%s<<\n", opt->video_enc_rec_);
printf(" audio_enc_rec: >>%s<<\n", opt->audio_enc_rec_);
diff --git a/src/options.h b/src/options.h
index 3f8d551..a6f1067 100644
--- a/src/options.h
+++ b/src/options.h
@@ -62,6 +62,8 @@ struct options_struct {
char* rtp_host_;
int rtp_port_base_;
+ char* rtp_addr_local_;
+ int rtp_port_base_local_;
char* preview_videosink_;
diff --git a/src/sydra.c b/src/sydra.c
index 69d3026..e1c67db 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -321,10 +321,22 @@ static gboolean create_udp_elements(options_t* opt, GstElement* pipeline, GstEle
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);
+ int rtp_port_local = opt->rtp_port_base_local_;
+ g_object_set(G_OBJECT(udp->rtp_video_), "host", opt->rtp_host_, "port", rtp_port++,
+ "bind-port", rtp_port_local++, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_video_), "host", opt->rtp_host_, "port", rtp_port++,
+ "bind-port", rtp_port_local++, "sync", FALSE, "async", FALSE, NULL);
+ g_object_set(G_OBJECT(udp->rtp_audio_), "host", opt->rtp_host_, "port", rtp_port++,
+ "bind-port", rtp_port_local++, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_audio_), "host", opt->rtp_host_, "port", rtp_port++,
+ "bind-port", rtp_port_local++, "sync", FALSE, "async", FALSE, NULL);
+
+ if(opt->rtp_addr_local_) {
+ g_object_set(G_OBJECT(udp->rtp_video_), "bind-address", opt->rtp_addr_local_, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_video_), "bind-address", opt->rtp_addr_local_, NULL);
+ g_object_set(G_OBJECT(udp->rtp_audio_), "bind-address", opt->rtp_addr_local_, NULL);
+ g_object_set(G_OBJECT(udp->rtcp_audio_), "bind-address", opt->rtp_addr_local_, NULL);
+ }
gst_bin_add_many(GST_BIN (pipeline), udp->rtp_video_, udp->rtcp_video_, udp->rtp_audio_, udp->rtcp_audio_, NULL);