Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/IptvSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 3 additions & 1 deletion src/iptvsimple/CatchupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 6 additions & 0 deletions src/iptvsimple/CatchupController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions src/iptvsimple/utilities/StreamUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool HasInputstreamAdaptiveDrmConfig(const T& entry)
}
} // unnamed namespace

void StreamUtils::SetAllStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, bool isChannelURL, std::map<std::string, std::string>& catchupProperties, std::shared_ptr<InstanceSettings>& settings)
void StreamUtils::SetAllStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, bool isChannelURL, std::map<std::string, std::string>& catchupProperties, std::shared_ptr<InstanceSettings>& 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:
Expand Down Expand Up @@ -84,6 +84,8 @@ void StreamUtils::SetAllStreamProperties(std::vector<kodi::addon::PVRStreamPrope
else
{
StreamType streamType = StreamUtils::GetStreamType(streamURL, channel.GetProperty(PVR_STREAM_PROPERTY_MIMETYPE), channel.IsCatchupTSStream());
if (streamType == StreamType::OTHER_TYPE)
streamType = knownStreamType;
if (streamType == StreamType::OTHER_TYPE)
streamType = StreamUtils::InspectStreamType(streamURL, channel.GetCatchupMode());

Expand Down Expand Up @@ -365,7 +367,9 @@ const StreamType StreamUtils::GetStreamType(const std::string& url, const std::s

const StreamType StreamUtils::InspectStreamType(const std::string& url, CatchupMode catchupMode)
{
if (!FileUtils::FileExists(url))
// Some servers reject the HEAD request used by FileExists() but allow GET,
// so for HTTP rely on the read below to detect an unreachable stream.
if (!WebUtils::IsHttpUrl(url) && !FileUtils::FileExists(url))
return StreamType::OTHER_TYPE;

int httpCode = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/iptvsimple/utilities/StreamUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace iptvsimple
class StreamUtils
{
public:
static void SetAllStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamUrl, bool isChannelURL, std::map<std::string, std::string>& catchupProperties, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
static void SetAllStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamUrl, bool isChannelURL, std::map<std::string, std::string>& catchupProperties, std::shared_ptr<iptvsimple::InstanceSettings>& settings, StreamType knownStreamType = StreamType::OTHER_TYPE);
static void SetAllStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::MediaEntry& mediaEntry, const std::string& streamUrl, std::shared_ptr<iptvsimple::InstanceSettings>& 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);
Expand Down
Loading