diff --git a/HISTORY b/HISTORY index dafa559..2a49ee5 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ VDR Plugin 'streamdev' Revision History --------------------------------------- +- Moved cStreamdevFilterStreamer to livefilter.[hc] - Return HTTP/1.1 compliant response headers plus some always useful headers - Return HTTP URL parameters ending with ".dlna.org" as response headers - Store HTTP URL parameters in a map diff --git a/server/connectionVTP.c b/server/connectionVTP.c index 7865757..c3ba74d 100644 --- a/server/connectionVTP.c +++ b/server/connectionVTP.c @@ -4,6 +4,7 @@ #include "server/connectionVTP.h" #include "server/livestreamer.h" +#include "server/livefilter.h" #include "server/suspend.h" #include "setup.h" diff --git a/server/livefilter.c b/server/livefilter.c index 67b0e37..113789b 100644 --- a/server/livefilter.c +++ b/server/livefilter.c @@ -2,14 +2,36 @@ * $Id: livefilter.c,v 1.7 2009/02/13 13:02:40 schmirl Exp $ */ +#include + #include "server/livefilter.h" -#include "server/streamer.h" #include "common.h" #ifndef TS_SYNC_BYTE # define TS_SYNC_BYTE 0x47 #endif + +// --- cStreamdevLiveFilter ------------------------------------------------- + +class cStreamdevLiveFilter: public cFilter { +private: + cStreamdevStreamer *m_Streamer; + +protected: + virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); + +public: + cStreamdevLiveFilter(cStreamdevStreamer *Streamer); + + void Set(u_short Pid, u_char Tid, u_char Mask) { + cFilter::Set(Pid, Tid, Mask); + } + void Del(u_short Pid, u_char Tid, u_char Mask) { + cFilter::Del(Pid, Tid, Mask); + } +}; + cStreamdevLiveFilter::cStreamdevLiveFilter(cStreamdevStreamer *Streamer) { m_Streamer = Streamer; } @@ -37,3 +59,68 @@ void cStreamdevLiveFilter::Process(u_short Pid, u_char Tid, const u_char *Data, m_Streamer->ReportOverflow(TS_SIZE - p); } } + +// --- cStreamdevFilterStreamer ------------------------------------------------- + +cStreamdevFilterStreamer::cStreamdevFilterStreamer(): + cStreamdevStreamer("streamdev-filterstreaming"), + m_Device(NULL), + m_Filter(NULL)/*, + m_Channel(NULL)*/ +{ +} + +cStreamdevFilterStreamer::~cStreamdevFilterStreamer() +{ + Dprintf("Desctructing Filter streamer\n"); + Detach(); + m_Device = NULL; + DELETENULL(m_Filter); + Stop(); +} + +void cStreamdevFilterStreamer::Attach(void) +{ + Dprintf("cStreamdevFilterStreamer::Attach()\n"); + LOCK_THREAD; + if(m_Device && m_Filter) + m_Device->AttachFilter(m_Filter); +} + +void cStreamdevFilterStreamer::Detach(void) +{ + Dprintf("cStreamdevFilterStreamer::Detach()\n"); + LOCK_THREAD; + if(m_Device && m_Filter) + m_Device->Detach(m_Filter); +} + +void cStreamdevFilterStreamer::SetDevice(cDevice *Device) +{ + Dprintf("cStreamdevFilterStreamer::SetDevice()\n"); + LOCK_THREAD; + Detach(); + m_Device = Device; + Attach(); +} + +bool cStreamdevFilterStreamer::SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On) +{ + Dprintf("cStreamdevFilterStreamer::SetFilter(%u,0x%x,0x%x,%s)\n", Pid, Tid, Mask, On?"On":"Off"); + + if(!m_Device) + return false; + + if (On) { + if (m_Filter == NULL) { + m_Filter = new cStreamdevLiveFilter(this); + Dprintf("attaching filter to device\n"); + Attach(); + } + m_Filter->Set(Pid, Tid, Mask); + } else if (m_Filter != NULL) + m_Filter->Del(Pid, Tid, Mask); + + return true; +} + diff --git a/server/livefilter.h b/server/livefilter.h index 13e8956..25174ad 100644 --- a/server/livefilter.h +++ b/server/livefilter.h @@ -5,28 +5,25 @@ #ifndef VDR_STREAMEV_LIVEFILTER_H #define VDR_STREAMEV_LIVEFILTER_H -#include +#include "server/streamer.h" -#include +class cDevice; +class cStreamdevLiveFilter; -class cStreamdevStreamer; - -class cStreamdevLiveFilter: public cFilter { +class cStreamdevFilterStreamer: public cStreamdevStreamer { private: - cStreamdevStreamer *m_Streamer; - -protected: - virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); + cDevice *m_Device; + cStreamdevLiveFilter *m_Filter; public: - cStreamdevLiveFilter(cStreamdevStreamer *Streamer); + cStreamdevFilterStreamer(); + virtual ~cStreamdevFilterStreamer(); - void Set(u_short Pid, u_char Tid, u_char Mask) { - cFilter::Set(Pid, Tid, Mask); - } - void Del(u_short Pid, u_char Tid, u_char Mask) { - cFilter::Del(Pid, Tid, Mask); - } + void SetDevice(cDevice *Device); + bool SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On); + + virtual void Attach(void); + virtual void Detach(void); }; #endif // VDR_STREAMEV_LIVEFILTER_H diff --git a/server/livestreamer.c b/server/livestreamer.c index 14d10c2..ae6281d 100644 --- a/server/livestreamer.c +++ b/server/livestreamer.c @@ -11,7 +11,6 @@ #include #include "server/livestreamer.h" -#include "server/livefilter.h" #include "common.h" using namespace Streamdev; @@ -609,105 +608,3 @@ std::string cStreamdevLiveStreamer::Report(void) result += "\n"; return result; } - -// --- cStreamdevFilterStreamer ------------------------------------------------- - -cStreamdevFilterStreamer::cStreamdevFilterStreamer(): - cStreamdevStreamer("streamdev-filterstreaming"), - m_Device(NULL), - m_Filter(NULL)/*, - m_Channel(NULL)*/ -{ -} - -cStreamdevFilterStreamer::~cStreamdevFilterStreamer() -{ - Dprintf("Desctructing Filter streamer\n"); - Detach(); - m_Device = NULL; - DELETENULL(m_Filter); - Stop(); -} - -void cStreamdevFilterStreamer::Attach(void) -{ - Dprintf("cStreamdevFilterStreamer::Attach()\n"); - LOCK_THREAD; - if(m_Device && m_Filter) - m_Device->AttachFilter(m_Filter); -} - -void cStreamdevFilterStreamer::Detach(void) -{ - Dprintf("cStreamdevFilterStreamer::Detach()\n"); - LOCK_THREAD; - if(m_Device && m_Filter) - m_Device->Detach(m_Filter); -} - -#if 0 -void cStreamdevFilterStreamer::SetChannel(const cChannel *Channel) -{ - LOCK_THREAD; - Dprintf("cStreamdevFilterStreamer::SetChannel(%s : %s)", Channel?Channel->Name():"", - Channel ? *Channel->GetChannelID().ToString() : ""); - m_Channel = Channel; -} -#endif - -void cStreamdevFilterStreamer::SetDevice(cDevice *Device) -{ - Dprintf("cStreamdevFilterStreamer::SetDevice()\n"); - LOCK_THREAD; - Detach(); - m_Device = Device; - //m_Channel = NULL; - Attach(); -} - -bool cStreamdevFilterStreamer::SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On) -{ - Dprintf("cStreamdevFilterStreamer::SetFilter(%u,0x%x,0x%x,%s)\n", Pid, Tid, Mask, On?"On":"Off"); - - if(!m_Device) - return false; - - if (On) { - if (m_Filter == NULL) { - m_Filter = new cStreamdevLiveFilter(this); - Dprintf("attaching filter to device\n"); - Attach(); - } - m_Filter->Set(Pid, Tid, Mask); - } else if (m_Filter != NULL) - m_Filter->Del(Pid, Tid, Mask); - - return true; -} - -#if 0 -void cStreamdevFilterStreamer::ChannelSwitch(const cDevice *Device, int ChannelNumber) { - LOCK_THREAD; - if(Device == m_Device) { - if(ChannelNumber > 0) { - cChannel *ch = Channels.GetByNumber(ChannelNumber); - if(ch != NULL) { - if(m_Filter != NULL && - m_Channel != NULL && - (! TRANSPONDER(ch, m_Channel))) { - - isyslog("***** LiveFilterStreamer: transponder changed ! %s", - *ch->GetChannelID().ToString()); - - uchar buffer[TS_SIZE] = {TS_SYNC_BYTE, 0xff, 0xff, 0xff, 0x7f, 0}; - strcpy((char*)(buffer + 5), ch->GetChannelID().ToString()); - int p = Put(buffer, TS_SIZE); - if (p != TS_SIZE) - ReportOverflow(TS_SIZE - p); - } - m_Channel = ch; - } - } - } -} -#endif diff --git a/server/livestreamer.h b/server/livestreamer.h index 037515c..ad41141 100644 --- a/server/livestreamer.h +++ b/server/livestreamer.h @@ -53,32 +53,4 @@ public: virtual std::string Report(void); }; - -// --- cStreamdevFilterStreamer ------------------------------------------------- - -//#include - -class cStreamdevLiveFilter; - -class cStreamdevFilterStreamer: public cStreamdevStreamer /*, public cStatus*/ { -private: - cDevice *m_Device; - cStreamdevLiveFilter *m_Filter; - //const cChannel *m_Channel; - -public: - cStreamdevFilterStreamer(); - virtual ~cStreamdevFilterStreamer(); - - void SetDevice(cDevice *Device); - //void SetChannel(const cChannel *Channel); - bool SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On); - - virtual void Attach(void); - virtual void Detach(void); - - // cStatus message handlers - //virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber); -}; - #endif // VDR_STREAMDEV_LIVESTREAMER_H