mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Fixed EIT scan (Thanks to Stefan Schallenberg).
This commit is contained in:
parent
04e7648c01
commit
2308fc4a65
1
HISTORY
1
HISTORY
@ -79,3 +79,4 @@ VDR Plugin 'satip' Revision History
|
|||||||
used SAT>IP servers.
|
used SAT>IP servers.
|
||||||
- Added support for SAT>IP frontend selection via
|
- Added support for SAT>IP frontend selection via
|
||||||
Radio ID.
|
Radio ID.
|
||||||
|
- Fixed EIT scan (Thanks to Stefan Schallenberg).
|
||||||
|
100
tuner.c
100
tuner.c
@ -25,6 +25,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
|
|||||||
handleM(NULL),
|
handleM(NULL),
|
||||||
headerListM(NULL),
|
headerListM(NULL),
|
||||||
keepAliveM(),
|
keepAliveM(),
|
||||||
|
statusUpdateM(),
|
||||||
pidUpdateCacheM(),
|
pidUpdateCacheM(),
|
||||||
sessionM(""),
|
sessionM(""),
|
||||||
timeoutM(eMinKeepAliveIntervalMs),
|
timeoutM(eMinKeepAliveIntervalMs),
|
||||||
@ -95,6 +96,21 @@ size_t cSatipTuner::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t cSatipTuner::DataCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
|
||||||
|
{
|
||||||
|
cSatipTuner *obj = reinterpret_cast<cSatipTuner *>(dataP);
|
||||||
|
size_t len = sizeP * nmembP;
|
||||||
|
//debug("cSatipTuner::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
|
if (obj && (len > 0)) {
|
||||||
|
char *data = strndup((char*)ptrP, len);
|
||||||
|
obj->ParseReceptionParameters(data);
|
||||||
|
FREE_POINTER(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
void cSatipTuner::Action(void)
|
void cSatipTuner::Action(void)
|
||||||
{
|
{
|
||||||
debug("cSatipTuner::%s(): entering [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s(): entering [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
@ -110,7 +126,8 @@ void cSatipTuner::Action(void)
|
|||||||
UpdatePids();
|
UpdatePids();
|
||||||
// Remember the heart beat
|
// Remember the heart beat
|
||||||
KeepAlive();
|
KeepAlive();
|
||||||
// Read reception statistics
|
// Read reception statistics via DESCRIBE and RTCP
|
||||||
|
ReadReceptionStatus();
|
||||||
if (rtcpSocketM && rtcpSocketM->IsOpen()) {
|
if (rtcpSocketM && rtcpSocketM->IsOpen()) {
|
||||||
unsigned char buf[1450];
|
unsigned char buf[1450];
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@ -150,19 +167,13 @@ void cSatipTuner::Action(void)
|
|||||||
bool cSatipTuner::Open(void)
|
bool cSatipTuner::Open(void)
|
||||||
{
|
{
|
||||||
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
if (Connect()) {
|
return Connect();
|
||||||
openedM = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::Close(void)
|
bool cSatipTuner::Close(void)
|
||||||
{
|
{
|
||||||
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
openedM = false;
|
return Disconnect();
|
||||||
Disconnect();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::Connect(void)
|
bool cSatipTuner::Connect(void)
|
||||||
@ -186,7 +197,16 @@ bool cSatipTuner::Connect(void)
|
|||||||
// Flush any old content
|
// Flush any old content
|
||||||
if (rtpSocketM)
|
if (rtpSocketM)
|
||||||
rtpSocketM->Flush();
|
rtpSocketM->Flush();
|
||||||
return true;
|
|
||||||
|
uri = cString::sprintf("rtsp://%s/?%s", *streamAddrM, *streamParamM);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
||||||
|
transport = cString::sprintf("RTP/AVP;unicast;client_port=%d-%d", rtpSocketM->Port(), rtcpSocketM->Port());
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_TRANSPORT, *transport);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_SETUP);
|
||||||
|
SATIP_CURL_EASY_PERFORM(handleM);
|
||||||
|
|
||||||
|
openedM = true;
|
||||||
|
return openedM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -222,7 +242,8 @@ bool cSatipTuner::Connect(void)
|
|||||||
}
|
}
|
||||||
if ((rtpSocketM->Port() <= 0) || (rtcpSocketM->Port() <= 0)) {
|
if ((rtpSocketM->Port() <= 0) || (rtcpSocketM->Port() <= 0)) {
|
||||||
error("Cannot open required RTP/RTCP ports [device %d]", deviceM->GetId());
|
error("Cannot open required RTP/RTCP ports [device %d]", deviceM->GetId());
|
||||||
return false;
|
openedM = false;
|
||||||
|
return openedM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request server options
|
// Request server options
|
||||||
@ -230,8 +251,10 @@ bool cSatipTuner::Connect(void)
|
|||||||
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_OPTIONS);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
SATIP_CURL_EASY_PERFORM(handleM);
|
||||||
if (!ValidateLatestResponse())
|
if (!ValidateLatestResponse()) {
|
||||||
return false;
|
openedM = false;
|
||||||
|
return openedM;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup media stream: "&pids=all" for the whole mux
|
// Setup media stream: "&pids=all" for the whole mux
|
||||||
uri = cString::sprintf("rtsp://%s/?%s", *streamAddrM, *streamParamM);
|
uri = cString::sprintf("rtsp://%s/?%s", *streamAddrM, *streamParamM);
|
||||||
@ -250,32 +273,32 @@ bool cSatipTuner::Connect(void)
|
|||||||
debug("cSatipTuner::%s(): session id quirk [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s(): session id quirk [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_SESSION_ID, SkipZeroes(*sessionM));
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_SESSION_ID, SkipZeroes(*sessionM));
|
||||||
}
|
}
|
||||||
if (!ValidateLatestResponse())
|
if (!ValidateLatestResponse()) {
|
||||||
return false;
|
openedM = false;
|
||||||
|
return openedM;
|
||||||
|
}
|
||||||
|
|
||||||
// Start playing
|
// Start playing
|
||||||
tunedM = true;
|
tunedM = true;
|
||||||
if (!pidsM.Size()) {
|
|
||||||
SetPid(0, 5, true);
|
|
||||||
if (nextServerM && nextServerM->Quirk(cSatipServer::eSatipQuirkPlayPids))
|
|
||||||
SetPid(eDummyPid, 5, true);
|
|
||||||
}
|
|
||||||
UpdatePids(true);
|
UpdatePids(true);
|
||||||
if (nextServerM) {
|
if (nextServerM) {
|
||||||
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
||||||
currentServerM = nextServerM;
|
currentServerM = nextServerM;
|
||||||
nextServerM = NULL;
|
nextServerM = NULL;
|
||||||
}
|
}
|
||||||
return true;
|
openedM = true;
|
||||||
|
return openedM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
openedM = false;
|
||||||
|
return openedM;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::Disconnect(void)
|
bool cSatipTuner::Disconnect(void)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
|
openedM = false;
|
||||||
|
|
||||||
// Terminate curl session
|
// Terminate curl session
|
||||||
if (handleM) {
|
if (handleM) {
|
||||||
@ -311,10 +334,12 @@ bool cSatipTuner::Disconnect(void)
|
|||||||
if (currentServerM)
|
if (currentServerM)
|
||||||
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
||||||
tunedM = false;
|
tunedM = false;
|
||||||
|
statusUpdateM.Set(0);
|
||||||
timeoutM = eMinKeepAliveIntervalMs;
|
timeoutM = eMinKeepAliveIntervalMs;
|
||||||
addPidsM.Clear();
|
addPidsM.Clear();
|
||||||
delPidsM.Clear();
|
delPidsM.Clear();
|
||||||
|
|
||||||
|
// return always true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,12 +499,15 @@ bool cSatipTuner::UpdatePids(bool forceP)
|
|||||||
tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
||||||
if (forceP || (currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkPlayPids))) {
|
bool usedummy = !!(currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkPlayPids));
|
||||||
|
if (forceP || usedummy) {
|
||||||
if (pidsM.Size()) {
|
if (pidsM.Size()) {
|
||||||
uri = cString::sprintf("%s?pids=", *uri);
|
uri = cString::sprintf("%s?pids=", *uri);
|
||||||
for (int i = 0; i < pidsM.Size(); ++i)
|
for (int i = 0; i < pidsM.Size(); ++i)
|
||||||
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
||||||
}
|
}
|
||||||
|
if (usedummy && (pidsM.Size() == 1) && (pidsM[0] < 0x20))
|
||||||
|
uri = cString::sprintf("%s,%d", *uri, eDummyPid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (addPidsM.Size()) {
|
if (addPidsM.Size()) {
|
||||||
@ -532,6 +560,32 @@ bool cSatipTuner::KeepAlive(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cSatipTuner::ReadReceptionStatus(void)
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
if (tunedM && handleM && !pidsM.Size() && statusUpdateM.TimedOut() ) {
|
||||||
|
debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
cString 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_DESCRIBE);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEFUNCTION, cSatipTuner::DataCallback);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEDATA, this);
|
||||||
|
SATIP_CURL_EASY_PERFORM(handleM);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEFUNCTION, NULL);
|
||||||
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEDATA, NULL);
|
||||||
|
if (ValidateLatestResponse())
|
||||||
|
statusUpdateM.Set(eStatusUpdateTimeoutMs);
|
||||||
|
else
|
||||||
|
Disconnect();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int cSatipTuner::SignalStrength(void)
|
int cSatipTuner::SignalStrength(void)
|
||||||
{
|
{
|
||||||
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
|
4
tuner.h
4
tuner.h
@ -29,6 +29,7 @@ private:
|
|||||||
eDummyPid = 100,
|
eDummyPid = 100,
|
||||||
eDefaultSignalStrength = 15,
|
eDefaultSignalStrength = 15,
|
||||||
eDefaultSignalQuality = 224,
|
eDefaultSignalQuality = 224,
|
||||||
|
eStatusUpdateTimeoutMs = 1000, // in milliseconds
|
||||||
eConnectTimeoutMs = 1500, // in milliseconds
|
eConnectTimeoutMs = 1500, // in milliseconds
|
||||||
ePidUpdateIntervalMs = 250, // in milliseconds
|
ePidUpdateIntervalMs = 250, // in milliseconds
|
||||||
eReConnectTimeoutMs = 5000, // in milliseconds
|
eReConnectTimeoutMs = 5000, // in milliseconds
|
||||||
@ -36,6 +37,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
||||||
|
static size_t DataCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
||||||
|
|
||||||
cCondWait sleepM;
|
cCondWait sleepM;
|
||||||
cSatipDeviceIf* deviceM;
|
cSatipDeviceIf* deviceM;
|
||||||
@ -51,6 +53,7 @@ private:
|
|||||||
CURL *handleM;
|
CURL *handleM;
|
||||||
struct curl_slist *headerListM;
|
struct curl_slist *headerListM;
|
||||||
cTimeMs keepAliveM;
|
cTimeMs keepAliveM;
|
||||||
|
cTimeMs statusUpdateM;
|
||||||
cTimeMs signalInfoCacheM;
|
cTimeMs signalInfoCacheM;
|
||||||
cTimeMs pidUpdateCacheM;
|
cTimeMs pidUpdateCacheM;
|
||||||
cString sessionM;
|
cString sessionM;
|
||||||
@ -72,6 +75,7 @@ private:
|
|||||||
void SetStreamId(int streamIdP);
|
void SetStreamId(int streamIdP);
|
||||||
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
||||||
bool KeepAlive(void);
|
bool KeepAlive(void);
|
||||||
|
bool ReadReceptionStatus(void);
|
||||||
bool UpdateSignalInfoCache(void);
|
bool UpdateSignalInfoCache(void);
|
||||||
bool UpdatePids(bool forceP = false);
|
bool UpdatePids(bool forceP = false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user