1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Added support for defining multiple SAT>IP servers via the command-line switch.

This commit is contained in:
Rolf Ahrenberg 2014-11-04 22:32:12 +02:00
parent aeb8f24474
commit 18ca0beaa7
5 changed files with 63 additions and 32 deletions

View File

@ -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.

2
README
View File

@ -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

View File

@ -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();
}

View File

@ -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<cSatipDiscoverServer> {
};
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); }

41
satip.c
View File

@ -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 <num>, --devices=<number> number of devices to be created\n"
" -s <ipaddr>;<model>;<desc>, --server=<ipaddr>;<model>;<desc> use a hard-coded SAT>IP server\n";
return " -d <num>, --devices=<number> set number of devices to be created\n"
" -s <ipaddr>|<model>|<desc>, --server=<ipaddr1>|<model1>|<desc1>;<ipaddr2>|<model2>|<desc2>\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++) {
//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:
serverAddrM = r;
serverAddr = r2;
break;
case 1:
serverModelM = r;
serverModel = r2;
break;
case 2:
serverDescriptionM = r;
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)