mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 11:37:42 +00:00
Refactored the frontend handling.
This commit is contained in:
parent
26be862d89
commit
a87dfc43f7
7
device.c
7
device.c
@ -328,20 +328,19 @@ bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cString address;
|
cString address;
|
||||||
cSatipServer *server = cSatipDiscover::GetInstance()->GetServer(channelP->Source(), channelP->Transponder(), dtp.System());
|
cSatipServer *server = cSatipDiscover::GetInstance()->AssignServer(channelP->Source(), channelP->Transponder(), dtp.System());
|
||||||
if (!server) {
|
if (!server) {
|
||||||
debug9("%s No suitable server found [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
|
debug9("%s No suitable server found [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cSatipDiscover::GetInstance()->SetTransponder(server, channelP->Transponder());
|
if (pTunerM && pTunerM->SetSource(server, channelP->Transponder(), *params, deviceIndexM)) {
|
||||||
if (pTunerM && pTunerM->SetSource(server, *params, deviceIndexM)) {
|
|
||||||
channelM = *channelP;
|
channelM = *channelP;
|
||||||
deviceNameM = cString::sprintf("%s %d %s", *DeviceType(), deviceIndexM, *cSatipDiscover::GetInstance()->GetServerString(server));
|
deviceNameM = cString::sprintf("%s %d %s", *DeviceType(), deviceIndexM, *cSatipDiscover::GetInstance()->GetServerString(server));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pTunerM) {
|
else if (pTunerM) {
|
||||||
pTunerM->SetSource(NULL, NULL, deviceIndexM);
|
pTunerM->SetSource(NULL, 0, NULL, deviceIndexM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
30
discover.c
30
discover.c
@ -269,11 +269,18 @@ int cSatipDiscover::GetServerCount(void)
|
|||||||
return serversM.Count();
|
return serversM.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
cSatipServer *cSatipDiscover::GetServer(int sourceP, int transponderP, int systemP)
|
cSatipServer *cSatipDiscover::AssignServer(int sourceP, int transponderP, int systemP)
|
||||||
{
|
{
|
||||||
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, sourceP, transponderP, systemP);
|
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, sourceP, transponderP, systemP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
return serversM.Find(sourceP, transponderP, systemP);
|
return serversM.Assign(sourceP, transponderP, systemP);
|
||||||
|
}
|
||||||
|
|
||||||
|
cSatipServer *cSatipDiscover::GetServer(int sourceP)
|
||||||
|
{
|
||||||
|
debug16("%s (%d)", __PRETTY_FUNCTION__, sourceP);
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
return serversM.Find(sourceP);
|
||||||
}
|
}
|
||||||
|
|
||||||
cSatipServer *cSatipDiscover::GetServer(cSatipServer *serverP)
|
cSatipServer *cSatipDiscover::GetServer(cSatipServer *serverP)
|
||||||
@ -304,18 +311,25 @@ cString cSatipDiscover::GetServerList(void)
|
|||||||
return serversM.List();
|
return serversM.List();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipDiscover::SetTransponder(cSatipServer *serverP, int transponderP)
|
void cSatipDiscover::UseServer(cSatipServer *serverP, int transponderP, bool onOffP)
|
||||||
{
|
{
|
||||||
debug16("%s (, %d)", __PRETTY_FUNCTION__, transponderP);
|
debug16("%s (, %d, %d)", __PRETTY_FUNCTION__, transponderP, onOffP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
serversM.SetTransponder(serverP, transponderP);
|
serversM.Use(serverP, transponderP, onOffP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipDiscover::UseServer(cSatipServer *serverP, bool onOffP)
|
bool cSatipDiscover::IsServerQuirk(cSatipServer *serverP, int quirkP)
|
||||||
{
|
{
|
||||||
debug16("%s (, %d)", __PRETTY_FUNCTION__, onOffP);
|
debug16("%s (, %d)", __PRETTY_FUNCTION__, quirkP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
serversM.Use(serverP, onOffP);
|
return serversM.IsQuirk(serverP, quirkP);
|
||||||
|
}
|
||||||
|
|
||||||
|
cString cSatipDiscover::GetServerAddress(cSatipServer *serverP)
|
||||||
|
{
|
||||||
|
debug16("%s", __PRETTY_FUNCTION__);
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
return serversM.GetAddress(serverP);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cSatipDiscover::NumProvidedSystems(void)
|
int cSatipDiscover::NumProvidedSystems(void)
|
||||||
|
@ -74,12 +74,14 @@ public:
|
|||||||
virtual ~cSatipDiscover();
|
virtual ~cSatipDiscover();
|
||||||
void TriggerScan(void) { probeIntervalM.Set(0); }
|
void TriggerScan(void) { probeIntervalM.Set(0); }
|
||||||
int GetServerCount(void);
|
int GetServerCount(void);
|
||||||
cSatipServer *GetServer(int sourceP, int transponderP = 0, int systemP = -1);
|
cSatipServer *AssignServer(int sourceP, int transponderP, int systemP);
|
||||||
|
cSatipServer *GetServer(int sourceP);
|
||||||
cSatipServer *GetServer(cSatipServer *serverP);
|
cSatipServer *GetServer(cSatipServer *serverP);
|
||||||
cSatipServers *GetServers(void);
|
cSatipServers *GetServers(void);
|
||||||
cString GetServerString(cSatipServer *serverP);
|
cString GetServerString(cSatipServer *serverP);
|
||||||
void SetTransponder(cSatipServer *serverP, int transponderP);
|
void UseServer(cSatipServer *serverP, int transponderP, bool onOffP);
|
||||||
void UseServer(cSatipServer *serverP, bool onOffP);
|
bool IsServerQuirk(cSatipServer *serverP, int quirkP);
|
||||||
|
cString GetServerAddress(cSatipServer *serverP);
|
||||||
cString GetServerList(void);
|
cString GetServerList(void);
|
||||||
int NumProvidedSystems(void);
|
int NumProvidedSystems(void);
|
||||||
|
|
||||||
|
274
server.c
274
server.c
@ -12,20 +12,70 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
|
// --- cSatipFrontend ---------------------------------------------------------
|
||||||
|
|
||||||
|
cSatipFrontend::cSatipFrontend(const int indexP, const char *descriptionP)
|
||||||
|
: indexM(indexP),
|
||||||
|
transponderM(0),
|
||||||
|
descriptionM(descriptionP),
|
||||||
|
usedM(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
cSatipFrontend::~cSatipFrontend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- cSatipFrontends --------------------------------------------------------
|
||||||
|
|
||||||
|
bool cSatipFrontends::Matches(int transponderP)
|
||||||
|
{
|
||||||
|
for (cSatipFrontend *f = First(); f; f = Next(f)) {
|
||||||
|
if (f->IsUsed() && (f->Transponder() == transponderP))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cSatipFrontends::Assign(int transponderP)
|
||||||
|
{
|
||||||
|
cSatipFrontend *tmp = First();
|
||||||
|
// Prefer any unused one
|
||||||
|
for (cSatipFrontend *f = First(); f; f = Next(f)) {
|
||||||
|
if (!f->IsUsed()) {
|
||||||
|
tmp = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tmp) {
|
||||||
|
tmp->SetTransponder(transponderP);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cSatipFrontends::Use(int transponderP, bool onOffP)
|
||||||
|
{
|
||||||
|
for (cSatipFrontend *f = First(); f; f = Next(f)) {
|
||||||
|
if (f->Transponder() == transponderP) {
|
||||||
|
f->Use(onOffP);
|
||||||
|
debug9("%s (%d, %d) %s/#%d", __PRETTY_FUNCTION__, transponderP, onOffP, *f->Description(), f->Index());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// --- cSatipServer -----------------------------------------------------------
|
// --- cSatipServer -----------------------------------------------------------
|
||||||
|
|
||||||
cSatipServer::cSatipServer(const char *addressP, const char *modelP, const char *descriptionP)
|
cSatipServer::cSatipServer(const char *addressP, const char *modelP, 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"),
|
||||||
descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"),
|
descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"),
|
||||||
modelTypeM(eSatipModelTypeNone),
|
|
||||||
quirkM(eSatipQuirkNone),
|
quirkM(eSatipQuirkNone),
|
||||||
useCountM(0),
|
|
||||||
transponderM(0),
|
|
||||||
createdM(time(NULL)),
|
createdM(time(NULL)),
|
||||||
lastSeenM(0)
|
lastSeenM(0)
|
||||||
{
|
{
|
||||||
memset(modelCountM, 0, sizeof(modelCountM));
|
|
||||||
if (!SatipConfig.GetDisableServerQuirks()) {
|
if (!SatipConfig.GetDisableServerQuirks()) {
|
||||||
debug3("%s quirks=%s", __PRETTY_FUNCTION__, *descriptionM);
|
debug3("%s quirks=%s", __PRETTY_FUNCTION__, *descriptionM);
|
||||||
// These devices contain a session id bug:
|
// These devices contain a session id bug:
|
||||||
@ -51,34 +101,31 @@ cSatipServer::cSatipServer(const char *addressP, const char *modelP, const char
|
|||||||
char *s, *p = strdup(*modelM);
|
char *s, *p = strdup(*modelM);
|
||||||
char *r = strtok_r(p, ",", &s);
|
char *r = strtok_r(p, ",", &s);
|
||||||
while (r) {
|
while (r) {
|
||||||
if (strstr(r, "DVBS2-")) {
|
char *c;
|
||||||
modelTypeM |= eSatipModelTypeDVBS2;
|
if (c = strstr(r, "DVBS2-")) {
|
||||||
if (char *c = strstr(r, "-"))
|
int count = atoi(c + 6);
|
||||||
modelCountM[eSatipModuleDVBS2] = atoi(++c);
|
for (int i = 1; i <= count; ++i)
|
||||||
|
frontendsM[eSatipFrontendDVBS2].Add(new cSatipFrontend(i, "DVB-S2"));
|
||||||
}
|
}
|
||||||
else if (strstr(r, "DVBT2-")) {
|
else if (c = strstr(r, "DVBT-")) {
|
||||||
modelTypeM |= eSatipModelTypeDVBT2;
|
int count = atoi(c + 5);
|
||||||
if (char *c = strstr(r, "-"))
|
for (int i = 1; i <= count; ++i)
|
||||||
modelCountM[eSatipModuleDVBT2] = atoi(++c);
|
frontendsM[eSatipFrontendDVBT].Add(new cSatipFrontend(i, "DVB-T"));
|
||||||
modelTypeM |= eSatipModelTypeDVBT;
|
|
||||||
modelCountM[eSatipModuleDVBT] = modelCountM[eSatipModuleDVBT2];
|
|
||||||
}
|
}
|
||||||
else if (strstr(r, "DVBT-")) {
|
else if (c = strstr(r, "DVBT2-")) {
|
||||||
modelTypeM |= eSatipModelTypeDVBT;
|
int count = atoi(c + 6);
|
||||||
if (char *c = strstr(r, "-"))
|
for (int i = 1; i <= count; ++i)
|
||||||
modelCountM[eSatipModuleDVBT] = atoi(++c);
|
frontendsM[eSatipFrontendDVBT2].Add(new cSatipFrontend(i, "DVB-T2"));
|
||||||
}
|
}
|
||||||
else if (strstr(r, "DVBC2-")) {
|
else if (c = strstr(r, "DVBC-")) {
|
||||||
modelTypeM |= eSatipModelTypeDVBC2;
|
int count = atoi(c + 5);
|
||||||
if (char *c = strstr(r, "-"))
|
for (int i = 1; i <= count; ++i)
|
||||||
modelCountM[eSatipModuleDVBC2] = atoi(++c);
|
frontendsM[eSatipFrontendDVBC].Add(new cSatipFrontend(i, "DVB-C"));
|
||||||
modelTypeM |= eSatipModelTypeDVBC;
|
|
||||||
modelCountM[eSatipModuleDVBC] = modelCountM[eSatipModuleDVBC2];
|
|
||||||
}
|
}
|
||||||
else if (strstr(r, "DVBC-")) {
|
else if (c = strstr(r, "DVBC2-")) {
|
||||||
modelTypeM |= eSatipModelTypeDVBC;
|
int count = atoi(c + 6);
|
||||||
if (char *c = strstr(r, "-"))
|
for (int i = 1; i <= count; ++i)
|
||||||
modelCountM[eSatipModuleDVBC] = atoi(++c);
|
frontendsM[eSatipFrontendDVBC2].Add(new cSatipFrontend(i, "DVB-C2"));
|
||||||
}
|
}
|
||||||
r = strtok_r(NULL, ",", &s);
|
r = strtok_r(NULL, ",", &s);
|
||||||
}
|
}
|
||||||
@ -101,12 +148,88 @@ int cSatipServer::Compare(const cListObject &listObjectP) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipServer::Use(bool onOffP)
|
bool cSatipServer::Assign(int sourceP, int systemP, int transponderP)
|
||||||
{
|
{
|
||||||
if (onOffP)
|
bool result = false;
|
||||||
++useCountM;
|
if (cSource::IsType(sourceP, 'S'))
|
||||||
|
result = frontendsM[eSatipFrontendDVBS2].Assign(transponderP);
|
||||||
|
else if (cSource::IsType(sourceP, 'T')) {
|
||||||
|
if (systemP)
|
||||||
|
result = frontendsM[eSatipFrontendDVBT2].Assign(transponderP);
|
||||||
else
|
else
|
||||||
--useCountM;
|
result = frontendsM[eSatipFrontendDVBT].Assign(transponderP) || frontendsM[eSatipFrontendDVBT2].Assign(transponderP);
|
||||||
|
}
|
||||||
|
else if (cSource::IsType(sourceP, 'C')) {
|
||||||
|
if (systemP)
|
||||||
|
result = frontendsM[eSatipFrontendDVBC2].Assign(transponderP);
|
||||||
|
else
|
||||||
|
result = frontendsM[eSatipFrontendDVBC].Assign(transponderP) || frontendsM[eSatipFrontendDVBC2].Assign(transponderP);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cSatipServer::Matches(int sourceP)
|
||||||
|
{
|
||||||
|
if (cSource::IsType(sourceP, 'S'))
|
||||||
|
return GetModulesDVBS2();
|
||||||
|
else if (cSource::IsType(sourceP, 'T'))
|
||||||
|
return GetModulesDVBT() || GetModulesDVBT2();
|
||||||
|
else if (cSource::IsType(sourceP, 'C'))
|
||||||
|
return GetModulesDVBC() || GetModulesDVBC2();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cSatipServer::Matches(int sourceP, int systemP, int transponderP)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (cSource::IsType(sourceP, 'S'))
|
||||||
|
result = frontendsM[eSatipFrontendDVBS2].Matches(transponderP);
|
||||||
|
else if (cSource::IsType(sourceP, 'T')) {
|
||||||
|
if (systemP)
|
||||||
|
result = frontendsM[eSatipFrontendDVBT2].Matches(transponderP);
|
||||||
|
else
|
||||||
|
result = frontendsM[eSatipFrontendDVBT].Matches(transponderP) || frontendsM[eSatipFrontendDVBT2].Matches(transponderP);
|
||||||
|
}
|
||||||
|
else if (cSource::IsType(sourceP, 'C')) {
|
||||||
|
if (systemP)
|
||||||
|
result = frontendsM[eSatipFrontendDVBC2].Matches(transponderP);
|
||||||
|
else
|
||||||
|
result = frontendsM[eSatipFrontendDVBC].Matches(transponderP) || frontendsM[eSatipFrontendDVBC2].Matches(transponderP);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSatipServer::Use(int transponderP, bool onOffP)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < eSatipFrontendCount; ++i) {
|
||||||
|
if (frontendsM[i].Use(transponderP, onOffP))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cSatipServer::GetModulesDVBS2(void)
|
||||||
|
{
|
||||||
|
return frontendsM[eSatipFrontendDVBS2].Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int cSatipServer::GetModulesDVBT(void)
|
||||||
|
{
|
||||||
|
return frontendsM[eSatipFrontendDVBT].Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int cSatipServer::GetModulesDVBT2(void)
|
||||||
|
{
|
||||||
|
return frontendsM[eSatipFrontendDVBT2].Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int cSatipServer::GetModulesDVBC(void)
|
||||||
|
{
|
||||||
|
return frontendsM[eSatipFrontendDVBC].Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int cSatipServer::GetModulesDVBC2(void)
|
||||||
|
{
|
||||||
|
return frontendsM[eSatipFrontendDVBC2].Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- cSatipServers ----------------------------------------------------------
|
// --- cSatipServers ----------------------------------------------------------
|
||||||
@ -114,49 +237,32 @@ void cSatipServer::Use(bool onOffP)
|
|||||||
cSatipServer *cSatipServers::Find(cSatipServer *serverP)
|
cSatipServer *cSatipServers::Find(cSatipServer *serverP)
|
||||||
{
|
{
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
if (s == serverP)
|
if (s->Compare(*serverP) == 0)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cSatipServer *cSatipServers::Find(int sourceP, int transponderP, int systemP)
|
cSatipServer *cSatipServers::Find(int sourceP)
|
||||||
{
|
{
|
||||||
cSatipServer *result = NULL;
|
|
||||||
int model = 0;
|
|
||||||
if (cSource::IsType(sourceP, 'S'))
|
|
||||||
model |= cSatipServer::eSatipModelTypeDVBS2;
|
|
||||||
else if (cSource::IsType(sourceP, 'T')) {
|
|
||||||
if (systemP < 0)
|
|
||||||
model |= cSatipServer::eSatipModelTypeDVBT2 | cSatipServer::eSatipModelTypeDVBT;
|
|
||||||
else
|
|
||||||
model |= systemP ? cSatipServer::eSatipModelTypeDVBT2 : cSatipServer::eSatipModelTypeDVBT;
|
|
||||||
}
|
|
||||||
else if (cSource::IsType(sourceP, 'C'))
|
|
||||||
model |= cSatipServer::eSatipModelTypeDVBC;
|
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
if (s->Match(model) && s->Used() && (s->Transponder() == transponderP))
|
if (s->Matches(sourceP))
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cSatipServer *cSatipServers::Assign(int sourceP, int transponderP, int systemP)
|
||||||
|
{
|
||||||
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
|
if (s->Matches(sourceP, systemP, transponderP))
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
if (s->Match(model)) {
|
if (s->Assign(sourceP, systemP, transponderP))
|
||||||
result = s;
|
return s;
|
||||||
if (!s->Used()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cSatipServers::SetTransponder(cSatipServer *serverP, int transponderP)
|
|
||||||
{
|
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
|
||||||
if (s == serverP) {
|
|
||||||
s->SetTransponder(transponderP);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cSatipServer *cSatipServers::Update(cSatipServer *serverP)
|
cSatipServer *cSatipServers::Update(cSatipServer *serverP)
|
||||||
@ -170,16 +276,28 @@ cSatipServer *cSatipServers::Update(cSatipServer *serverP)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipServers::Use(cSatipServer *serverP, bool onOffP)
|
void cSatipServers::Use(cSatipServer *serverP, int transponderP, bool onOffP)
|
||||||
{
|
{
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
if (s == serverP) {
|
if (s == serverP) {
|
||||||
s->Use(onOffP);
|
s->Use(transponderP, onOffP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cSatipServers::IsQuirk(cSatipServer *serverP, int quirkP)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
|
if (s == serverP) {
|
||||||
|
result = s->Quirk(quirkP);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void cSatipServers::Cleanup(uint64_t intervalMsP)
|
void cSatipServers::Cleanup(uint64_t intervalMsP)
|
||||||
{
|
{
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
@ -190,6 +308,18 @@ void cSatipServers::Cleanup(uint64_t intervalMsP)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cString cSatipServers::GetAddress(cSatipServer *serverP)
|
||||||
|
{
|
||||||
|
cString address = "";
|
||||||
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
|
if (s == serverP) {
|
||||||
|
address = s->Address();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
cString cSatipServers::GetString(cSatipServer *serverP)
|
cString cSatipServers::GetString(cSatipServer *serverP)
|
||||||
{
|
{
|
||||||
cString list = "";
|
cString list = "";
|
||||||
@ -215,13 +345,15 @@ int cSatipServers::NumProvidedSystems(void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
// DVB-S2: qpsk, 8psk, 16apsk, 32apsk
|
// DVB-S2: qpsk, 8psk, 16apsk, 32apsk
|
||||||
count += s->Satellite() * 4;
|
count += s->GetModulesDVBS2() * 4;
|
||||||
// DVB-T2: qpsk, qam16, qam64, qam256
|
|
||||||
// DVB-T: qpsk, qam16, qam64
|
// DVB-T: qpsk, qam16, qam64
|
||||||
count += s->Terrestrial2() ? s->Terrestrial2() * 4 : s->Terrestrial() * 3;
|
count += s->GetModulesDVBT() * 3;
|
||||||
// DVB-C2: qam16, qam32, qam64, qam128, qam256
|
// DVB-T2: qpsk, qam16, qam64, qam256
|
||||||
|
count += s->GetModulesDVBT2() * 4;
|
||||||
// DVB-C: qam64, qam128, qam256
|
// DVB-C: qam64, qam128, qam256
|
||||||
count += s->Cable2() ? s->Cable2() * 5 : s->Cable() * 3;
|
count += s->GetModulesDVBC() * 3;
|
||||||
|
// DVB-C2: qam16, qam32, qam64, qam128, qam256
|
||||||
|
count += s->GetModulesDVBC2() * 5;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
87
server.h
87
server.h
@ -8,26 +8,54 @@
|
|||||||
#ifndef __SATIP_SERVER_H
|
#ifndef __SATIP_SERVER_H
|
||||||
#define __SATIP_SERVER_H
|
#define __SATIP_SERVER_H
|
||||||
|
|
||||||
|
class cSatipServer;
|
||||||
|
|
||||||
|
// --- cSatipFrontend ---------------------------------------------------------
|
||||||
|
|
||||||
|
class cSatipFrontend : public cListObject {
|
||||||
|
private:
|
||||||
|
int indexM;
|
||||||
|
int transponderM;
|
||||||
|
cString descriptionM;
|
||||||
|
bool usedM;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cSatipFrontend(const int indexP, const char *descriptionP);
|
||||||
|
virtual ~cSatipFrontend();
|
||||||
|
void Use(bool onOffP) { usedM = onOffP; }
|
||||||
|
cString Description(void) { return descriptionM; }
|
||||||
|
bool IsUsed(void) { return usedM; }
|
||||||
|
int Index(void) { return indexM; }
|
||||||
|
int Transponder(void) { return transponderM; }
|
||||||
|
void SetTransponder(int transponderP) { transponderM = transponderP; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- cSatipFrontends --------------------------------------------------------
|
||||||
|
|
||||||
|
class cSatipFrontends : public cList<cSatipFrontend> {
|
||||||
|
public:
|
||||||
|
bool Matches(int transponderP);
|
||||||
|
bool Assign(int transponderP);
|
||||||
|
bool Use(int transponderP, bool onOffP);
|
||||||
|
};
|
||||||
|
|
||||||
// --- cSatipServer -----------------------------------------------------------
|
// --- cSatipServer -----------------------------------------------------------
|
||||||
|
|
||||||
class cSatipServer : public cListObject {
|
class cSatipServer : public cListObject {
|
||||||
private:
|
private:
|
||||||
enum eSatipModule {
|
enum eSatipFrontend {
|
||||||
eSatipModuleDVBS2 = 0,
|
eSatipFrontendDVBS2 = 0,
|
||||||
eSatipModuleDVBT,
|
eSatipFrontendDVBT,
|
||||||
eSatipModuleDVBT2,
|
eSatipFrontendDVBT2,
|
||||||
eSatipModuleDVBC,
|
eSatipFrontendDVBC,
|
||||||
eSatipModuleDVBC2,
|
eSatipFrontendDVBC2,
|
||||||
eSatipModuleCount
|
eSatipFrontendCount
|
||||||
};
|
};
|
||||||
cString addressM;
|
cString addressM;
|
||||||
cString modelM;
|
cString modelM;
|
||||||
cString descriptionM;
|
cString descriptionM;
|
||||||
int modelCountM[eSatipModuleCount];
|
cSatipFrontends frontendsM[eSatipFrontendCount];
|
||||||
int modelTypeM;
|
|
||||||
int quirkM;
|
int quirkM;
|
||||||
int useCountM;
|
|
||||||
int transponderM;
|
|
||||||
time_t createdM;
|
time_t createdM;
|
||||||
cTimeMs lastSeenM;
|
cTimeMs lastSeenM;
|
||||||
|
|
||||||
@ -40,33 +68,22 @@ public:
|
|||||||
eSatipQuirkUseXCI = 0x08,
|
eSatipQuirkUseXCI = 0x08,
|
||||||
eSatipQuirkMask = 0x0F
|
eSatipQuirkMask = 0x0F
|
||||||
};
|
};
|
||||||
enum eSatipModelType {
|
|
||||||
eSatipModelTypeNone = 0x00,
|
|
||||||
eSatipModelTypeDVBS2 = 0x01,
|
|
||||||
eSatipModelTypeDVBT = 0x02,
|
|
||||||
eSatipModelTypeDVBT2 = 0x04,
|
|
||||||
eSatipModelTypeDVBC = 0x08,
|
|
||||||
eSatipModelTypeDVBC2 = 0x10,
|
|
||||||
eSatipModelTypeMask = 0xFF
|
|
||||||
};
|
|
||||||
cSatipServer(const char *addressP, const char *modelP, const char *descriptionP);
|
cSatipServer(const char *addressP, const char *modelP, const char *descriptionP);
|
||||||
virtual ~cSatipServer();
|
virtual ~cSatipServer();
|
||||||
virtual int Compare(const cListObject &listObjectP) const;
|
virtual int Compare(const cListObject &listObjectP) const;
|
||||||
void Use(bool onOffP);
|
bool Assign(int sourceP, int systemP, int transponderP);
|
||||||
void SetTransponder(const int transponderP) { transponderM = transponderP; }
|
bool Matches(int sourceP);
|
||||||
int Transponder(void) { return transponderM; }
|
bool Matches(int sourceP, int systemP, int transponderP);
|
||||||
bool Used(void) { return !!useCountM; }
|
void Use(int transponderP, bool onOffP);
|
||||||
|
int GetModulesDVBS2(void);
|
||||||
|
int GetModulesDVBT(void);
|
||||||
|
int GetModulesDVBT2(void);
|
||||||
|
int GetModulesDVBC(void);
|
||||||
|
int GetModulesDVBC2(void);
|
||||||
const char *Address() { return *addressM; }
|
const char *Address() { return *addressM; }
|
||||||
const char *Model(void) { return *modelM; }
|
const char *Model(void) { return *modelM; }
|
||||||
const char *Description() { return *descriptionM; }
|
const char *Description() { return *descriptionM; }
|
||||||
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
|
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
|
||||||
int ModelType(void) { return modelTypeM; }
|
|
||||||
bool Match(int modelP) { return ((modelP & eSatipModelTypeMask) & modelTypeM); }
|
|
||||||
int Cable() { return Match(eSatipModelTypeDVBC) ? modelCountM[eSatipModuleDVBC] : 0; }
|
|
||||||
int Cable2() { return Match(eSatipModelTypeDVBC2) ? modelCountM[eSatipModuleDVBC2] : 0; }
|
|
||||||
int Satellite() { return Match(eSatipModelTypeDVBS2) ? modelCountM[eSatipModuleDVBS2] : 0; }
|
|
||||||
int Terrestrial() { return Match(eSatipModelTypeDVBT) ? modelCountM[eSatipModuleDVBT] : 0; }
|
|
||||||
int Terrestrial2() { return Match(eSatipModelTypeDVBT2) ? modelCountM[eSatipModuleDVBT2] : 0; }
|
|
||||||
void Update(void) { lastSeenM.Set(); }
|
void Update(void) { lastSeenM.Set(); }
|
||||||
uint64_t LastSeen(void) { return lastSeenM.Elapsed(); }
|
uint64_t LastSeen(void) { return lastSeenM.Elapsed(); }
|
||||||
time_t Created(void) { return createdM; }
|
time_t Created(void) { return createdM; }
|
||||||
@ -77,11 +94,13 @@ public:
|
|||||||
class cSatipServers : public cList<cSatipServer> {
|
class cSatipServers : public cList<cSatipServer> {
|
||||||
public:
|
public:
|
||||||
cSatipServer *Find(cSatipServer *serverP);
|
cSatipServer *Find(cSatipServer *serverP);
|
||||||
cSatipServer *Find(int sourceP, int transponderP, int systemP);
|
cSatipServer *Find(int sourceP);
|
||||||
void SetTransponder(cSatipServer *serverP, int transponderP);
|
cSatipServer *Assign(int sourceP, int transponderP, int systemP);
|
||||||
cSatipServer *Update(cSatipServer *serverP);
|
cSatipServer *Update(cSatipServer *serverP);
|
||||||
void Use(cSatipServer *serverP, bool onOffP);
|
void Use(cSatipServer *serverP, int transponderP, bool onOffP);
|
||||||
|
bool IsQuirk(cSatipServer *serverP, int quirkP);
|
||||||
void Cleanup(uint64_t intervalMsP = 0);
|
void Cleanup(uint64_t intervalMsP = 0);
|
||||||
|
cString GetAddress(cSatipServer *serverP);
|
||||||
cString GetString(cSatipServer *serverP);
|
cString GetString(cSatipServer *serverP);
|
||||||
cString List(void);
|
cString List(void);
|
||||||
int NumProvidedSystems(void);
|
int NumProvidedSystems(void);
|
||||||
|
31
tuner.c
31
tuner.c
@ -25,8 +25,8 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
|
|||||||
rtcpM(*this),
|
rtcpM(*this),
|
||||||
streamAddrM(""),
|
streamAddrM(""),
|
||||||
streamParamM(""),
|
streamParamM(""),
|
||||||
currentServerM(NULL),
|
currentServerM(NULL, 0),
|
||||||
nextServerM(NULL),
|
nextServerM(NULL, 0),
|
||||||
mutexM(),
|
mutexM(),
|
||||||
reConnectM(),
|
reConnectM(),
|
||||||
keepAliveM(),
|
keepAliveM(),
|
||||||
@ -119,7 +119,7 @@ void cSatipTuner::Action(void)
|
|||||||
// Read reception statistics via DESCRIBE and RTCP
|
// Read reception statistics via DESCRIBE and RTCP
|
||||||
if (hasLockM || ReadReceptionStatus()) {
|
if (hasLockM || ReadReceptionStatus()) {
|
||||||
// Quirk for devices without valid reception data
|
// Quirk for devices without valid reception data
|
||||||
if (currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkForceLock)) {
|
if (currentServerM.IsQuirk(cSatipServer::eSatipQuirkForceLock)) {
|
||||||
hasLockM = true;
|
hasLockM = true;
|
||||||
signalStrengthM = eDefaultSignalStrength;
|
signalStrengthM = eDefaultSignalStrength;
|
||||||
signalQualityM = eDefaultSignalQuality;
|
signalQualityM = eDefaultSignalQuality;
|
||||||
@ -201,11 +201,11 @@ bool cSatipTuner::Connect(void)
|
|||||||
rtcpM.Flush();
|
rtcpM.Flush();
|
||||||
if (rtspM.Setup(*uri, rtpM.Port(), rtcpM.Port())) {
|
if (rtspM.Setup(*uri, rtpM.Port(), rtcpM.Port())) {
|
||||||
keepAliveM.Set(timeoutM);
|
keepAliveM.Set(timeoutM);
|
||||||
if (nextServerM) {
|
if (nextServerM.IsValid()) {
|
||||||
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
|
||||||
currentServerM = nextServerM;
|
currentServerM = nextServerM;
|
||||||
nextServerM = NULL;
|
nextServerM.Reset();
|
||||||
}
|
}
|
||||||
|
currentServerM.Use(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,8 +237,7 @@ bool cSatipTuner::Disconnect(void)
|
|||||||
signalQualityM = -1;
|
signalQualityM = -1;
|
||||||
frontendIdM = -1;
|
frontendIdM = -1;
|
||||||
|
|
||||||
if (currentServerM)
|
currentServerM.Use(false);
|
||||||
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
|
||||||
statusUpdateM.Set(0);
|
statusUpdateM.Set(0);
|
||||||
timeoutM = eMinKeepAliveIntervalMs;
|
timeoutM = eMinKeepAliveIntervalMs;
|
||||||
pmtPidM = -1;
|
pmtPidM = -1;
|
||||||
@ -335,7 +334,7 @@ void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP)
|
|||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug1("%s (%s, %d) [device %d]", __PRETTY_FUNCTION__, sessionP, timeoutP, deviceIdM);
|
debug1("%s (%s, %d) [device %d]", __PRETTY_FUNCTION__, sessionP, timeoutP, deviceIdM);
|
||||||
sessionM = sessionP;
|
sessionM = sessionP;
|
||||||
if (nextServerM && nextServerM->Quirk(cSatipServer::eSatipQuirkSessionId) && !isempty(*sessionM) && startswith(*sessionM, "0"))
|
if (nextServerM.IsQuirk(cSatipServer::eSatipQuirkSessionId) && !isempty(*sessionM) && startswith(*sessionM, "0"))
|
||||||
rtspM.SetSession(SkipZeroes(*sessionM));
|
rtspM.SetSession(SkipZeroes(*sessionM));
|
||||||
timeoutM = (timeoutP > eMinKeepAliveIntervalMs) ? timeoutP : eMinKeepAliveIntervalMs;
|
timeoutM = (timeoutP > eMinKeepAliveIntervalMs) ? timeoutP : eMinKeepAliveIntervalMs;
|
||||||
}
|
}
|
||||||
@ -346,15 +345,15 @@ int cSatipTuner::GetId(void)
|
|||||||
return deviceIdM;
|
return deviceIdM;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP)
|
bool cSatipTuner::SetSource(cSatipServer *serverP, const int transponderP, const char *parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug1("%s (%s, %d) [device %d]", __PRETTY_FUNCTION__, parameterP, indexP, deviceIdM);
|
debug1("%s (%d, %s, %d) [device %d]", __PRETTY_FUNCTION__, transponderP, parameterP, indexP, deviceIdM);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (serverP) {
|
if (serverP) {
|
||||||
nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP);
|
nextServerM.Set(serverP, transponderP);
|
||||||
if (nextServerM && !isempty(nextServerM->Address()) && !isempty(parameterP)) {
|
if (!isempty(*nextServerM.GetAddress()) && !isempty(parameterP)) {
|
||||||
// Update stream address and parameter
|
// Update stream address and parameter
|
||||||
streamAddrM = rtspM.RtspUnescapeString(nextServerM->Address());
|
streamAddrM = rtspM.RtspUnescapeString(*nextServerM.GetAddress());
|
||||||
streamParamM = rtspM.RtspUnescapeString(parameterP);
|
streamParamM = rtspM.RtspUnescapeString(parameterP);
|
||||||
// Reconnect
|
// Reconnect
|
||||||
RequestState(tsSet, smExternal);
|
RequestState(tsSet, smExternal);
|
||||||
@ -395,8 +394,8 @@ bool cSatipTuner::UpdatePids(bool forceP)
|
|||||||
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
||||||
!isempty(*streamAddrM) && (streamIdM > 0)) {
|
!isempty(*streamAddrM) && (streamIdM > 0)) {
|
||||||
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
||||||
bool useci = (SatipConfig.GetCIExtension() && !!(currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkUseXCI)));
|
bool useci = (SatipConfig.GetCIExtension() && currentServerM.IsQuirk(cSatipServer::eSatipQuirkUseXCI));
|
||||||
bool usedummy = !!(currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkPlayPids));
|
bool usedummy = currentServerM.IsQuirk(cSatipServer::eSatipQuirkPlayPids);
|
||||||
if (forceP || usedummy) {
|
if (forceP || usedummy) {
|
||||||
if (pidsM.Size())
|
if (pidsM.Size())
|
||||||
uri = cString::sprintf("%s?pids=%s", *uri, *pidsM.ListPids());
|
uri = cString::sprintf("%s?pids=%s", *uri, *pidsM.ListPids());
|
||||||
|
27
tuner.h
27
tuner.h
@ -13,6 +13,7 @@
|
|||||||
#include <vdr/tools.h>
|
#include <vdr/tools.h>
|
||||||
|
|
||||||
#include "deviceif.h"
|
#include "deviceif.h"
|
||||||
|
#include "discover.h"
|
||||||
#include "rtp.h"
|
#include "rtp.h"
|
||||||
#include "rtcp.h"
|
#include "rtcp.h"
|
||||||
#include "rtsp.h"
|
#include "rtsp.h"
|
||||||
@ -76,6 +77,26 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class cSatipTunerServer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
cSatipServer *serverM;
|
||||||
|
int transponderM;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cSatipTunerServer(cSatipServer *serverP, const int transponderP) : serverM(serverP), transponderM(transponderP) {}
|
||||||
|
~cSatipTunerServer() {}
|
||||||
|
cSatipTunerServer(const cSatipTunerServer &objP) { serverM = NULL; transponderM = 0; }
|
||||||
|
cSatipTunerServer& operator= (const cSatipTunerServer &objP) { serverM = objP.serverM; transponderM = objP.transponderM; return *this; }
|
||||||
|
bool IsValid(void) { return !!serverM; }
|
||||||
|
bool IsQuirk(int quirkP) { return (serverM && cSatipDiscover::GetInstance()->IsServerQuirk(serverM, quirkP)); }
|
||||||
|
void Use(bool onOffP) { if (serverM) cSatipDiscover::GetInstance()->UseServer(serverM, transponderM, onOffP); }
|
||||||
|
void Set(cSatipServer *serverP, const int transponderP) { serverM = serverP; transponderM = transponderP; }
|
||||||
|
void Reset(void) { serverM = NULL; transponderM = 0; }
|
||||||
|
cString GetAddress(void) { return serverM ? cSatipDiscover::GetInstance()->GetServerAddress(serverM) : ""; }
|
||||||
|
cString GetInfo(void) { return cString::sprintf("server=%s transponder=%d", serverM ? "assigned" : "null", transponderM); }
|
||||||
|
};
|
||||||
|
|
||||||
class cSatipTuner : public cThread, public cSatipTunerStatistics, public cSatipTunerIf
|
class cSatipTuner : public cThread, public cSatipTunerStatistics, public cSatipTunerIf
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -100,8 +121,8 @@ private:
|
|||||||
cSatipRtcp rtcpM;
|
cSatipRtcp rtcpM;
|
||||||
cString streamAddrM;
|
cString streamAddrM;
|
||||||
cString streamParamM;
|
cString streamParamM;
|
||||||
cSatipServer *currentServerM;
|
cSatipTunerServer currentServerM;
|
||||||
cSatipServer *nextServerM;
|
cSatipTunerServer nextServerM;
|
||||||
cMutex mutexM;
|
cMutex mutexM;
|
||||||
cTimeMs reConnectM;
|
cTimeMs reConnectM;
|
||||||
cTimeMs keepAliveM;
|
cTimeMs keepAliveM;
|
||||||
@ -140,7 +161,7 @@ public:
|
|||||||
cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP);
|
cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP);
|
||||||
virtual ~cSatipTuner();
|
virtual ~cSatipTuner();
|
||||||
bool IsTuned(void) const { return (currentStateM >= tsTuned); }
|
bool IsTuned(void) const { return (currentStateM >= tsTuned); }
|
||||||
bool SetSource(cSatipServer *serverP, const char *parameterP, const int indexP);
|
bool SetSource(cSatipServer *serverP, const int transponderP, const char *parameterP, const int indexP);
|
||||||
bool SetPid(int pidP, int typeP, bool onP);
|
bool SetPid(int pidP, int typeP, bool onP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user