The Free Software Media System - Server Backend & API
remove dead throttle code
Luke Pulverenti016f2791d637
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 49d5f1c8d8..bab0d1a6e4 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -877,14 +877,6 @@ namespace MediaBrowser.Api.Playbackreturn "copy";}- private bool SupportsThrottleWithStream- {- get- {- return false;- }- }-/// <summary>/// Gets the input argument./// </summary>@@ -908,23 +900,15 @@ namespace MediaBrowser.Api.Playbackprivate string GetInputPathArgument(string transcodingJobId, 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)- {- if (SupportsThrottleWithStream)- {- var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId;-- url += "&transcodingJobId=" + transcodingJobId;-- return string.Format("\"{0}\"", url);- }- }- }+ //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 protocol = state.InputProtocol;diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.csindex 9dbe3389e6..09f1ab567f 100644--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs@@ -153,49 +153,12 @@ namespace MediaBrowser.Api.Playback.Progressiveusing (state){- var job = string.IsNullOrEmpty(request.TranscodingJobId) ?- null :- ApiEntryPoint.Instance.GetTranscodingJob(request.TranscodingJobId);-- var limits = new List<long>();- if (state.InputBitrate.HasValue)- {- // Bytes per second- limits.Add((state.InputBitrate.Value / 8));- }- if (state.InputFileSize.HasValue && state.RunTimeTicks.HasValue)- {- var totalSeconds = TimeSpan.FromTicks(state.RunTimeTicks.Value).TotalSeconds;-- if (totalSeconds > 1)- {- var timeBasedLimit = state.InputFileSize.Value / totalSeconds;- limits.Add(Convert.ToInt64(timeBasedLimit));- }- }-- // Take the greater of the above to methods, just to be safe- var throttleLimit = limits.Count > 0 ? limits.First() : 0;-- // Pad to play it safe- var bytesPerSecond = Convert.ToInt64(1.05 * throttleLimit);-- // Don't even start evaluating this until at least two minutes have content have been consumed- var targetGap = throttleLimit * 120;-return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions{ResponseHeaders = responseHeaders,ContentType = contentType,IsHeadRequest = isHeadRequest,- Path = state.MediaPath,- Throttle = request.Throttle,-- ThrottleLimit = bytesPerSecond,-- MinThrottlePosition = targetGap,-- ThrottleCallback = (l1, l2) => ThrottleCallack(l1, l2, bytesPerSecond, job)+ Path = state.MediaPath});}}@@ -238,6 +201,36 @@ namespace MediaBrowser.Api.Playback.Progressiveprivate long ThrottleCallack(long currentBytesPerSecond, long bytesWritten, long originalBytesPerSecond, TranscodingJob job){+ //var job = string.IsNullOrEmpty(request.TranscodingJobId) ?+ //null :+ //ApiEntryPoint.Instance.GetTranscodingJob(request.TranscodingJobId);++ //var limits = new List<long>();+ //if (state.InputBitrate.HasValue)+ //{+ // // Bytes per second+ // limits.Add((state.InputBitrate.Value / 8));+ //}+ //if (state.InputFileSize.HasValue && state.RunTimeTicks.HasValue)+ //{+ // var totalSeconds = TimeSpan.FromTicks(state.RunTimeTicks.Value).TotalSeconds;++ // if (totalSeconds > 1)+ // {+ // var timeBasedLimit = state.InputFileSize.Value / totalSeconds;+ // limits.Add(Convert.ToInt64(timeBasedLimit));+ // }+ //}++ //// Take the greater of the above to methods, just to be safe+ //var throttleLimit = limits.Count > 0 ? limits.First() : 0;++ //// Pad to play it safe+ //var bytesPerSecond = Convert.ToInt64(1.05 * throttleLimit);++ //// Don't even start evaluating this until at least two minutes have content have been consumed+ //var targetGap = throttleLimit * 120;+var bytesDownloaded = job.BytesDownloaded ?? 0;var transcodingPositionTicks = job.TranscodingPositionTicks ?? 0;var downloadPositionTicks = job.DownloadPositionTicks ?? 0;diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.csindex dc22fc7548..907b17b244 100644--- a/MediaBrowser.Api/Playback/StreamRequest.cs+++ b/MediaBrowser.Api/Playback/StreamRequest.cs@@ -72,7 +72,6 @@ namespace MediaBrowser.Api.Playbackpublic string Params { get; set; }public string ClientTime { get; set; }- public bool Throttle { get; set; }public string TranscodingJobId { get; set; }}diff --git a/MediaBrowser.Controller/Net/StaticResultOptions.cs b/MediaBrowser.Controller/Net/StaticResultOptions.csindex 5bb2c9a5c3..6a104554af 100644--- a/MediaBrowser.Controller/Net/StaticResultOptions.cs+++ b/MediaBrowser.Controller/Net/StaticResultOptions.cs@@ -18,11 +18,6 @@ namespace MediaBrowser.Controller.Netpublic IDictionary<string, string> ResponseHeaders { get; set; }- public bool Throttle { get; set; }- public long ThrottleLimit { get; set; }- public long MinThrottlePosition { get; set; }- public Func<long, long, long> ThrottleCallback { get; set; }-public Action OnComplete { get; set; }public StaticResultOptions()diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.csindex ffae8612ed..ead080c605 100644--- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs@@ -452,24 +452,6 @@ namespace MediaBrowser.MediaEncoding.Encoderprivate string GetInputPathArgument(EncodingJob job){- //if (job.InputProtocol == MediaProtocol.File &&- // job.RunTimeTicks.HasValue &&- // job.VideoType == VideoType.VideoFile &&- // !string.Equals(job.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))- //{- // if (job.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks && job.IsInputVideo)- // {- // if (SupportsThrottleWithStream)- // {- // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId;-- // url += "&transcodingJobId=" + transcodingJobId;-- // return string.Format("\"{0}\"", url);- // }- // }- //}-var protocol = job.InputProtocol;var inputPath = new[] { job.MediaPath };diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.csindex 681d3ac5e5..ecf58e4a67 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs@@ -461,10 +461,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer{return new RangeRequestWriter(rangeHeader, stream, contentType, isHeadRequest){- Throttle = options.Throttle,- ThrottleLimit = options.ThrottleLimit,- MinThrottlePosition = options.MinThrottlePosition,- ThrottleCallback = options.ThrottleCallback,OnComplete = options.OnComplete};}@@ -480,10 +476,6 @@ namespace MediaBrowser.Server.Implementations.HttpServerreturn new StreamWriter(stream, contentType, _logger){- Throttle = options.Throttle,- ThrottleLimit = options.ThrottleLimit,- MinThrottlePosition = options.MinThrottlePosition,- ThrottleCallback = options.ThrottleCallback,OnComplete = options.OnComplete};}diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.csindex cdd4c6d7ca..8c72f9e7e6 100644--- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs@@ -24,10 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServerprivate long RangeLength { get; set; }private long TotalContentLength { get; set; }- public bool Throttle { get; set; }- public long ThrottleLimit { get; set; }- public long MinThrottlePosition;- public Func<long, long, long> ThrottleCallback { get; set; }public Action OnComplete { get; set; }/// <summary>@@ -165,14 +161,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <param name="responseStream">The response stream.</param>public void WriteTo(Stream responseStream){- if (Throttle)- {- responseStream = new ThrottledStream(responseStream, ThrottleLimit)- {- MinThrottlePosition = MinThrottlePosition,- ThrottleCallback = ThrottleCallback- };- }WriteToInternal(responseStream);}diff --git a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.csindex 1db14e8878..fe662542ef 100644--- a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs@@ -35,10 +35,6 @@ namespace MediaBrowser.Server.Implementations.HttpServerget { return _options; }}- public bool Throttle { get; set; }- public long ThrottleLimit { get; set; }- public long MinThrottlePosition;- public Func<long, long, long> ThrottleCallback { get; set; }public Action OnComplete { get; set; }/// <summary>@@ -82,14 +78,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <param name="responseStream">The response stream.</param>public void WriteTo(Stream responseStream){- if (Throttle)- {- responseStream = new ThrottledStream(responseStream, ThrottleLimit)- {- MinThrottlePosition = MinThrottlePosition,- ThrottleCallback = ThrottleCallback- };- }WriteToInternal(responseStream);}