diff options
| author | Jan Müller <github@lonebyte.de> | 2023-08-01 17:22:42 +0200 |
|---|---|---|
| committer | Jan Müller <github@lonebyte.de> | 2023-08-01 19:06:30 +0200 |
| commit | 19fb061381dd107d5e0236cf9d8b59b2e2318130 (patch) | |
| tree | 98c5c94f9a08ae6b414638670d526636384e82e4 | |
| parent | e9f23c61c937b230b1d3bd7865a083aeb3d51657 (diff) | |
Correct the HLS Opus codec string
Apple doesn't support Opus via HLS yet, but if they ever do, they will
definitely expect "Opus" instead of "opus".
See https://mp4ra.org/#/codecs
Fixes: #10066
| -rw-r--r-- | Jellyfin.Api/Helpers/DynamicHlsHelper.cs | 28 | ||||
| -rw-r--r-- | Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs index dfcccddfc..888b667a6 100644 --- a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs +++ b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs @@ -198,11 +198,11 @@ public class DynamicHlsHelper var basicPlaylist = AppendPlaylist(builder, state, playlistUrl, totalBitrate, subtitleGroup); - // Provide a workaround for the case issue between flac and fLaC. - var flacWaPlaylist = ApplyFlacCaseWorkaround(state, basicPlaylist.ToString()); - if (!string.IsNullOrEmpty(flacWaPlaylist)) + // Provide a workaround for alternative codec string capitalization. + var alternativeCodecCapitalizationPlaylist = ApplyCodecCapitalizationWorkaround(state, basicPlaylist.ToString()); + if (!string.IsNullOrEmpty(alternativeCodecCapitalizationPlaylist)) { - builder.Append(flacWaPlaylist); + builder.Append(alternativeCodecCapitalizationPlaylist); } if (state.VideoStream is not null && state.VideoRequest is not null) @@ -238,11 +238,11 @@ public class DynamicHlsHelper var sdrTotalBitrate = sdrOutputAudioBitrate + sdrOutputVideoBitrate; var sdrPlaylist = AppendPlaylist(builder, state, sdrVideoUrl, sdrTotalBitrate, subtitleGroup); - // Provide a workaround for the case issue between flac and fLaC. - flacWaPlaylist = ApplyFlacCaseWorkaround(state, sdrPlaylist.ToString()); - if (!string.IsNullOrEmpty(flacWaPlaylist)) + // Provide a workaround for alternative codec string capitalization. + alternativeCodecCapitalizationPlaylist = ApplyCodecCapitalizationWorkaround(state, sdrPlaylist.ToString()); + if (!string.IsNullOrEmpty(alternativeCodecCapitalizationPlaylist)) { - builder.Append(flacWaPlaylist); + builder.Append(alternativeCodecCapitalizationPlaylist); } // Restore the video codec @@ -275,11 +275,11 @@ public class DynamicHlsHelper var newPlaylist = ReplacePlaylistCodecsField(basicPlaylist, playlistCodecsField, newPlaylistCodecsField); builder.Append(newPlaylist); - // Provide a workaround for the case issue between flac and fLaC. - flacWaPlaylist = ApplyFlacCaseWorkaround(state, newPlaylist); - if (!string.IsNullOrEmpty(flacWaPlaylist)) + // Provide a workaround for alternative codec string capitalization. + alternativeCodecCapitalizationPlaylist = ApplyCodecCapitalizationWorkaround(state, newPlaylist); + if (!string.IsNullOrEmpty(alternativeCodecCapitalizationPlaylist)) { - builder.Append(flacWaPlaylist); + builder.Append(alternativeCodecCapitalizationPlaylist); } } } @@ -768,7 +768,7 @@ public class DynamicHlsHelper StringComparison.Ordinal); } - private string ApplyFlacCaseWorkaround(StreamState state, string srcPlaylist) + private string ApplyCodecCapitalizationWorkaround(StreamState state, string srcPlaylist) { if (!string.Equals(state.ActualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase)) { @@ -779,6 +779,8 @@ public class DynamicHlsHelper newPlaylist = newPlaylist.Replace(",fLaC\"", ",flac\"", StringComparison.Ordinal); newPlaylist = newPlaylist.Replace("\"fLaC\"", "\"flac\"", StringComparison.Ordinal); + newPlaylist = newPlaylist.Replace(",Opus\"", ",opus\"", StringComparison.Ordinal); + newPlaylist = newPlaylist.Replace("\"Opus\"", "\"opus\"", StringComparison.Ordinal); return string.Equals(srcPlaylist, newPlaylist, StringComparison.Ordinal) ? string.Empty : newPlaylist; } diff --git a/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs b/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs index 9b1c52045..5eec1b0ca 100644 --- a/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs +++ b/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs @@ -39,7 +39,7 @@ public static class HlsCodecStringHelpers /// <summary> /// Codec name for OPUS. /// </summary> - public const string OPUS = "opus"; + public const string OPUS = "Opus"; /// <summary> /// Gets a MP3 codec string. |
