From 081d942d0361a4ad8aa918edcbb2f20c4c3f8471 Mon Sep 17 00:00:00 2001 From: Maximilian Marschall Date: Sun, 12 Jan 2020 00:31:17 +0100 Subject: [PATCH 1/5] Enable Throttling when transcoding without Hardware-Acceleration --- CONTRIBUTORS.md | 1 + MediaBrowser.Api/Playback/BaseStreamingService.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 458944778e..2d2e5712a5 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -32,6 +32,7 @@ - [nevado](https://github.com/nevado) - [mark-monteiro](https://github.com/mark-monteiro) - [ullmie02](https://github.com/ullmie02) + - [geilername](https://github.com/geilername) # Emby Contributors diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 5881e22a7c..023d373d5b 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -327,6 +327,18 @@ namespace MediaBrowser.Api.Playback private bool EnableThrottling(StreamState state) { + var encodingOptions = ServerConfigurationManager.GetEncodingOptions(); + + // enable throttling when not using hardware acceleration + if (encodingOptions.HardwareAccelerationType == string.Empty) + { + return state.InputProtocol == MediaProtocol.File && + state.RunTimeTicks.HasValue && + state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks && + state.IsInputVideo && + state.VideoType == VideoType.VideoFile && + !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase); + } return false; //// do not use throttling with hardware encoders //return state.InputProtocol == MediaProtocol.File && From 71abf1d3ce915289cf952a6d581a50d83fa9b259 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 31 Jan 2020 22:46:10 +0100 Subject: [PATCH 2/5] Enable TreatWarningsAsErrors and Nullable for test projects --- MediaBrowser.Controller/Net/IAuthService.cs | 4 +++- .../Auth/CustomAuthenticationHandlerTests.cs | 2 +- .../Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj | 2 ++ .../Jellyfin.Common.Tests.csproj | 2 ++ .../EncoderValidatorTests.cs | 16 ++++++++-------- .../Jellyfin.MediaEncoding.Tests.csproj | 2 ++ .../Jellyfin.Naming.Tests.csproj | 2 ++ .../Jellyfin.Server.Implementations.Tests.csproj | 2 ++ 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs index 4c9120e0c9..9132404a08 100644 --- a/MediaBrowser.Controller/Net/IAuthService.cs +++ b/MediaBrowser.Controller/Net/IAuthService.cs @@ -1,3 +1,5 @@ +#nullable enable + using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; @@ -7,6 +9,6 @@ namespace MediaBrowser.Controller.Net public interface IAuthService { void Authenticate(IRequest request, IAuthenticationAttributes authAttribtues); - User Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues); + User? Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues); } } diff --git a/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs b/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs index a2f5c25016..3b3d03c8b7 100644 --- a/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs +++ b/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs @@ -83,7 +83,7 @@ namespace Jellyfin.Api.Tests.Auth a => a.Authenticate( It.IsAny(), It.IsAny())) - .Returns((User)null); + .Returns((User?)null); var authenticateResult = await _sut.AuthenticateAsync(); diff --git a/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj index 0e8ef135ef..1d7e4f7af3 100644 --- a/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj +++ b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj @@ -3,6 +3,8 @@ netcoreapp3.1 false + true + enable diff --git a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj index da5e6576d3..86bb11bd4c 100644 --- a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj +++ b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj @@ -3,6 +3,8 @@ netcoreapp3.1 false + true + enable diff --git a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs index a7848316e7..e0f1f236c7 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs +++ b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs @@ -9,15 +9,15 @@ namespace Jellyfin.MediaEncoding.Tests { public class EncoderValidatorTests { - private class GetFFmpegVersionTestData : IEnumerable + private class GetFFmpegVersionTestData : IEnumerable { - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() { - yield return new object[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) }; - yield return new object[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) }; - yield return new object[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) }; - yield return new object[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) }; - yield return new object[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null }; + yield return new object?[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) }; + yield return new object?[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) }; + yield return new object?[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) }; + yield return new object?[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) }; + yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null }; } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); @@ -25,7 +25,7 @@ namespace Jellyfin.MediaEncoding.Tests [Theory] [ClassData(typeof(GetFFmpegVersionTestData))] - public void GetFFmpegVersionTest(string versionOutput, Version version) + public void GetFFmpegVersionTest(string versionOutput, Version? version) { Assert.Equal(version, EncoderValidator.GetFFmpegVersion(versionOutput)); } diff --git a/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj b/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj index c01edd9fed..b5e4a1287b 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj +++ b/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj @@ -3,6 +3,8 @@ netcoreapp3.1 false + true + enable diff --git a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj index f246d459ba..ebc1a54590 100644 --- a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj +++ b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj @@ -3,6 +3,8 @@ netcoreapp3.1 false + + enable diff --git a/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj b/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj index c554bc9372..29733a1c47 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj +++ b/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj @@ -3,6 +3,8 @@ netcoreapp3.1 false + true + enable Jellyfin.Server.Implementations.Tests From 22510909fbbe23aa250df95424dae40f08974643 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 6 Feb 2020 13:00:15 +0100 Subject: [PATCH 3/5] Update Jellyfin.Naming.Tests.csproj --- tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj index ebc1a54590..9602d9e58a 100644 --- a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj +++ b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj @@ -3,7 +3,6 @@ netcoreapp3.1 false - enable From a26c1ab17dd0bb4c7cefa9130c19128a08a57aee Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 12 Feb 2020 14:19:11 +0300 Subject: [PATCH 4/5] Remove commented code --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 43e8374467..7837aa65b0 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -329,7 +329,7 @@ namespace MediaBrowser.Api.Playback { var encodingOptions = ServerConfigurationManager.GetEncodingOptions(); - // enable throttling when not using hardware acceleration + // enable throttling when NOT using hardware acceleration if (encodingOptions.HardwareAccelerationType == string.Empty) { return state.InputProtocol == MediaProtocol.File && @@ -340,14 +340,6 @@ namespace MediaBrowser.Api.Playback !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase); } return false; - //// do not use throttling with hardware encoders - //return state.InputProtocol == MediaProtocol.File && - // state.RunTimeTicks.HasValue && - // state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks && - // state.IsInputVideo && - // state.VideoType == VideoType.VideoFile && - // !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && - // string.Equals(GetVideoEncoder(state), "libx264", StringComparison.OrdinalIgnoreCase); } /// From f5db4c8402ffbbcd7a9837b9cecc01a74e778043 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 12 Feb 2020 20:57:34 +0100 Subject: [PATCH 5/5] Another baseurl related fix Baseurl always starts with a '/' (unless it's empty) --- Emby.Server.Implementations/ApplicationHost.cs | 2 +- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index e2df8877ab..0837db251f 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1522,7 +1522,7 @@ namespace Emby.Server.Implementations string baseUrl = ServerConfigurationManager.Configuration.BaseUrl; if (baseUrl.Length != 0) { - url.Append('/').Append(baseUrl); + url.Append(baseUrl); } return url.ToString(); diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index f42aa2b447..5280d455c4 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -165,6 +165,7 @@ namespace MediaBrowser.Model.Configuration public bool SkipDeserializationForBasicTypes { get; set; } public string ServerName { get; set; } + public string BaseUrl { get => _baseUrl;