Skip to content

Commit

Permalink
Optionally use inputstream.ffmpegdirect
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvana-7777 committed Nov 3, 2023
1 parent b48a153 commit 96d424e
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pvr.eon/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.eon"
version="20.7.2"
version="20.7.3"
name="EON PVR Client"
provider-name="Nirvana">
<requires>
Expand Down
2 changes: 2 additions & 0 deletions pvr.eon/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ v20.7.1
- Adapt user agent header for platforms when streaming
v20.7.2
- Fix EPG date
v20.7.3
- Optionally use inputstream.ffmpegdirect
20 changes: 20 additions & 0 deletions pvr.eon/resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,23 @@ msgstr ""
msgctxt "#30048"
msgid "min Zeit."
msgstr ""

msgctxt "#30049"
msgid "Streaming"
msgstr "Streaming"

msgctxt "#30050"
msgid "Inputstream"
msgstr "Inputstream"

msgctxt "#30051"
msgid "Select Inputstream"
msgstr "Inputstream auswählen"

msgctxt "#30052"
msgid "inputstream.adaptive"
msgstr "inputstream.adaptive"

msgctxt "#30053"
msgid "inputstream.ffmpegdirect"
msgstr "inputstream.ffmpegdirect"
20 changes: 20 additions & 0 deletions pvr.eon/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,23 @@ msgstr ""
msgctxt "#30048"
msgid "min left."
msgstr ""

msgctxt "#30049"
msgid "Streaming"
msgstr ""

msgctxt "#30050"
msgid "Inputstream"
msgstr ""

msgctxt "#30051"
msgid "Select Inputstream"
msgstr ""

msgctxt "#30052"
msgid "inputstream.adaptive"
msgstr ""

msgctxt "#30053"
msgid "inputstream.ffmpegdirect"
msgstr ""
20 changes: 20 additions & 0 deletions pvr.eon/resources/language/resource.language.en_us/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,23 @@ msgstr ""
msgctxt "#30048"
msgid "min left."
msgstr ""

msgctxt "#30049"
msgid "Streaming"
msgstr ""

msgctxt "#30050"
msgid "Inputstream"
msgstr ""

msgctxt "#30051"
msgid "Select Inputstream"
msgstr ""

msgctxt "#30052"
msgid "inputstream.adaptive"
msgstr ""

msgctxt "#30053"
msgid "inputstream.ffmpegdirect"
msgstr ""
15 changes: 15 additions & 0 deletions pvr.eon/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,20 @@
</setting>
</group>
</category>
<category id="streaming" label="30049">
<group id="3" label="30050">
<setting id="inputstream" type="integer" label="30051">
<level>0</level>
<default>0</default>
<constraints>
<options>
<option label="30052">0</option> <!-- inputstream.adaptive -->
<option label="30053">1</option> <!-- inputstream.ffmpegdirect -->
</options>
</constraints>
<control type="list" format="integer" />
</setting>
</group>
</category>
</section>
</settings>
55 changes: 33 additions & 22 deletions src/PVREon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,30 +833,41 @@ bool CPVREon::HandleSession(bool start, int cid, int epg_id)

void CPVREon::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties,
const std::string& url,
bool realtime, bool playTimeshiftBuffer,
const std::string& license)
const bool& realtime, const bool& playTimeshiftBuffer, const bool& isLive,
const int& starttime, const int& endtime)
{
kodi::Log(ADDON_LOG_DEBUG, "[PLAY STREAM] url: %s", url.c_str());

properties.emplace_back(PVR_STREAM_PROPERTY_STREAMURL, url);
properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
properties.emplace_back(PVR_STREAM_PROPERTY_ISREALTIMESTREAM, realtime ? "true" : "false");

kodi::Log(ADDON_LOG_DEBUG, "[PLAY STREAM] hls");
properties.emplace_back("inputstream.adaptive.manifest_type", "hls");
properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/x-mpegURL");
// properties.emplace_back("inputstream.adaptive.original_audio_language", "bs");
// properties.emplace_back("inputstream.adaptive.stream_selection_type", "adaptive");
properties.emplace_back("inputstream.adaptive.stream_selection_type", "manual-osd");
properties.emplace_back("inputstream.adaptive.manifest_headers", "User-Agent=" + m_parameters.user_agent);

// properties.emplace_back("inputstream.adaptive.license_type", "com.widevine.alpha");
// properties.emplace_back("inputstream.adaptive.license_key",
// "https://lic.drmtoday.com/license-proxy-widevine/cenc/"
// "|Content-Type=text%2Fxml&dt-custom-data=" +
// license + "|R{SSM}|JBlicense");

properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");

int inputstream = m_settings->GetInputstream();

if (inputstream == INPUTSTREAM_ADAPTIVE)
{
properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
properties.emplace_back("inputstream.adaptive.manifest_type", "hls");
// properties.emplace_back("inputstream.adaptive.original_audio_language", "bs");
// properties.emplace_back("inputstream.adaptive.stream_selection_type", "adaptive");
properties.emplace_back("inputstream.adaptive.stream_selection_type", "manual-osd");
properties.emplace_back("inputstream.adaptive.manifest_headers", "User-Agent=" + m_parameters.user_agent);
properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
} else if (inputstream == INPUTSTREAM_FFMPEGDIRECT)
{
properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.ffmpegdirect");
properties.emplace_back("inputstream.ffmpegdirect.manifest_type", "hls");
properties.emplace_back("inputstream.ffmpegdirect.is_realtime_stream", "true");
properties.emplace_back("inputstream.ffmpegdirect.stream_mode", isLive ? "timeshift" : "catchup");
if (!isLive) {
properties.emplace_back("inputstream.ffmpegdirect.catchup_buffer_start_time", std::to_string(starttime));
properties.emplace_back("inputstream.ffmpegdirect.catchup_buffer_end_time", std::to_string(endtime));
properties.emplace_back("inputstream.ffmpegdirect.programme_start_time", std::to_string(starttime));
properties.emplace_back("inputstream.ffmpegdirect.programme_end_time", std::to_string(endtime));
}
} else {
kodi::Log(ADDON_LOG_DEBUG, "Unknown inputstream detected");
}
}


