summaryrefslogtreecommitdiff
path: root/tsworker.h
blob: cb1652d949c9f105a0f4d6163b6c7c0930ce4b9e (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
/*
 * tsworker.h: TS worker thread 
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef _TSWORKER__H
#define _TSWORKER__H

#include <vdr/thread.h>

#include "tools/socket.h"
#include "streamdevice.h"
#include "remote.h"
#include "netosd.h"
#include "ffnetdev.h"

typedef unsigned long long u64;

#define TCP_SEND_SIZE (1024 * 20)


// --- cTSWorker -------------------------------------------------------------

class cTSWorker : public cThread {
private:
	bool m_Active;
	bool have_Streamclient;
	bool close_Streamclient_request;
	static cTSWorker *m_Instance;
	cStreamDevice *m_StreamDevice;
	cTBSocket *m_StreamClient;
	int TSPort;
	int origPrimaryDevice;
	cPluginFFNetDev *m_pPlugin;	
	u64 get_time(void);

protected:
	virtual void Action(void);
	virtual void ActionTCP(void);
	virtual void ActionUDP(void);
	void Stop(void);
public:
	cTSWorker(void);
	virtual ~cTSWorker();

	static void Init(cStreamDevice*, int, cPluginFFNetDev*);
	static void Exit(void);
	static bool Active(void);
	
	static bool HaveStreamClient(void);
	static void CloseStreamClient(void);
};

inline bool cTSWorker::Active(void) {
    return m_Instance && (m_Instance->have_Streamclient==true);
}

inline bool cTSWorker::HaveStreamClient(void) {
	return m_Instance->have_Streamclient;
}
#endif