aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback/BaseStreamingService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-02 10:19:29 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-02 10:19:29 -0500
commitd69894d09bdcb6ce8fef05c932284fa6c82b23e4 (patch)
treef3bcd9bfd807694fcc89db51f70c5857a3b01e9f /MediaBrowser.Api/Playback/BaseStreamingService.cs
parent5cc11294b117068dd6a65b228dd65473be2e0935 (diff)
added new setting to allow video upscaling
Diffstat (limited to 'MediaBrowser.Api/Playback/BaseStreamingService.cs')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index c6ea91d69..81729cbc8 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1222,6 +1222,8 @@ namespace MediaBrowser.Api.Playback
state.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.Playback
return 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;