The Free Software Media System - Server Backend & API
added new setting to allow video upscaling
Luke Pulverentid69894d09bdc
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex c6ea91d691..81729cbc81 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1222,6 +1222,8 @@ namespace MediaBrowser.Api.Playbackstate.VideoStream = GetMediaStream(mediaStreams, videoRequest.VideoStreamIndex, MediaStreamType.Video);state.SubtitleStream = GetMediaStream(mediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);++ EnforceResolutionLimit(state, videoRequest);}else{@@ -1233,6 +1235,50 @@ namespace MediaBrowser.Api.Playbackreturn state;}+ /// <summary>+ /// Enforces the resolution limit.+ /// </summary>+ /// <param name="state">The state.</param>+ /// <param name="videoRequest">The video request.</param>+ private void EnforceResolutionLimit(StreamState state, VideoStreamRequest videoRequest)+ {+ int? videoWidth = null;+ int? videoHeight = null;++ // Grab the values from the source video, if we have them+ if (state.VideoStream != null)+ {+ videoWidth = state.VideoStream.Width;+ videoHeight = state.VideoStream.Height;+ }++ if (videoRequest.Width.HasValue && videoWidth.HasValue)+ {+ if (videoRequest.Width.Value > videoWidth.Value)+ {+ throw new ArgumentException("Video upscaling has not been enabled by the user");+ }+ }++ if (videoRequest.Height.HasValue && videoHeight.HasValue)+ {+ if (videoRequest.Height.Value > videoHeight.Value)+ {+ throw new ArgumentException("Video upscaling has not been enabled by the user");+ }+ }++ // We don't know the source resolution. Don't allow an exact resolution unless upscaling is allowed+ if (!ServerConfigurationManager.Configuration.AllowVideoUpscaling)+ {+ videoRequest.MaxWidth = videoRequest.MaxWidth ?? videoRequest.Width;+ videoRequest.MaxHeight = videoRequest.MaxHeight ?? videoRequest.Height;++ videoRequest.Width = null;+ videoRequest.Height = null;+ }+ }+protected string GetInputModifier(StreamState state){var inputModifier = string.Empty;diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex f874bdbb25..a7cc205baa 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -187,6 +187,8 @@ namespace MediaBrowser.Model.Configuration/// <value>The encoding quality.</value>public EncodingQuality MediaEncodingQuality { get; set; }+ public bool AllowVideoUpscaling { get; set; }+public bool EnableMovieChapterImageExtraction { get; set; }public bool EnableEpisodeChapterImageExtraction { get; set; }public bool EnableOtherVideoChapterImageExtraction { get; set; }