Skip to content

Commit

Permalink
Merge pull request #104 from phunkyfish/fix-hls-bitrate
Browse files Browse the repository at this point in the history
Fix hls bitrate
  • Loading branch information
phunkyfish authored May 9, 2021
2 parents b102c52 + 9892fa6 commit 063c1ad
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
7 changes: 5 additions & 2 deletions inputstream.ffmpegdirect/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="inputstream.ffmpegdirect"
version="1.21.2"
version="1.21.3"
name="Inputstream FFmpeg Direct"
provider-name="Ross Nicholson">
<requires>@ADDON_DEPENDS@</requires>
Expand All @@ -26,8 +26,11 @@
<fanart>fanart.jpg</fanart>
</assets>
<news>
v1.21.3
- Fixed: fix hls bitrate selection

v1.21.2
Fixed: Allow timezone shift when live URLs have placeholders
- Fixed: Allow timezone shift when live URLs have placeholders

v1.21.1
- Fixed: remove workaround for ffmpeg deprecated function on windowsstore
Expand Down
5 changes: 4 additions & 1 deletion inputstream.ffmpegdirect/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
v1.21.3
- Fixed: fix hls bitrate selection

v1.21.2
Fixed: Allow timezone shift when live URLs have placeholders
- Fixed: Allow timezone shift when live URLs have placeholders

v1.21.1
- Fixed: remove workaround for ffmpeg deprecated function on windowsstore
Expand Down
62 changes: 31 additions & 31 deletions src/StreamManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,85 +75,85 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props

if (PROGRAM_NUMBER == prop.first)
{
properties.m_programProperty = prop.second;
m_properties.m_programProperty = prop.second;
}
else if (IS_REALTIME_STREAM == prop.first)
{
properties.m_isRealTimeStream = StringUtils::EqualsNoCase(prop.second, "true");
m_properties.m_isRealTimeStream = StringUtils::EqualsNoCase(prop.second, "true");
}
else if (STREAM_MODE == prop.first)
{
if (StringUtils::EqualsNoCase(prop.second, "catchup"))
properties.m_streamMode = StreamMode::CATCHUP;
m_properties.m_streamMode = StreamMode::CATCHUP;
else if (StringUtils::EqualsNoCase(prop.second, "timeshift"))
properties.m_streamMode = StreamMode::TIMESHIFT;
m_properties.m_streamMode = StreamMode::TIMESHIFT;
}
else if (OPEN_MODE == prop.first)
{
if (StringUtils::EqualsNoCase(prop.second, "ffmpeg"))
properties.m_openMode = OpenMode::FFMPEG;
m_properties.m_openMode = OpenMode::FFMPEG;
else if (StringUtils::EqualsNoCase(prop.second, "curl"))
properties.m_openMode = OpenMode::CURL;
m_properties.m_openMode = OpenMode::CURL;
}
else if (MANIFEST_TYPE == prop.first)
{
properties.m_manifestType = prop.second;
m_properties.m_manifestType = prop.second;
}
else if (DEFAULT_URL == prop.first)
{
properties.m_defaultUrl = prop.second;
m_properties.m_defaultUrl = prop.second;
}
else if (PLAYBACK_AS_LIVE == prop.first)
{
properties.m_playbackAsLive = StringUtils::EqualsNoCase(prop.second, "true");
m_properties.m_playbackAsLive = StringUtils::EqualsNoCase(prop.second, "true");
}
else if (PROGRAMME_START_TIME == prop.first)
{
properties.m_programmeStartTime = static_cast<time_t>(std::stoll(prop.second));
m_properties.m_programmeStartTime = static_cast<time_t>(std::stoll(prop.second));
}
else if (PROGRAMME_END_TIME == prop.first)
{
properties.m_programmeEndTime = static_cast<time_t>(std::stoll(prop.second));
m_properties.m_programmeEndTime = static_cast<time_t>(std::stoll(prop.second));
}
else if (CATCHUP_URL_FORMAT_STRING == prop.first)
{
properties.m_catchupUrlFormatString = prop.second;
m_properties.m_catchupUrlFormatString = prop.second;
}
else if (CATCHUP_URL_NEAR_LIVE_FORMAT_STRING == prop.first)
{
properties.m_catchupUrlNearLiveFormatString = prop.second;
m_properties.m_catchupUrlNearLiveFormatString = prop.second;
}
else if (CATCHUP_BUFFER_START_TIME == prop.first)
{
properties.m_catchupBufferStartTime = static_cast<time_t>(std::stoll(prop.second));
m_properties.m_catchupBufferStartTime = static_cast<time_t>(std::stoll(prop.second));
}
else if (CATCHUP_BUFFER_END_TIME == prop.first)
{
properties.m_catchupBufferEndTime = static_cast<time_t>(std::stoll(prop.second));
m_properties.m_catchupBufferEndTime = static_cast<time_t>(std::stoll(prop.second));
}
else if (CATCHUP_BUFFER_OFFSET == prop.first)
{
properties.m_catchupBufferOffset = std::stoll(prop.second);
m_properties.m_catchupBufferOffset = std::stoll(prop.second);
}
else if (CATCHUP_TERMINATES == prop.first)
{
properties.m_catchupTerminates = StringUtils::EqualsNoCase(prop.second, "true");
m_properties.m_catchupTerminates = StringUtils::EqualsNoCase(prop.second, "true");
}
else if (CATCHUP_GRANULARITY == prop.first)
{
properties.m_catchupGranularity = std::stoi(prop.second);
m_properties.m_catchupGranularity = std::stoi(prop.second);
}
else if (TIMEZONE_SHIFT == prop.first)
{
properties.m_timezoneShiftSecs = std::stoi(prop.second);
m_properties.m_timezoneShiftSecs = std::stoi(prop.second);
}
else if (DEFAULT_PROGRAMME_DURATION == prop.first)
{
properties.m_defaultProgrammeDurationSecs = std::stoi(prop.second);
m_properties.m_defaultProgrammeDurationSecs = std::stoi(prop.second);
}
else if (PROGRAMME_CATCHUP_ID == prop.first)
{
properties.m_programmeCatchupId = prop.second;
m_properties.m_programmeCatchupId = prop.second;
}
}

