diff --git a/src/IptvSimple.cpp b/src/IptvSimple.cpp index 02383e54..19426f95 100644 --- a/src/IptvSimple.cpp +++ b/src/IptvSimple.cpp @@ -240,7 +240,8 @@ PVR_ERROR IptvSimple::GetChannelStreamProperties(const kodi::addon::PVRChannel& streamURL = m_catchupController.ProcessStreamUrl(m_currentChannel); streamURL = StreamUtils::WebStreamExtractor(streamURL, m_currentChannel); - StreamUtils::SetAllStreamProperties(properties, m_currentChannel, streamURL, catchupUrl.empty(), catchupProperties, m_settings); + // The catchup controller already looked up the stream type of this URL + StreamUtils::SetAllStreamProperties(properties, m_currentChannel, streamURL, catchupUrl.empty(), catchupProperties, m_settings, m_catchupController.GetKnownStreamType(streamURL)); Logger::Log(LogLevel::LEVEL_INFO, "%s - Live %s URL: %s", __FUNCTION__, catchupUrl.empty() ? "Stream" : "Catchup", WebUtils::RedactUrl(streamURL).c_str()); diff --git a/src/iptvsimple/CatchupController.cpp b/src/iptvsimple/CatchupController.cpp index 39ec0ad8..21732bb9 100644 --- a/src/iptvsimple/CatchupController.cpp +++ b/src/iptvsimple/CatchupController.cpp @@ -246,7 +246,9 @@ void CatchupController::SetCatchupInputStreamProperties(bool playbackAsLive, con StreamType CatchupController::StreamTypeLookup(const Channel& channel, bool fromEpg /* false */) { - StreamType streamType = m_streamManager.StreamTypeLookup(channel, GetStreamTestUrl(channel, fromEpg), GetStreamKey(channel, fromEpg)); + m_lastStreamTestUrl = GetStreamTestUrl(channel, fromEpg); + StreamType streamType = m_streamManager.StreamTypeLookup(channel, m_lastStreamTestUrl, GetStreamKey(channel, fromEpg)); + m_lastStreamType = streamType; m_controlsLiveStream = StreamUtils::GetEffectiveInputStreamName(streamType, channel, m_settings) == "inputstream.ffmpegdirect" && channel.CatchupSupportsTimeshifting(); diff --git a/src/iptvsimple/CatchupController.h b/src/iptvsimple/CatchupController.h index 0b7969cc..e9d65a79 100644 --- a/src/iptvsimple/CatchupController.h +++ b/src/iptvsimple/CatchupController.h @@ -38,6 +38,10 @@ namespace iptvsimple std::string ProcessStreamUrl(const data::Channel& channel) const; bool ControlsLiveStream() const { return m_controlsLiveStream; } + StreamType GetKnownStreamType(const std::string& url) const + { + return url == m_lastStreamTestUrl ? m_lastStreamType : StreamType::OTHER_TYPE; + } void ResetCatchupState(); data::EpgEntry* GetEPGEntry(const iptvsimple::data::Channel& myChannel, time_t lookupTime); @@ -71,6 +75,8 @@ namespace iptvsimple std::string m_programmeCatchupId; bool m_controlsLiveStream = false; + std::string m_lastStreamTestUrl; + StreamType m_lastStreamType = StreamType::OTHER_TYPE; iptvsimple::Epg& m_epg; std::mutex* m_mutex = nullptr; diff --git a/src/iptvsimple/utilities/StreamUtils.cpp b/src/iptvsimple/utilities/StreamUtils.cpp index 09b7cc8f..c75ae0c8 100644 --- a/src/iptvsimple/utilities/StreamUtils.cpp +++ b/src/iptvsimple/utilities/StreamUtils.cpp @@ -47,7 +47,7 @@ bool HasInputstreamAdaptiveDrmConfig(const T& entry) } } // unnamed namespace -void StreamUtils::SetAllStreamProperties(std::vector& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, bool isChannelURL, std::map& catchupProperties, std::shared_ptr& settings) +void StreamUtils::SetAllStreamProperties(std::vector& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, bool isChannelURL, std::map& catchupProperties, std::shared_ptr& settings, StreamType knownStreamType) { // Check if the channel explicitly uses inputstream.adaptive, or has its DRM configuration // without another explicit inputstream. If so, the best behaviour for media services is: @@ -84,6 +84,8 @@ void StreamUtils::SetAllStreamProperties(std::vector& properties, const iptvsimple::data::Channel& channel, const std::string& streamUrl, bool isChannelURL, std::map& catchupProperties, std::shared_ptr& settings); + static void SetAllStreamProperties(std::vector& properties, const iptvsimple::data::Channel& channel, const std::string& streamUrl, bool isChannelURL, std::map& catchupProperties, std::shared_ptr& settings, StreamType knownStreamType = StreamType::OTHER_TYPE); static void SetAllStreamProperties(std::vector& properties, const iptvsimple::data::MediaEntry& mediaEntry, const std::string& streamUrl, std::shared_ptr& settings); static const StreamType GetStreamType(const std::string& url, const std::string& mimeType, bool isCatchupTSStream); static const StreamType InspectStreamType(const std::string& url, iptvsimple::CatchupMode catchupMode);