mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 11:37:42 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb9c1c6a44 | ||
|
|
5e2770a0e5 | ||
|
|
53b643139f | ||
|
|
9a8c6f8c0d | ||
|
|
fbbfdfab2b | ||
|
|
78ef582bea | ||
|
|
6e72eba09c |
18
HISTORY
18
HISTORY
@@ -46,3 +46,21 @@ VDR Plugin 'satip' Revision History
|
|||||||
- Fixed parameters of the OPTIONS command.
|
- Fixed parameters of the OPTIONS command.
|
||||||
- Added a device identication into the user agent string.
|
- Added a device identication into the user agent string.
|
||||||
- Removed unnecessary PLAY commands and header callbacks.
|
- Removed unnecessary PLAY commands and header callbacks.
|
||||||
|
|
||||||
|
2014-04-20: Version 0.3.0
|
||||||
|
|
||||||
|
- Tweaked the pid update mechanism.
|
||||||
|
|
||||||
|
2014-04-27: Version 0.3.1
|
||||||
|
|
||||||
|
- Fixed the device discovery.
|
||||||
|
|
||||||
|
2014-05-10: Version 0.3.2
|
||||||
|
|
||||||
|
- Fixed model detection and OctopusNet DVB-C model quirks.
|
||||||
|
- Added a session id quirk for GSSBOX.
|
||||||
|
|
||||||
|
2014-05-18: Version 0.3.3
|
||||||
|
|
||||||
|
- Added a validity check for the session member.
|
||||||
|
- Added a session id quirk for Triax TSS 400.
|
||||||
|
|||||||
9
common.c
9
common.c
@@ -57,6 +57,15 @@ char *StripTags(char *strP)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *SkipZeroes(const char *strP)
|
||||||
|
{
|
||||||
|
if ((uchar)*strP != '0')
|
||||||
|
return (char *)strP;
|
||||||
|
while (*strP && (uchar)*strP == '0')
|
||||||
|
strP++;
|
||||||
|
return (char *)strP;
|
||||||
|
}
|
||||||
|
|
||||||
cString ChangeCase(const cString &strP, bool upperP)
|
cString ChangeCase(const cString &strP, bool upperP)
|
||||||
{
|
{
|
||||||
cString res(strP);
|
cString res(strP);
|
||||||
|
|||||||
1
common.h
1
common.h
@@ -93,6 +93,7 @@ uint16_t ts_pid(const uint8_t *bufP);
|
|||||||
uint8_t payload(const uint8_t *bufP);
|
uint8_t payload(const uint8_t *bufP);
|
||||||
const char *id_pid(const u_short pidP);
|
const char *id_pid(const u_short pidP);
|
||||||
char *StripTags(char *strP);
|
char *StripTags(char *strP);
|
||||||
|
char *SkipZeroes(const char *strP);
|
||||||
cString ChangeCase(const cString &strP, bool upperP);
|
cString ChangeCase(const cString &strP, bool upperP);
|
||||||
|
|
||||||
struct section_filter_table_type {
|
struct section_filter_table_type {
|
||||||
|
|||||||
34
discover.c
34
discover.c
@@ -179,7 +179,7 @@ void cSatipDiscover::Read(void)
|
|||||||
int len = socketM->Read(buf, eProbeBufferSize);
|
int len = socketM->Read(buf, eProbeBufferSize);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
//debug("cSatipDiscover::%s(): len=%d", __FUNCTION__, len);
|
//debug("cSatipDiscover::%s(): len=%d", __FUNCTION__, len);
|
||||||
bool status = false;
|
bool status = false, valid = false;
|
||||||
char *s, *p = reinterpret_cast<char *>(buf), *location = NULL;
|
char *s, *p = reinterpret_cast<char *>(buf), *location = NULL;
|
||||||
char *r = strtok_r(p, "\r\n", &s);
|
char *r = strtok_r(p, "\r\n", &s);
|
||||||
while (r) {
|
while (r) {
|
||||||
@@ -187,18 +187,30 @@ void cSatipDiscover::Read(void)
|
|||||||
// Check the status code
|
// Check the status code
|
||||||
// HTTP/1.1 200 OK
|
// HTTP/1.1 200 OK
|
||||||
if (!status && startswith(r, "HTTP/1.1 200 OK")) {
|
if (!status && startswith(r, "HTTP/1.1 200 OK")) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
// Check the location data
|
if (status) {
|
||||||
// LOCATION: http://192.168.0.115:8888/octonet.xml
|
// Check the location data
|
||||||
if (status && startswith(r, "LOCATION:")) {
|
// LOCATION: http://192.168.0.115:8888/octonet.xml
|
||||||
location = compactspace(r + 9);
|
if (startswith(r, "LOCATION:")) {
|
||||||
debug("cSatipDiscover::%s(): location='%s'", __FUNCTION__, location);
|
location = compactspace(r + 9);
|
||||||
break;
|
debug("cSatipDiscover::%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("cSatipDiscover::%s(): st='%s'", __FUNCTION__, st);
|
||||||
|
}
|
||||||
|
// Check whether all the required data is found
|
||||||
|
if (valid && !isempty(location))
|
||||||
|
break;
|
||||||
|
}
|
||||||
r = strtok_r(NULL, "\r\n", &s);
|
r = strtok_r(NULL, "\r\n", &s);
|
||||||
}
|
}
|
||||||
if (handleM && !isempty(location)) {
|
if (handleM && valid && !isempty(location)) {
|
||||||
long rc = 0;
|
long rc = 0;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: vdr-satip 0.2.3\n"
|
"Project-Id-Version: vdr-satip 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: <see README>\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
|
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
|
||||||
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
|
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
|
||||||
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
|
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
|
||||||
"Language-Team: Catalan <vdr@linuxtv.org>\n"
|
"Language-Team: Catalan <vdr@linuxtv.org>\n"
|
||||||
"Language: ca\n"
|
"Language: ca\n"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: vdr-satip 0.2.3\n"
|
"Project-Id-Version: vdr-satip 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: <see README>\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
|
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
|
||||||
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
|
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
|
||||||
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
|
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
|
||||||
"Language-Team: German <vdr@linuxtv.org>\n"
|
"Language-Team: German <vdr@linuxtv.org>\n"
|
||||||
"Language: de\n"
|
"Language: de\n"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: vdr-satip 0.2.3\n"
|
"Project-Id-Version: vdr-satip 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: <see README>\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
|
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
|
||||||
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
|
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
|
||||||
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
|
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
|
||||||
"Language-Team: Spanish <vdr@linuxtv.org>\n"
|
"Language-Team: Spanish <vdr@linuxtv.org>\n"
|
||||||
"Language: es\n"
|
"Language: es\n"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: vdr-satip 0.2.3\n"
|
"Project-Id-Version: vdr-satip 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: <see README>\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
|
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
|
||||||
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
|
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
|
||||||
"Last-Translator: Rolf Ahrenberg\n"
|
"Last-Translator: Rolf Ahrenberg\n"
|
||||||
"Language-Team: Finnish <vdr@linuxtv.org>\n"
|
"Language-Team: Finnish <vdr@linuxtv.org>\n"
|
||||||
"Language: fi\n"
|
"Language: fi\n"
|
||||||
|
|||||||
4
satip.c
4
satip.c
@@ -14,7 +14,7 @@
|
|||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x072400
|
#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x072400
|
||||||
#warning "CURL version >= 0.7.36 is recommended"
|
#warning "CURL version >= 7.36.0 is recommended"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM < 20000
|
#if defined(APIVERSNUM) && APIVERSNUM < 20000
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#define GITVERSION ""
|
#define GITVERSION ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char VERSION[] = "0.2.3" GITVERSION;
|
const char VERSION[] = "0.3.3" GITVERSION;
|
||||||
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
|
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
|
||||||
|
|
||||||
class cPluginSatip : public cPlugin {
|
class cPluginSatip : public cPlugin {
|
||||||
|
|||||||
16
server.c
16
server.c
@@ -16,7 +16,8 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
|
|||||||
: addressM(addressP),
|
: addressM(addressP),
|
||||||
descriptionM(descriptionP),
|
descriptionM(descriptionP),
|
||||||
modelM(modelP),
|
modelM(modelP),
|
||||||
modelTypeM(eSatipModelTypeMask),
|
modelTypeM(eSatipModelTypeNone),
|
||||||
|
quirkM(eSatipQuirkNone),
|
||||||
useCountM(0),
|
useCountM(0),
|
||||||
createdM(time(NULL)),
|
createdM(time(NULL)),
|
||||||
lastSeenM(0)
|
lastSeenM(0)
|
||||||
@@ -24,6 +25,15 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
|
|||||||
memset(modelCountM, 0, sizeof(modelCountM));
|
memset(modelCountM, 0, sizeof(modelCountM));
|
||||||
if (isempty(*modelM))
|
if (isempty(*modelM))
|
||||||
modelM = "DVBS-1";
|
modelM = "DVBS-1";
|
||||||
|
// These devices contain a session id bug:
|
||||||
|
// Inverto Airscreen Server IDL 400 ?
|
||||||
|
// Telestar Digibit R1 ?
|
||||||
|
// Elgato EyeTV Netstream 4Sat ?
|
||||||
|
if (!isempty(*descriptionM) &&
|
||||||
|
(strstr(*descriptionM, "GSSBOX") || // Grundig Sat Systems GSS.box DSI 400
|
||||||
|
strstr(*descriptionM, "Triax SatIP Converter") // Triax TSS 400
|
||||||
|
))
|
||||||
|
quirkM |= eSatipQuirkSessionId;
|
||||||
char *s, *p = strdup(*modelM);
|
char *s, *p = strdup(*modelM);
|
||||||
char *r = strtok_r(p, ",", &s);
|
char *r = strtok_r(p, ",", &s);
|
||||||
while (r) {
|
while (r) {
|
||||||
@@ -41,7 +51,7 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
|
|||||||
else
|
else
|
||||||
modelCountM[eSatipModuleDVBT2] = 1;
|
modelCountM[eSatipModuleDVBT2] = 1;
|
||||||
// Add model quirks here
|
// Add model quirks here
|
||||||
if (strstr(*addressM, "OctopusNet"))
|
if (!isempty(*descriptionM) && strstr(*descriptionM, "OctopusNet"))
|
||||||
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
|
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
|
||||||
}
|
}
|
||||||
if (strstr(r, "DVBT")) {
|
if (strstr(r, "DVBT")) {
|
||||||
@@ -51,7 +61,7 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
|
|||||||
else
|
else
|
||||||
modelCountM[eSatipModuleDVBT] = 1;
|
modelCountM[eSatipModuleDVBT] = 1;
|
||||||
// Add model quirks here
|
// Add model quirks here
|
||||||
if (strstr(*addressM, "OctopusNet"))
|
if (!isempty(*descriptionM) && strstr(*descriptionM, "OctopusNet"))
|
||||||
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
|
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
|
||||||
}
|
}
|
||||||
r = strtok_r(NULL, ",", &s);
|
r = strtok_r(NULL, ",", &s);
|
||||||
|
|||||||
8
server.h
8
server.h
@@ -23,12 +23,19 @@ private:
|
|||||||
cString modelM;
|
cString modelM;
|
||||||
int modelCountM[eSatipModuleCount];
|
int modelCountM[eSatipModuleCount];
|
||||||
int modelTypeM;
|
int modelTypeM;
|
||||||
|
int quirkM;
|
||||||
int useCountM;
|
int useCountM;
|
||||||
time_t createdM;
|
time_t createdM;
|
||||||
cTimeMs lastSeenM;
|
cTimeMs lastSeenM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum eSatipQuirk {
|
||||||
|
eSatipQuirkNone = 0x00,
|
||||||
|
eSatipQuirkSessionId = 0x01,
|
||||||
|
eSatipQuirkMask = 0x0F
|
||||||
|
};
|
||||||
enum eSatipModelType {
|
enum eSatipModelType {
|
||||||
|
eSatipModelTypeNone = 0x00,
|
||||||
eSatipModelTypeDVBS2 = 0x01,
|
eSatipModelTypeDVBS2 = 0x01,
|
||||||
eSatipModelTypeDVBT = 0x02,
|
eSatipModelTypeDVBT = 0x02,
|
||||||
eSatipModelTypeDVBT2 = 0x04,
|
eSatipModelTypeDVBT2 = 0x04,
|
||||||
@@ -43,6 +50,7 @@ public:
|
|||||||
const char *Description() { return *descriptionM; }
|
const char *Description() { return *descriptionM; }
|
||||||
const char *Address() { return *addressM; }
|
const char *Address() { return *addressM; }
|
||||||
const char *Model(void) { return modelM; }
|
const char *Model(void) { return modelM; }
|
||||||
|
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
|
||||||
int ModelType(void) { return modelTypeM; }
|
int ModelType(void) { return modelTypeM; }
|
||||||
bool Match(int modelP) { return ((modelP & eSatipModelTypeMask) & modelTypeM); }
|
bool Match(int modelP) { return ((modelP & eSatipModelTypeMask) & modelTypeM); }
|
||||||
int Cable() { return Match(eSatipModelTypeDVBC) ? (Match(eSatipModelTypeDVBT2) ? modelCountM[eSatipModuleDVBT2] : modelCountM[eSatipModuleDVBT]) : 0; } // an ugly hack
|
int Cable() { return Match(eSatipModelTypeDVBC) ? (Match(eSatipModelTypeDVBT2) ? modelCountM[eSatipModuleDVBT2] : modelCountM[eSatipModuleDVBT]) : 0; } // an ugly hack
|
||||||
|
|||||||
114
tuner.c
114
tuner.c
@@ -26,7 +26,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
|
|||||||
headerListM(NULL),
|
headerListM(NULL),
|
||||||
keepAliveM(),
|
keepAliveM(),
|
||||||
pidUpdateCacheM(),
|
pidUpdateCacheM(),
|
||||||
sessionM(),
|
sessionM(""),
|
||||||
timeoutM(eMinKeepAliveIntervalMs),
|
timeoutM(eMinKeepAliveIntervalMs),
|
||||||
openedM(false),
|
openedM(false),
|
||||||
tunedM(false),
|
tunedM(false),
|
||||||
@@ -34,7 +34,8 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
|
|||||||
signalStrengthM(-1),
|
signalStrengthM(-1),
|
||||||
signalQualityM(-1),
|
signalQualityM(-1),
|
||||||
streamIdM(-1),
|
streamIdM(-1),
|
||||||
pidUpdatedM(false),
|
addPidsM(),
|
||||||
|
delPidsM(),
|
||||||
pidsM()
|
pidsM()
|
||||||
{
|
{
|
||||||
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
|
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
|
||||||
@@ -174,12 +175,8 @@ bool cSatipTuner::Connect(void)
|
|||||||
// Just retune
|
// Just retune
|
||||||
if (tunedM && (streamIdM >= 0)) {
|
if (tunedM && (streamIdM >= 0)) {
|
||||||
debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
keepAliveM.Set(0);
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
KeepAlive();
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
|
||||||
if (!ValidateLatestResponse())
|
|
||||||
return false;
|
|
||||||
// Flush any old content
|
// Flush any old content
|
||||||
if (rtpSocketM)
|
if (rtpSocketM)
|
||||||
rtpSocketM->Flush();
|
rtpSocketM->Flush();
|
||||||
@@ -243,23 +240,16 @@ bool cSatipTuner::Connect(void)
|
|||||||
// Session id is now known - disable header parsing
|
// Session id is now known - disable header parsing
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_HEADERFUNCTION, NULL);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_HEADERFUNCTION, NULL);
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEHEADER, NULL);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEHEADER, NULL);
|
||||||
//SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_SESSION_ID, *sessionM);
|
if (nextServerM && nextServerM->Quirk(cSatipServer::eSatipQuirkSessionId) && !isempty(*sessionM) && startswith(*sessionM, "0")) {
|
||||||
|
debug("cSatipTuner::%s(): session id quirk [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_SESSION_ID, SkipZeroes(*sessionM));
|
||||||
|
}
|
||||||
if (!ValidateLatestResponse())
|
if (!ValidateLatestResponse())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Start playing
|
// Start playing
|
||||||
if (pidsM.Size()) {
|
|
||||||
uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM);
|
|
||||||
for (int i = 0; i < pidsM.Size(); ++i)
|
|
||||||
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
|
||||||
if (!ValidateLatestResponse())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tunedM = true;
|
tunedM = true;
|
||||||
|
UpdatePids(true);
|
||||||
if (nextServerM) {
|
if (nextServerM) {
|
||||||
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
||||||
currentServerM = nextServerM;
|
currentServerM = nextServerM;
|
||||||
@@ -311,7 +301,8 @@ bool cSatipTuner::Disconnect(void)
|
|||||||
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
||||||
tunedM = false;
|
tunedM = false;
|
||||||
timeoutM = eMinKeepAliveIntervalMs;
|
timeoutM = eMinKeepAliveIntervalMs;
|
||||||
pidUpdatedM = false;
|
addPidsM.Clear();
|
||||||
|
delPidsM.Clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -416,38 +407,85 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
|
|||||||
for (int i = 0; i < pidsM.Size(); ++i) {
|
for (int i = 0; i < pidsM.Size(); ++i) {
|
||||||
if (pidsM[i] == pidP) {
|
if (pidsM[i] == pidP) {
|
||||||
found = true;
|
found = true;
|
||||||
if (!onP) {
|
if (!onP)
|
||||||
pidsM.Remove(i);
|
pidsM.Remove(i);
|
||||||
pidUpdatedM = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (onP && !found) {
|
if (onP && !found)
|
||||||
pidsM.Append(pidP);
|
pidsM.Append(pidP);
|
||||||
pidUpdatedM = true;
|
// Generate deltas
|
||||||
}
|
found = false;
|
||||||
|
if (onP) {
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i) {
|
||||||
|
if (addPidsM[i] == pidP) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
addPidsM.Append(pidP);
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i) {
|
||||||
|
if (delPidsM[i] == pidP) {
|
||||||
|
delPidsM.Remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i) {
|
||||||
|
if (delPidsM[i] == pidP) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
delPidsM.Append(pidP);
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i) {
|
||||||
|
if (addPidsM[i] == pidP) {
|
||||||
|
addPidsM.Remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
|
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::UpdatePids(void)
|
bool cSatipTuner::UpdatePids(bool forceP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (pidUpdateCacheM.TimedOut() && pidUpdatedM && pidsM.Size() && tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
||||||
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
//cString uri = cString::sprintf("rtsp://%s/stream=%d?%spids=%d", *streamAddrM, streamIdM, onP ? "add" : "del", pidP);
|
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
||||||
cString uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM);
|
if (forceP) {
|
||||||
|
if (pidsM.Size()) {
|
||||||
for (int i = 0; i < pidsM.Size(); ++i)
|
uri = cString::sprintf("%s?pids=", *uri);
|
||||||
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
for (int i = 0; i < pidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (addPidsM.Size()) {
|
||||||
|
uri = cString::sprintf("%s?addpids=", *uri);
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, addPidsM[i], (i == (addPidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
if (delPidsM.Size()) {
|
||||||
|
uri = cString::sprintf("%s%sdelpids=", *uri, addPidsM.Size() ? "&" : "?");
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, delPidsM[i], (i == (delPidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//debug("cSatipTuner::%s(): %s [device %d]", __FUNCTION__, *uri, deviceM->GetId());
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
SATIP_CURL_EASY_PERFORM(handleM);
|
||||||
if (ValidateLatestResponse())
|
if (ValidateLatestResponse()) {
|
||||||
pidUpdatedM = false;
|
addPidsM.Clear();
|
||||||
|
delPidsM.Clear();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
|
|||||||
7
tuner.h
7
tuner.h
@@ -27,7 +27,7 @@ class cSatipTuner : public cThread, public cSatipTunerStatistics {
|
|||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
eConnectTimeoutMs = 1500, // in milliseconds
|
eConnectTimeoutMs = 1500, // in milliseconds
|
||||||
ePidUpdateIntervalMs = 100, // in milliseconds
|
ePidUpdateIntervalMs = 250, // in milliseconds
|
||||||
eReConnectTimeoutMs = 5000, // in milliseconds
|
eReConnectTimeoutMs = 5000, // in milliseconds
|
||||||
eMinKeepAliveIntervalMs = 30000 // in milliseconds
|
eMinKeepAliveIntervalMs = 30000 // in milliseconds
|
||||||
};
|
};
|
||||||
@@ -58,7 +58,8 @@ private:
|
|||||||
int signalStrengthM;
|
int signalStrengthM;
|
||||||
int signalQualityM;
|
int signalQualityM;
|
||||||
int streamIdM;
|
int streamIdM;
|
||||||
bool pidUpdatedM;
|
cVector<int> addPidsM;
|
||||||
|
cVector<int> delPidsM;
|
||||||
cVector<int> pidsM;
|
cVector<int> pidsM;
|
||||||
|
|
||||||
bool Connect(void);
|
bool Connect(void);
|
||||||
@@ -69,7 +70,7 @@ private:
|
|||||||
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
||||||
bool KeepAlive(void);
|
bool KeepAlive(void);
|
||||||
bool UpdateSignalInfoCache(void);
|
bool UpdateSignalInfoCache(void);
|
||||||
bool UpdatePids(void);
|
bool UpdatePids(bool forceP = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Action(void);
|
virtual void Action(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user