summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-04-12 14:25:56 +0000
committersr55 <[email protected]>2015-04-12 14:25:56 +0000
commitca97a5f5239a29e87470509add1fd68099e35f2c (patch)
tree11bcfc445eedfab7859a47c7038e6a800169370d /win/CS/HandBrake.ApplicationServices/Services
parent6f27f7d0d9d11012cce503052c96946c35a196a8 (diff)
WinGui: Some further refactoring of the services library. Moving all the queueing functionality up to app layer for now.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7086 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs15
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs50
3 files changed, 29 insertions, 42 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
index 3ba8a847f..227a73f5e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
@@ -11,15 +11,14 @@ namespace HandBrake.ApplicationServices.Services.Encode
{
using System;
using System.Diagnostics;
- using System.Globalization;
using System.IO;
using System.Text;
- using System.Text.RegularExpressions;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.EventArgs;
using HandBrake.ApplicationServices.Services.Encode.Interfaces;
+ using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Utilities;
/// <summary>
@@ -237,13 +236,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// <summary>
/// Setup the logging.
/// </summary>
- /// <param name="encodeQueueTask">
- /// The encode QueueTask.
- /// </param>
- /// <param name="isLibhb">
- /// Indicates if this is libhb that is encoding or not.
- /// </param>
- protected void SetupLogging(QueueTask encodeQueueTask, bool isLibhb)
+ protected void SetupLogging()
{
this.ShutdownFileWriter();
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
@@ -369,12 +362,12 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// <exception cref="Exception">
/// If the creation fails, an exception is thrown.
/// </exception>
- protected void VerifyEncodeDestinationPath(QueueTask task)
+ protected void VerifyEncodeDestinationPath(EncodeTask task)
{
// Make sure the path exists, attempt to create it if it doesn't
try
{
- string path = Directory.GetParent(task.Task.Destination).ToString();
+ string path = Directory.GetParent(task.Destination).ToString();
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs
index e0685d4ad..60a5744ad 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs
@@ -13,6 +13,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Interfaces
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.Model;
/// <summary>
/// Encode Progess Status
@@ -82,7 +83,10 @@ namespace HandBrake.ApplicationServices.Services.Encode.Interfaces
/// <param name="job">
/// The job.
/// </param>
- void Start(QueueTask job);
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ void Start(EncodeTask job, HBConfiguration configuration);
/// <summary>
/// The pause.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
index 0ae99b964..3c92f9a6f 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
@@ -15,10 +15,10 @@ namespace HandBrake.ApplicationServices.Services.Encode
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.Interfaces;
- using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Factories;
using HandBrake.ApplicationServices.Services.Encode.Interfaces;
+ using HandBrake.ApplicationServices.Services.Encode.Model;
/// <summary>
/// LibHB Implementation of IEncode
@@ -27,25 +27,11 @@ namespace HandBrake.ApplicationServices.Services.Encode
{
#region Private Variables
- /// <summary>
- /// Lock for the log file
- /// </summary>
private static readonly object LogLock = new object();
-
- /// <summary>
- /// The instance.
- /// </summary>
private IHandBrakeInstance instance;
-
- /// <summary>
- /// The Start time of the current Encode;
- /// </summary>
private DateTime startTime;
-
- /// <summary>
- /// The Current Task
- /// </summary>
- private QueueTask currentTask;
+ private EncodeTask currentTask;
+ private HBConfiguration currentConfiguration;
#endregion
@@ -57,22 +43,26 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// <summary>
/// Start with a LibHb EncodeJob Object
/// </summary>
- /// <param name="job">
- /// The job.
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="configuration">
+ /// The configuration.
/// </param>
- public void Start(QueueTask job)
+ public void Start(EncodeTask task, HBConfiguration configuration)
{
try
{
// Setup
this.startTime = DateTime.Now;
- this.currentTask = job;
+ this.currentTask = task;
+ this.currentConfiguration = configuration;
// Create a new HandBrake instance
// Setup the HandBrake Instance
HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
- this.instance = HandBrakeInstanceManager.GetEncodeInstance(job.Configuration.Verbosity);
+ this.instance = HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
@@ -83,21 +73,21 @@ namespace HandBrake.ApplicationServices.Services.Encode
}
this.IsEncoding = true;
- this.SetupLogging(job, true);
+ this.SetupLogging();
// Verify the Destination Path Exists, and if not, create it.
- this.VerifyEncodeDestinationPath(job);
+ this.VerifyEncodeDestinationPath(task);
ServiceLogMessage("Starting Encode ...");
// Get an EncodeJob object for the Interop Library
- instance.StartEncode(EncodeFactory.Create(job.Task, job.Configuration));
+ instance.StartEncode(EncodeFactory.Create(task, configuration));
// Fire the Encode Started Event
this.InvokeEncodeStarted(System.EventArgs.Empty);
// Set the Process Priority
- switch (job.Configuration.ProcessPriority)
+ switch (configuration.ProcessPriority)
{
case "Realtime":
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
@@ -124,7 +114,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
this.IsEncoding = false;
ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
- this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", job.Task.Source));
+ this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source));
}
}
@@ -254,7 +244,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;
// Handling Log Data
- this.ProcessLogs(this.currentTask.Task.Destination, this.currentTask.Configuration);
+ this.ProcessLogs(this.currentTask.Destination, this.currentConfiguration);
// Cleanup
this.ShutdownFileWriter();
@@ -262,8 +252,8 @@ namespace HandBrake.ApplicationServices.Services.Encode
// Raise the Encode Completed EVent.
this.InvokeEncodeCompleted(
e.Error
- ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)
- : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
+ ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination)
+ : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination));
}
#endregion
}