diff --git a/device.c b/device.c index 7722e5d..6c8ea80 100644 --- a/device.c +++ b/device.c @@ -22,7 +22,8 @@ cSatipDevice::cSatipDevice(unsigned int indexP) deviceNameM(*cString::sprintf("%s %d", *DeviceType(), deviceIndexM)), channelM(), createdM(0), - mutexM() + mutexM(), + fixedPidsM() { unsigned int bufsize = (unsigned int)SATIP_BUFFER_SIZE; bufsize -= (bufsize % TS_SIZE); @@ -371,10 +372,16 @@ bool cSatipDevice::SetPid(cPidHandle *handleP, int typeP, bool onP) { debug12("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM); if (pTunerM && handleP && handleP->pid >= 0) { - if (onP) - return pTunerM->SetPid(handleP->pid, typeP, true, true); - else if (!handleP->used) - return pTunerM->SetPid(handleP->pid, typeP, false, true); + if (onP) { + fixedPidsM.AddPid(handleP->pid); + debug12("%s A%d fixedPidsM=%s [device %d]", __PRETTY_FUNCTION__, handleP->pid, *fixedPidsM.ListPids(), deviceIndexM); + return pTunerM->SetPid(handleP->pid, typeP, true); + } + else if (!handleP->used) { + fixedPidsM.RemovePid(handleP->pid); + debug12("%s R%d fixedPidsM=%s [device %d]", __PRETTY_FUNCTION__, handleP->pid, *fixedPidsM.ListPids(), deviceIndexM); + return pTunerM->SetPid(handleP->pid, typeP, false); + } } return true; } @@ -385,7 +392,7 @@ int cSatipDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP) if (pSectionFilterHandlerM) { int handle = pSectionFilterHandlerM->Open(pidP, tidP, maskP); if (pTunerM && (handle >= 0)) - pTunerM->SetPid(pidP, ptOther, true, false); + pTunerM->SetPid(pidP, ptOther, true); return handle; } return -1; @@ -396,8 +403,8 @@ void cSatipDevice::CloseFilter(int handleP) if (pSectionFilterHandlerM) { int pid = pSectionFilterHandlerM->GetPid(handleP); debug12("%s (%d) [device %u]", __PRETTY_FUNCTION__, pid, deviceIndexM); - if (pTunerM) - pTunerM->SetPid(pid, ptOther, false, false); + if (pTunerM && fixedPidsM.IndexOf(pid) == -1) + pTunerM->SetPid(pid, ptOther, false); pSectionFilterHandlerM->Close(handleP); } } @@ -545,15 +552,19 @@ bool cSatipDevice::GetTSPacket(uchar *&dataP) dataP = cs->Decrypt(dataP, available); SkipData(available); } - return true; + //return true; } } - dataP = GetData(); + else + dataP = GetData(); + if (dataP && (dataP[4] == 0x00) && (dataP[5] == 0x02) && ((dataP[6] & 0xf0) == 0xb0)) { - int pid = ((dataP[1] & 0x1f) << 8) | dataP[2]; - debug12("%s PID %d 0x%02x%02x%02x%02x%02x%02x%02x", __PRETTY_FUNCTION__, - pid, dataP[0], dataP[1], dataP[2], dataP[3], dataP[4], dataP[5], dataP[6]); + int pidA = ((dataP[1] & 0x1f) << 8) | dataP[2]; + int pidB = GetPmtPid(); + debug12("%s PID %d/%d 0x%02x%02x%02x%02x%02x%02x%02x", __PRETTY_FUNCTION__, + pidA, pidB, dataP[0], dataP[1], dataP[2], dataP[3], dataP[4], dataP[5], dataP[6]); } + return true; } dataP = NULL; diff --git a/device.h b/device.h index 983e24d..16e34dd 100644 --- a/device.h +++ b/device.h @@ -40,6 +40,7 @@ private: cSatipSectionFilterHandler *pSectionFilterHandlerM; cTimeMs createdM; cMutex mutexM; + cSatipPid fixedPidsM; // constructor & destructor public: diff --git a/tuner.c b/tuner.c index bde4d1a..bef87d4 100644 --- a/tuner.c +++ b/tuner.c @@ -47,8 +47,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP) pmtPidM(-1), addPidsM(), delPidsM(), - pidsM(), - fixedPidsM() + pidsM() { debug1("%s (, %d) [device %d]", __PRETTY_FUNCTION__, packetLenP, deviceIdM); @@ -406,7 +405,7 @@ bool cSatipTuner::SetSource(cSatipServer *serverP, const int transponderP, const return true; } -bool cSatipTuner::SetPid(int pidP, int typeP, bool onP, bool fixedP) +bool cSatipTuner::SetPid(int pidP, int typeP, bool onP) { debug16("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, deviceIdM); cMutexLock MutexLock(&mutexM); @@ -414,14 +413,11 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP, bool fixedP) pidsM.AddPid(pidP); addPidsM.AddPid(pidP); delPidsM.RemovePid(pidP); - if (fixedP) - fixedPidsM.AddPid(pidP); } - else if (fixedP || fixedPidsM.IndexOf(pidP) == -1) { + else { pidsM.RemovePid(pidP); delPidsM.AddPid(pidP); addPidsM.RemovePid(pidP); - fixedPidsM.RemovePid(pidP); } debug12("%s (%d, %d, %d) pids=%s [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, *pidsM.ListPids(), deviceIdM); sleepM.Signal(); @@ -481,7 +477,6 @@ bool cSatipTuner::UpdatePids(bool forceP) return false; addPidsM.Clear(); delPidsM.Clear(); - fixedPidsM.Clear(); } return true; diff --git a/tuner.h b/tuner.h index 0475d53..b70b1ac 100644 --- a/tuner.h +++ b/tuner.h @@ -122,7 +122,6 @@ private: cSatipPid addPidsM; cSatipPid delPidsM; cSatipPid pidsM; - cSatipPid fixedPidsM; bool Connect(void); bool Disconnect(void); @@ -144,7 +143,7 @@ public: virtual ~cSatipTuner(); bool IsTuned(void) const { return (currentStateM >= tsTuned); } bool SetSource(cSatipServer *serverP, const int transponderP, const char *parameterP, const int indexP); - bool SetPid(int pidP, int typeP, bool onP, bool fixedP = true); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); int FrontendId(void);