From 456dea09dfe3007d218280a0a7b655879b9bab2a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 11 Jun 2013 22:59:38 -0400 Subject: [PATCH] don't cache encoded media on resume --- MediaBrowser.Api/ApiEntryPoint.cs | 16 ++++++++++++---- .../Playback/BaseStreamingService.cs | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index a2ed1d7722..431b6d6151 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -82,7 +82,9 @@ namespace MediaBrowser.Api /// The path. /// The type. /// The process. - public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process) + /// if set to true [is video]. + /// The start time ticks. + public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, bool isVideo, long? startTimeTicks) { lock (_activeTranscodingJobs) { @@ -91,7 +93,9 @@ namespace MediaBrowser.Api Type = type, Path = path, Process = process, - ActiveRequestCount = 1 + ActiveRequestCount = 1, + IsVideo = isVideo, + StartTimeTicks = startTimeTicks }); } } @@ -262,7 +266,7 @@ namespace MediaBrowser.Api } catch (InvalidOperationException) { - + } catch (NotSupportedException) { @@ -273,7 +277,8 @@ namespace MediaBrowser.Api process.Dispose(); // If it didn't complete successfully cleanup the partial files - if (!hasExitedSuccessfully) + // Also don't cache output from resume points + if (!hasExitedSuccessfully || job.StartTimeTicks.HasValue) { Logger.Info("Deleting partial stream file(s) {0}", job.Path); @@ -364,6 +369,9 @@ namespace MediaBrowser.Api /// /// The kill timer. public Timer KillTimer { get; set; } + + public bool IsVideo { get; set; } + public long? StartTimeTicks { get; set; } } /// diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 4886af9163..1c1b569d7a 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -598,7 +598,7 @@ namespace MediaBrowser.Api.Playback EnableRaisingEvents = true }; - ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process); + ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process, video != null, state.Request.StartTimeTicks); Logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments);