From 1c879182e214eae51c4cb99babffeda0ae85ea67 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Tue, 19 Dec 2023 19:39:40 +0100 Subject: [PATCH] Add setting for threshold for reconnect on stalled stream. --- pvr.hts/addon.xml.in | 2 +- pvr.hts/changelog.txt | 3 +++ pvr.hts/resources/instance-settings.xml | 10 ++++++++++ .../language/resource.language.en_gb/strings.po | 6 +++++- src/tvheadend/HTSPDemuxer.cpp | 6 ++++-- src/tvheadend/InstanceSettings.cpp | 9 ++++++++- src/tvheadend/InstanceSettings.h | 3 +++ 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/pvr.hts/addon.xml.in b/pvr.hts/addon.xml.in index 8b4c09d5..fa084a07 100644 --- a/pvr.hts/addon.xml.in +++ b/pvr.hts/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index c62ce6fe..9c7fe966 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -1,3 +1,6 @@ +v21.2.0 +- Add setting for threshold for reconnect on stalled streams + v21.1.2 - Fix TV channels stuttering after wake from suspend - take 2 diff --git a/pvr.hts/resources/instance-settings.xml b/pvr.hts/resources/instance-settings.xml index b73cfa34..68159c5c 100644 --- a/pvr.hts/resources/instance-settings.xml +++ b/pvr.hts/resources/instance-settings.xml @@ -149,6 +149,16 @@ + + 0 + 10 + + 1 + 1 + 60 + + + diff --git a/pvr.hts/resources/language/resource.language.en_gb/strings.po b/pvr.hts/resources/language/resource.language.en_gb/strings.po index 58d2e31b..f511615c 100644 --- a/pvr.hts/resources/language/resource.language.en_gb/strings.po +++ b/pvr.hts/resources/language/resource.language.en_gb/strings.po @@ -78,7 +78,11 @@ msgctxt "#30012" msgid "Server MAC for Wake-on-LAN" msgstr "" -#empty strings from id 30013 to 30049 +msgctxt "#30013" +msgid "Threshold for reconnect on stalled streams (seconds)" +msgstr "" + +#empty strings from id 30014 to 30049 msgctxt "#30050" msgid "Auto recordings" diff --git a/src/tvheadend/HTSPDemuxer.cpp b/src/tvheadend/HTSPDemuxer.cpp index 389e7196..fb8716cc 100644 --- a/src/tvheadend/HTSPDemuxer.cpp +++ b/src/tvheadend/HTSPDemuxer.cpp @@ -149,10 +149,12 @@ DEMUX_PACKET* HTSPDemuxer::Read() } Logger::Log(LogLevel::LEVEL_TRACE, "demux read nothing"); - if (m_lastPkt > 0 && m_lastUse - m_lastPkt > 10 && !IsPaused()) + if (m_lastPkt > 0 && m_lastUse - m_lastPkt > m_settings->GetStreamStalledThreshold() && + !IsPaused()) { Logger::Log(LogLevel::LEVEL_WARNING, - "demux read no data for at least 10 secs; restarting connection"); + "demux read no data for at least %d secs; restarting connection", + m_settings->GetStreamStalledThreshold()); m_lastPkt = 0; m_conn.Disconnect(); } diff --git a/src/tvheadend/InstanceSettings.cpp b/src/tvheadend/InstanceSettings.cpp index 08df8124..aadaea94 100644 --- a/src/tvheadend/InstanceSettings.cpp +++ b/src/tvheadend/InstanceSettings.cpp @@ -43,6 +43,8 @@ const int DEFAULT_DVR_DUPDETECT = DVR_AUTOREC_RECORD_ALL; const bool DEFAULT_DVR_PLAYSTATUS = true; const int DEFAULT_STREAM_CHUNKSIZE = 64; // KB const bool DEFAULT_DVR_IGNORE_DUPLICATE_SCHEDULES = true; +const bool DEFAULT_STREAM_STALLED_THRESHOLD = 10; // seconds + } // namespace InstanceSettings::InstanceSettings(kodi::addon::IAddonInstance& instance) @@ -70,7 +72,8 @@ InstanceSettings::InstanceSettings(kodi::addon::IAddonInstance& instance) m_iDvrDupdetect(DEFAULT_DVR_DUPDETECT), m_bDvrPlayStatus(DEFAULT_DVR_PLAYSTATUS), m_iStreamReadChunkSizeKB(DEFAULT_STREAM_CHUNKSIZE), - m_bIgnoreDuplicateSchedules(DEFAULT_DVR_IGNORE_DUPLICATE_SCHEDULES) + m_bIgnoreDuplicateSchedules(DEFAULT_DVR_IGNORE_DUPLICATE_SCHEDULES), + m_streamStalledThreshold(DEFAULT_STREAM_STALLED_THRESHOLD) { ReadSettings(); } @@ -107,6 +110,8 @@ void InstanceSettings::ReadSettings() /* Streaming */ SetStreamingProfile(ReadStringSetting("streaming_profile", DEFAULT_STREAMING_PROFILE)); SetStreamingHTTP(ReadBoolSetting("streaming_http", DEFAULT_STREAMING_HTTP)); + SetStreamStalledThreshold(ReadIntSetting("stream_stalled_threshold", + DEFAULT_STREAM_STALLED_THRESHOLD)); /* Default dvr settings */ SetDvrPriority(ReadIntSetting("dvr_priority", DEFAULT_DVR_PRIO)); @@ -188,6 +193,8 @@ ADDON_STATUS InstanceSettings::SetSetting(const std::string& key, return SetStringSetting(GetStreamingProfile(), value); else if (key == "streaming_http") return SetBoolSetting(GetStreamingHTTP(), value); + else if (key == "stream_stalled_threshold") + return SetIntSetting(GetStreamStalledThreshold(), value); /* Default dvr settings */ else if (key == "dvr_priority") return SetIntSetting(GetDvrPriority(), value); diff --git a/src/tvheadend/InstanceSettings.h b/src/tvheadend/InstanceSettings.h index 24f2d73d..418931e1 100644 --- a/src/tvheadend/InstanceSettings.h +++ b/src/tvheadend/InstanceSettings.h @@ -53,6 +53,7 @@ class InstanceSettings bool GetDvrPlayStatus() const { return m_bDvrPlayStatus; } int GetStreamReadChunkSize() const { return m_iStreamReadChunkSizeKB; } bool GetIgnoreDuplicateSchedules() const { return m_bIgnoreDuplicateSchedules; } + int GetStreamStalledThreshold() const { return m_streamStalledThreshold; } private: InstanceSettings(const InstanceSettings&) = delete; @@ -89,6 +90,7 @@ class InstanceSettings void SetDvrPlayStatus(bool value) { m_bDvrPlayStatus = value; } void SetStreamReadChunkSizeKB(int value) { m_iStreamReadChunkSizeKB = value; } void SetIgnoreDuplicateSchedules(bool value) { m_bIgnoreDuplicateSchedules = value; } + void SetStreamStalledThreshold(int value) { m_streamStalledThreshold = value; } /** * Read/Set values according to definition in settings.xml @@ -129,6 +131,7 @@ class InstanceSettings bool m_bDvrPlayStatus; int m_iStreamReadChunkSizeKB; bool m_bIgnoreDuplicateSchedules; + int m_streamStalledThreshold; // seconds }; } // namespace tvheadend