diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamRequest.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamState.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/System/SystemService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemsService.cs | 2 |
7 files changed, 43 insertions, 8 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index b965bf6f1..a0a8ee61e 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -353,11 +353,9 @@ namespace MediaBrowser.Api.Playback { case EncodingQuality.HighSpeed: crf = "12"; - profileScore = 2; break; case EncodingQuality.HighQuality: crf = "8"; - profileScore = 1; break; case EncodingQuality.MaxQuality: crf = "4"; @@ -369,10 +367,11 @@ namespace MediaBrowser.Api.Playback if (isVc1) { profileScore++; - // Max of 2 - profileScore = Math.Min(profileScore, 2); } + // Max of 2 + profileScore = Math.Min(profileScore, 2); + // http://www.webmproject.org/docs/encoder-parameters/ param = string.Format("-speed 16 -quality good -profile:v {0} -slices 8 -crf {1}", profileScore.ToString(UsCulture), @@ -771,13 +770,31 @@ namespace MediaBrowser.Api.Playback return "copy"; } + protected virtual bool SupportsThrottling + { + get { return false; } + } + /// <summary> /// Gets the input argument. /// </summary> /// <param name="state">The state.</param> /// <returns>System.String.</returns> - protected virtual string GetInputArgument(StreamState state) + protected string GetInputArgument(StreamState state) { + if (state.InputProtocol == MediaProtocol.File && + state.RunTimeTicks.HasValue && + state.VideoType == VideoType.VideoFile && + !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase)) + { + if (state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks && state.IsInputVideo) + { + var url = "http://localhost:8096/mediabrowser/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; + + return string.Format("\"{0}\"", url); + } + } + var protocol = state.InputProtocol; var inputPath = new[] { state.MediaPath }; @@ -1494,6 +1511,7 @@ namespace MediaBrowser.Api.Playback state.MediaPath = mediaSource.Path; state.RunTimeTicks = item.RunTimeTicks; state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders; + state.InputBitrate = mediaSource.Bitrate; mediaStreams = mediaSource.MediaStreams; } else @@ -1508,6 +1526,7 @@ namespace MediaBrowser.Api.Playback state.MediaPath = mediaSource.Path; state.InputProtocol = mediaSource.Protocol; state.InputContainer = mediaSource.Container; + state.InputBitrate = mediaSource.Bitrate; if (item is Video) { diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index d4aa0836f..0d90e3739 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -79,6 +79,14 @@ namespace MediaBrowser.Api.Playback.Hls return ResultFactory.GetStaticFileResult(Request, file); } + protected override bool SupportsThrottling + { + get + { + return false; + } + } + /// <summary> /// Called when [begin request]. /// </summary> diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 028ada37b..d8255bd29 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -151,7 +151,9 @@ namespace MediaBrowser.Api.Playback.Progressive using (state) { - return ResultFactory.GetStaticFileResult(Request, state.MediaPath, contentType, null, FileShare.Read, responseHeaders, isHeadRequest); + var throttleLimit = state.InputBitrate.HasValue ? (state.InputBitrate.Value / 8) : 0; + + return ResultFactory.GetStaticFileResult(Request, state.MediaPath, contentType, null, FileShare.Read, responseHeaders, isHeadRequest, request.Throttle, throttleLimit); } } diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index c72ead949..0de8c28a9 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -70,6 +70,8 @@ namespace MediaBrowser.Api.Playback public string DeviceProfileId { get; set; } public string Params { get; set; } + + public bool Throttle { get; set; } } public class VideoStreamRequest : StreamRequest diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 1d3ff939a..139a78c80 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -68,6 +68,8 @@ namespace MediaBrowser.Api.Playback public long? RunTimeTicks; + public long? InputBitrate { get; set; } + public string OutputAudioSync = "1"; public string OutputVideoSync = "vfr"; diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index cb9d01956..cae648ae0 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -38,8 +38,10 @@ namespace MediaBrowser.Api.System { } + /// <summary> + /// This is currently not authenticated because the uninstaller needs to be able to shutdown the server. + /// </summary> [Route("/System/Shutdown", "POST", Summary = "Shuts down the application")] - [Authenticated] public class ShutdownApplication { } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index ba07571bf..25821c213 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -1430,7 +1430,7 @@ namespace MediaBrowser.Api.UserLibrary nextId = list[index + 1].Id; } - return list.Where(i => i.Id == previousId || i.Id == nextId); + return list.Where(i => i.Id == previousId || i.Id == nextId || i.Id == adjacentToIdGuid); } /// <summary> |
