forked from rofafor/vdr-plugin-satip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discover.h
113 lines (102 loc) · 3.87 KB
/
discover.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* discover.h: SAT>IP plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __SATIP_DISCOVER_H
#define __SATIP_DISCOVER_H
#include <curl/curl.h>
#include <vdr/thread.h>
#include <vdr/tools.h>
#include "common.h"
#include "discoverif.h"
#include "msearch.h"
#include "server.h"
#include "socket.h"
class cSatipDiscoverServer : public cListObject {
private:
int ipPortM;
int quirkM;
cString srcAddressM;
cString ipAddressM;
cString descriptionM;
cString modelM;
cString filtersM;
public:
cSatipDiscoverServer(const char *srcAddressP, const char *ipAddressP, const int ipPortP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP)
{
srcAddressM = srcAddressP; ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; filtersM = filtersP; descriptionM = descriptionP; quirkM = quirkP;
}
int IpPort(void) { return ipPortM; }
int Quirk(void) { return quirkM; }
const char *SrcAddress(void) { return *srcAddressM; }
const char *IpAddress(void) { return *ipAddressM; }
const char *Model(void) { return *modelM; }
const char *Filters(void) { return *filtersM; }
const char *Description(void) { return *descriptionM; }
};
class cSatipDiscoverServers : public cList<cSatipDiscoverServer> {
};
class cSatipDiscover : public cThread, public cSatipDiscoverIf {
private:
enum {
eSleepTimeoutMs = 500, // in milliseconds
eConnectTimeoutMs = 1500, // in milliseconds
eProbeTimeoutMs = 2000, // in milliseconds
eProbeIntervalMs = 60000, // in milliseconds
eCleanupTimeoutMs = 124000 // in milliseoonds
};
static cSatipDiscover *instanceS;
static size_t HeaderCallback(char *ptrP, size_t sizeP, size_t nmembP, void *dataP);
static size_t DataCallback(char *ptrP, size_t sizeP, size_t nmembP, void *dataP);
static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP);
cMutex mutexM;
cSatipMemoryBuffer headerBufferM;
cSatipMemoryBuffer dataBufferM;
cSatipMsearch msearchM;
cStringList probeUrlListM;
CURL *handleM;
cCondWait sleepM;
cTimeMs probeIntervalM;
cSatipServers serversM;
void Activate(void);
void Deactivate(void);
int ParseRtspPort(void);
void ParseDeviceInfo(const char *addrP, const int portP);
void AddServer(const char *srcAddrP, const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP);
void Fetch(const char *urlP);
// constructor
cSatipDiscover();
// to prevent copy constructor and assignment
cSatipDiscover(const cSatipDiscover&);
cSatipDiscover& operator=(const cSatipDiscover&);
protected:
virtual void Action(void);
public:
static cSatipDiscover *GetInstance(void);
static bool Initialize(cSatipDiscoverServers *serversP);
static void Destroy(void);
virtual ~cSatipDiscover();
void TriggerScan(void) { probeIntervalM.Set(0); }
int GetServerCount(void);
cSatipServer *AssignServer(int deviceIdP, int sourceP, int transponderP, int systemP);
cSatipServer *GetServer(int sourceP);
cSatipServer *GetServer(cSatipServer *serverP);
cSatipServers *GetServers(void);
cString GetServerString(cSatipServer *serverP);
void ActivateServer(cSatipServer *serverP, bool onOffP);
void AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
void DetachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
bool IsServerQuirk(cSatipServer *serverP, int quirkP);
bool HasServerCI(cSatipServer *serverP);
cString GetServerAddress(cSatipServer *serverP);
cString GetSourceAddress(cSatipServer *serverP);
int GetServerPort(cSatipServer *serverP);
cString GetServerList(void);
int NumProvidedSystems(void);
// for internal discover interface
public:
virtual void SetUrl(const char *urlP);
};
#endif // __SATIP_DISCOVER_H