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

Fixed a channel switching logic bug (Thanks to REELcoder).

This commit is contained in:
Rolf Ahrenberg 2020-01-03 23:02:52 +02:00
parent a3fa5865f3
commit 826dea4ba8
3 changed files with 26 additions and 6 deletions

View File

@ -211,3 +211,5 @@ VDR Plugin 'satip' Revision History
2019-XX-XX: Version 2.4.1
- Added an option to enable/disable frontend reuse.
- Added a preliminary ATSC support.
- Fixed a channel switching logic bug (Thanks to REELcoder).

24
tuner.c
View File

@ -25,6 +25,8 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
rtcpM(*this),
streamAddrM(""),
streamParamM(""),
lastAddrM(""),
lastParamM(""),
tnrParamM(""),
streamPortM(SATIP_DEFAULT_RTSP_PORT),
currentServerM(NULL, deviceP.GetId(), 0),
@ -34,6 +36,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
keepAliveM(),
statusUpdateM(),
pidUpdateCacheM(),
setupTimeoutM(-1),
sessionM(""),
currentStateM(tsIdle),
internalStateM(),
@ -192,8 +195,6 @@ bool cSatipTuner::Open(void)
cMutexLock MutexLock(&mutexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM);
RequestState(tsSet, smExternal);
// return always true
return true;
}
@ -203,7 +204,8 @@ bool cSatipTuner::Close(void)
cMutexLock MutexLock(&mutexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM);
RequestState(tsRelease, smExternal);
if (setupTimeoutM.TimedOut())
RequestState(tsRelease, smExternal);
// return always true
return true;
@ -219,10 +221,15 @@ bool cSatipTuner::Connect(void)
tnrParamM = "";
// Just retune
if (streamIdM >= 0) {
if (!strcmp(*streamParamM, *lastParamM)) {
debug1("%s Identical parameters [device %d]", __PRETTY_FUNCTION__, deviceIdM);
return true;
}
cString uri = cString::sprintf("%sstream=%d?%s", *connectionUri, streamIdM, *streamParamM);
debug1("%s Retuning [device %d]", __PRETTY_FUNCTION__, deviceIdM);
if (rtspM.Play(*uri)) {
keepAliveM.Set(timeoutM);
lastParamM = streamParamM;
return true;
}
}
@ -240,6 +247,7 @@ bool cSatipTuner::Connect(void)
currentServerM = nextServerM;
nextServerM.Reset();
}
lastAddrM = connectionUri;
currentServerM.Attach();
return true;
}
@ -257,8 +265,8 @@ bool cSatipTuner::Disconnect(void)
cMutexLock MutexLock(&mutexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM);
if (!isempty(*streamAddrM) && (streamIdM >= 0)) {
cString uri = cString::sprintf("%sstream=%d", *GetBaseUrl(*streamAddrM, streamPortM), streamIdM);
if (!isempty(*lastAddrM) && (streamIdM >= 0)) {
cString uri = cString::sprintf("%sstream=%d", *lastAddrM, streamIdM);
rtspM.Teardown(*uri);
// some devices requires a teardown for TCP connection also
rtspM.Reset();
@ -447,7 +455,13 @@ bool cSatipTuner::SetSource(cSatipServer *serverP, const int transponderP, const
if (nextServerM.IsQuirk(cSatipServer::eSatipQuirkForcePilot) && strstr(parameterP, "msys=dvbs2") && !strstr(parameterP, "plts="))
streamParamM = rtspM.RtspUnescapeString(*cString::sprintf("%s&plts=on", parameterP));
// Reconnect
if (!isempty(*lastAddrM)) {
cString connectionUri = GetBaseUrl(*streamAddrM, streamPortM);
if (strcmp(*connectionUri, *lastAddrM))
RequestState(tsRelease, smInternal);
}
RequestState(tsSet, smExternal);
setupTimeoutM.Set(eSetupTimeoutMs);
}
}
else {

View File

@ -88,7 +88,8 @@ private:
eConnectTimeoutMs = 5000, // in milliseconds
eIdleCheckTimeoutMs = 15000, // in milliseconds
eTuningTimeoutMs = 20000, // in milliseconds
eMinKeepAliveIntervalMs = 30000 // in milliseconds
eMinKeepAliveIntervalMs = 30000, // in milliseconds
eSetupTimeoutMs = 2000 // in milliseconds
};
enum eTunerState { tsIdle, tsRelease, tsSet, tsTuned, tsLocked };
enum eStateMode { smInternal, smExternal };
@ -101,6 +102,8 @@ private:
cSatipRtcp rtcpM;
cString streamAddrM;
cString streamParamM;
cString lastAddrM;
cString lastParamM;
cString tnrParamM;
int streamPortM;
cSatipTunerServer currentServerM;
@ -110,6 +113,7 @@ private:
cTimeMs keepAliveM;
cTimeMs statusUpdateM;
cTimeMs pidUpdateCacheM;
cTimeMs setupTimeoutM;
cString sessionM;
eTunerState currentStateM;
cVector<eTunerState> internalStateM;