summaryrefslogtreecommitdiff
path: root/clientcontrol.h
blob: 99fd4e61f0a2df4f8e0d67e51d24e2291aaf322b (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
/*
 * clientcontrol.h: ClientControl thread 
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef _CLIENTCONTROL__H
#define _CLIENTCONTROL__H

#include <vdr/thread.h>

#include "tool_socket.h"
#include "ffnetdev.h"

enum CCPakType{ ptInfo=0, ptPlayState, ptPlayStateReq, ptStillPicture, ptFreeze };

struct SClientControl
{
   char pakType;
   int dataLen;
   char data[0];
};

struct SClientControlInfo
{
   char clientName[20];
};

struct SClientControlPlayState
{
   char PlayMode;
   bool Play;
   bool Forward;
   char Speed;
};

struct SClientControlStillPicture
{
   uchar *Data;
   int Length;
};


// --- cClientControl -------------------------------------------------------------

class cClientControl : public cThread {
private:
	bool m_Active;
	bool m_bHaveClient;
	bool m_bCloseClientRequest;
	static cClientControl *m_Instance;
	cTBSocket *m_ClientSocket;
	int m_iPort;
	cPluginFFNetDev *m_pPlugin;
	bool m_bPlayStateReq;

protected:
	virtual void Action(void);
	void Stop(void);
public:
	cClientControl(void);
	virtual ~cClientControl();

	static void Init(int, cPluginFFNetDev*);
	static void Exit(void);
	static bool Active(void);
	
	static bool HaveClient(void);
	static void CloseStreamClient(void);
	
	static bool SendPlayState(ePlayMode PlayMode, bool bPlay, bool bForward, int iSpeed);
	static bool PlayStateReq(void) { return m_Instance->m_bPlayStateReq; };
	static bool SendStillPicture(const uchar *Data, int Length);
	static bool SendSFreeze();
};

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

inline bool cClientControl::HaveClient(void) {
	return m_Instance->m_bHaveClient;
}
#endif