Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for threshold for reconnect on stalled stream. #640

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="21.1.2"
version="21.2.0"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 10 additions & 0 deletions pvr.hts/resources/instance-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@
</constraints>
<control type="slider" format="integer" />
</setting>
<setting id="stream_stalled_threshold" type="integer" label="30013" help="-1">
<level>0</level>
<default>10</default>
<constraints>
<minimum>1</minimum>
<step>1</step>
<maximum>60</maximum>
</constraints>
<control type="slider" format="integer" />
</setting>
</group>
</category>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/tvheadend/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
9 changes: 8 additions & 1 deletion src/tvheadend/InstanceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/tvheadend/InstanceSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -129,6 +131,7 @@ class InstanceSettings
bool m_bDvrPlayStatus;
int m_iStreamReadChunkSizeKB;
bool m_bIgnoreDuplicateSchedules;
int m_streamStalledThreshold; // seconds
};

} // namespace tvheadend
Loading