From aed2d9de0a7edb974cea58e8fe0c3fe73ccb58f3 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 2 Oct 2014 03:19:03 +0200 Subject: added command line switch to disable automatic client handling added some warnings for pointless configuration combinations --- src/options.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/options.c') 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_); -- cgit v1.2.3