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

Changed SATIP_USE_SINGLE_MODEL_SERVERS_ONLY into a command-line switch.

This commit is contained in:
Rolf Ahrenberg 2015-01-15 19:27:02 +02:00
parent fb7a7fe3a2
commit c9abfddf11
5 changed files with 37 additions and 32 deletions

View File

@ -14,10 +14,6 @@
#SATIP_XCI = 1
# Split any mixed model server into several single ones
#SATIP_USE_SINGLE_MODEL_SERVERS_ONLY = 1
# Strip debug symbols? Set eg. to /bin/true if not
STRIP = strip

View File

@ -16,7 +16,8 @@ cSatipConfig::cSatipConfig(void)
traceModeM(eTraceModeNormal),
ciExtensionM(0),
eitScanM(1),
useBytesM(1)
useBytesM(1),
useSingleModelServersM(false)
{
for (unsigned int i = 0; i < ELEMENTS(cicamsM); ++i)
cicamsM[i] = 0;

View File

@ -19,6 +19,7 @@ private:
unsigned int ciExtensionM;
unsigned int eitScanM;
unsigned int useBytesM;
bool useSingleModelServersM;
int cicamsM[MAX_CICAM_COUNT];
int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT];
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE];
@ -64,6 +65,7 @@ public:
int GetCICAM(unsigned int indexP) const;
unsigned int GetEITScan(void) const { return eitScanM; }
unsigned int GetUseBytes(void) const { return useBytesM; }
bool GetUseSingleModelServers(void) const { return useSingleModelServersM; }
unsigned int GetDisabledSourcesCount(void) const;
int GetDisabledSources(unsigned int indexP) const;
unsigned int GetDisabledFiltersCount(void) const;
@ -75,6 +77,7 @@ public:
void SetCICAM(unsigned int indexP, int cicamP);
void SetEITScan(unsigned int onOffP) { eitScanM = onOffP; }
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
void SetUseSingleModelServers(bool onOffP) { useSingleModelServersM = onOffP; }
void SetDisabledSources(unsigned int indexP, int sourceP);
void SetDisabledFilters(unsigned int indexP, int numberP);
};

View File

@ -233,33 +233,33 @@ void cSatipDiscover::AddServer(const char *addrP, const char *modelP, const char
{
debug1("%s (%s, %s, %s)", __PRETTY_FUNCTION__, addrP, modelP, descP);
cMutexLock MutexLock(&mutexM);
#ifdef USE_SINGLE_MODEL_SERVERS_ONLY
int n = 0;
char *s, *p = strdup(modelP);
char *r = strtok_r(p, ",", &s);
while (r) {
r = skipspace(r);
cString desc = cString::sprintf("%s #%d", descP, n++);
cSatipServer *tmp = new cSatipServer(addrP, r, desc);
if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s'", tmp->Address(), tmp->Model(), tmp->Description());
serversM.Add(tmp);
if (SatipConfig.GetUseSingleModelServers()) {
int n = 0;
char *s, *p = strdup(modelP);
char *r = strtok_r(p, ",", &s);
while (r) {
r = skipspace(r);
cString desc = cString::sprintf("%s #%d", descP, n++);
cSatipServer *tmp = new cSatipServer(addrP, r, desc);
if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s'", tmp->Address(), tmp->Model(), tmp->Description());
serversM.Add(tmp);
}
else
DELETENULL(tmp);
r = strtok_r(NULL, ",\n", &s);
}
else
DELETENULL(tmp);
r = strtok_r(NULL, ",\n", &s);
}
FREE_POINTER(p);
#else
cSatipServer *tmp = new cSatipServer(addrP, modelP, descP);
// Validate against existing servers
if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s'", tmp->Address(), tmp->Model(), tmp->Description());
serversM.Add(tmp);
FREE_POINTER(p);
}
else {
cSatipServer *tmp = new cSatipServer(addrP, modelP, descP);
if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s'", tmp->Address(), tmp->Model(), tmp->Description());
serversM.Add(tmp);
}
else
DELETENULL(tmp);
}
else
DELETENULL(tmp);
#endif
}
int cSatipDiscover::GetServerCount(void)

View File

@ -84,7 +84,8 @@ const char *cPluginSatip::CommandLineHelp(void)
return " -d <num>, --devices=<number> set number of devices to be created\n"
" -t <mode>, --trace=<mode> set the tracing mode\n"
" -s <ipaddr>|<model>|<desc>, --server=<ipaddr1>|<model1>|<desc1>;<ipaddr2>|<model2>|<desc2>\n"
" define hard-coded SAT>IP server(s)\n";
" define hard-coded SAT>IP server(s)"
" -S, --single set the single model server mode on/off\n";
}
bool cPluginSatip::ProcessArgs(int argc, char *argv[])
@ -95,11 +96,12 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
{ "devices", required_argument, NULL, 'd' },
{ "trace", required_argument, NULL, 't' },
{ "server", required_argument, NULL, 's' },
{ "single", no_argument, NULL, 'S' },
{ NULL, no_argument, NULL, 0 }
};
int c;
while ((c = getopt_long(argc, argv, "d:t:s:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "d:t:s:S", long_options, NULL)) != -1) {
switch (c) {
case 'd':
deviceCountM = strtol(optarg, NULL, 0);
@ -110,6 +112,9 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
case 's':
ParseServer(optarg);
break;
case 'S':
SatipConfig.SetUseSingleModelServers(true);
break;
default:
return false;
}