Skip to content

Commit

Permalink
Merge pull request #830 from phunkyfish/fix-epg-playback-as-live
Browse files Browse the repository at this point in the history
Fix epg playback as live
  • Loading branch information
phunkyfish committed Feb 3, 2024
2 parents a063bdd + df71357 commit c03cd1d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pvr.iptvsimple/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.iptvsimple"
version="21.7.1"
version="21.7.2"
name="IPTV Simple Client"
provider-name="nightik and Ross Nicholson">
<requires>@ADDON_DEPENDS@
Expand Down
3 changes: 3 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/IptvSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions src/iptvsimple/CatchupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ CatchupController::CatchupController(Epg& epg, std::mutex* mutex, std::shared_pt

void CatchupController::ProcessChannelForPlayback(const Channel& channel, std::map<std::string, std::string>& 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())
Expand All @@ -52,7 +56,6 @@ void CatchupController::ProcessChannelForPlayback(const Channel& channel, std::m
m_catchupStartTime = 0;
m_catchupEndTime = 0;
}
m_fromEpgTag = false;
}

if (m_controlsLiveStream)
Expand All @@ -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.
Expand Down Expand Up @@ -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<std::string, std::string>& catchupProperties)
Expand Down Expand Up @@ -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<std::string, std::string>& catchupProperties, const StreamType& streamType)
Expand Down
4 changes: 2 additions & 2 deletions src/iptvsimple/CatchupController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit c03cd1d

Please sign in to comment.