From 0a2d24aff3d2e78c97b4b2294a418e2cd4a16be1 Mon Sep 17 00:00:00 2001
From: Andreas B <6439218+YouKnowBlom@users.noreply.github.com>
Date: Sun, 15 Mar 2020 18:13:19 +0100
Subject: [PATCH] Add RESOLUTION field to HLS master playlist
---
.../Playback/Hls/DynamicHlsService.cs | 26 ++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index d56b5cbff4..ce25676ff5 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -856,6 +856,24 @@ namespace MediaBrowser.Api.Playback.Hls
}
}
+ ///
+ /// Appends a RESOLUTION field containing the resolution of the output stream.
+ ///
+ ///
+ /// StringBuilder to append the field to.
+ /// StreamState of the current stream.
+ private void AppendPlaylistResolutionField(StringBuilder builder, StreamState state)
+ {
+ if (state.OutputWidth.HasValue && state.OutputHeight.HasValue)
+ {
+ builder.Append(",RESOLUTION=\"")
+ .Append(state.OutputWidth.GetValueOrDefault())
+ .Append('x')
+ .Append(state.OutputHeight.GetValueOrDefault())
+ .Append('"');
+ }
+ }
+
private void AppendPlaylist(StringBuilder builder, StreamState state, string url, int bitrate, string subtitleGroup)
{
builder.Append("#EXT-X-STREAM-INF:BANDWIDTH=")
@@ -863,14 +881,10 @@ namespace MediaBrowser.Api.Playback.Hls
.Append(",AVERAGE-BANDWIDTH=")
.Append(bitrate.ToString(CultureInfo.InvariantCulture));
- // tvos wants resolution, codecs, framerate
- //if (state.TargetFramerate.HasValue)
- //{
- // header += string.Format(",FRAME-RATE=\"{0}\"", state.TargetFramerate.Value.ToString(CultureInfo.InvariantCulture));
- //}
-
AppendPlaylistCodecsField(builder, state);
+ AppendPlaylistResolutionField(builder, state);
+
AppendPlaylistFramerateField(builder, state);
if (!string.IsNullOrWhiteSpace(subtitleGroup))