Moved cStreamdevFilterStreamer to livefilter.[hc]

This commit is contained in:
Frank Schmirler 2012-11-24 23:35:10 +01:00
parent c267b585fd
commit 83e9f3250f
6 changed files with 103 additions and 148 deletions

View File

@ -1,6 +1,7 @@
VDR Plugin 'streamdev' Revision History VDR Plugin 'streamdev' Revision History
--------------------------------------- ---------------------------------------
- Moved cStreamdevFilterStreamer to livefilter.[hc]
- Return HTTP/1.1 compliant response headers plus some always useful headers - Return HTTP/1.1 compliant response headers plus some always useful headers
- Return HTTP URL parameters ending with ".dlna.org" as response headers - Return HTTP URL parameters ending with ".dlna.org" as response headers
- Store HTTP URL parameters in a map - Store HTTP URL parameters in a map

View File

@ -4,6 +4,7 @@
#include "server/connectionVTP.h" #include "server/connectionVTP.h"
#include "server/livestreamer.h" #include "server/livestreamer.h"
#include "server/livefilter.h"
#include "server/suspend.h" #include "server/suspend.h"
#include "setup.h" #include "setup.h"

View File

@ -2,14 +2,36 @@
* $Id: livefilter.c,v 1.7 2009/02/13 13:02:40 schmirl Exp $ * $Id: livefilter.c,v 1.7 2009/02/13 13:02:40 schmirl Exp $
*/ */
#include <vdr/filter.h>
#include "server/livefilter.h" #include "server/livefilter.h"
#include "server/streamer.h"
#include "common.h" #include "common.h"
#ifndef TS_SYNC_BYTE #ifndef TS_SYNC_BYTE
# define TS_SYNC_BYTE 0x47 # define TS_SYNC_BYTE 0x47
#endif #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) { cStreamdevLiveFilter::cStreamdevLiveFilter(cStreamdevStreamer *Streamer) {
m_Streamer = 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); 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;
}

View File

@ -5,28 +5,25 @@
#ifndef VDR_STREAMEV_LIVEFILTER_H #ifndef VDR_STREAMEV_LIVEFILTER_H
#define VDR_STREAMEV_LIVEFILTER_H #define VDR_STREAMEV_LIVEFILTER_H
#include <vdr/config.h> #include "server/streamer.h"
#include <vdr/filter.h> class cDevice;
class cStreamdevLiveFilter;
class cStreamdevStreamer; class cStreamdevFilterStreamer: public cStreamdevStreamer {
class cStreamdevLiveFilter: public cFilter {
private: private:
cStreamdevStreamer *m_Streamer; cDevice *m_Device;
cStreamdevLiveFilter *m_Filter;
protected:
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
public: public:
cStreamdevLiveFilter(cStreamdevStreamer *Streamer); cStreamdevFilterStreamer();
virtual ~cStreamdevFilterStreamer();
void Set(u_short Pid, u_char Tid, u_char Mask) { void SetDevice(cDevice *Device);
cFilter::Set(Pid, Tid, Mask); bool SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On);
}
void Del(u_short Pid, u_char Tid, u_char Mask) { virtual void Attach(void);
cFilter::Del(Pid, Tid, Mask); virtual void Detach(void);
}
}; };
#endif // VDR_STREAMEV_LIVEFILTER_H #endif // VDR_STREAMEV_LIVEFILTER_H

View File

@ -11,7 +11,6 @@
#include <vdr/ringbuffer.h> #include <vdr/ringbuffer.h>
#include "server/livestreamer.h" #include "server/livestreamer.h"
#include "server/livefilter.h"
#include "common.h" #include "common.h"
using namespace Streamdev; using namespace Streamdev;
@ -609,105 +608,3 @@ std::string cStreamdevLiveStreamer::Report(void)
result += "\n"; result += "\n";
return result; 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():"<null>",
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

View File

@ -53,32 +53,4 @@ public:
virtual std::string Report(void); virtual std::string Report(void);
}; };
// --- cStreamdevFilterStreamer -------------------------------------------------
//#include <vdr/status.h>
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 #endif // VDR_STREAMDEV_LIVESTREAMER_H