Expand Down Expand Up @@ -1012,7 +1023,7 @@ PVR_ERROR CPVREon::GetEPGTagStreamProperties(
{
if (channel.iUniqueId == tag.GetUniqueChannelId())
{
return GetStreamProperties(channel, properties, tag.GetStartTime(), false);
return GetStreamProperties(channel, properties, tag.GetStartTime(), tag.GetEndTime(), false);
}
}
return PVR_ERROR_NO_ERROR;
Expand Down Expand Up @@ -1068,7 +1079,7 @@ PVR_ERROR CPVREon::GetChannels(bool bRadio, kodi::addon::PVRChannelsResultSet& r
}

PVR_ERROR CPVREon::GetStreamProperties(
const EonChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties, int starttime, bool isLive)
const EonChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties, const int& starttime, const int& endtime, const bool& isLive)
{
kodi::Log(ADDON_LOG_DEBUG, "function call: [%s]", __FUNCTION__);
std::string streaming_profile = "hp7000";
Expand Down Expand Up @@ -1170,7 +1181,7 @@ PVR_ERROR CPVREon::GetStreamProperties(

kodi::Log(ADDON_LOG_DEBUG, "Encrypted Stream URL -> %s", enc_url.c_str());

SetStreamProperties(properties, enc_url, true, false, "");
SetStreamProperties(properties, enc_url, true, false, isLive, starttime, endtime);

return PVR_ERROR_NO_ERROR;
}
Expand All @@ -1182,7 +1193,7 @@ PVR_ERROR CPVREon::GetChannelStreamProperties(
EonChannel addonChannel;
if (GetChannel(channel, addonChannel)) {
if (addonChannel.subscribed) {
return GetStreamProperties(addonChannel, properties, 0, true);
return GetStreamProperties(addonChannel, properties, 0, 0, true);
}
kodi::Log(ADDON_LOG_DEBUG, "Channel not subscribed");
return PVR_ERROR_SERVER_ERROR;
Expand Down
22 changes: 6 additions & 16 deletions src/PVREon.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "http/HttpClient.h"
#include "rapidjson/document.h"

static const int INPUTSTREAM_ADAPTIVE = 0;
static const int INPUTSTREAM_FFMPEGDIRECT = 1;

struct EonChannelCategory
{
int id;
Expand Down Expand Up @@ -183,12 +186,12 @@ class ATTR_DLL_LOCAL CPVREon : public kodi::addon::CAddonBase,

void SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties,
const std::string& url,
bool realtime, bool playTimeshiftBuffer,
const std::string& license);
const bool& realtime, const bool& playTimeshiftBuffer, const bool& isLive,
const int& starttime, const int& endtime);

PVR_ERROR GetStreamProperties(
const EonChannel& channel,
std::vector<kodi::addon::PVRStreamProperty>& properties, int starttime, bool isLive);
std::vector<kodi::addon::PVRStreamProperty>& properties, const int& starttime, const int& endtime, const bool& isLive);

bool Parametrize(const int id);

Expand Down Expand Up @@ -247,17 +250,4 @@ class ATTR_DLL_LOCAL CPVREon : public kodi::addon::CAddonBase,
bool GetCategories(const bool isRadio);
int GetDefaultNumber(const bool isRadio, int id);
bool HandleSession(bool start, int cid, int epg_id);
/*
bool HrtiLogin();
bool GetIpAddress();
bool GrantAccess();
bool RegisterDevice();
bool LoadChannels();
bool AuthorizeSession(std::string ref_id, std::string drm_id);
std::string GetLicense(std::string drm_id, std::string user_id);
*/
// std::string ltrim(const std::string &s);
// std::string rtrim(const std::string &s);
// std::string trim(const std::string &s);
// std::string urlencode(const std::string &s);
};
7 changes: 7 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ bool CSettings::Load()
return false;
}

if (!kodi::addon::CheckSettingInt("inputstream", m_eonInputstream))
{
/* If setting is unknown fallback to defaults */
kodi::Log(ADDON_LOG_ERROR, "Couldn't get 'inputstream' setting");
return false;
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ATTR_DLL_LOCAL CSettings

const int& GetEonServiceProvider() const { return m_eonServiceProvider; }
const int& GetPlatform() const { return m_eonPlatform; }
const int& GetInputstream() const { return m_eonInputstream; }
const std::string& GetEonUsername() const { return m_eonUsername; }
const std::string& GetEonPassword() const { return m_eonPassword; }
const std::string& GetEonAccessToken() const { return m_eonAccessToken; }
Expand All @@ -44,6 +45,7 @@ class ATTR_DLL_LOCAL CSettings
private:
int m_eonServiceProvider;
int m_eonPlatform;
int m_eonInputstream;
std::string m_eonUsername;
std::string m_eonPassword;
std::string m_eonAccessToken;
Expand Down

0 comments on commit 96d424e

Please sign in to comment.