mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
Add MediaStreamProtocol enum (#10153)
* Add MediaStreamProtocol enum * Add default handling for enum during deserialization --------- Co-authored-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
@@ -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 = "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 = "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 (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||
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 (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||
if (playlistItem.SubProtocol == MediaStreamProtocol.Hls)
|
||||
{
|
||||
if (string.Equals(playlistItem.Container, "mp4", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -1358,9 +1358,9 @@ namespace MediaBrowser.Model.Dlna
|
||||
PlayMethod playMethod,
|
||||
ITranscoderSupport transcoderSupport,
|
||||
string? outputContainer,
|
||||
string? transcodingSubProtocol)
|
||||
MediaStreamProtocol? transcodingSubProtocol)
|
||||
{
|
||||
if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || !string.Equals(transcodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase)))
|
||||
if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || transcodingSubProtocol != MediaStreamProtocol.Hls))
|
||||
{
|
||||
// Look for supported embedded subs of the same format
|
||||
foreach (var profile in subtitleProfiles)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
public string? Container { get; set; }
|
||||
|
||||
public string? SubProtocol { get; set; }
|
||||
public MediaStreamProtocol SubProtocol { get; set; }
|
||||
|
||||
public long StartPositionTicks { get; set; }
|
||||
|
||||
@@ -670,7 +670,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (MediaType == DlnaProfileType.Audio)
|
||||
{
|
||||
if (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||
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 (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||
if (SubProtocol == MediaStreamProtocol.Hls)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
|
||||
}
|
||||
@@ -716,9 +716,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
long startPositionTicks = item.StartPositionTicks;
|
||||
|
||||
var isHls = string.Equals(item.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (isHls)
|
||||
if (item.SubProtocol == MediaStreamProtocol.Hls)
|
||||
{
|
||||
list.Add(new NameValuePair("StartTimeTicks", string.Empty));
|
||||
}
|
||||
@@ -780,7 +778,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
list.Add(new NameValuePair("SubtitleCodec", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Embed ? subtitleCodecs : string.Empty));
|
||||
|
||||
if (isHls)
|
||||
if (item.SubProtocol == MediaStreamProtocol.Hls)
|
||||
{
|
||||
list.Add(new NameValuePair("SegmentContainer", item.Container ?? string.Empty));
|
||||
|
||||
@@ -831,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 = string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase)
|
||||
long startPositionTicks = SubProtocol == MediaStreamProtocol.Hls
|
||||
? 0
|
||||
: (PlayMethod == PlayMethod.Transcode && !CopyTimestamps ? StartPositionTicks : 0);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Xml.Serialization;
|
||||
using Jellyfin.Data.Enums;
|
||||
|
||||
namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
public string AudioCodec { get; set; } = string.Empty;
|
||||
|
||||
[XmlAttribute("protocol")]
|
||||
public string Protocol { get; set; } = string.Empty;
|
||||
public MediaStreamProtocol Protocol { get; set; } = MediaStreamProtocol.Http;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[XmlAttribute("estimateContentLength")]
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Session;
|
||||
@@ -102,7 +104,7 @@ namespace MediaBrowser.Model.Dto
|
||||
|
||||
public string TranscodingUrl { get; set; }
|
||||
|
||||
public string TranscodingSubProtocol { get; set; }
|
||||
public MediaStreamProtocol TranscodingSubProtocol { get; set; }
|
||||
|
||||
public string TranscodingContainer { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user