added new setting to allow video upscaling

This commit is contained in:
Luke Pulverenti 2014-02-02 10:19:29 -05:00
parent 5cc11294b1
commit d69894d09b
2 changed files with 48 additions and 0 deletions

View File

@ -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;

View File

@ -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; }