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()
|
||||
: cThread("SAT>IP discover"),
|
||||
mutexM(),
|
||||
msearchM(),
|
||||
msearchM(*this),
|
||||
probeUrlListM(),
|
||||
handleM(curl_easy_init()),
|
||||
sleepM(),
|
||||
@ -190,14 +190,6 @@ void cSatipDiscover::Action(void)
|
||||
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)
|
||||
{
|
||||
debug("cSatipDiscover::%s(%s)", __FUNCTION__, urlP);
|
||||
@ -312,3 +304,12 @@ int cSatipDiscover::NumProvidedSystems(void)
|
||||
cMutexLock MutexLock(&mutexM);
|
||||
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/tools.h>
|
||||
|
||||
#include "discoverif.h"
|
||||
#include "msearch.h"
|
||||
#include "server.h"
|
||||
#include "socket.h"
|
||||
@ -35,7 +36,7 @@ public:
|
||||
class cSatipDiscoverServers : public cList<cSatipDiscoverServer> {
|
||||
};
|
||||
|
||||
class cSatipDiscover : public cThread {
|
||||
class cSatipDiscover : public cThread, public cSatipDiscoverIf {
|
||||
private:
|
||||
enum {
|
||||
eSleepTimeoutMs = 500, // in milliseconds
|
||||
@ -71,7 +72,6 @@ public:
|
||||
static bool Initialize(cSatipDiscoverServers *serversP);
|
||||
static void Destroy(void);
|
||||
virtual ~cSatipDiscover();
|
||||
void Probe(const char *urlP);
|
||||
void TriggerScan(void) { probeIntervalM.Set(0); }
|
||||
int GetServerCount(void);
|
||||
cSatipServer *GetServer(int sourceP, int transponderP = 0, int systemP = -1);
|
||||
@ -82,6 +82,10 @@ public:
|
||||
void UseServer(cSatipServer *serverP, bool onOffP);
|
||||
cString GetServerList(void);
|
||||
int NumProvidedSystems(void);
|
||||
|
||||
// for internal discover interface
|
||||
public:
|
||||
virtual void SetUrl(const char *urlP);
|
||||
};
|
||||
|
||||
#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" \
|
||||
"MX: 2\r\n\r\n";
|
||||
|
||||
cSatipMsearch::cSatipMsearch(void)
|
||||
: bufferLenM(eProbeBufferSize),
|
||||
cSatipMsearch::cSatipMsearch(cSatipDiscoverIf &discoverP)
|
||||
: discoverM(discoverP),
|
||||
bufferLenM(eProbeBufferSize),
|
||||
bufferM(MALLOC(unsigned char, bufferLenM)),
|
||||
registeredM(false)
|
||||
{
|
||||
@ -53,8 +54,8 @@ void cSatipMsearch::Process(void)
|
||||
{
|
||||
//debug("cSatipMsearch::%s()", __FUNCTION__);
|
||||
if (bufferM) {
|
||||
int length = Read(bufferM, bufferLenM);
|
||||
if (length > 0) {
|
||||
int length;
|
||||
while ((length = Read(bufferM, bufferLenM)) > 0) {
|
||||
bufferM[min(length, int(bufferLenM - 1))] = 0;
|
||||
//debug("cSatipMsearch::%s(): len=%d buf=%s", __FUNCTION__, length, bufferM);
|
||||
bool status = false, valid = false;
|
||||
@ -83,13 +84,15 @@ void cSatipMsearch::Process(void)
|
||||
}
|
||||
// Check whether all the required data is found
|
||||
if (valid && !isempty(location)) {
|
||||
cSatipDiscover::GetInstance()->Probe(location);
|
||||
discoverM.SetUrl(location);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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_
|
||||
#define __SATIP_MSEARCH_H_
|
||||
|
||||
#include "discoverif.h"
|
||||
#include "socket.h"
|
||||
#include "pollerif.h"
|
||||
|
||||
@ -19,12 +20,13 @@ private:
|
||||
};
|
||||
static const char *bcastAddressS;
|
||||
static const char *bcastMessageS;
|
||||
cSatipDiscoverIf &discoverM;
|
||||
unsigned int bufferLenM;
|
||||
unsigned char *bufferM;
|
||||
bool registeredM;
|
||||
|
||||
public:
|
||||
cSatipMsearch(void);
|
||||
cSatipMsearch(cSatipDiscoverIf &discoverP);
|
||||
virtual ~cSatipMsearch();
|
||||
void Probe(void);
|
||||
|
||||
|
2
rtcp.c
2
rtcp.c
@ -88,7 +88,7 @@ void cSatipRtcp::Process(void)
|
||||
tunerM.ProcessApplicationData(bufferM + offset, length);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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