Fixed keepalive heartbeat.

This commit is contained in:
Rolf Ahrenberg 2014-03-27 23:27:38 +02:00
parent e7a74f3ad4
commit b5ec84fd91
5 changed files with 22 additions and 17 deletions

View File

@ -20,7 +20,8 @@ VDR Plugin 'satip' Revision History
- Fixed EIT scan functionality. - Fixed EIT scan functionality.
- Updated for vdr-2.1.6. - Updated for vdr-2.1.6.
2014-xx-xx: Version 0.2.0 2014-03-28: Version 0.2.0
- Added support for cDevice::Ready(). - Added support for cDevice::Ready().
- Fixed pid leaking while disabling section filters. - Fixed pid leaking while disabling section filters.
- Fixed keepalive heartbeat.

View File

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 0.2.0\n" "Project-Id-Version: vdr-satip 0.2.0\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-03-16 03:16+0200\n" "POT-Creation-Date: 2014-03-28 03:28+0200\n"
"PO-Revision-Date: 2014-03-16 03:16+0200\n" "PO-Revision-Date: 2014-03-28 03:28+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"

View File

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 0.2.0\n" "Project-Id-Version: vdr-satip 0.2.0\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-03-16 03:16+0200\n" "POT-Creation-Date: 2014-03-28 03:28+0200\n"
"PO-Revision-Date: 2014-03-16 03:16+0200\n" "PO-Revision-Date: 2014-03-28 03:28+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"

19
tuner.c
View File

@ -27,7 +27,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
keepAliveM(), keepAliveM(),
pidUpdateCacheM(), pidUpdateCacheM(),
sessionM(), sessionM(),
timeoutM(eKeepAliveIntervalMs), timeoutM(eDefKeepAliveIntervalMs),
openedM(false), openedM(false),
tunedM(false), tunedM(false),
hasLockM(false), hasLockM(false),
@ -183,7 +183,6 @@ bool cSatipTuner::Connect(void)
// Flush any old content // Flush any old content
if (rtpSocketM) if (rtpSocketM)
rtpSocketM->Flush(); rtpSocketM->Flush();
keepAliveM.Set(eKeepAliveIntervalMs);
return true; return true;
} }
@ -229,6 +228,7 @@ bool cSatipTuner::Connect(void)
} }
// Request server options: "&pids=all" for the whole mux // Request server options: "&pids=all" for the whole mux
keepAliveM.Set(timeoutM);
uri = cString::sprintf("rtsp://%s/?%s&pids=0", *streamAddrM, *streamParamM); uri = cString::sprintf("rtsp://%s/?%s&pids=0", *streamAddrM, *streamParamM);
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);
@ -253,7 +253,6 @@ bool cSatipTuner::Connect(void)
if (!ValidateLatestResponse()) if (!ValidateLatestResponse())
return false; return false;
keepAliveM.Set(eKeepAliveIntervalMs);
tunedM = true; tunedM = true;
if (nextServerM) { if (nextServerM) {
cSatipDiscover::GetInstance()->UseServer(nextServerM, true); cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
@ -305,6 +304,7 @@ bool cSatipTuner::Disconnect(void)
if (currentServerM) if (currentServerM)
cSatipDiscover::GetInstance()->UseServer(currentServerM, false); cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
tunedM = false; tunedM = false;
timeoutM = eDefKeepAliveIntervalMs;
return true; return true;
} }
@ -383,7 +383,12 @@ void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP)
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cSatipTuner::%s(%s, %d)", __FUNCTION__, sessionP, timeoutP); debug("cSatipTuner::%s(%s, %d)", __FUNCTION__, sessionP, timeoutP);
sessionM = sessionP; sessionM = sessionP;
timeoutM = timeoutP > 0 ? timeoutP * 1000L : eKeepAliveIntervalMs; if (timeoutP > 30)
timeoutM = timeoutP * 1000L;
else if (timeoutP > 0)
timeoutM = eMinKeepAliveIntervalMs;
else
timeoutM = eDefKeepAliveIntervalMs;
} }
bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP) bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP)
@ -439,10 +444,8 @@ bool cSatipTuner::UpdatePids(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_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())
keepAliveM.Set(eKeepAliveIntervalMs);
pidUpdatedM = false; pidUpdatedM = false;
}
else else
Disconnect(); Disconnect();
@ -464,7 +467,7 @@ bool cSatipTuner::KeepAlive(void)
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())
keepAliveM.Set(eKeepAliveIntervalMs); keepAliveM.Set(timeoutM);
else else
Disconnect(); Disconnect();

View File

@ -26,10 +26,11 @@
class cSatipTuner : public cThread, public cSatipTunerStatistics { class cSatipTuner : public cThread, public cSatipTunerStatistics {
private: private:
enum { enum {
eConnectTimeoutMs = 1500, // in milliseconds eConnectTimeoutMs = 1500, // in milliseconds
ePidUpdateIntervalMs = 100, // in milliseconds ePidUpdateIntervalMs = 100, // in milliseconds
eReConnectTimeoutMs = 5000, // in milliseconds eReConnectTimeoutMs = 5000, // in milliseconds
eKeepAliveIntervalMs = 600000 // in milliseconds eMinKeepAliveIntervalMs = 300000, // in milliseconds
eDefKeepAliveIntervalMs = 600000 // in milliseconds
}; };
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);