diff options
Diffstat (limited to 'win/C#/CLI')
-rw-r--r-- | win/C#/CLI/Jobs/Encode.cs | 15 | ||||
-rw-r--r-- | win/C#/CLI/Jobs/Job.cs | 28 | ||||
-rw-r--r-- | win/C#/CLI/Jobs/ParseDVD.cs | 15 | ||||
-rw-r--r-- | win/C#/CLI/Manager.cs | 83 |
4 files changed, 140 insertions, 1 deletions
diff --git a/win/C#/CLI/Jobs/Encode.cs b/win/C#/CLI/Jobs/Encode.cs new file mode 100644 index 000000000..e09673856 --- /dev/null +++ b/win/C#/CLI/Jobs/Encode.cs @@ -0,0 +1,15 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class Encode
+ {
+ public override string ToString()
+ {
+ // TODO: generate param string to be used with hbcli
+ return base.ToString();
+ }
+ }
+}
diff --git a/win/C#/CLI/Jobs/Job.cs b/win/C#/CLI/Jobs/Job.cs new file mode 100644 index 000000000..f1c02c352 --- /dev/null +++ b/win/C#/CLI/Jobs/Job.cs @@ -0,0 +1,28 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class Job
+ {
+ private string m_exec;
+
+ private Process m_proc;
+ /// <summary>
+ /// The base process associated with this job
+ /// </summary>
+ public Process Process
+ {
+ get
+ {
+ return this.m_proc;
+ }
+ }
+
+ public Job()
+ {
+ }
+ }
+}
diff --git a/win/C#/CLI/Jobs/ParseDVD.cs b/win/C#/CLI/Jobs/ParseDVD.cs new file mode 100644 index 000000000..d902fc35c --- /dev/null +++ b/win/C#/CLI/Jobs/ParseDVD.cs @@ -0,0 +1,15 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class ParseDVD
+ {
+ public override string ToString()
+ {
+ // TODO: generate param string to be used with hbcli
+ return base.ToString();
+ }
+ }
+}
diff --git a/win/C#/CLI/Manager.cs b/win/C#/CLI/Manager.cs index ac20609a3..d6627ba8a 100644 --- a/win/C#/CLI/Manager.cs +++ b/win/C#/CLI/Manager.cs @@ -6,15 +6,96 @@ using System.Diagnostics; namespace Handbrake.CLI
{
/// <summary>
+ /// Delegate to handle pointers to event subscriptions regarding CLI jobs
+ /// </summary>
+ /// <param name="Sender">The object which raised the event using this delegate</param>
+ /// <param name="Job">The job which caused this delegate to fire</param>
+ public delegate void JobStatusHandler(Jobs.Job Job);
+
+ /// <summary>
/// still workin on this
/// </summary>
class Manager
{
private static Queue<Process> m_processQueue = new Queue<Process>();
- public static void Enqueue(object s)
+ /// <summary>
+ /// Raised upon a job being completed
+ /// </summary>
+ public static event JobStatusHandler OnJobCompleted;
+
+ /// <summary>
+ /// Raised upon a new job starting
+ /// </summary>
+ public static event JobStatusHandler OnJobStarted;
+
+ /// <summary>
+ /// Raised upon any noteable progress during a job
+ /// </summary>
+ public static event JobStatusHandler OnJobProgress;
+
+ /// <summary>
+ /// Used for queueing up a job to be processed later
+ /// </summary>
+ /// <param name="job">The job to be processed later</param>
+ public static void EnqueueJob(Jobs.Job job)
{
//TODO: create new Process object from passed
+ m_processQueue.Enqueue(CreateProcess(job));
+ }
+
+ /// <summary>
+ /// Starts the job queue
+ /// </summary>
+ public static void StartJobs()
+ {
+ while (m_processQueue.Count > 0)
+ {
+ Process proc = m_processQueue.Dequeue();
+ proc.Start();
+ proc.Close();
+ }
+ }
+
+ /// <summary>
+ /// Creates a new Process object from a Job object
+ /// </summary>
+ /// <param name="job">The Job object to create a process from</param>
+ /// <returns>A Process object based on the requirements of the Job passed</returns>
+ private static Process CreateProcess(Jobs.Job job)
+ {
+ Process hbProc = new Process();
+ hbProc.StartInfo.FileName = "hbcli.exe";
+ hbProc.StartInfo.Arguments = job.ToString();
+ hbProc.StartInfo.RedirectStandardOutput = true;
+ hbProc.StartInfo.RedirectStandardError = true;
+ hbProc.StartInfo.UseShellExecute = false;
+ hbProc.StartInfo.CreateNoWindow = true;
+
+ // Set the process Priority
+ switch (Properties.Settings.Default.processPriority)
+ {
+ case "Realtime":
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;
+ break;
+ case "High":
+ hbProc.PriorityClass = ProcessPriorityClass.High;
+ break;
+ case "Above Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case "Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case "Low":
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
+
+ return hbProc;
}
}
}
|