Skip to content

Commit

Permalink
Merge pull request #899 from phunkyfish/media-inputstream
Browse files Browse the repository at this point in the history
Correctly set inputstream properties for media entries
  • Loading branch information
phunkyfish authored Oct 5, 2024
2 parents 383e8c8 + dd1d824 commit d0b4e97
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 52 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="22.1.2"
version="22.2.0"
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 @@
v22.2.0
- Correctly set inputstream properties for media entries

v22.1.2
- Fix #KODIPROP parsing from playlists

Expand Down
5 changes: 3 additions & 2 deletions src/IptvSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ PVR_ERROR IptvSimple::GetRecordings(bool deleted, kodi::addon::PVRRecordingsResu

PVR_ERROR IptvSimple::GetRecordingStreamProperties(const kodi::addon::PVRRecording& recording, std::vector<kodi::addon::PVRStreamProperty>& properties)
{
auto mediaEntry = m_media.GetMediaEntry(recording);
std::string url = m_media.GetMediaEntryURL(recording);

if (!url.empty())
if (!mediaEntry.GetMediaEntryId().empty() && !url.empty())
{
properties.emplace_back(PVR_STREAM_PROPERTY_STREAMURL, url);
StreamUtils::SetAllStreamProperties(properties, mediaEntry, url, m_settings);

return PVR_ERROR_NO_ERROR;
}
Expand Down
7 changes: 7 additions & 0 deletions src/iptvsimple/Media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ bool Media::IsInVirtualMediaEntryFolder(const MediaEntry& mediaEntryToCheck) con
return false;
}

const MediaEntry Media::GetMediaEntry(const kodi::addon::PVRRecording& recording)
{
Logger::Log(LEVEL_INFO, "%s", __func__);

return GetMediaEntry(recording.GetRecordingId());
}

const std::string Media::GetMediaEntryURL(const kodi::addon::PVRRecording& recording)
{
Logger::Log(LEVEL_INFO, "%s", __func__);
Expand Down
1 change: 1 addition & 0 deletions src/iptvsimple/Media.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace iptvsimple
void GetMedia(std::vector<kodi::addon::PVRRecording>& kodiRecordings);
int GetNumMedia() const;
void Clear();
const data::MediaEntry GetMediaEntry(const kodi::addon::PVRRecording& mediaEntry);
const std::string GetMediaEntryURL(const kodi::addon::PVRRecording& mediaEntry);
const iptvsimple::data::MediaEntry* FindMediaEntry(const std::string& id, const std::string& displayName) const;

Expand Down
4 changes: 2 additions & 2 deletions src/iptvsimple/StreamManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ StreamEntry StreamManager::StreamEntryLookup(const Channel& channel, const std::

if (!streamEntry)
{
StreamType streamType = StreamUtils::GetStreamType(streamTestUrl, channel);
StreamType streamType = StreamUtils::GetStreamType(streamTestUrl, channel.GetProperty(PVR_STREAM_PROPERTY_MIMETYPE), channel.IsCatchupTSStream());
if (streamType == StreamType::OTHER_TYPE)
streamType = StreamUtils::InspectStreamType(streamTestUrl, channel);
streamType = StreamUtils::InspectStreamType(streamTestUrl, channel.GetCatchupMode());

streamEntry = std::make_shared<StreamEntry>();
streamEntry->SetStreamKey(streamKey);
Expand Down
9 changes: 9 additions & 0 deletions src/iptvsimple/data/MediaEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,12 @@ void MediaEntry::UpdateTo(kodi::addon::PVRRecording& left, bool isInVirtualMedia

left.SetDirectory(newDirectory);
}

std::string MediaEntry::GetProperty(const std::string& propName) const
{
auto propPair = m_properties.find(propName);
if (propPair != m_properties.end())
return propPair->second;

return {};
}
169 changes: 128 additions & 41 deletions src/iptvsimple/utilities/StreamUtils.cpp

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions src/iptvsimple/utilities/StreamUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include "../data/Channel.h"
#include "../data/MediaEntry.h"
#include "../data/StreamEntry.h"

#include <map>
Expand All @@ -29,12 +30,13 @@ namespace iptvsimple
{
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 const StreamType GetStreamType(const std::string& url, const iptvsimple::data::Channel& channel);
static const StreamType InspectStreamType(const std::string& url, const iptvsimple::data::Channel& channel);
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);
static const std::string GetManifestType(const StreamType& streamType);
static const std::string GetMimeType(const StreamType& streamType);
static bool HasMimeType(const StreamType& streamType);
static std::string GetURLWithFFmpegReconnectOptions(const std::string& streamUrl, const StreamType& streamType, const iptvsimple::data::Channel& channel, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
static std::string GetURLWithFFmpegReconnectOptions(const std::string& streamUrl, const StreamType& streamType, const std::string& inputstreamName, bool hasHTTPReconnect, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
static std::string AddHeader(const std::string& headerTarget, const std::string& headerName, const std::string& headerValue, bool encodeHeaderValue);
static std::string AddHeaderToStreamUrl(const std::string& streamUrl, const std::string& headerName, const std::string& headerValue);
static bool UseKodiInputstreams(const StreamType& streamType, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
Expand All @@ -43,9 +45,9 @@ namespace iptvsimple
static std::string GetEffectiveInputStreamName(const StreamType& streamType, const iptvsimple::data::Channel& channel, std::shared_ptr<iptvsimple::InstanceSettings>& settings);

private:
static bool SupportsFFmpegReconnect(const StreamType& streamType, const iptvsimple::data::Channel& channel);
static void InspectAndSetFFmpegDirectStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamUrl, bool isChannelURL, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
static void SetFFmpegDirectManifestTypeStreamProperty(std::vector<kodi::addon::PVRStreamProperty>& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, const StreamType& streamType);
static bool SupportsFFmpegReconnect(const StreamType& streamType, const std::string& inputstreamName);
static void InspectAndSetFFmpegDirectStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const std::string& mimeType, const std::string& manifestType, iptvsimple::CatchupMode catchupMode, bool isCatchupTSStream, const std::string& streamUrl, std::shared_ptr<iptvsimple::InstanceSettings>& settings);
static void SetFFmpegDirectManifestTypeStreamProperty(std::vector<kodi::addon::PVRStreamProperty>& properties, const std::string& manifestType, const std::string& streamURL, const StreamType& streamType);
static bool CheckInputstreamInstalledAndEnabled(const std::string& inputstreamName);

};
Expand Down

0 comments on commit d0b4e97

Please sign in to comment.