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

Deduplicated pid listings.

This commit is contained in:
Rolf Ahrenberg 2014-12-14 17:54:37 +02:00
parent 778f3bd84a
commit 7f9d016b52
2 changed files with 17 additions and 26 deletions

32
tuner.c
View File

@ -374,13 +374,7 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
delPidsM.AddPid(pidP);
addPidsM.RemovePid(pidP);
}
if (pidsM.Size()) {
cString s = "";
for (int i = 0; i < pidsM.Size(); ++i)
s = cString::sprintf("%s%d,", *s, pidsM[i]);
s = s.Truncate(-1);
debug9("%s (%d, %d, %d) pids=%s [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, *s, deviceIdM);
}
debug9("%s (%d, %d, %d) pids=%s [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, *pidsM.ListPids(), deviceIdM);
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
sleepM.Signal();
@ -395,28 +389,16 @@ bool cSatipTuner::UpdatePids(bool forceP)
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
bool usedummy = !!(currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkPlayPids));
if (forceP || usedummy) {
if (pidsM.Size()) {
uri = cString::sprintf("%s?pids=", *uri);
for (int i = 0; i < pidsM.Size(); ++i)
uri = cString::sprintf("%s%d,", *uri, pidsM[i]);
uri = uri.Truncate(-1);
}
if (pidsM.Size())
uri = cString::sprintf("%s?pids=%s", *uri, *pidsM.ListPids());
if (usedummy && (pidsM.Size() == 1) && (pidsM[0] < 0x20))
uri = cString::sprintf("%s,%d", *uri, eDummyPid);
}
else {
if (addPidsM.Size()) {
uri = cString::sprintf("%s?addpids=", *uri);
for (int i = 0; i < addPidsM.Size(); ++i)
uri = cString::sprintf("%s%d,", *uri, addPidsM[i]);
uri = uri.Truncate(-1);
}
if (delPidsM.Size()) {
uri = cString::sprintf("%s%sdelpids=", *uri, addPidsM.Size() ? "&" : "?");
for (int i = 0; i < delPidsM.Size(); ++i)
uri = cString::sprintf("%s%d,", *uri, delPidsM[i]);
uri = uri.Truncate(-1);
}
if (addPidsM.Size())
uri = cString::sprintf("%s?addpids=%s", *uri, *addPidsM.ListPids());
if (delPidsM.Size())
uri = cString::sprintf("%s%sdelpids=%s", *uri, addPidsM.Size() ? "&" : "?", *delPidsM.ListPids());
}
if (!rtspM.Play(*uri))
return false;

11
tuner.h
View File

@ -42,7 +42,6 @@ public:
Sort(PidCompare);
}
}
void AddPid(int pidP)
{
if (PidIndex(pidP) < 0) {
@ -50,6 +49,16 @@ public:
Sort(PidCompare);
}
}
cString ListPids(void)
{
cString list = "";
if (Size()) {
for (int i = 0; i < Size(); ++i)
list = cString::sprintf("%s%d,", *list, At(i));
list = list.Truncate(-1);
}
return list;
}
};
class cSatipTuner : public cThread, public cSatipTunerStatistics, public cSatipTunerIf