diff --git a/device.c b/device.c index 76b3ae8..04373ec 100644 --- a/device.c +++ b/device.c @@ -293,7 +293,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) } sidScanEnabledM = itp.SidScan() ? true : false; pidScanEnabledM = itp.PidScan() ? true : false; - if (pIptvStreamerM->Set(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) { + if (pIptvStreamerM && pIptvStreamerM->SetSource(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) { channelM = *channelP; if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering()) pSidScannerM->SetChannel(channelM.GetChannelID()); @@ -306,22 +306,30 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP) { debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP->pid, typeP, onP); + if (pIptvStreamerM && handleP) + return pIptvStreamerM->SetPid(handleP->pid, typeP, onP); return true; } int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP) { //debug("cIptvDevice::%s(%d): pid=%d tid=%d mask=%d", __FUNCTION__, deviceIndexM, pidP, tidP, maskP); - if (pIptvSectionM && IptvConfig.GetSectionFiltering()) + if (pIptvSectionM && IptvConfig.GetSectionFiltering()) { + if (pIptvStreamerM) + pIptvStreamerM->SetPid(pidP, ptOther, true); return pIptvSectionM->Open(pidP, tidP, maskP); + } return -1; } void cIptvDevice::CloseFilter(int handleP) { //debug("cIptvDevice::%s(%d): handle=%d", __FUNCTION__, deviceIndexM, handleP); - if (pIptvSectionM) + if (pIptvSectionM) { + if (pIptvStreamerM) + pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false); pIptvSectionM->Close(handleP); + } } bool cIptvDevice::OpenDvr(void) diff --git a/protocolcurl.c b/protocolcurl.c index d198fbe..ef1a7aa 100644 --- a/protocolcurl.c +++ b/protocolcurl.c @@ -503,7 +503,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) return len; } -bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const int indexP) +bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, const int indexP) { debug("cIptvProtocolCurl::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -531,6 +531,12 @@ bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const i return true; } +bool cIptvProtocolCurl::SetPid(int pidP, int typeP, bool onP) +{ + //debug("cIptvProtocolCurl::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + return true; +} + cString cIptvProtocolCurl::GetInformation(void) { //debug("cIptvProtocolCurl::%s()", __FUNCTION__); diff --git a/protocolcurl.h b/protocolcurl.h index ef6a464..aaa0476 100644 --- a/protocolcurl.h +++ b/protocolcurl.h @@ -60,7 +60,8 @@ public: cIptvProtocolCurl(); virtual ~cIptvProtocolCurl(); int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); - bool Set(const char* locationP, const int parameterP, const int indexP); + bool SetSource(const char* locationP, const int parameterP, const int indexP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void); diff --git a/protocolext.c b/protocolext.c index 556665c..364ad3f 100644 --- a/protocolext.c +++ b/protocolext.c @@ -152,7 +152,7 @@ int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) return cIptvUdpSocket::Read(bufferAddrP, bufferLenP); } -bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const int indexP) +bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, const int indexP) { debug("cIptvProtocolExt::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -170,6 +170,12 @@ bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const in return true; } +bool cIptvProtocolExt::SetPid(int pidP, int typeP, bool onP) +{ + //debug("cIptvProtocolExt::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + return true; +} + cString cIptvProtocolExt::GetInformation(void) { //debug("cIptvProtocolExt::%s()", __FUNCTION__); diff --git a/protocolext.h b/protocolext.h index bd19feb..22c2833 100644 --- a/protocolext.h +++ b/protocolext.h @@ -27,7 +27,8 @@ public: cIptvProtocolExt(); virtual ~cIptvProtocolExt(); int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); - bool Set(const char* locationP, const int parameterP, const int indexP); + bool SetSource(const char* locationP, const int parameterP, const int indexP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void); diff --git a/protocolfile.c b/protocolfile.c index 885d137..51cd746 100644 --- a/protocolfile.c +++ b/protocolfile.c @@ -95,7 +95,7 @@ bool cIptvProtocolFile::Close(void) return true; } -bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const int indexP) +bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, const int indexP) { debug("cIptvProtocolFile::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -110,6 +110,12 @@ bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const i return true; } +bool cIptvProtocolFile::SetPid(int pidP, int typeP, bool onP) +{ + //debug("cIptvProtocolFile::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + return true; +} + cString cIptvProtocolFile::GetInformation(void) { //debug("cIptvProtocolFile::%s()", __FUNCTION__); diff --git a/protocolfile.h b/protocolfile.h index 97d4e13..90b770a 100644 --- a/protocolfile.h +++ b/protocolfile.h @@ -26,7 +26,8 @@ public: cIptvProtocolFile(); virtual ~cIptvProtocolFile(); int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); - bool Set(const char* locationP, const int parameterP, const int indexP); + bool SetSource(const char* locationP, const int parameterP, const int indexP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void); diff --git a/protocolhttp.c b/protocolhttp.c index 5d85348..3d933aa 100644 --- a/protocolhttp.c +++ b/protocolhttp.c @@ -177,7 +177,7 @@ int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) return cIptvTcpSocket::Read(bufferAddrP, bufferLenP); } -bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const int indexP) +bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, const int indexP) { debug("cIptvProtocolHttp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -199,6 +199,12 @@ bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const i return true; } +bool cIptvProtocolHttp::SetPid(int pidP, int typeP, bool onP) +{ + //debug("cIptvProtocolHttp::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + return true; +} + cString cIptvProtocolHttp::GetInformation(void) { //debug("cIptvProtocolHttp::%s()", __FUNCTION__); diff --git a/protocolhttp.h b/protocolhttp.h index 99bec0e..12f3772 100644 --- a/protocolhttp.h +++ b/protocolhttp.h @@ -28,7 +28,8 @@ public: cIptvProtocolHttp(); virtual ~cIptvProtocolHttp(); int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); - bool Set(const char* locationP, const int parameterP, const int indexP); + bool SetSource(const char* locationP, const int parameterP, const int indexP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void); diff --git a/protocolif.h b/protocolif.h index a76f76a..d90cfc0 100644 --- a/protocolif.h +++ b/protocolif.h @@ -13,7 +13,8 @@ public: cIptvProtocolIf() {} virtual ~cIptvProtocolIf() {} virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP) = 0; - virtual bool Set(const char* locationP, const int parameterP, const int indexP) = 0; + virtual bool SetSource(const char* locationP, const int parameterP, const int indexP) = 0; + virtual bool SetPid(int pidP, int typeP, bool onP) = 0; virtual bool Open(void) = 0; virtual bool Close(void) = 0; virtual cString GetInformation(void) = 0; diff --git a/protocoludp.c b/protocoludp.c index 1b2869f..a83845e 100644 --- a/protocoludp.c +++ b/protocoludp.c @@ -70,7 +70,7 @@ int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) return cIptvUdpSocket::Read(bufferAddrP, bufferLenP); } -bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const int indexP) +bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, const int indexP) { debug("cIptvProtocolUdp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -103,6 +103,12 @@ bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const in return true; } +bool cIptvProtocolUdp::SetPid(int pidP, int typeP, bool onP) +{ + //debug("cIptvProtocolUdp::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + return true; +} + cString cIptvProtocolUdp::GetInformation(void) { //debug("cIptvProtocolUdp::%s()", __FUNCTION__); diff --git a/protocoludp.h b/protocoludp.h index 15f2ca4..5674019 100644 --- a/protocoludp.h +++ b/protocoludp.h @@ -23,7 +23,8 @@ public: cIptvProtocolUdp(); virtual ~cIptvProtocolUdp(); int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); - bool Set(const char* locationP, const int parameterP, const int indexP); + bool SetSource(const char* locationP, const int parameterP, const int indexP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void); diff --git a/sectionfilter.c b/sectionfilter.c index 02cefbe..ac731ed 100644 --- a/sectionfilter.c +++ b/sectionfilter.c @@ -380,6 +380,20 @@ void cIptvSectionFilterHandler::Close(int handleP) } } +int cIptvSectionFilterHandler::GetPid(int handleP) +{ + // Lock + cMutexLock MutexLock(&mutexM); + // Search the filter for data + for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { + if (filtersM[i] && (handleP == filtersM[i]->GetFd())) { + debug("cIptvSectionFilterHandler::%s(%d): pid=%d handle=%d index=%d", __FUNCTION__, deviceIndexM, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i); + return filtersM[i]->GetPid(); + } + } + return -1; +} + void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP) { //debug("cIptvSectionFilterHandler::%s(%d): length=%d", __FUNCTION__, deviceIndexM, lengthP); diff --git a/sectionfilter.h b/sectionfilter.h index c9982e9..9d022a8 100644 --- a/sectionfilter.h +++ b/sectionfilter.h @@ -84,6 +84,7 @@ public: cString GetInformation(void); int Open(u_short pidP, u_char tidP, u_char maskP); void Close(int handleP); + int GetPid(int handleP); void Write(u_char *bufferP, int lengthP); }; diff --git a/streamer.c b/streamer.c index 0434336..2afffb1 100644 --- a/streamer.c +++ b/streamer.c @@ -79,7 +79,7 @@ bool cIptvStreamer::Close(void) return true; } -bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP) +bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP) { debug("cIptvStreamer::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); if (!isempty(locationP)) { @@ -89,16 +89,24 @@ bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int i protocolM->Close(); protocolM = protocolP; if (protocolM) { - protocolM->Set(locationP, parameterP, indexP); + protocolM->SetSource(locationP, parameterP, indexP); protocolM->Open(); } } else if (protocolM) - protocolM->Set(locationP, parameterP, indexP); + protocolM->SetSource(locationP, parameterP, indexP); } return true; } +bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP) +{ + debug("cIptvStreamer::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); + if (protocolM) + return protocolM->SetPid(pidP, typeP, onP); + return true; +} + cString cIptvStreamer::GetInformation(void) { //debug("cIptvStreamer::%s()", __FUNCTION__); diff --git a/streamer.h b/streamer.h index d43232b..9a08499 100644 --- a/streamer.h +++ b/streamer.h @@ -30,7 +30,8 @@ protected: public: cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP); virtual ~cIptvStreamer(); - bool Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP); + bool SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP); + bool SetPid(int pidP, int typeP, bool onP); bool Open(void); bool Close(void); cString GetInformation(void);