From ca0c0bdcb921cd662b2871f0f788bbec77f822d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 Mar 2015 12:16:33 -0400 Subject: use stream id's to close streams --- MediaBrowser.Api/ApiEntryPoint.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Api/ApiEntryPoint.cs') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index ef415ec57..281f764b5 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -132,6 +132,7 @@ namespace MediaBrowser.Api /// Called when [transcode beginning]. /// /// The path. + /// The stream identifier. /// The transcoding job identifier. /// The type. /// The process. @@ -140,6 +141,7 @@ namespace MediaBrowser.Api /// The cancellation token source. /// TranscodingJob. public TranscodingJob OnTranscodeBeginning(string path, + string streamId, string transcodingJobId, TranscodingJobType type, Process process, @@ -157,7 +159,8 @@ namespace MediaBrowser.Api ActiveRequestCount = 1, DeviceId = deviceId, CancellationTokenSource = cancellationTokenSource, - Id = transcodingJobId + Id = transcodingJobId, + StreamId = streamId }; _activeTranscodingJobs.Add(job); @@ -316,17 +319,26 @@ namespace MediaBrowser.Api /// Kills the single transcoding job. /// /// The device id. + /// The stream identifier. /// The delete files. /// Task. - /// deviceId - internal void KillTranscodingJobs(string deviceId, Func deleteFiles) + internal void KillTranscodingJobs(string deviceId, string streamId, Func deleteFiles) { if (string.IsNullOrEmpty(deviceId)) { throw new ArgumentNullException("deviceId"); } - KillTranscodingJobs(j => string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase), deleteFiles); + KillTranscodingJobs(j => + { + if (string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase)) + { + return string.IsNullOrWhiteSpace(streamId) || string.Equals(streamId, j.StreamId, StringComparison.OrdinalIgnoreCase); + } + + return false; + + }, deleteFiles); } /// @@ -335,7 +347,7 @@ namespace MediaBrowser.Api /// The kill job. /// The delete files. /// Task. - internal void KillTranscodingJobs(Func killJob, Func deleteFiles) + private void KillTranscodingJobs(Func killJob, Func deleteFiles) { var jobs = new List(); @@ -516,6 +528,11 @@ namespace MediaBrowser.Api /// public class TranscodingJob { + /// + /// Gets or sets the stream identifier. + /// + /// The stream identifier. + public string StreamId { get; set; } /// /// Gets or sets the path. /// -- cgit v1.2.3