aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/ApiEntryPoint.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-03 10:14:40 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-03 10:14:40 -0400
commit16fd474ad3e7d74cd78779350d2ee0ea7017f627 (patch)
treedfd6012a22f5410e34410773ea164a2b578e9468 /MediaBrowser.Api/ApiEntryPoint.cs
parenteb72c2db513f5306eecccb94f0f1cd5296a7d7db (diff)
safer hls kill
Diffstat (limited to 'MediaBrowser.Api/ApiEntryPoint.cs')
-rw-r--r--MediaBrowser.Api/ApiEntryPoint.cs27
1 files changed, 15 insertions, 12 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs
index b648e7fd3..343672877 100644
--- a/MediaBrowser.Api/ApiEntryPoint.cs
+++ b/MediaBrowser.Api/ApiEntryPoint.cs
@@ -85,7 +85,8 @@ namespace MediaBrowser.Api
/// <param name="isVideo">if set to <c>true</c> [is video].</param>
/// <param name="startTimeTicks">The start time ticks.</param>
/// <param name="sourcePath">The source path.</param>
- public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, bool isVideo, long? startTimeTicks, string sourcePath)
+ /// <param name="deviceId">The device id.</param>
+ public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, bool isVideo, long? startTimeTicks, string sourcePath, string deviceId)
{
lock (_activeTranscodingJobs)
{
@@ -97,7 +98,8 @@ namespace MediaBrowser.Api
ActiveRequestCount = 1,
IsVideo = isVideo,
StartTimeTicks = startTimeTicks,
- SourcePath = sourcePath
+ SourcePath = sourcePath,
+ DeviceId = deviceId
});
}
}
@@ -180,7 +182,7 @@ namespace MediaBrowser.Api
if (job.ActiveRequestCount == 0)
{
- var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 180000;
+ var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 120000;
if (job.KillTimer == null)
{
@@ -208,12 +210,14 @@ namespace MediaBrowser.Api
/// <summary>
/// Kills the single transcoding job.
/// </summary>
- /// <param name="sourcePath">The source path.</param>
- internal void KillSingleTranscodingJob(string sourcePath)
+ /// <param name="deviceId">The device id.</param>
+ /// <param name="isVideo">if set to <c>true</c> [is video].</param>
+ /// <exception cref="System.ArgumentNullException">sourcePath</exception>
+ internal void KillTranscodingJobs(string deviceId, bool isVideo)
{
- if (string.IsNullOrEmpty(sourcePath))
+ if (string.IsNullOrEmpty(deviceId))
{
- throw new ArgumentNullException("sourcePath");
+ throw new ArgumentNullException("deviceId");
}
var jobs = new List<TranscodingJob>();
@@ -222,14 +226,12 @@ namespace MediaBrowser.Api
{
// This is really only needed for HLS.
// Progressive streams can stop on their own reliably
- jobs.AddRange(_activeTranscodingJobs.Where(i => string.Equals(sourcePath, i.SourcePath) && i.Type == TranscodingJobType.Hls));
+ jobs.AddRange(_activeTranscodingJobs.Where(i => isVideo == i.IsVideo && string.Equals(deviceId, i.DeviceId, StringComparison.OrdinalIgnoreCase)));
}
- // This method of killing is a bit of a shortcut, but it saves clients from having to send a request just for that
- // But we can only kill if there's one active job. If there are more we won't know which one to stop
- if (jobs.Count == 1)
+ foreach (var job in jobs)
{
- KillTranscodingJob(jobs.First());
+ KillTranscodingJob(job);
}
}
@@ -405,6 +407,7 @@ namespace MediaBrowser.Api
public bool IsVideo { get; set; }
public long? StartTimeTicks { get; set; }
public string SourcePath { get; set; }
+ public string DeviceId { get; set; }
}
/// <summary>