diff options
author | phintuka <phintuka> | 2008-11-18 14:09:08 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2008-11-18 14:09:08 +0000 |
commit | 322f687a629f1772663c17425fc62429306fe6a5 (patch) | |
tree | 335731a6000c86e05f871f56507ce9da8d4623ab | |
parent | 2a739a2939a6737acdf156eb7b108221b59a2115 (diff) | |
download | xineliboutput-322f687a629f1772663c17425fc62429306fe6a5.tar.gz xineliboutput-322f687a629f1772663c17425fc62429306fe6a5.tar.bz2 |
Added an option to limit number of remote clients
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | config.c | 4 | ||||
-rw-r--r-- | config.h | 8 | ||||
-rw-r--r-- | frontend_svr.c | 18 | ||||
-rw-r--r-- | frontend_svr.h | 5 | ||||
-rw-r--r-- | setup_menu.c | 6 |
6 files changed, 32 insertions, 10 deletions
@@ -3,6 +3,7 @@ VDR Plugin 'xineliboutput' Revision History ????-??-??: Version 1.1.0 +- Added an option to limit number of remote clients - Added math library (-lm) to vdr-sxfe when building with Xrender / HUD OSD support (Thanks to Anssi Hannula) - Implemented build-time configuration script @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: config.c,v 1.73 2008-11-10 20:10:33 phintuka Exp $ + * $Id: config.c,v 1.74 2008-11-18 14:09:07 phintuka Exp $ * */ @@ -541,6 +541,7 @@ config_t::config_t() { remote_mode = 0; listen_port = LISTEN_PORT; remote_keyboard = 1; + remote_max_clients = MAXCLIENTS; remote_usetcp = 1; remote_useudp = 1; remote_usertp = 1; @@ -768,6 +769,7 @@ bool config_t::SetupParse(const char *Name, const char *Value) else if (!strcasecmp(Name, "RemoteMode")) remote_mode = atoi(Value); else if (!strcasecmp(Name, "Remote.ListenPort")) listen_port = atoi(Value); else if (!strcasecmp(Name, "Remote.Keyboard")) remote_keyboard = atoi(Value); + else if (!strcasecmp(Name, "Remote.MaxClients")) remote_max_clients = atoi(Value); else if (!strcasecmp(Name, "Remote.UseTcp")) remote_usetcp = atoi(Value); else if (!strcasecmp(Name, "Remote.UseUdp")) remote_useudp = atoi(Value); else if (!strcasecmp(Name, "Remote.UseRtp")) remote_usertp = atoi(Value); @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: config.h,v 1.55 2008-11-10 20:10:33 phintuka Exp $ + * $Id: config.h,v 1.56 2008-11-18 14:09:07 phintuka Exp $ * */ @@ -18,6 +18,9 @@ #include <vdr/config.h> +// Max number of remote clients +#define MAXCLIENTS 10 + // Decoder buffer size #define PES_BUFFERS_CUSTOM 0 #define PES_BUFFERS_TINY_50 1 @@ -358,8 +361,9 @@ class config_t { char remote_local_if[32]; // Listen only on this interface char remote_local_ip[32]; // Bind locally to this IP int remote_keyboard; // Allow remote client to control VDR with keyboard, LIRC, etc. + int remote_max_clients; // Max. number of clients - int remote_usebcast; // Use proadcasts to find servers automatically + int remote_usebcast; // Use broadcasts to find servers automatically int remote_usepipe; // enable local pipes for video transport int remote_usertp; // enable RTP multicast for video transport int remote_useudp; // enable UDP unicast for video transport diff --git a/frontend_svr.c b/frontend_svr.c index c58888f4..6b0ffad3 100644 --- a/frontend_svr.c +++ b/frontend_svr.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: frontend_svr.c,v 1.61 2008-11-16 15:02:45 rofafor Exp $ + * $Id: frontend_svr.c,v 1.62 2008-11-18 14:09:08 phintuka Exp $ * */ @@ -1697,7 +1697,7 @@ void cXinelibServer::Handle_ClientConnected(int fd) return; } - if(cli>=MAXCLIENTS) { + if(cli>=xc.remote_max_clients || cli>=MAXCLIENTS) { const char *msg = "Server busy.\r\n"; ssize_t len = strlen(msg); // too many clients @@ -1736,8 +1736,20 @@ void cXinelibServer::Handle_Discovery_Broadcast(void) struct sockaddr_in from; if(udp_discovery_recv(fd_discovery, buf, 0, &from) > 0) - if(udp_discovery_is_valid_search(buf)) + if(udp_discovery_is_valid_search(buf)) { + + // Reply only if we can accept one more client + int clients = 0; + for(int c=0; c<MAXCLIENTS; c++) + if(fd_control[c].open()) + clients++; + if(clients >= xc.remote_max_clients) { + LOGMSG("Not replying to discovery broadcast (too many clients)"); + return; + } + udp_discovery_broadcast(fd_discovery, m_Port, xc.remote_local_ip); + } } void cXinelibServer::Action(void) diff --git a/frontend_svr.h b/frontend_svr.h index f8809f1c..cd7e9fb7 100644 --- a/frontend_svr.h +++ b/frontend_svr.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: frontend_svr.h,v 1.18 2007-03-15 13:29:04 phintuka Exp $ + * $Id: frontend_svr.h,v 1.19 2008-11-18 14:09:08 phintuka Exp $ * */ @@ -12,12 +12,11 @@ #define __XINELIB_FRONTEND_SVR_H +#include "config.h" #include "frontend.h" //----------------------------- cXinelibServer -------------------------------- -#define MAXCLIENTS 10 - class cBackgroundWriterI; class cUdpScheduler; class cStcFuture; diff --git a/setup_menu.c b/setup_menu.c index e2230323..2b4e3950 100644 --- a/setup_menu.c +++ b/setup_menu.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: setup_menu.c,v 1.63 2008-11-01 07:23:00 phintuka Exp $ + * $Id: setup_menu.c,v 1.64 2008-11-18 14:09:07 phintuka Exp $ * */ @@ -1466,6 +1466,9 @@ void cMenuSetupRemote::Set(void) &newconfig.remote_local_ip[0], 16, "0123456789.")); Add(new cMenuEditBoolItem(tr(" Remote keyboard"), &newconfig.remote_keyboard)); + Add(new cMenuEditIntItem( tr(" Max number of clients"), + &newconfig.remote_max_clients, + 1, MAXCLIENTS)); Add(new cMenuEditBoolItem(tr(" PIPE transport"), &newconfig.remote_usepipe)); @@ -1570,6 +1573,7 @@ void cMenuSetupRemote::Store(void) SetupStore("Remote.LocalIP", xc.remote_local_ip); SetupStore("Remote.Keyboard", xc.remote_keyboard); + SetupStore("Remote.MaxClients", xc.remote_max_clients); SetupStore("Remote.UsePipe",xc.remote_usepipe); SetupStore("Remote.UseTcp", xc.remote_usetcp); SetupStore("Remote.UseUdp", xc.remote_useudp); |