summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-10-02 03:19:03 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-10-02 03:19:15 +0200
commitaed2d9de0a7edb974cea58e8fe0c3fe73ccb58f3 (patch)
tree2127f0049f082333ffc2edcc7ece16b671253e47 /src
parentfixed error output (diff)
added command line switch to disable automatic client handling
added some warnings for pointless configuration combinations
Diffstat (limited to 'src')
-rw-r--r--src/options.c33
-rw-r--r--src/options.h1
-rw-r--r--src/sydra.c2
-rw-r--r--src/udp.c3
4 files changed, 30 insertions, 9 deletions
diff --git a/src/options.c b/src/options.c
index c9d1af3..354b3be 100644
--- a/src/options.c
+++ b/src/options.c
@@ -50,13 +50,13 @@ static void options_defaults(options_t* opt)
return;
opt->progname_ = g_strdup("sydra");
- opt->daemonize_ = 1;
+ opt->daemonize_ = TRUE;
opt->username_ = NULL;
opt->groupname_ = NULL;
opt->chroot_dir_ = NULL;
opt->pid_file_ = NULL;
opt->log_targets_ = NULL;
- opt->debug_ = 0;
+ opt->debug_ = FALSE;
opt->appname_ = NULL;
opt->mode_ = SENDER;
@@ -82,6 +82,7 @@ static void options_defaults(options_t* opt)
opt->rtp_port_base_ = 5000;
opt->rtp_addr_local_ = NULL;
opt->rtp_port_base_local_ = 5000;
+ opt->auto_client_ = TRUE;
opt->timeout_ = 30;
opt->keepalive_int_ = 10;
@@ -143,7 +144,7 @@ static GOptionGroup* options_get_avrecv_group(options_t* opt)
{ "audio-decoder", 0, 0, G_OPTION_ARG_STRING, &opt->audio_dec_,
"pipeline for audio decoder (i.e. opusdnc)", "BIN DESCRIPTION" },
{ "sink", 0, 0, G_OPTION_ARG_STRING, &opt->sink_,
- "video/audio sink element", "BIN DESCRIPTION" },
+ "video and audio sink bin", "BIN DESCRIPTION" },
{ NULL }
};
GOptionGroup* avrecv_group = g_option_group_new ("avrecv", "Audio/Video Receiver Options",
@@ -165,6 +166,8 @@ static GOptionGroup* options_get_rtp_group(options_t* opt)
"local address to bind to", "ADDRESS" },
{ "rtp-port-base-local", 'O', 0, G_OPTION_ARG_INT, &opt->rtp_port_base_local_,
"base number for local ports to bind to", "PORT" },
+ { "no-auto-client", 'c', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt->auto_client_,
+ "disable auto-detection for clients (aka. ignore incoming keepalives) - sender mode only!", NULL },
{ "timeout", 't', 0, G_OPTION_ARG_INT, &opt->timeout_,
"client timeout in seconds (0 means no timeout) - sender mode only!", "VALUE" },
{ "keepalive-interval", 'k', 0, G_OPTION_ARG_INT, &opt->keepalive_int_,
@@ -266,7 +269,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
GOptionGroup* rec_group = options_get_rec_group(opt);
GOptionGroup* gst_group = gst_init_get_option_group();
if(!main_group || !avsend_group || !avrecv_group || !rtp_group || !rec_group || !gst_group) {
- printf("Failed to initialize: memory error\n");
+ printf("ERROR: Failed to initialize: memory error\n");
return -127;
}
g_option_context_set_main_group(ctx, main_group);
@@ -278,7 +281,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
GError *err = NULL;
if(!g_option_context_parse(ctx, &argc, &argv, &err)) {
- printf("Failed to initialize: %s\n", err->message);
+ printf("ERROR: Failed to initialize: %s\n", err->message);
g_error_free(err);
return 1;
}
@@ -293,19 +296,32 @@ static int options_parse_post(options_t* opt)
{
if(opt->rtp_port_base_ < 1 || opt->rtp_port_base_ > 65535 ||
opt->rtp_port_base_local_ < 1 || opt->rtp_port_base_local_ > 65535) {
- printf("Failed to initialize: rtp port is invalid\n");
+ printf("ERROR: Failed to initialize: rtp port is invalid\n");
return -2;
}
if(opt->timeout_ < 0) {
- printf("Failed to initialize: timeout is invalid\n");
+ printf("ERROR: Failed to initialize: timeout is invalid\n");
return -3;
}
if(opt->keepalive_int_ < 0) {
- printf("Failed to initialize: keep alive interval is invalid\n");
+ printf("ERROR: Failed to initialize: keep alive interval is invalid\n");
return -3;
}
+ if(opt->rtp_host_ && opt->auto_client_) {
+ printf("WARNING: you have set a remote RTP host and the automatic client handling is enabled.\n" \
+ " Please mind that the remote RTP host is always added as a receiver and it shouldn't be\n" \
+ " configured to send keepalives. This would re-add the receiver to the list of clients\n" \
+ " and as a result duplicate packages will be sent.\n" \
+ " Also the remote RTP host is excluded from client timeout handling and remove requests\n" \
+ " will get ignored.\n\n");
+ } else if(!opt->rtp_host_ && !opt->auto_client_) {
+ printf("WARNING: both, the remote RTP host, as well as the automatic client detection are disabled\n" \
+ " this means that no streaming will be done. Recording will work but this is most probably\n" \
+ " not what you intended - please check your configuration.\n\n");
+ }
+
if(opt->debug_) {
opt->daemonize_ = 0;
g_strfreev(opt->log_targets_);
@@ -418,6 +434,7 @@ void options_print(options_t* opt)
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(" auto_client: %s\n", opt->auto_client_ ? "true" : "false");
printf(" timeout: %d\n", opt->timeout_);
printf(" keepalive_int: %d\n", opt->keepalive_int_);
printf(" preview_video_sink: >>%s<<\n", opt->preview_videosink_);
diff --git a/src/options.h b/src/options.h
index cf18b9f..9ebcb01 100644
--- a/src/options.h
+++ b/src/options.h
@@ -70,6 +70,7 @@ struct options_struct {
gint rtp_port_base_;
gchar* rtp_addr_local_;
gint rtp_port_base_local_;
+ gboolean auto_client_;
gint timeout_;
gint keepalive_int_;
diff --git a/src/sydra.c b/src/sydra.c
index 9201ab4..ec8d805 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -192,7 +192,7 @@ int main_loop(options_t* opt)
log_printf(NOTICE, "Set State: Paused");
gst_element_set_state(pipeline, GST_STATE_PAUSED);
- if((opt->mode_ == SENDER && !attach_udpsinks(&sinks)) ||
+ if((opt->mode_ == SENDER && opt->auto_client_ && !attach_udpsinks(&sinks)) ||
(opt->mode_ == RECEIVER && !attach_udpsources(&sources, opt->rtp_host_)))
return -1;
diff --git a/src/udp.c b/src/udp.c
index d9133aa..719bb2f 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -212,6 +212,8 @@ gboolean attach_udpsinks(struct udp_sinks *sinks)
if(!sinks)
return FALSE;
+ log_printf(NOTICE, "enabling automatic client handling");
+
if(!attach_udpsink(&(sinks->rtp_video_), "RTP(video) IPv4", "used-socket") ||
!attach_udpsink(&(sinks->rtp_video_), "RTP(video) IPv6", "used-socket-v6") ||
!attach_udpsink(&(sinks->rtcp_video_), "RTCP(video) IPv4", "used-socket") ||
@@ -230,6 +232,7 @@ gboolean attach_udpsinks(struct udp_sinks *sinks)
return TRUE;
}
+
static gboolean send_udpsrc_buf(GstElement* source, const char* name, GInetAddress* remote, guint port, u_int8_t* buf, size_t buflen)
{
GSocket *sock;