The Free Software Media System - Server Backend & API
Backport pull request #8411 from jellyfin/release-10.8.z
Maxr1998bf059d5b581c
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex b121a29058..da1e6c3d38 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -436,9 +436,9 @@ namespace MediaBrowser.Model.Dlna{containerSupported = true;- videoSupported = videoStream != null && profile.SupportsVideoCodec(videoStream.Codec);+ videoSupported = videoStream == null || profile.SupportsVideoCodec(videoStream.Codec);- audioSupported = audioStream != null && profile.SupportsAudioCodec(audioStream.Codec);+ audioSupported = audioStream == null || profile.SupportsAudioCodec(audioStream.Codec);if (videoSupported && audioSupported){@@ -447,18 +447,17 @@ namespace MediaBrowser.Model.Dlna}}- var list = new List<TranscodeReason>();if (!containerSupported){reasons |= TranscodeReason.ContainerNotSupported;}- if (videoStream != null && !videoSupported)+ if (!videoSupported){reasons |= TranscodeReason.VideoCodecNotSupported;}- if (audioStream != null && !audioSupported)+ if (!audioSupported){reasons |= TranscodeReason.AudioCodecNotSupported;}@@ -587,21 +586,19 @@ namespace MediaBrowser.Model.Dlna}// Collect candidate audio streams- IEnumerable<MediaStream> candidateAudioStreams = audioStream == null ? Array.Empty<MediaStream>() : new[] { audioStream };+ ICollection<MediaStream> candidateAudioStreams = audioStream == null ? Array.Empty<MediaStream>() : new[] { audioStream };if (!options.AudioStreamIndex.HasValue || options.AudioStreamIndex < 0){if (audioStream?.IsDefault == true){- candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault);+ candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault).ToArray();}else{- candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.Language == audioStream?.Language);+ candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.Language == audioStream?.Language).ToArray();}}- candidateAudioStreams = candidateAudioStreams.ToArray();-var videoStream = item.VideoStream;var directPlayBitrateEligibility = IsBitrateEligibleForDirectPlayback(item, options.GetMaxBitrate(false) ?? 0, options, PlayMethod.DirectPlay);@@ -1057,7 +1054,7 @@ namespace MediaBrowser.Model.DlnaMediaSourceInfo mediaSource,MediaStream videoStream,MediaStream audioStream,- IEnumerable<MediaStream> candidateAudioStreams,+ ICollection<MediaStream> candidateAudioStreams,MediaStream subtitleStream,bool isEligibleForDirectPlay,bool isEligibleForDirectStream)@@ -1179,14 +1176,18 @@ namespace MediaBrowser.Model.Dlna}// Check audio codec- var selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec));- if (selectedAudioStream == null)- {- directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported;- }- else+ MediaStream selectedAudioStream = null;+ if (candidateAudioStreams.Any()){- audioCodecProfileReasons = audioStreamMatches.GetValueOrDefault(selectedAudioStream);+ selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec));+ if (selectedAudioStream == null)+ {+ directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported;+ }+ else+ {+ audioCodecProfileReasons = audioStreamMatches.GetValueOrDefault(selectedAudioStream);+ }}var failureReasons = directPlayProfileReasons | containerProfileReasons | subtitleProfileReasons;