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
|
77
msearch.c
77
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,43 +54,45 @@ void cSatipMsearch::Process(void)
|
||||
{
|
||||
//debug("cSatipMsearch::%s()", __FUNCTION__);
|
||||
if (bufferM) {
|
||||
int length = Read(bufferM, bufferLenM);
|
||||
if (length > 0) {
|
||||
bufferM[min(length, int(bufferLenM - 1))] = 0;
|
||||
//debug("cSatipMsearch::%s(): len=%d buf=%s", __FUNCTION__, length, bufferM);
|
||||
bool status = false, valid = false;
|
||||
char *s, *p = reinterpret_cast<char *>(bufferM), *location = NULL;
|
||||
char *r = strtok_r(p, "\r\n", &s);
|
||||
while (r) {
|
||||
//debug("cSatipMsearch::%s(): %s", __FUNCTION__, r);
|
||||
// Check the status code
|
||||
// HTTP/1.1 200 OK
|
||||
if (!status && startswith(r, "HTTP/1.1 200 OK"))
|
||||
status = true;
|
||||
if (status) {
|
||||
// Check the location data
|
||||
// LOCATION: http://192.168.0.115:8888/octonet.xml
|
||||
if (startswith(r, "LOCATION:")) {
|
||||
location = compactspace(r + 9);
|
||||
debug("cSatipMsearch::%s(): location='%s'", __FUNCTION__, location);
|
||||
}
|
||||
// Check the source type
|
||||
// ST: urn:ses-com:device:SatIPServer:1
|
||||
else if (startswith(r, "ST:")) {
|
||||
char *st = compactspace(r + 3);
|
||||
if (strstr(st, "urn:ses-com:device:SatIPServer:1"))
|
||||
valid = true;
|
||||
debug("cSatipMsearch::%s(): st='%s'", __FUNCTION__, st);
|
||||
}
|
||||
// Check whether all the required data is found
|
||||
if (valid && !isempty(location)) {
|
||||
cSatipDiscover::GetInstance()->Probe(location);
|
||||
break;
|
||||
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;
|
||||
char *s, *p = reinterpret_cast<char *>(bufferM), *location = NULL;
|
||||
char *r = strtok_r(p, "\r\n", &s);
|
||||
while (r) {
|
||||
//debug("cSatipMsearch::%s(): %s", __FUNCTION__, r);
|
||||
// Check the status code
|
||||
// HTTP/1.1 200 OK
|
||||
if (!status && startswith(r, "HTTP/1.1 200 OK"))
|
||||
status = true;
|
||||
if (status) {
|
||||
// Check the location data
|
||||
// LOCATION: http://192.168.0.115:8888/octonet.xml
|
||||
if (startswith(r, "LOCATION:")) {
|
||||
location = compactspace(r + 9);
|
||||
debug("cSatipMsearch::%s(): location='%s'", __FUNCTION__, location);
|
||||
}
|
||||
// Check the source type
|
||||
// ST: urn:ses-com:device:SatIPServer:1
|
||||
else if (startswith(r, "ST:")) {
|
||||
char *st = compactspace(r + 3);
|
||||
if (strstr(st, "urn:ses-com:device:SatIPServer:1"))
|
||||
valid = true;
|
||||
debug("cSatipMsearch::%s(): st='%s'", __FUNCTION__, st);
|
||||
}
|
||||
// Check whether all the required data is found
|
||||
if (valid && !isempty(location)) {
|
||||
discoverM.SetUrl(location);
|
||||
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_
|
||||
#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);
|
||||
|
||||
|
16
rtcp.c
16
rtcp.c
@ -81,14 +81,14 @@ void cSatipRtcp::Process(void)
|
||||
{
|
||||
//debug("cSatipRtcp::%s() [device %d]", __FUNCTION__, tunerM.GetId());
|
||||
if (bufferM) {
|
||||
int length;
|
||||
while ((length = Read(bufferM, bufferLenM)) > 0) {
|
||||
int offset = GetApplicationOffset(&length);
|
||||
if (offset >= 0)
|
||||
tunerM.ProcessApplicationData(bufferM + offset, length);
|
||||
}
|
||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
error("Error %d reading from RTCP socket [device %d]", errno, tunerM.GetId());
|
||||
int length;
|
||||
while ((length = Read(bufferM, bufferLenM)) > 0) {
|
||||
int offset = GetApplicationOffset(&length);
|
||||
if (offset >= 0)
|
||||
tunerM.ProcessApplicationData(bufferM + offset, length);
|
||||
}
|
||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
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