Never treat matroska as webm for audio playback

This would break browsers like Firefox where the matroska file cannot be played as audio file.
This commit is contained in:
gnattu 2025-01-10 15:24:10 +08:00
parent 5c6317f68d
commit cc9c000412

View File

@ -2249,7 +2249,7 @@ namespace MediaBrowser.Model.Dlna
} }
} }
private static bool IsAudioDirectPlaySupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream audioStream) private static bool IsAudioContainerSupported(DirectPlayProfile profile, MediaSourceInfo item)
{ {
// Check container type // Check container type
if (!profile.SupportsContainer(item.Container)) if (!profile.SupportsContainer(item.Container))
@ -2257,6 +2257,20 @@ namespace MediaBrowser.Model.Dlna
return false; return false;
} }
// Never direct play audio in matroska when the device only declare support for webm.
// The first check is not enough because mkv is assumed can be webm.
// See https://github.com/jellyfin/jellyfin/issues/13344
return !ContainerHelper.ContainsContainer("mkv", item.Container)
|| profile.SupportsContainer("mkv");
}
private static bool IsAudioDirectPlaySupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream audioStream)
{
if (!IsAudioContainerSupported(profile, item))
{
return false;
}
// Check audio codec // Check audio codec
string? audioCodec = audioStream?.Codec; string? audioCodec = audioStream?.Codec;
if (!profile.SupportsAudioCodec(audioCodec)) if (!profile.SupportsAudioCodec(audioCodec))
@ -2271,19 +2285,16 @@ namespace MediaBrowser.Model.Dlna
{ {
// Check container type, this should NOT be supported // Check container type, this should NOT be supported
// If the container is supported, the file should be directly played // If the container is supported, the file should be directly played
if (!profile.SupportsContainer(item.Container)) if (IsAudioContainerSupported(profile, item))
{ {
// Check audio codec, we cannot use the SupportsAudioCodec here return false;
// Because that one assumes empty container supports all codec, which is just useless
string? audioCodec = audioStream?.Codec;
if (string.Equals(profile.AudioCodec, audioCodec, StringComparison.OrdinalIgnoreCase) ||
string.Equals(profile.Container, audioCodec, StringComparison.OrdinalIgnoreCase))
{
return true;
}
} }
return false; // Check audio codec, we cannot use the SupportsAudioCodec here
// Because that one assumes empty container supports all codec, which is just useless
string? audioCodec = audioStream?.Codec;
return string.Equals(profile.AudioCodec, audioCodec, StringComparison.OrdinalIgnoreCase)
|| string.Equals(profile.Container, audioCodec, StringComparison.OrdinalIgnoreCase);
} }
private int GetRank(ref TranscodeReason a, TranscodeReason[] rankings) private int GetRank(ref TranscodeReason a, TranscodeReason[] rankings)