vdr-plugin-streamdev/client/device.h

83 lines
2.3 KiB
C
Raw Normal View History

2004-12-30 23:43:55 +01:00
/*
2010-12-02 09:57:17 +01:00
* $Id: device.h,v 1.10 2010/08/18 10:26:55 schmirl Exp $
2004-12-30 23:43:55 +01:00
*/
#ifndef VDR_STREAMDEV_DEVICE_H
#define VDR_STREAMDEV_DEVICE_H
#include <vdr/device.h>
#include "client/socket.h"
#include "client/filter.h"
class cTBString;
#define CMD_LOCK_OBJ(x) cMutexLock CmdLock((cMutex*)&(x)->m_Mutex)
class cStreamdevDevice: public cDevice {
private:
bool m_Disabled;
cClientSocket *m_ClientSocket;
2004-12-30 23:43:55 +01:00
const cChannel *m_Channel;
cTSBuffer *m_TSBuffer;
cStreamdevFilters *m_Filters;
int m_Pids;
2004-12-30 23:43:55 +01:00
static const cChannel *m_DenyChannel;
2004-12-30 23:43:55 +01:00
protected:
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
#if APIVERSNUM >= 10738
virtual bool HasLock(int TimeoutMs) const
#else
virtual bool HasLock(int TimeoutMs)
#endif
2005-02-08 16:21:19 +01:00
{
//printf("HasLock is %d\n", (ClientSocket.DataSocket(siLive) != NULL));
//return ClientSocket.DataSocket(siLive) != NULL;
return true;
}
2004-12-30 23:43:55 +01:00
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
virtual bool OpenDvr(void);
virtual void CloseDvr(void);
virtual bool GetTSPacket(uchar *&Data);
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
Fixed problems related to VTP filter streaming like ringbuffer overflows, stuttering or aborting video stream (refs #2045) Toerless Eckert wrote: This patch tries to resolve problems in streamdev-client that can occur when enabling "StreamFilters". Enabling this option is necessary to receive certain programs with dynamic PIDs such as some german "regional" broadcast (eg: NDR). Problem: Without this fix, the following behavior was observed on a Raspberry PI running streamdev-0.6.1-git with VDR-2.6.1: - Buffer overflows of filter data - Stop/go video on channels - Total stopping of video More logs in: http://www.vdr-portal.de/board16-video-disk-recorder/board55-vdr-plugins/125237- streamdev-client-filter-daten-streamen-ndr-raspberry-haengt/ Analysis: VDR expect section data from filters separately from the main program stream. Historically, it received each filter data via a separate file descriptor from the DVB card. In the streamdev-client module, a socketpair is used to feed filter data to the main VDR code. During certain operations in VDR, such as startup or channel change (depending also on the speed of initialization of the video output driver), VDR does not consume the filter data as fast as it is provided by streamdev-client, resulting in overflow of the default socket buffers used by streamdev-client. To add to the problem of overflowing the socketpair buffers, the streamdev-client code sends several times a second short packets into the socketpair to determine if the receiving side (VDR) has closed the socketpair (IsClosed(), CarbageCollect()). This further clogs up the socketpair() buffer. The raspberry PI socketpair buffering behavior seems to be the same as that of other 3.x linux systems, the socket buffer size is by default 163840, and it can be increased via sysctl net.core.wmem_max. During startup, it can take up to 10 seconds before VDR will consume filter data, so the socketpair buffer can fill up with 10 seconds worth of data. Solution 1. IsClosed()/CarbageCollect() where removed from client/filter.c and replaced by explicitly tracking when VDR closes a filter socket. This alone seems to already resolve the problem of hanging or stop&go video and seems to be sufficient to receive dynamic-PID channels reliably. 2. filter.c was enhanced to request a larger socket buffer size if config option FilterSockBufSize is set. 3. If supported (if streamdev-client runs on linux), the socketpair queue is "flushed" to reduce the amount of "random" packet drop messages and to rather drop sequential messages.
2015-01-24 00:19:04 +01:00
virtual void CloseFilter(int Handle);
2004-12-30 23:43:55 +01:00
public:
cStreamdevDevice(void);
virtual ~cStreamdevDevice();
virtual bool HasInternalCam(void) { return true; }
2004-12-30 23:43:55 +01:00
virtual bool ProvidesSource(int Source) const;
virtual bool ProvidesTransponder(const cChannel *Channel) const;
2004-12-30 23:43:55 +01:00
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1,
bool *NeedsDetachReceivers = NULL) const;
#if APIVERSNUM >= 10700
virtual int NumProvidedSystems(void) const;
#endif
#if APIVERSNUM >= 10719
virtual bool AvoidRecording(void) const { return true; }
#endif
2011-12-09 09:05:09 +01:00
#if APIVERSNUM >= 10722
virtual bool IsTunedToTransponder(const cChannel *Channel) const;
#else
virtual bool IsTunedToTransponder(const cChannel *Channel);
2011-12-09 09:05:09 +01:00
#endif
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
virtual cString DeviceName(void) const;
virtual cString DeviceType(void) const;
virtual int SignalStrength(void) const;
virtual int SignalQuality(void) const;
2004-12-30 23:43:55 +01:00
bool ReInit(bool Disable);
void UpdatePriority(bool SwitchingChannels = false) const;
bool SuspendServer() { return m_ClientSocket->SuspendServer(); }
static void DenyChannel(const cChannel *Channel) { m_DenyChannel = Channel; }
2004-12-30 23:43:55 +01:00
};
#endif // VDR_STREAMDEV_DEVICE_H