diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-08-07 17:17:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-07 17:17:05 -0400 |
| commit | 2026a682ed363338ec6a27f099b0788f33be46f8 (patch) | |
| tree | 4113625119679c2264edf13d266150a7041cfc8e /MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs | |
| parent | daf2d41c9d1ac4c6f6baf10b2ed850aa4f5b9b30 (diff) | |
| parent | a86336ebc6913489f7e30b8fdf02947397b01bcb (diff) | |
Merge pull request #2037 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs')
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 449100fc4..4649499c4 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -142,7 +142,8 @@ namespace MediaBrowser.Api.Playback.Progressive var outputPath = state.OutputFilePath; var outputPathExists = FileSystem.FileExists(outputPath); - var isTranscodeCached = outputPathExists && !ApiEntryPoint.Instance.HasActiveTranscodingJob(outputPath, TranscodingJobType.Progressive); + var transcodingJob = ApiEntryPoint.Instance.GetTranscodingJob(outputPath, TranscodingJobType.Progressive); + var isTranscodeCached = outputPathExists && transcodingJob != null; AddDlnaHeaders(state, responseHeaders, request.Static || isTranscodeCached); @@ -159,6 +160,7 @@ namespace MediaBrowser.Api.Playback.Progressive ContentType = contentType, IsHeadRequest = isHeadRequest, Path = state.MediaPath + }).ConfigureAwait(false); } } @@ -170,13 +172,25 @@ namespace MediaBrowser.Api.Playback.Progressive try { + if (transcodingJob != null) + { + ApiEntryPoint.Instance.OnTranscodeBeginRequest(transcodingJob); + } + return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions { ResponseHeaders = responseHeaders, ContentType = contentType, IsHeadRequest = isHeadRequest, Path = outputPath, - FileShare = FileShare.ReadWrite + FileShare = FileShare.ReadWrite, + OnComplete = () => + { + if (transcodingJob != null) + { + ApiEntryPoint.Instance.OnTranscodeEndRequest(transcodingJob); + } + } }).ConfigureAwait(false); } @@ -348,7 +362,7 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders[item.Key] = item.Value; } - Func<Stream,Task> streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None); + Func<Stream, Task> streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None); return ResultFactory.GetAsyncStreamWriter(streamWriter, outputHeaders); } |
