Merge pull request #8411 from Maxr1998/audio-stream-fix

Allow direct play even if no audio stream is available
This commit is contained in:
Claus Vium 2022-10-09 09:08:01 +02:00 committed by GitHub
commit bf129ab9b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 18 deletions

View File

@ -436,9 +436,9 @@ namespace MediaBrowser.Model.Dlna
{ {
containerSupported = true; 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) if (videoSupported && audioSupported)
{ {
@ -447,18 +447,17 @@ namespace MediaBrowser.Model.Dlna
} }
} }
var list = new List<TranscodeReason>();
if (!containerSupported) if (!containerSupported)
{ {
reasons |= TranscodeReason.ContainerNotSupported; reasons |= TranscodeReason.ContainerNotSupported;
} }
if (videoStream != null && !videoSupported) if (!videoSupported)
{ {
reasons |= TranscodeReason.VideoCodecNotSupported; reasons |= TranscodeReason.VideoCodecNotSupported;
} }
if (audioStream != null && !audioSupported) if (!audioSupported)
{ {
reasons |= TranscodeReason.AudioCodecNotSupported; reasons |= TranscodeReason.AudioCodecNotSupported;
} }
@ -590,21 +589,19 @@ namespace MediaBrowser.Model.Dlna
} }
// Collect candidate audio streams // 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 (!options.AudioStreamIndex.HasValue || options.AudioStreamIndex < 0)
{ {
if (audioStream?.IsDefault == true) 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 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 videoStream = item.VideoStream;
var directPlayBitrateEligibility = IsBitrateEligibleForDirectPlayback(item, options.GetMaxBitrate(false) ?? 0, options, PlayMethod.DirectPlay); var directPlayBitrateEligibility = IsBitrateEligibleForDirectPlayback(item, options.GetMaxBitrate(false) ?? 0, options, PlayMethod.DirectPlay);
@ -1060,7 +1057,7 @@ namespace MediaBrowser.Model.Dlna
MediaSourceInfo mediaSource, MediaSourceInfo mediaSource,
MediaStream videoStream, MediaStream videoStream,
MediaStream audioStream, MediaStream audioStream,
IEnumerable<MediaStream> candidateAudioStreams, ICollection<MediaStream> candidateAudioStreams,
MediaStream subtitleStream, MediaStream subtitleStream,
bool isEligibleForDirectPlay, bool isEligibleForDirectPlay,
bool isEligibleForDirectStream) bool isEligibleForDirectStream)
@ -1182,14 +1179,18 @@ namespace MediaBrowser.Model.Dlna
} }
// Check audio codec // Check audio codec
var selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec)); MediaStream selectedAudioStream = null;
if (selectedAudioStream == null) if (candidateAudioStreams.Any())
{ {
directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported; selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec));
} if (selectedAudioStream == null)
else {
{ directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported;
audioCodecProfileReasons = audioStreamMatches.GetValueOrDefault(selectedAudioStream); }
else
{
audioCodecProfileReasons = audioStreamMatches.GetValueOrDefault(selectedAudioStream);
}
} }
var failureReasons = directPlayProfileReasons | containerProfileReasons | subtitleProfileReasons; var failureReasons = directPlayProfileReasons | containerProfileReasons | subtitleProfileReasons;