Expand All @@ -162,8 +162,8 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props

Log(LOGLEVEL_INFO, "Stream mimetype: %s", m_mimeType.c_str());

const std::string& manifestType = properties.m_manifestType;
if (properties.m_openMode == OpenMode::DEFAULT)
const std::string& manifestType = m_properties.m_manifestType;
if (m_properties.m_openMode == OpenMode::DEFAULT)
{
if (m_mimeType == "application/x-mpegURL" || // HLS
m_mimeType == "application/vnd.apple.mpegurl" || //HLS
Expand All @@ -186,9 +186,9 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
StringUtils::StartsWithNoCase(m_streamUrl, "rtmpe://") ||
StringUtils::StartsWithNoCase(m_streamUrl, "rtmpte://") ||
StringUtils::StartsWithNoCase(m_streamUrl, "rtmps://"))
properties.m_openMode = OpenMode::FFMPEG;
m_properties.m_openMode = OpenMode::FFMPEG;
else
properties.m_openMode = OpenMode::CURL;
m_properties.m_openMode = OpenMode::CURL;
}

HttpProxy httpProxy;
Expand All @@ -208,16 +208,16 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
httpProxy.SetProxyPassword(kodi::GetSettingString("httpProxyPassword"));
}

if (properties.m_streamMode == StreamMode::CATCHUP)
m_stream = std::make_shared<FFmpegCatchupStream>(static_cast<IManageDemuxPacket*>(this), properties, httpProxy);
else if (properties.m_streamMode == StreamMode::TIMESHIFT)
m_stream = std::make_shared<TimeshiftStream>(static_cast<IManageDemuxPacket*>(this), properties, httpProxy);
if (m_properties.m_streamMode == StreamMode::CATCHUP)
m_stream = std::make_shared<FFmpegCatchupStream>(static_cast<IManageDemuxPacket*>(this), m_properties, httpProxy);
else if (m_properties.m_streamMode == StreamMode::TIMESHIFT)
m_stream = std::make_shared<TimeshiftStream>(static_cast<IManageDemuxPacket*>(this), m_properties, httpProxy);
else
m_stream = std::make_shared<FFmpegStream>(static_cast<IManageDemuxPacket*>(this), properties, httpProxy);
m_stream = std::make_shared<FFmpegStream>(static_cast<IManageDemuxPacket*>(this), m_properties, httpProxy);

m_stream->SetVideoResolution(m_videoWidth, m_videoHeight);

m_opened = m_stream->Open(m_streamUrl, m_mimeType, properties.m_isRealTimeStream, properties.m_programProperty);
m_opened = m_stream->Open(m_streamUrl, m_mimeType, m_properties.m_isRealTimeStream, m_properties.m_programProperty);

return m_opened;
}
Expand Down
2 changes: 1 addition & 1 deletion src/StreamManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ATTRIBUTE_HIDDEN InputStreamFFmpegDirect
std::string m_streamUrl;
std::string m_mimeType;

ffmpegdirect::Properties properties;
ffmpegdirect::Properties m_properties;

int m_videoWidth;
int m_videoHeight;
Expand Down
11 changes: 8 additions & 3 deletions src/stream/FFmpegStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,14 @@ bool FFmpegStream::Open(bool fileinfo)

// select the correct program if requested
m_initialProgramNumber = UINT_MAX;
CVariant programProp(m_programProperty);
if (!programProp.isNull())
m_initialProgramNumber = static_cast<int>(programProp.asInteger());
CVariant programProp;
if (!m_programProperty.empty())
{
CVariant programProp(m_programProperty);

if (!programProp.isNull() && programProp.isInteger())
m_initialProgramNumber = static_cast<int>(programProp.asInteger());
}

// in case of mpegts and we have not seen pat/pmt, defer creation of streams
if (!skipCreateStreams || m_pFormatContext->nb_programs > 0)
Expand Down

0 comments on commit 063c1ad

Please sign in to comment.