From b5ec84fd917f91f0ccd31519a887dbfa96f423e6 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Thu, 27 Mar 2014 23:27:38 +0200 Subject: [PATCH] Fixed keepalive heartbeat. --- HISTORY | 3 ++- po/de_DE.po | 4 ++-- po/fi_FI.po | 4 ++-- tuner.c | 19 +++++++++++-------- tuner.h | 9 +++++---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/HISTORY b/HISTORY index 2a72cea..0ac3863 100644 --- a/HISTORY +++ b/HISTORY @@ -20,7 +20,8 @@ VDR Plugin 'satip' Revision History - Fixed EIT scan functionality. - 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(). - Fixed pid leaking while disabling section filters. +- Fixed keepalive heartbeat. diff --git a/po/de_DE.po b/po/de_DE.po index 68fdea6..e6d84d9 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-16 03:16+0200\n" -"PO-Revision-Date: 2014-03-16 03:16+0200\n" +"POT-Creation-Date: 2014-03-28 03:28+0200\n" +"PO-Revision-Date: 2014-03-28 03:28+0200\n" "Last-Translator: Frank Neumann \n" "Language-Team: German \n" "Language: de\n" diff --git a/po/fi_FI.po b/po/fi_FI.po index 83d90ed..d8e6766 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-16 03:16+0200\n" -"PO-Revision-Date: 2014-03-16 03:16+0200\n" +"POT-Creation-Date: 2014-03-28 03:28+0200\n" +"PO-Revision-Date: 2014-03-28 03:28+0200\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: Finnish \n" "Language: fi\n" diff --git a/tuner.c b/tuner.c index 39c6685..1915db2 100644 --- a/tuner.c +++ b/tuner.c @@ -27,7 +27,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP) keepAliveM(), pidUpdateCacheM(), sessionM(), - timeoutM(eKeepAliveIntervalMs), + timeoutM(eDefKeepAliveIntervalMs), openedM(false), tunedM(false), hasLockM(false), @@ -183,7 +183,6 @@ bool cSatipTuner::Connect(void) // Flush any old content if (rtpSocketM) rtpSocketM->Flush(); - keepAliveM.Set(eKeepAliveIntervalMs); return true; } @@ -229,6 +228,7 @@ bool cSatipTuner::Connect(void) } // Request server options: "&pids=all" for the whole mux + keepAliveM.Set(timeoutM); 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_REQUEST, (long)CURL_RTSPREQ_OPTIONS); @@ -253,7 +253,6 @@ bool cSatipTuner::Connect(void) if (!ValidateLatestResponse()) return false; - keepAliveM.Set(eKeepAliveIntervalMs); tunedM = true; if (nextServerM) { cSatipDiscover::GetInstance()->UseServer(nextServerM, true); @@ -305,6 +304,7 @@ bool cSatipTuner::Disconnect(void) if (currentServerM) cSatipDiscover::GetInstance()->UseServer(currentServerM, false); tunedM = false; + timeoutM = eDefKeepAliveIntervalMs; return true; } @@ -383,7 +383,12 @@ void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP) cMutexLock MutexLock(&mutexM); debug("cSatipTuner::%s(%s, %d)", __FUNCTION__, sessionP, timeoutP); 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) @@ -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_REQUEST, (long)CURL_RTSPREQ_PLAY); SATIP_CURL_EASY_PERFORM(handleM); - if (ValidateLatestResponse()) { - keepAliveM.Set(eKeepAliveIntervalMs); + if (ValidateLatestResponse()) pidUpdatedM = false; - } else Disconnect(); @@ -464,7 +467,7 @@ bool cSatipTuner::KeepAlive(void) SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS); SATIP_CURL_EASY_PERFORM(handleM); if (ValidateLatestResponse()) - keepAliveM.Set(eKeepAliveIntervalMs); + keepAliveM.Set(timeoutM); else Disconnect(); diff --git a/tuner.h b/tuner.h index c156a18..12f8153 100644 --- a/tuner.h +++ b/tuner.h @@ -26,10 +26,11 @@ class cSatipTuner : public cThread, public cSatipTunerStatistics { private: enum { - eConnectTimeoutMs = 1500, // in milliseconds - ePidUpdateIntervalMs = 100, // in milliseconds - eReConnectTimeoutMs = 5000, // in milliseconds - eKeepAliveIntervalMs = 600000 // in milliseconds + eConnectTimeoutMs = 1500, // in milliseconds + ePidUpdateIntervalMs = 100, // in milliseconds + eReConnectTimeoutMs = 5000, // in milliseconds + eMinKeepAliveIntervalMs = 300000, // in milliseconds + eDefKeepAliveIntervalMs = 600000 // in milliseconds }; static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);