2013-12-14 23:21:03 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Controller.Plugins;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
2013-06-12 21:47:02 +00:00
|
|
|
|
using System.IO;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class ServerEntryPoint
|
|
|
|
|
/// </summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
public class ApiEntryPoint : IServerEntryPoint
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The instance
|
|
|
|
|
/// </summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
public static ApiEntryPoint Instance;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the logger.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The logger.</value>
|
|
|
|
|
private ILogger Logger { get; set; }
|
|
|
|
|
|
2013-12-22 18:58:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The application paths
|
|
|
|
|
/// </summary>
|
2014-02-15 16:36:09 +00:00
|
|
|
|
private readonly IServerApplicationPaths _appPaths;
|
2013-12-22 18:58:51 +00:00
|
|
|
|
|
2013-03-03 02:47:04 +00:00
|
|
|
|
/// <summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
/// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
|
2013-03-03 02:47:04 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2013-12-22 18:58:51 +00:00
|
|
|
|
/// <param name="appPaths">The application paths.</param>
|
2013-12-14 23:21:03 +00:00
|
|
|
|
public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
Logger = logger;
|
2014-02-15 16:36:09 +00:00
|
|
|
|
_appPaths = appPaths;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
Instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Runs this instance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Run()
|
|
|
|
|
{
|
2013-12-14 23:21:03 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DeleteEncodedMediaCache();
|
|
|
|
|
}
|
2013-12-22 18:58:51 +00:00
|
|
|
|
catch (DirectoryNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
// Don't clutter the log
|
|
|
|
|
}
|
2013-12-14 23:21:03 +00:00
|
|
|
|
catch (IOException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deleting encoded media cache", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the encoded media cache.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void DeleteEncodedMediaCache()
|
|
|
|
|
{
|
2014-05-09 04:38:12 +00:00
|
|
|
|
foreach (var file in Directory.EnumerateFiles(_appPaths.TranscodingTempPath, "*", SearchOption.AllDirectories)
|
2013-12-14 23:21:03 +00:00
|
|
|
|
.ToList())
|
|
|
|
|
{
|
|
|
|
|
File.Delete(file);
|
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Releases unmanaged and - optionally - managed resources.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
|
|
|
protected virtual void Dispose(bool dispose)
|
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
var jobCount = _activeTranscodingJobs.Count;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
2013-12-25 14:39:46 +00:00
|
|
|
|
Parallel.ForEach(_activeTranscodingJobs.ToList(), KillTranscodingJob);
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
// Try to allow for some time to kill the ffmpeg processes and delete the partial stream files
|
|
|
|
|
if (jobCount > 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The active transcoding jobs
|
|
|
|
|
/// </summary>
|
2013-04-10 15:32:09 +00:00
|
|
|
|
private readonly List<TranscodingJob> _activeTranscodingJobs = new List<TranscodingJob>();
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when [transcode beginning].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
/// <param name="process">The process.</param>
|
2013-06-12 02:59:38 +00:00
|
|
|
|
/// <param name="startTimeTicks">The start time ticks.</param>
|
2013-09-24 19:54:42 +00:00
|
|
|
|
/// <param name="sourcePath">The source path.</param>
|
2013-10-03 14:14:40 +00:00
|
|
|
|
/// <param name="deviceId">The device id.</param>
|
2014-06-02 19:32:41 +00:00
|
|
|
|
/// <param name="cancellationTokenSource">The cancellation token source.</param>
|
|
|
|
|
public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, long? startTimeTicks, string sourcePath, string deviceId, CancellationTokenSource cancellationTokenSource)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
_activeTranscodingJobs.Add(new TranscodingJob
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
Type = type,
|
|
|
|
|
Path = path,
|
|
|
|
|
Process = process,
|
2013-06-12 02:59:38 +00:00
|
|
|
|
ActiveRequestCount = 1,
|
2013-09-24 19:54:42 +00:00
|
|
|
|
StartTimeTicks = startTimeTicks,
|
2013-10-03 14:14:40 +00:00
|
|
|
|
SourcePath = sourcePath,
|
2014-06-02 19:32:41 +00:00
|
|
|
|
DeviceId = deviceId,
|
|
|
|
|
CancellationTokenSource = cancellationTokenSource
|
2013-03-03 02:47:04 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The progressive
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// Called when [transcode failed to start].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
public void OnTranscodeFailedToStart(string path, TranscodingJobType type)
|
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
var job = _activeTranscodingJobs.First(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
2013-04-10 15:32:09 +00:00
|
|
|
|
_activeTranscodingJobs.Remove(job);
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether [has active transcoding job] [the specified path].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
/// <returns><c>true</c> if [has active transcoding job] [the specified path]; otherwise, <c>false</c>.</returns>
|
|
|
|
|
public bool HasActiveTranscodingJob(string path, TranscodingJobType type)
|
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
return _activeTranscodingJobs.Any(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when [transcode begin request].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
public void OnTranscodeBeginRequest(string path, TranscodingJobType type)
|
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
if (job == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
job.ActiveRequestCount++;
|
|
|
|
|
|
|
|
|
|
if (job.KillTimer != null)
|
|
|
|
|
{
|
|
|
|
|
job.KillTimer.Dispose();
|
|
|
|
|
job.KillTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when [transcode end request].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
public void OnTranscodeEndRequest(string path, TranscodingJobType type)
|
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
if (job == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
job.ActiveRequestCount--;
|
|
|
|
|
|
|
|
|
|
if (job.ActiveRequestCount == 0)
|
|
|
|
|
{
|
2013-10-11 13:47:38 +00:00
|
|
|
|
// 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;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
if (job.KillTimer == null)
|
|
|
|
|
{
|
|
|
|
|
job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
job.KillTimer.Change(timerDuration, Timeout.Infinite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when [transcode kill timer stopped].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state">The state.</param>
|
2013-09-24 19:54:42 +00:00
|
|
|
|
private void OnTranscodeKillTimerStopped(object state)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
var job = (TranscodingJob)state;
|
|
|
|
|
|
2013-09-24 19:54:42 +00:00
|
|
|
|
KillTranscodingJob(job);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Kills the single transcoding job.
|
|
|
|
|
/// </summary>
|
2013-10-03 14:14:40 +00:00
|
|
|
|
/// <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)
|
2013-09-24 19:54:42 +00:00
|
|
|
|
{
|
2013-10-03 14:14:40 +00:00
|
|
|
|
if (string.IsNullOrEmpty(deviceId))
|
2013-09-24 19:54:42 +00:00
|
|
|
|
{
|
2013-10-03 14:14:40 +00:00
|
|
|
|
throw new ArgumentNullException("deviceId");
|
2013-09-24 19:54:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jobs = new List<TranscodingJob>();
|
|
|
|
|
|
|
|
|
|
lock (_activeTranscodingJobs)
|
|
|
|
|
{
|
|
|
|
|
// This is really only needed for HLS.
|
|
|
|
|
// Progressive streams can stop on their own reliably
|
2014-05-09 04:38:12 +00:00
|
|
|
|
jobs.AddRange(_activeTranscodingJobs.Where(i => string.Equals(deviceId, i.DeviceId, StringComparison.OrdinalIgnoreCase)));
|
2013-09-24 19:54:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 14:14:40 +00:00
|
|
|
|
foreach (var job in jobs)
|
2013-09-24 19:54:42 +00:00
|
|
|
|
{
|
2013-10-03 14:14:40 +00:00
|
|
|
|
KillTranscodingJob(job);
|
2013-09-24 19:54:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Kills the transcoding job.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="job">The job.</param>
|
2014-02-20 21:07:19 +00:00
|
|
|
|
private void KillTranscodingJob(TranscodingJob job)
|
2013-09-24 19:54:42 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
lock (_activeTranscodingJobs)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-04-10 15:32:09 +00:00
|
|
|
|
_activeTranscodingJobs.Remove(job);
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
2014-06-02 19:32:41 +00:00
|
|
|
|
if (!job.CancellationTokenSource.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
job.CancellationTokenSource.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 02:47:04 +00:00
|
|
|
|
if (job.KillTimer != null)
|
|
|
|
|
{
|
|
|
|
|
job.KillTimer.Dispose();
|
|
|
|
|
job.KillTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var process = job.Process;
|
|
|
|
|
|
|
|
|
|
var hasExited = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
hasExited = process.HasExited;
|
|
|
|
|
}
|
2013-10-01 18:24:27 +00:00
|
|
|
|
catch (Exception ex)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 04:00:44 +00:00
|
|
|
|
if (!hasExited)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
2013-06-10 04:00:44 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Logger.Info("Killing ffmpeg process for {0}", job.Path);
|
|
|
|
|
|
|
|
|
|
process.Kill();
|
|
|
|
|
|
|
|
|
|
// Need to wait because killing is asynchronous
|
|
|
|
|
process.WaitForExit(5000);
|
|
|
|
|
}
|
|
|
|
|
catch (Win32Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
|
|
|
|
|
}
|
|
|
|
|
catch (InvalidOperationException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
|
|
|
|
|
}
|
|
|
|
|
catch (NotSupportedException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
|
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 04:00:44 +00:00
|
|
|
|
// Dispose the process
|
|
|
|
|
process.Dispose();
|
|
|
|
|
|
2014-05-09 04:38:12 +00:00
|
|
|
|
DeletePartialStreamFiles(job.Path, job.Type, 0, 1500);
|
2014-01-03 04:58:22 +00:00
|
|
|
|
}
|
2013-06-10 04:00:44 +00:00
|
|
|
|
|
2014-01-03 04:58:22 +00:00
|
|
|
|
private async void DeletePartialStreamFiles(string path, TranscodingJobType jobType, int retryCount, int delayMs)
|
|
|
|
|
{
|
2014-06-02 19:32:41 +00:00
|
|
|
|
if (retryCount >= 8)
|
2014-01-03 04:58:22 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-06-10 04:00:44 +00:00
|
|
|
|
|
2014-01-03 04:58:22 +00:00
|
|
|
|
Logger.Info("Deleting partial stream file(s) {0}", path);
|
|
|
|
|
|
|
|
|
|
await Task.Delay(delayMs).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (jobType == TranscodingJobType.Progressive)
|
2013-06-10 04:00:44 +00:00
|
|
|
|
{
|
2014-01-03 04:58:22 +00:00
|
|
|
|
DeleteProgressivePartialStreamFiles(path);
|
2013-06-10 04:00:44 +00:00
|
|
|
|
}
|
2014-01-03 04:58:22 +00:00
|
|
|
|
else
|
2013-06-10 04:00:44 +00:00
|
|
|
|
{
|
2014-01-03 04:58:22 +00:00
|
|
|
|
DeleteHlsPartialStreamFiles(path);
|
2013-06-10 04:00:44 +00:00
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
2014-01-03 04:58:22 +00:00
|
|
|
|
catch (IOException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path);
|
|
|
|
|
|
|
|
|
|
DeletePartialStreamFiles(path, jobType, retryCount + 1, 500);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path);
|
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 04:00:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the progressive partial stream files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="outputFilePath">The output file path.</param>
|
|
|
|
|
private void DeleteProgressivePartialStreamFiles(string outputFilePath)
|
|
|
|
|
{
|
|
|
|
|
File.Delete(outputFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the HLS partial stream files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="outputFilePath">The output file path.</param>
|
|
|
|
|
private void DeleteHlsPartialStreamFiles(string outputFilePath)
|
|
|
|
|
{
|
|
|
|
|
var directory = Path.GetDirectoryName(outputFilePath);
|
|
|
|
|
var name = Path.GetFileNameWithoutExtension(outputFilePath);
|
|
|
|
|
|
|
|
|
|
var filesToDelete = Directory.EnumerateFiles(directory)
|
|
|
|
|
.Where(f => f.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var file in filesToDelete)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Logger.Info("Deleting HLS file {0}", file);
|
|
|
|
|
File.Delete(file);
|
|
|
|
|
}
|
|
|
|
|
catch (IOException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deleting HLS file {0}", ex, file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class TranscodingJob
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TranscodingJob
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The path.</value>
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the type.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The type.</value>
|
|
|
|
|
public TranscodingJobType Type { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the process.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The process.</value>
|
|
|
|
|
public Process Process { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the active request count.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The active request count.</value>
|
|
|
|
|
public int ActiveRequestCount { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the kill timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The kill timer.</value>
|
|
|
|
|
public Timer KillTimer { get; set; }
|
2013-06-12 02:59:38 +00:00
|
|
|
|
|
|
|
|
|
public long? StartTimeTicks { get; set; }
|
2013-09-24 19:54:42 +00:00
|
|
|
|
public string SourcePath { get; set; }
|
2013-10-03 14:14:40 +00:00
|
|
|
|
public string DeviceId { get; set; }
|
2014-06-02 19:32:41 +00:00
|
|
|
|
|
|
|
|
|
public CancellationTokenSource CancellationTokenSource { get; set; }
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Enum TranscodingJobType
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum TranscodingJobType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The progressive
|
|
|
|
|
/// </summary>
|
|
|
|
|
Progressive,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The HLS
|
|
|
|
|
/// </summary>
|
|
|
|
|
Hls
|
|
|
|
|
}
|
|
|
|
|
}
|