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>
|
|
|
|
|
2015-03-22 17:51:39 +01:00
|
|
|
#include "common.h"
|
2014-11-29 14:37:21 +01:00
|
|
|
#include "discoverif.h"
|
2014-11-16 23:23:20 +01:00
|
|
|
#include "msearch.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:
|
2016-02-22 16:58:33 +01:00
|
|
|
int ipPortM;
|
2016-10-09 17:53:40 +02:00
|
|
|
int quirkM;
|
2017-07-19 16:47:22 +02:00
|
|
|
cString srcAddressM;
|
2014-11-04 21:32:12 +01:00
|
|
|
cString ipAddressM;
|
|
|
|
cString descriptionM;
|
|
|
|
cString modelM;
|
2016-07-23 21:40:01 +02:00
|
|
|
cString filtersM;
|
2014-11-04 21:32:12 +01:00
|
|
|
public:
|
2017-07-19 16:47:22 +02:00
|
|
|
cSatipDiscoverServer(const char *srcAddressP, const char *ipAddressP, const int ipPortP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP)
|
2014-11-04 21:32:12 +01:00
|
|
|
{
|
2017-07-19 16:47:22 +02:00
|
|
|
srcAddressM = srcAddressP; ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; filtersM = filtersP; descriptionM = descriptionP; quirkM = quirkP;
|
2014-11-04 21:32:12 +01:00
|
|
|
}
|
2016-02-22 16:58:33 +01:00
|
|
|
int IpPort(void) { return ipPortM; }
|
2016-10-09 17:53:40 +02:00
|
|
|
int Quirk(void) { return quirkM; }
|
2017-07-19 16:47:22 +02:00
|
|
|
const char *SrcAddress(void) { return *srcAddressM; }
|
2014-11-04 21:32:12 +01:00
|
|
|
const char *IpAddress(void) { return *ipAddressM; }
|
|
|
|
const char *Model(void) { return *modelM; }
|
2016-07-23 21:40:01 +02:00
|
|
|
const char *Filters(void) { return *filtersM; }
|
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-11-29 14:37:21 +01:00
|
|
|
class cSatipDiscover : public cThread, public cSatipDiscoverIf {
|
2014-03-08 12:07:47 +01:00
|
|
|
private:
|
|
|
|
enum {
|
2015-03-25 23:28:17 +01:00
|
|
|
eSleepTimeoutMs = 500, // in milliseconds
|
|
|
|
eConnectTimeoutMs = 1500, // in milliseconds
|
|
|
|
eProbeTimeoutMs = 2000, // in milliseconds
|
|
|
|
eProbeIntervalMs = 60000, // in milliseconds
|
|
|
|
eCleanupTimeoutMs = 124000 // in milliseoonds
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
static cSatipDiscover *instanceS;
|
2016-02-22 16:58:33 +01:00
|
|
|
static size_t HeaderCallback(char *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
2015-03-22 17:51:39 +01:00
|
|
|
static size_t DataCallback(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;
|
2016-02-22 16:58:33 +01:00
|
|
|
cSatipMemoryBuffer headerBufferM;
|
2015-03-22 17:51:39 +01:00
|
|
|
cSatipMemoryBuffer dataBufferM;
|
2014-11-16 23:23:20 +01:00
|
|
|
cSatipMsearch msearchM;
|
|
|
|
cStringList probeUrlListM;
|
2014-03-08 12:07:47 +01:00
|
|
|
CURL *handleM;
|
|
|
|
cCondWait sleepM;
|
|
|
|
cTimeMs probeIntervalM;
|
2014-11-17 21:33:38 +01:00
|
|
|
cSatipServers serversM;
|
2014-03-13 17:23:55 +01:00
|
|
|
void Activate(void);
|
|
|
|
void Deactivate(void);
|
2016-02-22 16:58:33 +01:00
|
|
|
int ParseRtspPort(void);
|
|
|
|
void ParseDeviceInfo(const char *addrP, const int portP);
|
2017-07-19 16:47:22 +02:00
|
|
|
void AddServer(const char *srcAddrP, const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP);
|
2014-11-16 23:23:20 +01:00
|
|
|
void Fetch(const char *urlP);
|
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);
|
2015-02-16 16:21:00 +01:00
|
|
|
cSatipServer *AssignServer(int deviceIdP, int sourceP, int transponderP, int systemP);
|
2015-01-15 22:33:51 +01:00
|
|
|
cSatipServer *GetServer(int sourceP);
|
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);
|
2016-06-22 21:27:53 +02:00
|
|
|
void ActivateServer(cSatipServer *serverP, bool onOffP);
|
2015-02-16 16:21:00 +01:00
|
|
|
void AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
|
|
|
void DetachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
2015-01-15 22:33:51 +01:00
|
|
|
bool IsServerQuirk(cSatipServer *serverP, int quirkP);
|
2015-01-25 23:21:55 +01:00
|
|
|
bool HasServerCI(cSatipServer *serverP);
|
2015-01-15 22:33:51 +01:00
|
|
|
cString GetServerAddress(cSatipServer *serverP);
|
2017-07-19 16:47:22 +02:00
|
|
|
cString GetSourceAddress(cSatipServer *serverP);
|
2016-02-22 16:58:33 +01:00
|
|
|
int GetServerPort(cSatipServer *serverP);
|
2014-03-08 12:07:47 +01:00
|
|
|
cString GetServerList(void);
|
|
|
|
int NumProvidedSystems(void);
|
2014-11-29 14:37:21 +01:00
|
|
|
|
|
|
|
// for internal discover interface
|
|
|
|
public:
|
|
|
|
virtual void SetUrl(const char *urlP);
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_DISCOVER_H
|