From d2b31461087d73ddd44690291dcbc8abbb0d789f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 Feb 2015 21:09:00 -0500 Subject: 3.0.5518.7 --- MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 6e8ba1c1d..4727e6035 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -410,7 +410,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer return "/mediabrowser/mediabrowser" + path; } - return "mediabrowser//mediabrowser" + path; + return "mediabrowser/mediabrowser/" + path; } /// -- cgit v1.2.3 From 016f2791d63706de09cc77228c6282c06574d611 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 26 Feb 2015 13:24:38 -0500 Subject: remove dead throttle code --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 34 +++-------- .../Progressive/BaseProgressiveStreamingService.cs | 69 ++++++++++------------ MediaBrowser.Api/Playback/StreamRequest.cs | 1 - MediaBrowser.Controller/Net/StaticResultOptions.cs | 5 -- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 18 ------ .../HttpServer/HttpResultFactory.cs | 8 --- .../HttpServer/RangeRequestWriter.cs | 12 ---- .../HttpServer/StreamWriter.cs | 12 ---- 8 files changed, 40 insertions(+), 119 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 49d5f1c8d..bab0d1a6e 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -877,14 +877,6 @@ namespace MediaBrowser.Api.Playback return "copy"; } - private bool SupportsThrottleWithStream - { - get - { - return false; - } - } - /// /// Gets the input argument. /// @@ -908,23 +900,15 @@ namespace MediaBrowser.Api.Playback private 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.cs index 9dbe3389e..09f1ab567 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -153,49 +153,12 @@ namespace MediaBrowser.Api.Playback.Progressive using (state) { - var job = string.IsNullOrEmpty(request.TranscodingJobId) ? - null : - ApiEntryPoint.Instance.GetTranscodingJob(request.TranscodingJobId); - - var limits = new List(); - 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.Progressive 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(); + //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.cs index dc22fc754..907b17b24 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -72,7 +72,6 @@ namespace MediaBrowser.Api.Playback public 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.cs index 5bb2c9a5c..6a104554a 100644 --- a/MediaBrowser.Controller/Net/StaticResultOptions.cs +++ b/MediaBrowser.Controller/Net/StaticResultOptions.cs @@ -18,11 +18,6 @@ namespace MediaBrowser.Controller.Net public IDictionary ResponseHeaders { get; set; } - public bool Throttle { get; set; } - public long ThrottleLimit { get; set; } - public long MinThrottlePosition { get; set; } - public Func ThrottleCallback { get; set; } - public Action OnComplete { get; set; } public StaticResultOptions() diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index ffae8612e..ead080c60 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -452,24 +452,6 @@ namespace MediaBrowser.MediaEncoding.Encoder 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 inputPath = new[] { job.MediaPath }; diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 681d3ac5e..ecf58e4a6 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.HttpServer return 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.cs index cdd4c6d7c..8c72f9e7e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -24,10 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer private long RangeLength { get; set; } private long TotalContentLength { get; set; } - public bool Throttle { get; set; } - public long ThrottleLimit { get; set; } - public long MinThrottlePosition; - public Func ThrottleCallback { get; set; } public Action OnComplete { get; set; } /// @@ -165,14 +161,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The response stream. 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.cs index 1db14e887..fe662542e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs @@ -35,10 +35,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer get { return _options; } } - public bool Throttle { get; set; } - public long ThrottleLimit { get; set; } - public long MinThrottlePosition; - public Func ThrottleCallback { get; set; } public Action OnComplete { get; set; } /// @@ -82,14 +78,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The response stream. public void WriteTo(Stream responseStream) { - if (Throttle) - { - responseStream = new ThrottledStream(responseStream, ThrottleLimit) - { - MinThrottlePosition = MinThrottlePosition, - ThrottleCallback = ThrottleCallback - }; - } WriteToInternal(responseStream); } -- cgit v1.2.3 From 98992ca580a3e921d57653161c7a27f2442e4dd3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 8 Mar 2015 14:49:51 -0400 Subject: simplify message parsing --- .../HttpServer/SocketSharp/SharpWebSocket.cs | 3 ++- .../ServerManager/WebSocketConnection.cs | 24 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 9dcb679f4..583b8809d 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -65,9 +65,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e) { - if (OnReceive != null) + if (OnReceiveBytes != null) { OnReceiveBytes(e.RawData); + //OnReceive(e.Data); } } diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs index 9f75d522c..08e4c2ec2 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Events; +using System.Text; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; @@ -122,22 +123,21 @@ namespace MediaBrowser.Server.Implementations.ServerManager } try { - WebSocketMessageInfo info; - + //_logger.Debug(Encoding.UTF8.GetString(bytes)); using (var memoryStream = new MemoryStream(bytes)) { - var stub = (WebSocketMessage)_jsonSerializer.DeserializeFromStream(memoryStream, typeof(WebSocketMessage)); + var info = (WebSocketMessageInfo)_jsonSerializer.DeserializeFromStream(memoryStream, typeof(WebSocketMessageInfo)); - info = new WebSocketMessageInfo - { - MessageType = stub.MessageType, - Data = stub.Data == null ? null : stub.Data.ToString() - }; - } + //info = new WebSocketMessageInfo + //{ + // MessageType = stub.MessageType, + // Data = stub.Data == null ? null : stub.Data.ToString() + //}; + info.Connection = this; - info.Connection = this; + OnReceive(info); + } - OnReceive(info); } catch (Exception ex) { -- cgit v1.2.3 From 55c47e50fc261849c277cb65654d91a8c5a8e308 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 8 Mar 2015 15:06:15 -0400 Subject: exclude httplistener from project --- .../HttpServer/SocketSharp/SharpWebSocket.cs | 9 ++++++++- .../MediaBrowser.Server.Implementations.csproj | 5 +++-- .../ServerManager/ServerManager.cs | 3 +-- .../Session/SessionWebSocketListener.cs | 3 +-- 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 583b8809d..9faf2bc47 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -65,10 +65,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e) { + //if (!string.IsNullOrWhiteSpace(e.Data)) + //{ + // if (OnReceive != null) + // { + // OnReceive(e.Data); + // } + // return; + //} if (OnReceiveBytes != null) { OnReceiveBytes(e.RawData); - //OnReceive(e.Data); } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 41f970041..81b47daff 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -152,7 +152,6 @@ - @@ -511,7 +510,9 @@ - + + +