remove dead throttle code
This commit is contained in:
parent
17ea0217f5
commit
016f2791d6
|
@ -877,14 +877,6 @@ namespace MediaBrowser.Api.Playback
|
||||||
return "copy";
|
return "copy";
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SupportsThrottleWithStream
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the input argument.
|
/// Gets the input argument.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -908,23 +900,15 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
private string GetInputPathArgument(string transcodingJobId, StreamState state)
|
private string GetInputPathArgument(string transcodingJobId, StreamState state)
|
||||||
{
|
{
|
||||||
if (state.InputProtocol == MediaProtocol.File &&
|
//if (state.InputProtocol == MediaProtocol.File &&
|
||||||
state.RunTimeTicks.HasValue &&
|
// state.RunTimeTicks.HasValue &&
|
||||||
state.VideoType == VideoType.VideoFile &&
|
// state.VideoType == VideoType.VideoFile &&
|
||||||
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
// !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
//{
|
||||||
if (state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks && state.IsInputVideo)
|
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var protocol = state.InputProtocol;
|
var protocol = state.InputProtocol;
|
||||||
|
|
||||||
|
|
|
@ -153,49 +153,12 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
|
||||||
using (state)
|
using (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
|
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||||
{
|
{
|
||||||
ResponseHeaders = responseHeaders,
|
ResponseHeaders = responseHeaders,
|
||||||
ContentType = contentType,
|
ContentType = contentType,
|
||||||
IsHeadRequest = isHeadRequest,
|
IsHeadRequest = isHeadRequest,
|
||||||
Path = state.MediaPath,
|
Path = state.MediaPath
|
||||||
Throttle = request.Throttle,
|
|
||||||
|
|
||||||
ThrottleLimit = bytesPerSecond,
|
|
||||||
|
|
||||||
MinThrottlePosition = targetGap,
|
|
||||||
|
|
||||||
ThrottleCallback = (l1, l2) => ThrottleCallack(l1, l2, bytesPerSecond, job)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +201,36 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
|
||||||
private long ThrottleCallack(long currentBytesPerSecond, long bytesWritten, long originalBytesPerSecond, TranscodingJob job)
|
private 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 bytesDownloaded = job.BytesDownloaded ?? 0;
|
||||||
var transcodingPositionTicks = job.TranscodingPositionTicks ?? 0;
|
var transcodingPositionTicks = job.TranscodingPositionTicks ?? 0;
|
||||||
var downloadPositionTicks = job.DownloadPositionTicks ?? 0;
|
var downloadPositionTicks = job.DownloadPositionTicks ?? 0;
|
||||||
|
|
|
@ -72,7 +72,6 @@ namespace MediaBrowser.Api.Playback
|
||||||
public string Params { get; set; }
|
public string Params { get; set; }
|
||||||
public string ClientTime { get; set; }
|
public string ClientTime { get; set; }
|
||||||
|
|
||||||
public bool Throttle { get; set; }
|
|
||||||
public string TranscodingJobId { get; set; }
|
public string TranscodingJobId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,6 @@ namespace MediaBrowser.Controller.Net
|
||||||
|
|
||||||
public IDictionary<string, string> ResponseHeaders { get; set; }
|
public 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 Action OnComplete { get; set; }
|
||||||
|
|
||||||
public StaticResultOptions()
|
public StaticResultOptions()
|
||||||
|
|
|
@ -452,24 +452,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
private string GetInputPathArgument(EncodingJob job)
|
private 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 protocol = job.InputProtocol;
|
||||||
|
|
||||||
var inputPath = new[] { job.MediaPath };
|
var inputPath = new[] { job.MediaPath };
|
||||||
|
|
|
@ -461,10 +461,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
return new RangeRequestWriter(rangeHeader, stream, contentType, isHeadRequest)
|
return new RangeRequestWriter(rangeHeader, stream, contentType, isHeadRequest)
|
||||||
{
|
{
|
||||||
Throttle = options.Throttle,
|
|
||||||
ThrottleLimit = options.ThrottleLimit,
|
|
||||||
MinThrottlePosition = options.MinThrottlePosition,
|
|
||||||
ThrottleCallback = options.ThrottleCallback,
|
|
||||||
OnComplete = options.OnComplete
|
OnComplete = options.OnComplete
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -480,10 +476,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
return new StreamWriter(stream, contentType, _logger)
|
return new StreamWriter(stream, contentType, _logger)
|
||||||
{
|
{
|
||||||
Throttle = options.Throttle,
|
|
||||||
ThrottleLimit = options.ThrottleLimit,
|
|
||||||
MinThrottlePosition = options.MinThrottlePosition,
|
|
||||||
ThrottleCallback = options.ThrottleCallback,
|
|
||||||
OnComplete = options.OnComplete
|
OnComplete = options.OnComplete
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
private long RangeLength { get; set; }
|
private long RangeLength { get; set; }
|
||||||
private long TotalContentLength { 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; }
|
public Action OnComplete { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -165,14 +161,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
/// <param name="responseStream">The response stream.</param>
|
/// <param name="responseStream">The response stream.</param>
|
||||||
public void WriteTo(Stream responseStream)
|
public void WriteTo(Stream responseStream)
|
||||||
{
|
{
|
||||||
if (Throttle)
|
|
||||||
{
|
|
||||||
responseStream = new ThrottledStream(responseStream, ThrottleLimit)
|
|
||||||
{
|
|
||||||
MinThrottlePosition = MinThrottlePosition,
|
|
||||||
ThrottleCallback = ThrottleCallback
|
|
||||||
};
|
|
||||||
}
|
|
||||||
WriteToInternal(responseStream);
|
WriteToInternal(responseStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
get { return _options; }
|
get { 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; }
|
public Action OnComplete { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -82,14 +78,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
/// <param name="responseStream">The response stream.</param>
|
/// <param name="responseStream">The response stream.</param>
|
||||||
public void WriteTo(Stream responseStream)
|
public void WriteTo(Stream responseStream)
|
||||||
{
|
{
|
||||||
if (Throttle)
|
|
||||||
{
|
|
||||||
responseStream = new ThrottledStream(responseStream, ThrottleLimit)
|
|
||||||
{
|
|
||||||
MinThrottlePosition = MinThrottlePosition,
|
|
||||||
ThrottleCallback = ThrottleCallback
|
|
||||||
};
|
|
||||||
}
|
|
||||||
WriteToInternal(responseStream);
|
WriteToInternal(responseStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user