diff --git a/HISTORY b/HISTORY index 9a06901..e17592b 100644 --- a/HISTORY +++ b/HISTORY @@ -75,5 +75,5 @@ VDR Plugin 'satip' Revision History - Added support for Telestar Digibit R1 (Thanks to Dirk Wagner). - Added a new device status menu. -- Added a command-line switch for manually defining a - SAT>IP server. +- Added a command-line switch for manually defining + used SAT>IP servers. diff --git a/README b/README index a6317f2..24d1c48 100644 --- a/README +++ b/README @@ -45,7 +45,7 @@ to one. This parameter defines how many simultaneous transponders can be received, if there are available SAT>IP tuners. The plugin accepts also a "--server" (-s) command-line parameter, that -can be used to manually configure one SAT>IP server, if autodetection +can be used to manually configure static SAT>IP servers if autodetection via UPnP somehow can't be used. SAT>IP satellite positions (aka. signal sources) shall be defined via diff --git a/discover.c b/discover.c index 928f390..bee329a 100644 --- a/discover.c +++ b/discover.c @@ -32,12 +32,14 @@ cSatipDiscover *cSatipDiscover::GetInstance(void) return instanceS; } -bool cSatipDiscover::Initialize(const char *serverAddrP, const char *serverDescriptionP, const char *serverModelP) +bool cSatipDiscover::Initialize(cSatipDiscoverServers *serversP) { - debug("cSatipDiscover::%s(%s, %s, %s)", __FUNCTION__, serverAddrP ? serverAddrP : "auto", serverDescriptionP ? serverDescriptionP : "auto", serverModelP ? serverModelP : "auto"); + debug("cSatipDiscover::%s()", __FUNCTION__); if (instanceS) { - if (serverAddrP && serverDescriptionP && serverModelP) - instanceS->AddServer(serverAddrP, serverDescriptionP, serverModelP); + if (serversP) { + for (cSatipDiscoverServer *s = serversP->First(); s; s = serversP->Next(s)) + instanceS->AddServer(s->IpAddress(), s->Description(), s->Model()); + } else instanceS->Activate(); } diff --git a/discover.h b/discover.h index ef6a087..1d38b71 100644 --- a/discover.h +++ b/discover.h @@ -16,6 +16,24 @@ #include "server.h" #include "socket.h" +class cSatipDiscoverServer : public cListObject { +private: + cString ipAddressM; + cString descriptionM; + cString modelM; +public: + cSatipDiscoverServer(const char *ipAddressP, const char *descriptionP, const char *modelP) + { + ipAddressM = ipAddressP; descriptionM = descriptionP; modelM = modelP; + } + const char *IpAddress(void) { return *ipAddressM; } + const char *Description(void) { return *descriptionM; } + const char *Model(void) { return *modelM; } +}; + +class cSatipDiscoverServers : public cList { +}; + class cSatipDiscover : public cThread { private: enum { @@ -52,7 +70,7 @@ protected: public: static cSatipDiscover *GetInstance(void); - static bool Initialize(const char *serverAddrP, const char *serverDescriptionP, const char *serverModelP); + static bool Initialize(cSatipDiscoverServers *serversP); static void Destroy(void); virtual ~cSatipDiscover(); void TriggerScan(void) { probeIntervalM.Set(0); } diff --git a/satip.c b/satip.c index 649fbae..a84cf11 100644 --- a/satip.c +++ b/satip.c @@ -31,9 +31,7 @@ static const char DESCRIPTION[] = trNOOP("SAT>IP Devices"); class cPluginSatip : public cPlugin { private: unsigned int deviceCountM; - cString serverAddrM; - cString serverDescriptionM; - cString serverModelM; + cSatipDiscoverServers *serversM; void ParseServer(const char *paramP); int ParseSources(const char *valueP, int *sourcesP); int ParseFilters(const char *valueP, int *filtersP); @@ -62,9 +60,7 @@ public: cPluginSatip::cPluginSatip(void) : deviceCountM(1), - serverAddrM(), - serverDescriptionM(), - serverModelM() + serversM(NULL) { //debug("cPluginSatip::%s()", __FUNCTION__); // Initialize any member variables here. @@ -82,8 +78,9 @@ const char *cPluginSatip::CommandLineHelp(void) { debug("cPluginSatip::%s()", __FUNCTION__); // Return a string that describes all known command line options. - return " -d , --devices= number of devices to be created\n" - " -s ;;, --server=;; use a hard-coded SAT>IP server\n"; + return " -d , --devices= set number of devices to be created\n" + " -s ||, --server=||;||\n" + " define hard-coded SAT>IP server(s)\n"; } bool cPluginSatip::ProcessArgs(int argc, char *argv[]) @@ -119,7 +116,7 @@ bool cPluginSatip::Initialize(void) if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) error("Unable to initialize CURL"); SatipConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); - cSatipDiscover::GetInstance()->Initialize(*serverAddrM, *serverDescriptionM, *serverModelM); + cSatipDiscover::GetInstance()->Initialize(serversM); return cSatipDevice::Initialize(deviceCountM); } @@ -196,23 +193,37 @@ void cPluginSatip::ParseServer(const char *paramP) char *r = strtok_r(p, ";", &s); while (r) { r = skipspace(r); - //debug("cPluginSatip::%s(): serverparam[%d]=%s", __FUNCTION__, n, r); - switch (n++) { - case 0: - serverAddrM = r; - break; - case 1: - serverModelM = r; - break; - case 2: - serverDescriptionM = r; - break; - default: - break; - } + //debug("cPluginSatip::%s(): server[%d]=%s", __FUNCTION__, n, r); + cString serverAddr, serverModel, serverDescription; + int n2 = 0; + char *s2, *p2 = r; + char *r2 = strtok_r(p2, "|", &s2); + while (r2) { + //debug("cPluginSatip::%s(): param[%d]=%s", __FUNCTION__, n2, r2); + switch (n2++) { + case 0: + serverAddr = r2; + break; + case 1: + serverModel = r2; + break; + case 2: + serverDescription = r2; + break; + default: + break; + } + r2 = strtok_r(NULL, "|", &s2); + } + if (*serverAddr && *serverModel && *serverDescription) { + debug("cPluginSatip::%s(): ipaddr=%s model=%s desc=%s", __FUNCTION__, *serverAddr, *serverModel, *serverDescription); + if (!serversM) + serversM = new cSatipDiscoverServers(); + serversM->Add(new cSatipDiscoverServer(*serverAddr, *serverDescription, *serverModel)); + } + ++n; r = strtok_r(NULL, ";", &s); } - //debug("cPluginSatip::%s(): ipaddr=%s model=%s desc=%s", __FUNCTION__, *serverAddrM, *serverModelM, *serverDescriptionM); } int cPluginSatip::ParseSources(const char *valueP, int *sourcesP)