mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Lowercase MediaStreamProtocol for backwards compatibility
This commit is contained in:
parent
a597f1e410
commit
e731250342
@ -157,7 +157,7 @@ public class UniversalAudioController : BaseJellyfinApiController
|
||||
}
|
||||
|
||||
var isStatic = mediaSource.SupportsDirectStream;
|
||||
if (!isStatic && mediaSource.TranscodingSubProtocol == MediaStreamProtocol.Hls)
|
||||
if (!isStatic && mediaSource.TranscodingSubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
// hls segment container can only be mpegts or fmp4 per ffmpeg documentation
|
||||
// ffmpeg option -> file extension
|
||||
@ -268,7 +268,7 @@ public class UniversalAudioController : BaseJellyfinApiController
|
||||
Context = EncodingContext.Streaming,
|
||||
Container = transcodingContainer ?? "mp3",
|
||||
AudioCodec = audioCodec ?? "mp3",
|
||||
Protocol = transcodingProtocol ?? MediaStreamProtocol.Http,
|
||||
Protocol = transcodingProtocol ?? MediaStreamProtocol.http,
|
||||
BreakOnNonKeyFrames = breakOnNonKeyFrames ?? false,
|
||||
MaxAudioChannels = transcodingAudioChannels?.ToString(CultureInfo.InvariantCulture)
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
#pragma warning disable SA1300 // Lowercase required for backwards compat.
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Jellyfin.Data.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Media streaming protocol.
|
||||
/// Lowercase for backwards compatibility.
|
||||
/// </summary>
|
||||
[DefaultValue(Http)]
|
||||
[DefaultValue(http)]
|
||||
public enum MediaStreamProtocol
|
||||
{
|
||||
/// <summary>
|
||||
/// HTTP.
|
||||
/// </summary>
|
||||
Http = 0,
|
||||
http = 0,
|
||||
|
||||
/// <summary>
|
||||
/// HTTP Live Streaming.
|
||||
/// </summary>
|
||||
Hls = 1
|
||||
hls = 1
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
private static void SetStreamInfoOptionsFromDirectPlayProfile(MediaOptions options, MediaSourceInfo item, StreamInfo playlistItem, DirectPlayProfile? directPlayProfile)
|
||||
{
|
||||
var container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Video, directPlayProfile);
|
||||
var protocol = MediaStreamProtocol.Http;
|
||||
var protocol = MediaStreamProtocol.http;
|
||||
|
||||
item.TranscodingContainer = container;
|
||||
item.TranscodingSubProtocol = protocol;
|
||||
@ -648,7 +648,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (directPlay == PlayMethod.DirectPlay)
|
||||
{
|
||||
playlistItem.SubProtocol = MediaStreamProtocol.Http;
|
||||
playlistItem.SubProtocol = MediaStreamProtocol.http;
|
||||
|
||||
var audioStreamIndex = directPlayInfo.AudioStreamIndex ?? audioStream?.Index;
|
||||
if (audioStreamIndex.HasValue)
|
||||
@ -803,7 +803,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
var videoCodecs = ContainerProfile.SplitValue(videoCodec);
|
||||
|
||||
// Enforce HLS video codec restrictions
|
||||
if (playlistItem.SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (playlistItem.SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
videoCodecs = videoCodecs.Where(codec => _supportedHlsVideoCodecs.Contains(codec)).ToArray();
|
||||
}
|
||||
@ -840,7 +840,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
var audioCodecs = ContainerProfile.SplitValue(audioCodec);
|
||||
|
||||
// Enforce HLS audio codec restrictions
|
||||
if (playlistItem.SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (playlistItem.SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
if (string.Equals(playlistItem.Container, "mp4", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@ -1360,7 +1360,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
string? outputContainer,
|
||||
MediaStreamProtocol? transcodingSubProtocol)
|
||||
{
|
||||
if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || transcodingSubProtocol != MediaStreamProtocol.Hls))
|
||||
if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || transcodingSubProtocol != MediaStreamProtocol.hls))
|
||||
{
|
||||
// Look for supported embedded subs of the same format
|
||||
foreach (var profile in subtitleProfiles)
|
||||
|
@ -670,7 +670,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (MediaType == DlnaProfileType.Audio)
|
||||
{
|
||||
if (SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
|
||||
}
|
||||
@ -678,7 +678,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
|
||||
}
|
||||
|
||||
if (SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
|
||||
}
|
||||
@ -716,7 +716,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
long startPositionTicks = item.StartPositionTicks;
|
||||
|
||||
if (item.SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (item.SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
list.Add(new NameValuePair("StartTimeTicks", string.Empty));
|
||||
}
|
||||
@ -778,7 +778,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
list.Add(new NameValuePair("SubtitleCodec", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Embed ? subtitleCodecs : string.Empty));
|
||||
|
||||
if (item.SubProtocol == MediaStreamProtocol.Hls)
|
||||
if (item.SubProtocol == MediaStreamProtocol.hls)
|
||||
{
|
||||
list.Add(new NameValuePair("SegmentContainer", item.Container ?? string.Empty));
|
||||
|
||||
@ -829,7 +829,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
var list = new List<SubtitleStreamInfo>();
|
||||
|
||||
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
||||
long startPositionTicks = SubProtocol == MediaStreamProtocol.Hls
|
||||
long startPositionTicks = SubProtocol == MediaStreamProtocol.hls
|
||||
? 0
|
||||
: (PlayMethod == PlayMethod.Transcode && !CopyTimestamps ? StartPositionTicks : 0);
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
public string AudioCodec { get; set; } = string.Empty;
|
||||
|
||||
[XmlAttribute("protocol")]
|
||||
public MediaStreamProtocol Protocol { get; set; } = MediaStreamProtocol.Http;
|
||||
public MediaStreamProtocol Protocol { get; set; } = MediaStreamProtocol.http;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[XmlAttribute("estimateContentLength")]
|
||||
|
@ -15,9 +15,9 @@ public class JsonDefaultStringEnumConverterTests
|
||||
/// <param name="input">The input string.</param>
|
||||
/// <param name="output">The expected enum value.</param>
|
||||
[Theory]
|
||||
[InlineData("\"\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.Hls)]
|
||||
[InlineData("\"\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.hls)]
|
||||
public void Deserialize_Enum_Direct(string input, MediaStreamProtocol output)
|
||||
{
|
||||
var value = JsonSerializer.Deserialize<MediaStreamProtocol>(input, _jsonOptions);
|
||||
@ -30,10 +30,10 @@ public class JsonDefaultStringEnumConverterTests
|
||||
/// <param name="input">The input string.</param>
|
||||
/// <param name="output">The expected enum value.</param>
|
||||
[Theory]
|
||||
[InlineData(null, MediaStreamProtocol.Http)]
|
||||
[InlineData("\"\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.Hls)]
|
||||
[InlineData(null, MediaStreamProtocol.http)]
|
||||
[InlineData("\"\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.hls)]
|
||||
public void Deserialize_Enum(string? input, MediaStreamProtocol output)
|
||||
{
|
||||
input ??= "null";
|
||||
@ -51,9 +51,9 @@ public class JsonDefaultStringEnumConverterTests
|
||||
/// <param name="output">The expected enum value.</param>
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("\"\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.Http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.Hls)]
|
||||
[InlineData("\"\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Http\"", MediaStreamProtocol.http)]
|
||||
[InlineData("\"Hls\"", MediaStreamProtocol.hls)]
|
||||
public void Deserialize_Enum_Nullable(string? input, MediaStreamProtocol? output)
|
||||
{
|
||||
input ??= "null";
|
||||
@ -69,8 +69,8 @@ public class JsonDefaultStringEnumConverterTests
|
||||
/// <param name="input">Input enum.</param>
|
||||
/// <param name="output">Output enum.</param>
|
||||
[Theory]
|
||||
[InlineData(MediaStreamProtocol.Http, MediaStreamProtocol.Http)]
|
||||
[InlineData(MediaStreamProtocol.Hls, MediaStreamProtocol.Hls)]
|
||||
[InlineData(MediaStreamProtocol.http, MediaStreamProtocol.http)]
|
||||
[InlineData(MediaStreamProtocol.hls, MediaStreamProtocol.hls)]
|
||||
public void Enum_RoundTrip(MediaStreamProtocol input, MediaStreamProtocol output)
|
||||
{
|
||||
var inputObj = new TestClass { EnumValue = input };
|
||||
@ -87,8 +87,8 @@ public class JsonDefaultStringEnumConverterTests
|
||||
/// <param name="input">Input enum.</param>
|
||||
/// <param name="output">Output enum.</param>
|
||||
[Theory]
|
||||
[InlineData(MediaStreamProtocol.Http, MediaStreamProtocol.Http)]
|
||||
[InlineData(MediaStreamProtocol.Hls, MediaStreamProtocol.Hls)]
|
||||
[InlineData(MediaStreamProtocol.http, MediaStreamProtocol.http)]
|
||||
[InlineData(MediaStreamProtocol.hls, MediaStreamProtocol.hls)]
|
||||
[InlineData(null, null)]
|
||||
public void Enum_RoundTrip_Nullable(MediaStreamProtocol? input, MediaStreamProtocol? output)
|
||||
{
|
||||
|
@ -389,21 +389,21 @@ namespace Jellyfin.Model.Tests
|
||||
// Assert.Equal("webm", val.Container);
|
||||
Assert.Equal(streamInfo.Container, uri.Extension);
|
||||
Assert.Equal("stream", uri.Filename);
|
||||
Assert.Equal(MediaStreamProtocol.Http, streamInfo.SubProtocol);
|
||||
Assert.Equal(MediaStreamProtocol.http, streamInfo.SubProtocol);
|
||||
}
|
||||
else if (transcodeProtocol.Equals("HLS.mp4", StringComparison.Ordinal))
|
||||
{
|
||||
Assert.Equal("mp4", streamInfo.Container);
|
||||
Assert.Equal("m3u8", uri.Extension);
|
||||
Assert.Equal("master", uri.Filename);
|
||||
Assert.Equal(MediaStreamProtocol.Hls, streamInfo.SubProtocol);
|
||||
Assert.Equal(MediaStreamProtocol.hls, streamInfo.SubProtocol);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal("ts", streamInfo.Container);
|
||||
Assert.Equal("m3u8", uri.Extension);
|
||||
Assert.Equal("master", uri.Filename);
|
||||
Assert.Equal(MediaStreamProtocol.Hls, streamInfo.SubProtocol);
|
||||
Assert.Equal(MediaStreamProtocol.hls, streamInfo.SubProtocol);
|
||||
}
|
||||
|
||||
// Full transcode
|
||||
@ -489,7 +489,7 @@ namespace Jellyfin.Model.Tests
|
||||
}
|
||||
else if (playMethod is null)
|
||||
{
|
||||
Assert.Equal(MediaStreamProtocol.Http, streamInfo.SubProtocol);
|
||||
Assert.Equal(MediaStreamProtocol.http, streamInfo.SubProtocol);
|
||||
Assert.Equal("stream", uri.Filename);
|
||||
|
||||
Assert.False(streamInfo.EstimateContentLength);
|
||||
|
Loading…
Reference in New Issue
Block a user