2014-03-08 12:07:47 +01:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2014-03-13 17:23:55 +01:00
|
|
|
#include "server.h"
|
2014-03-08 12:07:47 +01:00
|
|
|
#include "socket.h"
|
|
|
|
|
2014-11-04 21:32:12 +01:00
|
|
|
class cSatipDiscoverServer : public cListObject {
|
|
|
|
private:
|
|
|
|
cString ipAddressM;
|
|
|
|
cString descriptionM;
|
|
|
|
cString modelM;
|
|
|
|
public:
|
2014-11-10 23:05:03 +01:00
|
|
|
cSatipDiscoverServer(const char *ipAddressP, const char *modelP, const char *descriptionP)
|
2014-11-04 21:32:12 +01:00
|
|
|
{
|
2014-11-10 23:05:03 +01:00
|
|
|
ipAddressM = ipAddressP; modelM = modelP; descriptionM = descriptionP;
|
2014-11-04 21:32:12 +01:00
|
|
|
}
|
|
|
|
const char *IpAddress(void) { return *ipAddressM; }
|
|
|
|
const char *Model(void) { return *modelM; }
|
2014-11-10 23:05:03 +01:00
|
|
|
const char *Description(void) { return *descriptionM; }
|
2014-11-04 21:32:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class cSatipDiscoverServers : public cList<cSatipDiscoverServer> {
|
|
|
|
};
|
|
|
|
|
2014-03-08 12:07:47 +01:00
|
|
|
class cSatipDiscover : public cThread {
|
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
eConnectTimeoutMs = 1500, // in milliseconds
|
|
|
|
eDiscoveryPort = 1900,
|
|
|
|
eProbeBufferSize = 1024, // in bytes
|
|
|
|
eProbeTimeoutMs = 2000, // in milliseconds
|
|
|
|
eProbeIntervalMs = 60000 // in milliseconds
|
|
|
|
};
|
|
|
|
static cSatipDiscover *instanceS;
|
|
|
|
static const char *bcastAddressS;
|
|
|
|
static const char *bcastMessageS;
|
2014-03-16 18:58:09 +01:00
|
|
|
static size_t WriteCallback(char *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
2014-11-09 19:32:08 +01:00
|
|
|
static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP);
|
2014-03-08 12:07:47 +01:00
|
|
|
cMutex mutexM;
|
|
|
|
CURL *handleM;
|
|
|
|
cSatipSocket *socketM;
|
|
|
|
cCondWait sleepM;
|
|
|
|
cTimeMs probeIntervalM;
|
|
|
|
cSatipServers *serversM;
|
2014-03-13 17:23:55 +01:00
|
|
|
void Activate(void);
|
|
|
|
void Deactivate(void);
|
2014-03-08 12:07:47 +01:00
|
|
|
void Janitor(void);
|
|
|
|
void Probe(void);
|
|
|
|
void Read(void);
|
2014-11-10 23:05:03 +01:00
|
|
|
void AddServer(const char *addrP, const char *modelP, const char *descP);
|
2014-03-08 12:07:47 +01:00
|
|
|
// 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);
|
2014-11-04 21:32:12 +01:00
|
|
|
static bool Initialize(cSatipDiscoverServers *serversP);
|
2014-03-08 12:07:47 +01:00
|
|
|
static void Destroy(void);
|
|
|
|
virtual ~cSatipDiscover();
|
2014-03-13 17:23:55 +01:00
|
|
|
void TriggerScan(void) { probeIntervalM.Set(0); }
|
2014-03-23 16:59:08 +01:00
|
|
|
int GetServerCount(void);
|
2014-11-01 15:31:44 +01:00
|
|
|
cSatipServer *GetServer(int sourceP, int transponderP = 0, int systemP = -1);
|
2014-03-13 17:23:55 +01:00
|
|
|
cSatipServer *GetServer(cSatipServer *serverP);
|
2014-03-08 12:07:47 +01:00
|
|
|
cSatipServers *GetServers(void);
|
2014-03-13 17:23:55 +01:00
|
|
|
cString GetServerString(cSatipServer *serverP);
|
2014-11-01 15:31:44 +01:00
|
|
|
void SetTransponder(cSatipServer *serverP, int transponderP);
|
2014-03-13 17:23:55 +01:00
|
|
|
void UseServer(cSatipServer *serverP, bool onOffP);
|
2014-03-08 12:07:47 +01:00
|
|
|
cString GetServerList(void);
|
|
|
|
int NumProvidedSystems(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_DISCOVER_H
|