mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Add support for source filtering.
This commit is contained in:
parent
13a6b5938f
commit
c2fe2b748d
3
README
3
README
@ -52,9 +52,10 @@ separated list of "<ipaddress>|<model>|<description>" entries. The model
|
|||||||
consists of a DVB system (DVBS2,DVBT2,DVBT,DVBC) and number of available
|
consists of a DVB system (DVBS2,DVBT2,DVBT,DVBC) and number of available
|
||||||
frontends separated by a hyphen:
|
frontends separated by a hyphen:
|
||||||
|
|
||||||
vdr -P 'satip -s <ipaddress>|<model>|<description>;...'
|
vdr -P 'satip -s <ipaddress>[:<port>]|<model>[:<filter>]|<description>;...'
|
||||||
vdr -P 'satip -s 192.168.0.1|DVBS2-2,DVBT2-2|OctopusNet'
|
vdr -P 'satip -s 192.168.0.1|DVBS2-2,DVBT2-2|OctopusNet'
|
||||||
vdr -P 'satip -s 192.168.0.1|DVBS2-4|OctopusNet;192.168.0.2|DVBT2-4|minisatip'
|
vdr -P 'satip -s 192.168.0.1|DVBS2-4|OctopusNet;192.168.0.2|DVBT2-4|minisatip'
|
||||||
|
vdr -P 'satip -s 192.168.0.1:554|DVBS2-2:S19.2E|OctopusNet;192.168.0.2:8554|DVBS2-4:S19.2E,S1W|minisatip'
|
||||||
|
|
||||||
The plugin accepts a "--portrange" (-p) command-line parameter, that can
|
The plugin accepts a "--portrange" (-p) command-line parameter, that can
|
||||||
be used to manually specify the RTP & RTCP port range and therefore
|
be used to manually specify the RTP & RTCP port range and therefore
|
||||||
|
16
discover.c
16
discover.c
@ -32,7 +32,7 @@ bool cSatipDiscover::Initialize(cSatipDiscoverServers *serversP)
|
|||||||
if (instanceS) {
|
if (instanceS) {
|
||||||
if (serversP) {
|
if (serversP) {
|
||||||
for (cSatipDiscoverServer *s = serversP->First(); s; s = serversP->Next(s))
|
for (cSatipDiscoverServer *s = serversP->First(); s; s = serversP->Next(s))
|
||||||
instanceS->AddServer(s->IpAddress(), s->IpPort(), s->Model(), s->Description());
|
instanceS->AddServer(s->IpAddress(), s->IpPort(), s->Model(), s->Filters(), s->Description());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
instanceS->Activate();
|
instanceS->Activate();
|
||||||
@ -271,12 +271,12 @@ void cSatipDiscover::ParseDeviceInfo(const char *addrP, const int portP)
|
|||||||
model = modelNode.text().as_string("DVBS2-1");
|
model = modelNode.text().as_string("DVBS2-1");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
AddServer(addrP, portP, model, desc);
|
AddServer(addrP, portP, model, NULL, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *modelP, const char * descP)
|
void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP)
|
||||||
{
|
{
|
||||||
debug1("%s (%s, %d, %s, %s)", __PRETTY_FUNCTION__, addrP, portP, modelP, descP);
|
debug1("%s (%s, %d, %s, %s, %s)", __PRETTY_FUNCTION__, addrP, portP, modelP, filtersP, descP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (SatipConfig.GetUseSingleModelServers() && modelP && !isempty(modelP)) {
|
if (SatipConfig.GetUseSingleModelServers() && modelP && !isempty(modelP)) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -285,9 +285,9 @@ void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *m
|
|||||||
while (r) {
|
while (r) {
|
||||||
r = skipspace(r);
|
r = skipspace(r);
|
||||||
cString desc = cString::sprintf("%s #%d", !isempty(descP) ? descP : "MyBrokenHardware", n++);
|
cString desc = cString::sprintf("%s #%d", !isempty(descP) ? descP : "MyBrokenHardware", n++);
|
||||||
cSatipServer *tmp = new cSatipServer(addrP, portP, r, desc);
|
cSatipServer *tmp = new cSatipServer(addrP, portP, r, filtersP, desc);
|
||||||
if (!serversM.Update(tmp)) {
|
if (!serversM.Update(tmp)) {
|
||||||
info("Adding server '%s|%s|%s' CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
|
info("Adding server '%s|%s|%s' Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
|
||||||
serversM.Add(tmp);
|
serversM.Add(tmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -297,9 +297,9 @@ void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *m
|
|||||||
FREE_POINTER(p);
|
FREE_POINTER(p);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cSatipServer *tmp = new cSatipServer(addrP, portP, modelP, descP);
|
cSatipServer *tmp = new cSatipServer(addrP, portP, modelP, filtersP, descP);
|
||||||
if (!serversM.Update(tmp)) {
|
if (!serversM.Update(tmp)) {
|
||||||
info("Adding server '%s|%s|%s' CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
|
info("Adding server '%s|%s|%s' Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
|
||||||
serversM.Add(tmp);
|
serversM.Add(tmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -25,14 +25,16 @@ private:
|
|||||||
cString ipAddressM;
|
cString ipAddressM;
|
||||||
cString descriptionM;
|
cString descriptionM;
|
||||||
cString modelM;
|
cString modelM;
|
||||||
|
cString filtersM;
|
||||||
public:
|
public:
|
||||||
cSatipDiscoverServer(const char *ipAddressP, const int ipPortP, const char *modelP, const char *descriptionP)
|
cSatipDiscoverServer(const char *ipAddressP, const int ipPortP, const char *modelP, const char *filtersP, const char *descriptionP)
|
||||||
{
|
{
|
||||||
ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; descriptionM = descriptionP;
|
ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; filtersM = filtersP; descriptionM = descriptionP;
|
||||||
}
|
}
|
||||||
int IpPort(void) { return ipPortM; }
|
int IpPort(void) { return ipPortM; }
|
||||||
const char *IpAddress(void) { return *ipAddressM; }
|
const char *IpAddress(void) { return *ipAddressM; }
|
||||||
const char *Model(void) { return *modelM; }
|
const char *Model(void) { return *modelM; }
|
||||||
|
const char *Filters(void) { return *filtersM; }
|
||||||
const char *Description(void) { return *descriptionM; }
|
const char *Description(void) { return *descriptionM; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ private:
|
|||||||
void Deactivate(void);
|
void Deactivate(void);
|
||||||
int ParseRtspPort(void);
|
int ParseRtspPort(void);
|
||||||
void ParseDeviceInfo(const char *addrP, const int portP);
|
void ParseDeviceInfo(const char *addrP, const int portP);
|
||||||
void AddServer(const char *addrP, const int portP, const char *modelP, const char *descP);
|
void AddServer(const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP);
|
||||||
void Fetch(const char *urlP);
|
void Fetch(const char *urlP);
|
||||||
// constructor
|
// constructor
|
||||||
cSatipDiscover();
|
cSatipDiscover();
|
||||||
|
15
satip.c
15
satip.c
@ -84,7 +84,7 @@ const char *cPluginSatip::CommandLineHelp(void)
|
|||||||
// Return a string that describes all known command line options.
|
// Return a string that describes all known command line options.
|
||||||
return " -d <num>, --devices=<number> set number of devices to be created\n"
|
return " -d <num>, --devices=<number> set number of devices to be created\n"
|
||||||
" -t <mode>, --trace=<mode> set the tracing mode\n"
|
" -t <mode>, --trace=<mode> set the tracing mode\n"
|
||||||
" -s <ipaddr>|<model>|<desc>, --server=<ipaddr1>|<model1>|<desc1>;<ipaddr2:port>|<model2>|<desc2>\n"
|
" -s <ipaddr>|<model>|<desc>, --server=<ipaddr1>|<model1>|<desc1>;<ipaddr2>:<port>|<model2>:<filter>|<desc2>\n"
|
||||||
" define hard-coded SAT>IP server(s)\n"
|
" define hard-coded SAT>IP server(s)\n"
|
||||||
" -D, --detach set the detached mode on\n"
|
" -D, --detach set the detached mode on\n"
|
||||||
" -S, --single set the single model server mode on\n"
|
" -S, --single set the single model server mode on\n"
|
||||||
@ -232,7 +232,7 @@ void cPluginSatip::ParseServer(const char *paramP)
|
|||||||
while (r) {
|
while (r) {
|
||||||
r = skipspace(r);
|
r = skipspace(r);
|
||||||
debug3("%s server[%d]=%s", __PRETTY_FUNCTION__, n, r);
|
debug3("%s server[%d]=%s", __PRETTY_FUNCTION__, n, r);
|
||||||
cString serverAddr, serverModel, serverDescription;
|
cString serverAddr, serverModel, serverFilters, serverDescription;
|
||||||
int serverPort = SATIP_DEFAULT_RTSP_PORT;
|
int serverPort = SATIP_DEFAULT_RTSP_PORT;
|
||||||
int n2 = 0;
|
int n2 = 0;
|
||||||
char *s2, *p2 = r;
|
char *s2, *p2 = r;
|
||||||
@ -251,7 +251,14 @@ void cPluginSatip::ParseServer(const char *paramP)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
{
|
||||||
serverModel = r2;
|
serverModel = r2;
|
||||||
|
char *r3 = strchr(r2, ':');
|
||||||
|
if (r3) {
|
||||||
|
serverFilters = r3 + 1;
|
||||||
|
serverModel = serverModel.Truncate(r3 - r2);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
serverDescription = r2;
|
serverDescription = r2;
|
||||||
@ -262,10 +269,10 @@ void cPluginSatip::ParseServer(const char *paramP)
|
|||||||
r2 = strtok_r(NULL, "|", &s2);
|
r2 = strtok_r(NULL, "|", &s2);
|
||||||
}
|
}
|
||||||
if (*serverAddr && *serverModel && *serverDescription) {
|
if (*serverAddr && *serverModel && *serverDescription) {
|
||||||
debug1("%s ipaddr=%s port=%d model=%s desc=%s", __PRETTY_FUNCTION__, *serverAddr, serverPort, *serverModel, *serverDescription);
|
debug1("%s ipaddr=%s port=%d model=%s (%s) desc=%s", __PRETTY_FUNCTION__, *serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription);
|
||||||
if (!serversM)
|
if (!serversM)
|
||||||
serversM = new cSatipDiscoverServers();
|
serversM = new cSatipDiscoverServers();
|
||||||
serversM->Add(new cSatipDiscoverServer(*serverAddr, serverPort, *serverModel, *serverDescription));
|
serversM->Add(new cSatipDiscoverServer(*serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription));
|
||||||
}
|
}
|
||||||
++n;
|
++n;
|
||||||
r = strtok_r(NULL, ";", &s);
|
r = strtok_r(NULL, ";", &s);
|
||||||
|
41
server.c
41
server.c
@ -80,9 +80,10 @@ bool cSatipFrontends::Detach(int deviceIdP, int transponderP)
|
|||||||
|
|
||||||
// --- cSatipServer -----------------------------------------------------------
|
// --- cSatipServer -----------------------------------------------------------
|
||||||
|
|
||||||
cSatipServer::cSatipServer(const char *addressP, const int portP, const char *modelP, const char *descriptionP)
|
cSatipServer::cSatipServer(const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP)
|
||||||
: addressM((addressP && *addressP) ? addressP : "0.0.0.0"),
|
: addressM((addressP && *addressP) ? addressP : "0.0.0.0"),
|
||||||
modelM((modelP && *modelP) ? modelP : "DVBS-1"),
|
modelM((modelP && *modelP) ? modelP : "DVBS-1"),
|
||||||
|
filtersM((filtersP && *filtersP) ? filtersP : ""),
|
||||||
descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"),
|
descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"),
|
||||||
quirksM(""),
|
quirksM(""),
|
||||||
portM(portP),
|
portM(portP),
|
||||||
@ -92,6 +93,25 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo
|
|||||||
createdM(time(NULL)),
|
createdM(time(NULL)),
|
||||||
lastSeenM(0)
|
lastSeenM(0)
|
||||||
{
|
{
|
||||||
|
memset(sourceFiltersM, 0, sizeof(sourceFiltersM));
|
||||||
|
if (!isempty(*filtersM)) {
|
||||||
|
char *s, *p = strdup(*filtersM);
|
||||||
|
char *r = strtok_r(p, ",", &s);
|
||||||
|
unsigned int i = 0;
|
||||||
|
while (r) {
|
||||||
|
int t = cSource::FromString(skipspace(r));
|
||||||
|
if (t && i < ELEMENTS(sourceFiltersM))
|
||||||
|
sourceFiltersM[i++] = t;
|
||||||
|
r = strtok_r(NULL, ",", &s);
|
||||||
|
}
|
||||||
|
if (i) {
|
||||||
|
filtersM = "";
|
||||||
|
for (unsigned int j = 0; j < i; ++j)
|
||||||
|
filtersM = cString::sprintf("%s%s%s", *filtersM, isempty(*filtersM) ? "" : ",", *cSource::ToString(sourceFiltersM[j]));
|
||||||
|
debug3("%s filters=%s", __PRETTY_FUNCTION__, *filtersM);
|
||||||
|
}
|
||||||
|
FREE_POINTER(p);
|
||||||
|
}
|
||||||
if (!SatipConfig.GetDisableServerQuirks()) {
|
if (!SatipConfig.GetDisableServerQuirks()) {
|
||||||
// These devices contain a session id bug:
|
// These devices contain a session id bug:
|
||||||
// Inverto Airscreen Server IDL 400 ?
|
// Inverto Airscreen Server IDL 400 ?
|
||||||
@ -165,7 +185,7 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo
|
|||||||
}
|
}
|
||||||
r = strtok_r(NULL, ",", &s);
|
r = strtok_r(NULL, ",", &s);
|
||||||
}
|
}
|
||||||
free(p);
|
FREE_POINTER(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
cSatipServer::~cSatipServer()
|
cSatipServer::~cSatipServer()
|
||||||
@ -204,20 +224,36 @@ bool cSatipServer::Assign(int deviceIdP, int sourceP, int systemP, int transpond
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cSatipServer::IsValidSource(int sourceP)
|
||||||
|
{
|
||||||
|
if (sourceFiltersM[0]) {
|
||||||
|
for (unsigned int i = 0; i < ELEMENTS(sourceFiltersM); ++i) {
|
||||||
|
if (sourceP == sourceFiltersM[i]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool cSatipServer::Matches(int sourceP)
|
bool cSatipServer::Matches(int sourceP)
|
||||||
{
|
{
|
||||||
|
if (IsValidSource(sourceP)) {
|
||||||
if (cSource::IsType(sourceP, 'S'))
|
if (cSource::IsType(sourceP, 'S'))
|
||||||
return GetModulesDVBS2();
|
return GetModulesDVBS2();
|
||||||
else if (cSource::IsType(sourceP, 'T'))
|
else if (cSource::IsType(sourceP, 'T'))
|
||||||
return GetModulesDVBT() || GetModulesDVBT2();
|
return GetModulesDVBT() || GetModulesDVBT2();
|
||||||
else if (cSource::IsType(sourceP, 'C'))
|
else if (cSource::IsType(sourceP, 'C'))
|
||||||
return GetModulesDVBC() || GetModulesDVBC2();
|
return GetModulesDVBC() || GetModulesDVBC2();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipServer::Matches(int deviceIdP, int sourceP, int systemP, int transponderP)
|
bool cSatipServer::Matches(int deviceIdP, int sourceP, int systemP, int transponderP)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
if (IsValidSource(sourceP)) {
|
||||||
if (cSource::IsType(sourceP, 'S'))
|
if (cSource::IsType(sourceP, 'S'))
|
||||||
result = frontendsM[eSatipFrontendDVBS2].Matches(deviceIdP, transponderP);
|
result = frontendsM[eSatipFrontendDVBS2].Matches(deviceIdP, transponderP);
|
||||||
else if (cSource::IsType(sourceP, 'T')) {
|
else if (cSource::IsType(sourceP, 'T')) {
|
||||||
@ -232,6 +268,7 @@ bool cSatipServer::Matches(int deviceIdP, int sourceP, int systemP, int transpon
|
|||||||
else
|
else
|
||||||
result = frontendsM[eSatipFrontendDVBC].Matches(deviceIdP, transponderP) || frontendsM[eSatipFrontendDVBC2].Matches(deviceIdP, transponderP);
|
result = frontendsM[eSatipFrontendDVBC].Matches(deviceIdP, transponderP) || frontendsM[eSatipFrontendDVBC2].Matches(deviceIdP, transponderP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
server.h
9
server.h
@ -54,17 +54,23 @@ private:
|
|||||||
eSatipFrontendDVBC2,
|
eSatipFrontendDVBC2,
|
||||||
eSatipFrontendCount
|
eSatipFrontendCount
|
||||||
};
|
};
|
||||||
|
enum {
|
||||||
|
eSatipMaxSourceFilters = 16
|
||||||
|
};
|
||||||
cString addressM;
|
cString addressM;
|
||||||
cString modelM;
|
cString modelM;
|
||||||
|
cString filtersM;
|
||||||
cString descriptionM;
|
cString descriptionM;
|
||||||
cString quirksM;
|
cString quirksM;
|
||||||
cSatipFrontends frontendsM[eSatipFrontendCount];
|
cSatipFrontends frontendsM[eSatipFrontendCount];
|
||||||
|
int sourceFiltersM[eSatipMaxSourceFilters];
|
||||||
int portM;
|
int portM;
|
||||||
int quirkM;
|
int quirkM;
|
||||||
bool hasCiM;
|
bool hasCiM;
|
||||||
bool activeM;
|
bool activeM;
|
||||||
time_t createdM;
|
time_t createdM;
|
||||||
cTimeMs lastSeenM;
|
cTimeMs lastSeenM;
|
||||||
|
bool IsValidSource(int sourceP);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum eSatipQuirk {
|
enum eSatipQuirk {
|
||||||
@ -75,7 +81,7 @@ public:
|
|||||||
eSatipQuirkRtpOverTcp = 0x08,
|
eSatipQuirkRtpOverTcp = 0x08,
|
||||||
eSatipQuirkMask = 0x0F
|
eSatipQuirkMask = 0x0F
|
||||||
};
|
};
|
||||||
cSatipServer(const char *addressP, const int portP, const char *modelP, const char *descriptionP);
|
cSatipServer(const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP);
|
||||||
virtual ~cSatipServer();
|
virtual ~cSatipServer();
|
||||||
virtual int Compare(const cListObject &listObjectP) const;
|
virtual int Compare(const cListObject &listObjectP) const;
|
||||||
bool Assign(int deviceIdP, int sourceP, int systemP, int transponderP);
|
bool Assign(int deviceIdP, int sourceP, int systemP, int transponderP);
|
||||||
@ -91,6 +97,7 @@ public:
|
|||||||
void Activate(bool onOffP) { activeM = onOffP; }
|
void Activate(bool onOffP) { activeM = onOffP; }
|
||||||
const char *Address(void) { return *addressM; }
|
const char *Address(void) { return *addressM; }
|
||||||
const char *Model(void) { return *modelM; }
|
const char *Model(void) { return *modelM; }
|
||||||
|
const char *Filters(void) { return *filtersM; }
|
||||||
const char *Description(void) { return *descriptionM; }
|
const char *Description(void) { return *descriptionM; }
|
||||||
const char *Quirks(void) { return *quirksM; }
|
const char *Quirks(void) { return *quirksM; }
|
||||||
int Port(void) { return portM; }
|
int Port(void) { return portM; }
|
||||||
|
Loading…
Reference in New Issue
Block a user