1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 11:37:42 +00:00

7 Commits

Author SHA1 Message Date
Rolf Ahrenberg
fb9c1c6a44 Added a session id quirk for Triax TSS 400. 2014-05-17 21:41:55 +03:00
Rolf Ahrenberg
5e2770a0e5 Added a validity check for the session member. 2014-05-14 22:14:59 +03:00
Rolf Ahrenberg
53b643139f Fixed the warning message about the libcurl version. 2014-05-11 17:11:28 +03:00
Rolf Ahrenberg
9a8c6f8c0d Fixed model detection and OctopusNet DVB-C model quirks.
Added a session id quirk for GSSBOX.
2014-05-08 22:09:35 +03:00
Rolf Ahrenberg
fbbfdfab2b Fixed the device discovery. 2014-04-24 20:04:43 +03:00
Rolf Ahrenberg
78ef582bea Tweaked the pid update mechanism. 2014-04-19 17:27:47 +03:00
Rolf Ahrenberg
6e72eba09c Increased the pid update interval to 250ms. 2014-04-15 20:04:01 +03:00
13 changed files with 166 additions and 69 deletions

18
HISTORY
View File

@@ -46,3 +46,21 @@ VDR Plugin 'satip' Revision History
- Fixed parameters of the OPTIONS command.
- Added a device identication into the user agent string.
- 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.

View File

@@ -57,6 +57,15 @@ char *StripTags(char *strP)
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 res(strP);

View File

