From 20d1512105f9f71a6d40c4b176899b67fe09369d Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Thu, 1 Feb 2024 17:49:39 +0000 Subject: [PATCH 1/2] Only reset the catchup state if not playing a timeshifted EPG tag --- src/IptvSimple.cpp | 3 +++ src/iptvsimple/CatchupController.cpp | 24 ++++++++++++++++++++---- src/iptvsimple/CatchupController.h | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/IptvSimple.cpp b/src/IptvSimple.cpp index 9d51c6867..0e8983e45 100644 --- a/src/IptvSimple.cpp +++ b/src/IptvSimple.cpp @@ -222,6 +222,9 @@ PVR_ERROR IptvSimple::GetChannelStreamProperties(const kodi::addon::PVRChannel& { std::string streamURL = m_currentChannel.GetStreamURL(); + // This reset will have no effect if we tried to play an epg tag as live + // i.e GetEPGTagStreamProperties will have been called prior to GetChannelStreamProperties + // So the state will not be reset as we need to carry the EPG entry details over to the timehifted live stream. m_catchupController.ResetCatchupState(); // TODO: we need this currently until we have a way to know the stream stops. // We always call the catchup controller regardless so it can cleanup state diff --git a/src/iptvsimple/CatchupController.cpp b/src/iptvsimple/CatchupController.cpp index 9fa81f193..62b0484d8 100644 --- a/src/iptvsimple/CatchupController.cpp +++ b/src/iptvsimple/CatchupController.cpp @@ -29,12 +29,16 @@ CatchupController::CatchupController(Epg& epg, std::mutex* mutex, std::shared_pt void CatchupController::ProcessChannelForPlayback(const Channel& channel, std::map& catchupProperties) { + // This function is called in two different sceanrios + // 1) From a 'Switch' to a channel where we play a live stream + // 2) From a timeshifted EPG tag call where we want to playback as live + StreamType streamType = StreamTypeLookup(channel); // Anything from here is live! m_playbackIsVideo = false; // TODO: possible time jitter on UI as this will effect get stream times - if (!m_fromEpgTag || m_controlsLiveStream) + if (!m_fromTimeshiftedEpgTagCall) { EpgEntry* liveEpgEntry = GetLiveEPGEntry(channel); if (m_controlsLiveStream && liveEpgEntry && !m_settings->CatchupOnlyOnFinishedProgrammes()) @@ -52,7 +56,6 @@ void CatchupController::ProcessChannelForPlayback(const Channel& channel, std::m m_catchupStartTime = 0; m_catchupEndTime = 0; } - m_fromEpgTag = false; } if (m_controlsLiveStream) @@ -79,6 +82,9 @@ void CatchupController::ProcessChannelForPlayback(const Channel& channel, std::m UpdateProgrammeFrom(*currentEpgEntry, channel.GetTvgShift()); } + //We no longer need to know if this originated from an EPG tag + m_fromTimeshiftedEpgTagCall = false; + m_catchupStartTime = m_timeshiftBufferStartTime; // TODO: Need a method of updating an inputstream if already running such as web call to stream etc. @@ -126,9 +132,9 @@ void CatchupController::ProcessEPGTagForTimeshiftedPlayback(const kodi::addon::P m_timeshiftBufferStartTime = 0; m_timeshiftBufferOffset = 0; - - m_fromEpgTag = true; } + + m_fromTimeshiftedEpgTagCall = true; } void CatchupController::ProcessEPGTagForVideoPlayback(const kodi::addon::PVREPGTag& epgTag, const Channel& channel, std::map& catchupProperties) @@ -177,6 +183,16 @@ void CatchupController::ProcessEPGTagForVideoPlayback(const kodi::addon::PVREPGT if (m_catchupStartTime > 0) m_playbackIsVideo = true; + + m_fromTimeshiftedEpgTagCall = false; +} + +void CatchupController::ResetCatchupState() +{ + // 'm_fromTimeshiftedEpgTagCall' can only be set if we tried to play an EPG tag as live + // This can only happen in ProcessEPGTagForTimeshiftedPlayback() and nowhere else + if (!m_fromTimeshiftedEpgTagCall) + m_resetCatchupState = true; } void CatchupController::SetCatchupInputStreamProperties(bool playbackAsLive, const Channel& channel, std::map& catchupProperties, const StreamType& streamType) diff --git a/src/iptvsimple/CatchupController.h b/src/iptvsimple/CatchupController.h index 423f29556..0b7969cc7 100644 --- a/src/iptvsimple/CatchupController.h +++ b/src/iptvsimple/CatchupController.h @@ -38,7 +38,7 @@ namespace iptvsimple std::string ProcessStreamUrl(const data::Channel& channel) const; bool ControlsLiveStream() const { return m_controlsLiveStream; } - void ResetCatchupState() { m_resetCatchupState = true; } + void ResetCatchupState(); data::EpgEntry* GetEPGEntry(const iptvsimple::data::Channel& myChannel, time_t lookupTime); private: @@ -60,7 +60,7 @@ namespace iptvsimple long long m_timeshiftBufferOffset = 0; bool m_resetCatchupState = false; bool m_playbackIsVideo = false; - bool m_fromEpgTag = false; + bool m_fromTimeshiftedEpgTagCall = false; // Current programme details time_t m_programmeStartTime = 0; From df7135712b428304ad7ae275b6b9525081694fc8 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Thu, 1 Feb 2024 20:17:26 +0000 Subject: [PATCH 2/2] changelog and version 21.7.2 --- pvr.iptvsimple/addon.xml.in | 2 +- pvr.iptvsimple/changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pvr.iptvsimple/addon.xml.in b/pvr.iptvsimple/addon.xml.in index 60954a5b3..57c9df9db 100644 --- a/pvr.iptvsimple/addon.xml.in +++ b/pvr.iptvsimple/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.iptvsimple/changelog.txt b/pvr.iptvsimple/changelog.txt index eb7668fb7..630fe87ee 100644 --- a/pvr.iptvsimple/changelog.txt +++ b/pvr.iptvsimple/changelog.txt @@ -1,3 +1,6 @@ +v21.7.2 +- Only reset the catchup state if not playing a timeshifted EPG tag + v21.7.1 - Fix supporting of local paths in Connection Manager