mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Added cSatipDiscoverIf().
This commit is contained in:
parent
cdb2e0e3b4
commit
eea0aa33bd
19
discover.c
19
discover.c
@ -119,7 +119,7 @@ int cSatipDiscover::DebugCallback(CURL *handleP, curl_infotype typeP, char *data
|
|||||||
cSatipDiscover::cSatipDiscover()
|
cSatipDiscover::cSatipDiscover()
|
||||||
: cThread("SAT>IP discover"),
|
: cThread("SAT>IP discover"),
|
||||||
mutexM(),
|
mutexM(),
|
||||||
msearchM(),
|
msearchM(*this),
|
||||||
probeUrlListM(),
|
probeUrlListM(),
|
||||||
handleM(curl_easy_init()),
|
handleM(curl_easy_init()),
|
||||||
sleepM(),
|
sleepM(),
|
||||||
@ -190,14 +190,6 @@ void cSatipDiscover::Action(void)
|
|||||||
debug("cSatipDiscover::%s(): exiting", __FUNCTION__);
|
debug("cSatipDiscover::%s(): exiting", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipDiscover::Probe(const char *urlP)
|
|
||||||
{
|
|
||||||
debug("cSatipDiscover::%s(%s)", __FUNCTION__, urlP);
|
|
||||||
cMutexLock MutexLock(&mutexM);
|
|
||||||
probeUrlListM.Insert(strdup(urlP));
|
|
||||||
sleepM.Signal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cSatipDiscover::Fetch(const char *urlP)
|
void cSatipDiscover::Fetch(const char *urlP)
|
||||||
{
|
{
|
||||||
debug("cSatipDiscover::%s(%s)", __FUNCTION__, urlP);
|
debug("cSatipDiscover::%s(%s)", __FUNCTION__, urlP);
|
||||||
@ -312,3 +304,12 @@ int cSatipDiscover::NumProvidedSystems(void)
|
|||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
return serversM.NumProvidedSystems();
|
return serversM.NumProvidedSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cSatipDiscover::SetUrl(const char *urlP)
|
||||||
|
{
|
||||||
|
//debug("cSatipDiscover::%s(%s)", __FUNCTION__, urlP);
|
||||||
|
mutexM.Lock();
|
||||||
|
probeUrlListM.Insert(strdup(urlP));
|
||||||
|
mutexM.Unlock();
|
||||||
|
sleepM.Signal();
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <vdr/thread.h>
|
#include <vdr/thread.h>
|
||||||
#include <vdr/tools.h>
|
#include <vdr/tools.h>
|
||||||
|
|
||||||
|
#include "discoverif.h"
|
||||||
#include "msearch.h"
|
#include "msearch.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
@ -35,7 +36,7 @@ public:
|
|||||||
class cSatipDiscoverServers : public cList<cSatipDiscoverServer> {
|
class cSatipDiscoverServers : public cList<cSatipDiscoverServer> {
|
||||||
};
|
};
|
||||||
|
|
||||||
class cSatipDiscover : public cThread {
|
class cSatipDiscover : public cThread, public cSatipDiscoverIf {
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
eSleepTimeoutMs = 500, // in milliseconds
|
eSleepTimeoutMs = 500, // in milliseconds
|
||||||
@ -71,7 +72,6 @@ public:
|
|||||||
static bool Initialize(cSatipDiscoverServers *serversP);
|
static bool Initialize(cSatipDiscoverServers *serversP);
|
||||||
static void Destroy(void);
|
static void Destroy(void);
|
||||||
virtual ~cSatipDiscover();
|
virtual ~cSatipDiscover();
|
||||||
void Probe(const char *urlP);
|
|
||||||
void TriggerScan(void) { probeIntervalM.Set(0); }
|
void TriggerScan(void) { probeIntervalM.Set(0); }
|
||||||
int GetServerCount(void);
|
int GetServerCount(void);
|
||||||
cSatipServer *GetServer(int sourceP, int transponderP = 0, int systemP = -1);
|
cSatipServer *GetServer(int sourceP, int transponderP = 0, int systemP = -1);
|
||||||
@ -82,6 +82,10 @@ public:
|
|||||||
void UseServer(cSatipServer *serverP, bool onOffP);
|
void UseServer(cSatipServer *serverP, bool onOffP);
|
||||||
cString GetServerList(void);
|
cString GetServerList(void);
|
||||||
int NumProvidedSystems(void);
|
int NumProvidedSystems(void);
|
||||||
|
|
||||||
|
// for internal discover interface
|
||||||
|
public:
|
||||||
|
virtual void SetUrl(const char *urlP);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __SATIP_DISCOVER_H
|
#endif // __SATIP_DISCOVER_H
|
||||||
|
22
discoverif.h
Normal file
22
discoverif.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* discoverif.h: SAT>IP plugin for the Video Disk Recorder
|
||||||
|
*
|
||||||
|
* See the README file for copyright information and how to reach the author.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SATIP_DISCOVERIF_H
|
||||||
|
#define __SATIP_DISCOVERIF_H
|
||||||
|
|
||||||
|
class cSatipDiscoverIf {
|
||||||
|
public:
|
||||||
|
cSatipDiscoverIf() {}
|
||||||
|
virtual ~cSatipDiscoverIf() {}
|
||||||
|
virtual void SetUrl(const char *urlP) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cSatipDiscoverIf(const cSatipDiscoverIf&);
|
||||||
|
cSatipDiscoverIf& operator=(const cSatipDiscoverIf&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __SATIP_DISCOVERIF_H
|
13
msearch.c
13
msearch.c
@ -17,8 +17,9 @@ const char *cSatipMsearch::bcastMessageS = "M-SEARCH * HTTP/1.1\r\n"
|
|||||||
"ST: urn:ses-com:device:SatIPServer:1\r\n" \
|
"ST: urn:ses-com:device:SatIPServer:1\r\n" \
|
||||||
"MX: 2\r\n\r\n";
|
"MX: 2\r\n\r\n";
|
||||||
|
|
||||||
cSatipMsearch::cSatipMsearch(void)
|
cSatipMsearch::cSatipMsearch(cSatipDiscoverIf &discoverP)
|
||||||
: bufferLenM(eProbeBufferSize),
|
: discoverM(discoverP),
|
||||||
|
bufferLenM(eProbeBufferSize),
|
||||||
bufferM(MALLOC(unsigned char, bufferLenM)),
|
bufferM(MALLOC(unsigned char, bufferLenM)),
|
||||||
registeredM(false)
|
registeredM(false)
|
||||||
{
|
{
|
||||||
@ -53,8 +54,8 @@ void cSatipMsearch::Process(void)
|
|||||||
{
|
{
|
||||||
//debug("cSatipMsearch::%s()", __FUNCTION__);
|
//debug("cSatipMsearch::%s()", __FUNCTION__);
|
||||||
if (bufferM) {
|
if (bufferM) {
|
||||||
int length = Read(bufferM, bufferLenM);
|
int length;
|
||||||
if (length > 0) {
|
while ((length = Read(bufferM, bufferLenM)) > 0) {
|
||||||
bufferM[min(length, int(bufferLenM - 1))] = 0;
|
bufferM[min(length, int(bufferLenM - 1))] = 0;
|
||||||
//debug("cSatipMsearch::%s(): len=%d buf=%s", __FUNCTION__, length, bufferM);
|
//debug("cSatipMsearch::%s(): len=%d buf=%s", __FUNCTION__, length, bufferM);
|
||||||
bool status = false, valid = false;
|
bool status = false, valid = false;
|
||||||
@ -83,13 +84,15 @@ void cSatipMsearch::Process(void)
|
|||||||
}
|
}
|
||||||
// Check whether all the required data is found
|
// Check whether all the required data is found
|
||||||
if (valid && !isempty(location)) {
|
if (valid && !isempty(location)) {
|
||||||
cSatipDiscover::GetInstance()->Probe(location);
|
discoverM.SetUrl(location);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r = strtok_r(NULL, "\r\n", &s);
|
r = strtok_r(NULL, "\r\n", &s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||||
|
error("Error %d reading in %s", errno, *ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#ifndef __SATIP_MSEARCH_H_
|
#ifndef __SATIP_MSEARCH_H_
|
||||||
#define __SATIP_MSEARCH_H_
|
#define __SATIP_MSEARCH_H_
|
||||||
|
|
||||||
|
#include "discoverif.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "pollerif.h"
|
#include "pollerif.h"
|
||||||
|
|
||||||
@ -19,12 +20,13 @@ private:
|
|||||||
};
|
};
|
||||||
static const char *bcastAddressS;
|
static const char *bcastAddressS;
|
||||||
static const char *bcastMessageS;
|
static const char *bcastMessageS;
|
||||||
|
cSatipDiscoverIf &discoverM;
|
||||||
unsigned int bufferLenM;
|
unsigned int bufferLenM;
|
||||||
unsigned char *bufferM;
|
unsigned char *bufferM;
|
||||||
bool registeredM;
|
bool registeredM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cSatipMsearch(void);
|
cSatipMsearch(cSatipDiscoverIf &discoverP);
|
||||||
virtual ~cSatipMsearch();
|
virtual ~cSatipMsearch();
|
||||||
void Probe(void);
|
void Probe(void);
|
||||||
|
|
||||||
|
2
rtcp.c
2
rtcp.c
@ -88,7 +88,7 @@ void cSatipRtcp::Process(void)
|
|||||||
tunerM.ProcessApplicationData(bufferM + offset, length);
|
tunerM.ProcessApplicationData(bufferM + offset, length);
|
||||||
}
|
}
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||||
error("Error %d reading from RTCP socket [device %d]", errno, tunerM.GetId());
|
error("Error %d reading in %s", errno, *ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
rtp.c
2
rtp.c
@ -118,7 +118,7 @@ void cSatipRtp::Process(void)
|
|||||||
tunerM.ProcessVideoData(bufferM + headerlen, length - headerlen);
|
tunerM.ProcessVideoData(bufferM + headerlen, length - headerlen);
|
||||||
}
|
}
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||||
error("Error %d reading from RTP socket [device %d]", errno, tunerM.GetId());
|
error("Error %d reading in %s", errno, *ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user