From 75475285da4f95f0b8e8075a0367229acbc28ac2 Mon Sep 17 00:00:00 2001 From: jakobkukla Date: Thu, 17 Mar 2022 17:13:46 +0100 Subject: [PATCH] Fix supportsTranscoding not reflecting user permissions sometimes --- CONTRIBUTORS.md | 1 + .../Library/MediaSourceManager.cs | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c7b33d1c3..87086a728 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -224,3 +224,4 @@ - [lbenini](https://github.com/lbenini) - [gnuyent](https://github.com/gnuyent) - [Matthew Jones](https://github.com/matthew-jones-uk) + - [Jakob Kukla](https://github.com/jakobkukla) diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index c9202c264..d9a1a5487 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -172,24 +172,16 @@ namespace Emby.Server.Implementations.Library foreach (var source in dynamicMediaSources) { - if (user != null) - { - SetDefaultAudioAndSubtitleStreamIndexes(item, source, user); - } - // Validate that this is actually possible if (source.SupportsDirectStream) { source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol); } - list.Add(source); - } - - if (user != null) - { - foreach (var source in list) + if (user != null) { + SetDefaultAudioAndSubtitleStreamIndexes(item, source, user); + if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding); @@ -200,6 +192,8 @@ namespace Emby.Server.Implementations.Library source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing); } } + + list.Add(source); } return SortMediaSources(list); @@ -338,6 +332,16 @@ namespace Emby.Server.Implementations.Library foreach (var source in sources) { SetDefaultAudioAndSubtitleStreamIndexes(item, source, user); + + if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) + { + source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding); + } + else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) + { + source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding); + source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing); + } } }