summaryrefslogtreecommitdiff
path: root/device.h
blob: a8cb426599144f5bd5b293ed7547620b4728faa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 * (c) BayCom GmbH, http://www.baycom.de, info@baycom.de
 *
 * See the COPYING file for copyright information and
 * how to reach the author.
 *
 */

#ifndef VDR_MCLI_DEVICE_H
#define VDR_MCLI_DEVICE_H

#include <vdr/device.h>
#include <mcliheaders.h>

#include "packetbuffer.h"

class cPluginMcli;
struct tuner_pool;
struct cam_pool;

class cMcliDevice:public cDevice
{

      private:
	int m_pidsnum;
	int m_mcpidsnum;
	bool m_dvr_open;
	recv_info_t *m_r;
	recv_sec_t m_sec;
	int m_pos;
	struct dvb_frontend_parameters m_fep;
	dvb_pid_t m_pids[RECV_MAX_PIDS];
	tra_t m_ten;
	int m_fetype;
	cChannel m_chan;
	cMutex mutex;
	bool m_enable;
	time_t m_last;
	int m_filternum;
	int m_disabletimeout;
	bool m_tuned;
	bool m_showtuning;
	bool m_ca_enable;
	bool m_ca_override;
	struct tuner_pool *m_tunerref;
	struct cam_pool *m_camref;

      protected:
      	cPluginMcli *m_mcli;
	virtual bool SetChannelDevice (const cChannel * Channel, bool LiveView);
	virtual bool HasLock (int TimeoutMs);
	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);
	virtual void CloseFilter (int Handle);
	virtual bool CheckCAM(const cChannel * Channel, bool steal=false) const;

#ifdef GET_TS_PACKETS
	virtual int GetTSPackets (uchar *, int);
#endif
	bool IsTunedToTransponderConst (const cChannel * Channel) const;
	void TranslateTypePos(int &type, int &pos, const int Source) const;
	
	
      public:
	cCondVar m_locked;
#ifdef USE_VDR_PACKET_BUFFER
	cRingBufferLinear *m_PB;
	cMutex m_PB_Lock;
	bool delivered;
#else
	cMyPacketBuffer *m_PB;
#endif
	cMcliFilters *m_filters;
	cMcliDevice (void);
	virtual ~ cMcliDevice ();
	virtual bool Ready();
	void SetMcliRef(cPluginMcli *m)
	{
		m_mcli=m;
	}
	virtual int NumProvidedSystems(void) const
	{
		return (m_fetype == FE_DVBS2)?2:1;
	}
  
#ifdef REELVDR
	const cChannel *CurChan () const
	{
		return &m_chan;
	};
#endif
	unsigned int FrequencyToHz (unsigned int f)
	{
		while (f && f < 1000000)
			f *= 1000;
		return f;
	}
	virtual bool HasInternalCam (void)
	{
		return true; 
	}
	virtual bool ProvidesSource (int Source) const;
	virtual bool ProvidesTransponder (const cChannel * Channel) const;
	virtual bool ProvidesChannel (const cChannel * Channel, int Priority = -1, bool * NeedsDetachReceivers = NULL) const;
	virtual bool IsTunedToTransponder (const cChannel * Channel);

	virtual int HandleTsData (unsigned char *buffer, size_t len);
	tra_t *GetTenData (void) {
		return &m_ten;
	}
	void SetTenData (tra_t * ten);
	void SetCaEnable (bool val = true) 
	{
		m_ca_enable=val;
	}
	bool GetCaEnable (void) const
	{
		return m_ca_enable;
	}
	struct cam_pool *GetCAMref (void) const
	{
		return m_camref;
	}
	void SetCaOverride (bool val = true) 
	{
		m_ca_override=val;
	}
	bool GetCaOverride (void) const
	{
		return m_ca_override;
	}
	void SetEnable (bool val = true);
	bool SetTempDisable (bool now = false);
	void SetFEType (fe_type_t val);
	fe_type_t GetFEType (void)
	{
		return (fe_type_t)m_fetype;
	};
	void InitMcli (void);
	void ExitMcli (void);
	virtual bool ProvidesS2 () const
	{
		return m_fetype == FE_DVBS2;
	}
	virtual bool HasInput (void) const
	{
		return m_enable;
	}
#ifdef DEVICE_ATTRIBUTES
	// Reel extension
	virtual int GetAttribute (const char *attr_name, uint64_t * val);
	virtual int GetAttribute (const char *attr_name, char *val, int maxret);
#endif
#if VDRVERSNUM > 10720
	bool ProvidesEIT(void) const {
		return true;
	}
#endif
};

#endif // VDR_MCLI_DEVICE_H