@@ -93,6 +93,7 @@ uint16_t ts_pid(const uint8_t *bufP);
uint8_t payload(const uint8_t *bufP);
const char *id_pid(const u_short pidP);
char *StripTags(char *strP);
char *SkipZeroes(const char *strP);
cString ChangeCase(const cString &strP, bool upperP);
struct section_filter_table_type {

View File

@@ -179,7 +179,7 @@ void cSatipDiscover::Read(void)
int len = socketM->Read(buf, eProbeBufferSize);
if (len > 0) {
//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 *r = strtok_r(p, "\r\n", &s);
while (r) {
@@ -187,18 +187,30 @@ void cSatipDiscover::Read(void)
// Check the status code
// HTTP/1.1 200 OK
if (!status && startswith(r, "HTTP/1.1 200 OK")) {
status = true;
}
// Check the location data
// LOCATION: http://192.168.0.115:8888/octonet.xml
if (status && startswith(r, "LOCATION:")) {
location = compactspace(r + 9);
debug("cSatipDiscover::%s(): location='%s'", __FUNCTION__, location);
break;
}
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("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);
}
if (handleM && !isempty(location)) {
if (handleM && valid && !isempty(location)) {
long rc = 0;
CURLcode res = CURLE_OK;
#ifdef DEBUG

View File

@@ -5,10 +5,10 @@
#
msgid ""
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"
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Catalan <vdr@linuxtv.org>\n"
"Language: ca\n"

View File

@@ -5,10 +5,10 @@
#
msgid ""
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"
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
"Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n"

View File

@@ -5,10 +5,10 @@
#
msgid ""
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"
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Spanish <vdr@linuxtv.org>\n"
"Language: es\n"

View File

@@ -5,10 +5,10 @@
#
msgid ""
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"
"POT-Creation-Date: 2014-04-12 04:12+0200\n"
"PO-Revision-Date: 2014-04-12 04:12+0200\n"
"POT-Creation-Date: 2014-05-18 05:18+0200\n"
"PO-Revision-Date: 2014-05-18 05:18+0200\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n"

View File

@@ -14,7 +14,7 @@
#include "setup.h"
#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
#if defined(APIVERSNUM) && APIVERSNUM < 20000
@@ -25,7 +25,7 @@
#define GITVERSION ""
#endif
const char VERSION[] = "0.2.3" GITVERSION;
const char VERSION[] = "0.3.3" GITVERSION;
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
class cPluginSatip : public cPlugin {

View File

@@ -16,7 +16,8 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
: addressM(addressP),
descriptionM(descriptionP),
modelM(modelP),
modelTypeM(eSatipModelTypeMask),
modelTypeM(eSatipModelTypeNone),
quirkM(eSatipQuirkNone),
useCountM(0),
createdM(time(NULL)),
lastSeenM(0)
@@ -24,6 +25,15 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
memset(modelCountM, 0, sizeof(modelCountM));
if (isempty(*modelM))
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 *r = strtok_r(p, ",", &s);
while (r) {
@@ -41,7 +51,7 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
else
modelCountM[eSatipModuleDVBT2] = 1;
// Add model quirks here
if (strstr(*addressM, "OctopusNet"))
if (!isempty(*descriptionM) && strstr(*descriptionM, "OctopusNet"))
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
}
if (strstr(r, "DVBT")) {
@@ -51,7 +61,7 @@ cSatipServer::cSatipServer(const char *addressP, const char *descriptionP, const
else
modelCountM[eSatipModuleDVBT] = 1;
// Add model quirks here
if (strstr(*addressM, "OctopusNet"))
if (!isempty(*descriptionM) && strstr(*descriptionM, "OctopusNet"))
modelTypeM |= cSatipServer::eSatipModelTypeDVBC;
}
r = strtok_r(NULL, ",", &s);

View File

@@ -23,12 +23,19 @@ private:
cString modelM;
int modelCountM[eSatipModuleCount];
int modelTypeM;
int quirkM;
int useCountM;
time_t createdM;
cTimeMs lastSeenM;
public:
enum eSatipQuirk {
eSatipQuirkNone = 0x00,
eSatipQuirkSessionId = 0x01,
eSatipQuirkMask = 0x0F
};
enum eSatipModelType {
eSatipModelTypeNone = 0x00,
eSatipModelTypeDVBS2 = 0x01,
eSatipModelTypeDVBT = 0x02,
eSatipModelTypeDVBT2 = 0x04,
@@ -43,6 +50,7 @@ public:
const char *Description() { return *descriptionM; }
const char *Address() { return *addressM; }
const char *Model(void) { return modelM; }
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
int ModelType(void) { return modelTypeM; }
bool Match(int modelP) { return ((modelP & eSatipModelTypeMask) & modelTypeM); }
int Cable() { return Match(eSatipModelTypeDVBC) ? (Match(eSatipModelTypeDVBT2) ? modelCountM[eSatipModuleDVBT2] : modelCountM[eSatipModuleDVBT]) : 0; } // an ugly hack

114
tuner.c
View File

@@ -26,7 +26,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
headerListM(NULL),
keepAliveM(),
pidUpdateCacheM(),
sessionM(),
sessionM(""),
timeoutM(eMinKeepAliveIntervalMs),
openedM(false),
tunedM(false),
@@ -34,7 +34,8 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
signalStrengthM(-1),
signalQualityM(-1),
streamIdM(-1),
pidUpdatedM(false),
addPidsM(),
delPidsM(),
pidsM()
{
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
@@ -174,12 +175,8 @@ bool cSatipTuner::Connect(void)
// Just retune
if (tunedM && (streamIdM >= 0)) {
debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
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;
keepAliveM.Set(0);
KeepAlive();
// Flush any old content
if (rtpSocketM)
rtpSocketM->Flush();
@@ -243,23 +240,16 @@ bool cSatipTuner::Connect(void)
// Session id is now known - disable header parsing
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_HEADERFUNCTION, 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())
return false;
// 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;
UpdatePids(true);
if (nextServerM) {
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
currentServerM = nextServerM;
@@ -311,7 +301,8 @@ bool cSatipTuner::Disconnect(void)
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
tunedM = false;
timeoutM = eMinKeepAliveIntervalMs;
pidUpdatedM = false;
addPidsM.Clear();
delPidsM.Clear();
return true;
}
@@ -416,38 +407,85 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
for (int i = 0; i < pidsM.Size(); ++i) {
if (pidsM[i] == pidP) {
found = true;
if (!onP) {
if (!onP)
pidsM.Remove(i);
pidUpdatedM = true;
}
break;
}
}
if (onP && !found) {
if (onP && !found)
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);
return true;
}
bool cSatipTuner::UpdatePids(void)
bool cSatipTuner::UpdatePids(bool forceP)
{
cMutexLock MutexLock(&mutexM);
if (pidUpdateCacheM.TimedOut() && pidUpdatedM && pidsM.Size() && tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
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?pids=", *streamAddrM, streamIdM);
for (int i = 0; i < pidsM.Size(); ++i)
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
if (forceP) {
if (pidsM.Size()) {
uri = cString::sprintf("%s?pids=", *uri);
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_REQUEST, (long)CURL_RTSPREQ_PLAY);
SATIP_CURL_EASY_PERFORM(handleM);
if (ValidateLatestResponse())
pidUpdatedM = false;
if (ValidateLatestResponse()) {
addPidsM.Clear();
delPidsM.Clear();
}
else
Disconnect();

View File

@@ -27,7 +27,7 @@ class cSatipTuner : public cThread, public cSatipTunerStatistics {
private:
enum {
eConnectTimeoutMs = 1500, // in milliseconds
ePidUpdateIntervalMs = 100, // in milliseconds
ePidUpdateIntervalMs = 250, // in milliseconds
eReConnectTimeoutMs = 5000, // in milliseconds
eMinKeepAliveIntervalMs = 30000 // in milliseconds
};
@@ -58,7 +58,8 @@ private:
int signalStrengthM;
int signalQualityM;
int streamIdM;
bool pidUpdatedM;
cVector<int> addPidsM;
cVector<int> delPidsM;
cVector<int> pidsM;
bool Connect(void);
@@ -69,7 +70,7 @@ private:
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
bool KeepAlive(void);
bool UpdateSignalInfoCache(void);
bool UpdatePids(void);
bool UpdatePids(bool forceP = false);
protected:
virtual void Action(void);