From bda2c81dab2a1df11ba853a34e047a5be41e0827 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Fri, 10 Aug 2012 23:13:56 -0400 Subject: Reworked audio transcoding to output directly to response --- MediaBrowser.Api/Transcoding/TranscodingJob.cs | 102 ------------------------- 1 file changed, 102 deletions(-) delete mode 100644 MediaBrowser.Api/Transcoding/TranscodingJob.cs (limited to 'MediaBrowser.Api/Transcoding/TranscodingJob.cs') diff --git a/MediaBrowser.Api/Transcoding/TranscodingJob.cs b/MediaBrowser.Api/Transcoding/TranscodingJob.cs deleted file mode 100644 index e504fec09..000000000 --- a/MediaBrowser.Api/Transcoding/TranscodingJob.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Threading; -using MediaBrowser.Common.Logging; - -namespace MediaBrowser.Api.Transcoding -{ - /// - /// Represents an active transcoding job - /// - public class TranscodingJob - { - public string InputFile { get; set; } - public string OutputFile { get; set; } - public string TranscoderPath { get; set; } - public string Arguments { get; set; } - - public TranscoderJobStatus Status { get; private set; } - - /// - /// Starts the job - /// - public void Start() - { - ApiService.AddTranscodingJob(this); - - ProcessStartInfo startInfo = new ProcessStartInfo(); - - startInfo.CreateNoWindow = true; - - startInfo.UseShellExecute = false; - - startInfo.FileName = TranscoderPath; - startInfo.WorkingDirectory = Path.GetDirectoryName(TranscoderPath); - startInfo.Arguments = Arguments; - - Logger.LogInfo("TranscodingJob.Start: " + TranscoderPath + " " + Arguments); - - Process process = new Process(); - - process.StartInfo = startInfo; - - process.EnableRaisingEvents = true; - - process.Start(); - - process.Exited += process_Exited; - } - - void process_Exited(object sender, EventArgs e) - { - ApiService.RemoveTranscodingJob(this); - - Process process = sender as Process; - - // If it terminated with an error - if (process.ExitCode != 0) - { - Status = TranscoderJobStatus.Error; - - // Delete this since it won't be valid - if (File.Exists(OutputFile)) - { - File.Delete(OutputFile); - } - } - else - { - Status = TranscoderJobStatus.Completed; - } - - process.Dispose(); - } - - /// - /// Provides a helper to wait for the job to exit - /// - public void WaitForExit() - { - while (true) - { - TranscoderJobStatus status = Status; - - if (status == TranscoderJobStatus.Completed || status == TranscoderJobStatus.Error) - { - break; - } - - Thread.Sleep(500); - } - } - } - - public enum TranscoderJobStatus - { - Queued, - Started, - Completed, - Error - } -} -- cgit v1.2.3