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

Added cSatipPid().

This commit is contained in:
Rolf Ahrenberg 2014-11-09 02:32:50 +02:00
parent 123fc5f96b
commit 72a5ad34fb
2 changed files with 35 additions and 44 deletions

47
tuner.c
View File

@ -474,50 +474,15 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
{
//debug("cSatipTuner::%s(%d, %d, %d) [device %d]", __FUNCTION__, pidP, typeP, onP, deviceM->GetId());
cMutexLock MutexLock(&mutexM);
bool found = false;
for (int i = 0; i < pidsM.Size(); ++i) {
if (pidsM[i] == pidP) {
found = true;
if (!onP)
pidsM.Remove(i);
break;
}
}
if (onP && !found)
pidsM.Append(pidP);
// Generate deltas
found = false;
if (onP) {
for (int i = 0; i < addPidsM.Size(); ++i) {
if (addPidsM[i] == pidP) {
found = true;
break;
}
}
if (!found)
addPidsM.Append(pidP);
for (int i = 0; i < delPidsM.Size(); ++i) {
if (delPidsM[i] == pidP) {
delPidsM.Remove(i);
break;
}
}
pidsM.AddPid(pidP);
addPidsM.AddPid(pidP);
delPidsM.RemovePid(pidP);
}
else {
for (int i = 0; i < delPidsM.Size(); ++i) {
if (delPidsM[i] == pidP) {
found = true;
break;
}
}
if (!found)
delPidsM.Append(pidP);
for (int i = 0; i < addPidsM.Size(); ++i) {
if (addPidsM[i] == pidP) {
addPidsM.Remove(i);
break;
}
}
pidsM.RemovePid(pidP);
delPidsM.AddPid(pidP);
addPidsM.RemovePid(pidP);
}
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
return true;

32
tuner.h
View File

@ -23,6 +23,32 @@
#include "statistics.h"
#include "socket.h"
class cSatipPid : public cVector<int> {
private:
int PidIndex(const int &pidP)
{
for (int i = 0; i < this->Size(); ++i) {
if (pidP == this->At(i))
return i;
}
return -1;
}
public:
void RemovePid(const int &pidP)
{
int i = PidIndex(pidP);
if (i >= 0)
this->Remove(i);
}
void AddPid(int pidP)
{
if (PidIndex(pidP) < 0)
this->Append(pidP);
}
};
class cSatipTuner : public cThread, public cSatipTunerStatistics {
private:
enum {
@ -65,9 +91,9 @@ private:
int signalStrengthM;
int signalQualityM;
int streamIdM;
cVector<int> addPidsM;
cVector<int> delPidsM;
cVector<int> pidsM;
cSatipPid addPidsM;
cSatipPid delPidsM;
cSatipPid pidsM;
bool Connect(void);
bool Disconnect(void);