-
Notifications
You must be signed in to change notification settings - Fork 0
/
comthread.h
95 lines (72 loc) · 2.43 KB
/
comthread.h
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
//***************************************************************************
// Group VDR/GraphTFTng
// File comthread.h
// Date 31.10.06
// This code is distributed under the terms and conditions of the
// GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
// (c) 2006-2013 Jörg Wendel
//--------------------------------------------------------------------------
// Class ComThread
//***************************************************************************
#ifndef __GTFT_COMTHREAD_H__
#define __GTFT_COMTHREAD_H__
#include <vector>
#include <vdr/plugin.h>
#include <vdr/remote.h>
#include <tcpchannel.h>
#include <renderer.h>
#include <service.h>
using std::vector;
//***************************************************************************
// Communication Thread
//***************************************************************************
class ComThread : protected cThread, protected cRemote, public cGraphTftComService
{
public:
enum Misc
{
maxBuf = 512*1024
};
struct TcpClient
{
TcpChannel* channel;
int jpgQuality;
time_t lastCheck;
};
ComThread(void* aDisplay, int width, int height);
virtual ~ComThread();
void stop() { running = false; }
int refresh();
int init(Renderer* aRenderer, unsigned int aPort = 0, const char* aHost = 0);
bool Start() { return cThread::Start(); }
void Stop();
void setHost(const char* aHost) { strcpy(host, aHost); }
void setPort(unsigned short aPort) { port = aPort; }
void setJpegQuality(int value) { jpgQuality = value; }
protected:
void Action();
int close(TcpClient* client, int status, const char* message = 0);
int read(fd_set* readSet);
int read(TcpClient* client);
int refresh(TcpClient* client);
virtual bool Put(uint64_t Code, bool Repeat = false, bool Release = false);
// data
TcpChannel* listener;
Renderer* renderer;
void* display;
cMutex _mutex;
int themeWidth;
int themeHeight;
char* buffer;
int bufferSize;
int timeout;
int checkTime;
int running;
unsigned short port;
char host[100+TB];
int pid;
int jpgQuality;
vector<TcpClient> clients;
};
//***************************************************************************
#endif // __GTFT_COMTHREAD_H__