From 60d1d5cdee642ee9d5be7e91be5caeb9a1a756df Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 2 Sep 2014 22:30:24 -0400 Subject: [PATCH] restore nuget targets for mono build --- MediaBrowser.Api/ApiEntryPoint.cs | 94 +++++++++++------- MediaBrowser.Api/MediaBrowser.Api.csproj | 2 +- .../Playback/BaseStreamingService.cs | 63 ++++++++---- .../Playback/Hls/BaseHlsService.cs | 28 +++--- .../Playback/Hls/DynamicHlsService.cs | 63 ++++++++---- .../Playback/Hls/HlsSegmentService.cs | 38 ++++---- .../Playback/Hls/VideoHlsService.cs | 22 ++--- .../Playback/Progressive/AudioService.cs | 12 +-- .../BaseProgressiveStreamingService.cs | 95 ++++++++++++++++--- .../Progressive/ProgressiveStreamWriter.cs | 29 +++++- .../Playback/Progressive/VideoService.cs | 11 +-- MediaBrowser.Api/Playback/StreamRequest.cs | 1 + .../Entities/UserViewBuilder.cs | 6 +- .../MediaBrowser.Controller.csproj | 2 +- .../Net/StaticResultOptions.cs | 3 + MediaBrowser.Dlna/Ssdp/Datagram.cs | 14 +-- MediaBrowser.Dlna/Ssdp/SsdpHandler.cs | 10 +- .../MediaBrowser.MediaEncoding.csproj | 2 +- MediaBrowser.Model/MediaBrowser.Model.csproj | 2 +- .../MediaBrowser.Providers.csproj | 2 +- .../Dto/DtoService.cs | 4 +- .../HttpServer/HttpResultFactory.cs | 43 ++------- .../HttpServer/RangeRequestWriter.cs | 37 +++++--- .../HttpServer/StreamWriter.cs | 12 ++- .../HttpServer/ThrottledStream.cs | 46 ++++++--- ...MediaBrowser.Server.Implementations.csproj | 2 +- .../MediaBrowser.WebDashboard.csproj | 2 +- 27 files changed, 395 insertions(+), 250 deletions(-) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index c51d9e7c01..b49fbce486 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -120,12 +120,15 @@ namespace MediaBrowser.Api /// Called when [transcode beginning]. /// /// The path. + /// The transcoding job identifier. /// The type. /// The process. /// The device id. /// The state. /// The cancellation token source. - public void OnTranscodeBeginning(string path, + /// TranscodingJob. + public TranscodingJob OnTranscodeBeginning(string path, + string transcodingJobId, TranscodingJobType type, Process process, string deviceId, @@ -134,22 +137,37 @@ namespace MediaBrowser.Api { lock (_activeTranscodingJobs) { - _activeTranscodingJobs.Add(new TranscodingJob + var job = new TranscodingJob { Type = type, Path = path, Process = process, ActiveRequestCount = 1, DeviceId = deviceId, - CancellationTokenSource = cancellationTokenSource - }); + CancellationTokenSource = cancellationTokenSource, + Id = transcodingJobId + }; + + _activeTranscodingJobs.Add(job); + + ReportTranscodingProgress(job, state, null, null, null, null); - ReportTranscodingProgress(state, null, null); + return job; } } - public void ReportTranscodingProgress(StreamState state, float? framerate, double? percentComplete) + public void ReportTranscodingProgress(TranscodingJob job, StreamState state, TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded) { + var ticks = transcodingPosition.HasValue ? transcodingPosition.Value.Ticks : (long?)null; + + if (job != null) + { + job.Framerate = framerate; + job.CompletionPercentage = percentComplete; + job.TranscodingPositionTicks = ticks; + job.BytesTranscoded = bytesTranscoded; + } + var deviceId = state.Request.DeviceId; if (!string.IsNullOrWhiteSpace(deviceId)) @@ -226,12 +244,20 @@ namespace MediaBrowser.Api } } + public TranscodingJob GetTranscodingJob(string id) + { + lock (_activeTranscodingJobs) + { + return _activeTranscodingJobs.FirstOrDefault(j => j.Id.Equals(id, StringComparison.OrdinalIgnoreCase)); + } + } + /// /// Called when [transcode begin request]. /// /// The path. /// The type. - public void OnTranscodeBeginRequest(string path, TranscodingJobType type) + public TranscodingJob OnTranscodeBeginRequest(string path, TranscodingJobType type) { lock (_activeTranscodingJobs) { @@ -239,7 +265,7 @@ namespace MediaBrowser.Api if (job == null) { - return; + return null; } job.ActiveRequestCount++; @@ -249,40 +275,27 @@ namespace MediaBrowser.Api job.KillTimer.Dispose(); job.KillTimer = null; } + + return job; } } - /// - /// Called when [transcode end request]. - /// - /// The path. - /// The type. - public void OnTranscodeEndRequest(string path, TranscodingJobType type) + public void OnTranscodeEndRequest(TranscodingJob job) { - lock (_activeTranscodingJobs) + job.ActiveRequestCount--; + + if (job.ActiveRequestCount == 0) { - var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase)); + // The HLS kill timer is long - 1/2 hr. clients should use the manual kill command when stopping. + var timerDuration = job.Type == TranscodingJobType.Progressive ? 1000 : 1800000; - if (job == null) + if (job.KillTimer == null) { - return; + job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite); } - - job.ActiveRequestCount--; - - if (job.ActiveRequestCount == 0) + else { - // The HLS kill timer is long - 1/2 hr. clients should use the manual kill command when stopping. - var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 1800000; - - if (job.KillTimer == null) - { - job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite); - } - else - { - job.KillTimer.Change(timerDuration, Timeout.Infinite); - } + job.KillTimer.Change(timerDuration, Timeout.Infinite); } } } @@ -306,7 +319,6 @@ namespace MediaBrowser.Api /// if set to true [acquire lock]. /// Task. /// deviceId - /// sourcePath internal Task KillTranscodingJobs(string deviceId, Func deleteFiles, bool acquireLock) { if (string.IsNullOrEmpty(deviceId)) @@ -324,8 +336,7 @@ namespace MediaBrowser.Api /// The delete files. /// if set to true [acquire lock]. /// Task. - /// deviceId - internal async Task KillTranscodingJobs(Func killJob, Func deleteFiles, bool acquireLock) + internal async Task KillTranscodingJobs(Func killJob, Func deleteFiles, bool acquireLock) { var jobs = new List(); @@ -542,6 +553,17 @@ namespace MediaBrowser.Api public object ProcessLock = new object(); public bool HasExited { get; set; } + + public string Id { get; set; } + + public float? Framerate { get; set; } + public double? CompletionPercentage { get; set; } + + public long? BytesDownloaded { get; set; } + public long? BytesTranscoded { get; set; } + + public long? TranscodingPositionTicks { get; set; } + public long? DownloadPositionTicks { get; set; } } /// diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index b0131b5c26..5cb9ebb1b0 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -169,7 +169,7 @@ - +