00001
00002
00003 #ifndef _DVBSTREAMHANDLER_H_
00004 #define _DVBSTREAMHANDLER_H_
00005
00006 #include <vector>
00007 using namespace std;
00008
00009 #include <QString>
00010 #include <QMutex>
00011 #include <QMap>
00012
00013 #include "streamhandler.h"
00014
00015 class QString;
00016 class DVBStreamHandler;
00017 class DTVSignalMonitor;
00018 class DVBChannel;
00019 class DeviceReadBuffer;
00020
00021
00022
00023 class DVBPIDInfo : public PIDInfo
00024 {
00025 public:
00026 DVBPIDInfo(uint pid) : PIDInfo(pid) {}
00027 DVBPIDInfo(uint pid, uint stream_type, int pes_type) :
00028 PIDInfo(pid, stream_type, pes_type) {}
00029 bool Open(const QString &dvb_dev, bool use_section_reader);
00030 bool Close(const QString &dvb_dev);
00031 };
00032
00033 class DVBStreamHandler : public StreamHandler
00034 {
00035 public:
00036 static DVBStreamHandler *Get(const QString &dvb_device);
00037 static void Return(DVBStreamHandler * & ref);
00038
00039
00040
00041 void RetuneMonitor(void);
00042
00043 bool IsRetuneAllowed(void) const { return _allow_retune; }
00044
00045 void SetRetuneAllowed(bool allow,
00046 DTVSignalMonitor *sigmon,
00047 DVBChannel *dvbchan);
00048
00049 private:
00050 DVBStreamHandler(const QString &);
00051
00052 virtual void run(void);
00053 void RunTS(void);
00054 void RunSR(void);
00055
00056 virtual void CycleFiltersByPriority(void);
00057
00058 bool SupportsTSMonitoring(void);
00059
00060 virtual PIDInfo *CreatePIDInfo(uint pid, uint stream_type, int pes_type)
00061 { return new DVBPIDInfo(pid, stream_type, pes_type); }
00062
00063 virtual void SetRunningDesired(bool desired);
00064
00065 private:
00066 QString _dvr_dev_path;
00067 volatile bool _allow_retune;
00068
00069 DTVSignalMonitor *_sigmon;
00070 DVBChannel *_dvbchannel;
00071 DeviceReadBuffer *_drb;
00072
00073
00074 static QMutex _rec_supports_ts_monitoring_lock;
00075 static QMap<QString,bool> _rec_supports_ts_monitoring;
00076
00077
00078 static QMutex _handlers_lock;
00079 static QMap<QString,DVBStreamHandler*> _handlers;
00080 static QMap<QString,uint> _handlers_refcnt;
00081 };
00082
00083 #endif // _DVBSTREAMHANDLER_H_