diff options
author | sr55 <[email protected]> | 2013-11-19 22:30:26 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-11-19 22:30:26 +0000 |
commit | 830bb18b173a1c68720eb0df2ed860daea7d4c7e (patch) | |
tree | 780e4ad48d4917555121766f5e1f3eb838970042 /win/CS/HandBrake.ApplicationServices/Services | |
parent | f83ab26ab8e1d2ce277f0c12f23b5753bf63d763 (diff) |
WinGui: Removed the need for the user settings service from IEncode and IScan interfaces and various other places. This makes the API much simpler to use.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5897 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
9 files changed, 36 insertions, 95 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index f1a94a05b..720330c50 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -34,11 +34,6 @@ namespace HandBrake.ApplicationServices.Services.Base private static readonly object FileWriterLock = new object();
/// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// The Log File Header
/// </summary>
private readonly StringBuilder header;
@@ -58,16 +53,10 @@ namespace HandBrake.ApplicationServices.Services.Base /// <summary>
/// Initializes a new instance of the <see cref="EncodeBase"/> class.
/// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public EncodeBase(IUserSettingService userSettingService)
+ public EncodeBase()
{
- this.userSettingService = userSettingService;
this.logBuffer = new StringBuilder();
- header =
- GeneralUtilities.CreateCliLogHeader();
-
+ header = GeneralUtilities.CreateCliLogHeader();
this.LogIndex = 0;
}
@@ -197,7 +186,10 @@ namespace HandBrake.ApplicationServices.Services.Base /// <param name="destination">
/// The Destination File Path
/// </param>
- public void ProcessLogs(string destination)
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ public void ProcessLogs(string destination, HBConfiguration configuration)
{
try
{
@@ -220,17 +212,16 @@ namespace HandBrake.ApplicationServices.Services.Base File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));
// Save a copy of the log file in the same location as the enocde.
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogWithVideo))
+ if (configuration.SaveLogWithVideo)
{
File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));
}
// Save a copy of the log file to a user specified location
- if (Directory.Exists(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory)) &&
- this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogToCopyDirectory))
+ if (Directory.Exists(configuration.SaveLogCopyDirectory) && configuration.SaveLogToCopyDirectory)
{
File.Copy(
- tempLogFile, Path.Combine(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory), encodeLogFile));
+ tempLogFile, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
}
}
catch (Exception)
@@ -320,13 +311,7 @@ namespace HandBrake.ApplicationServices.Services.Base try
{
- string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
- encodeQueueTask.Configuration.IsDvdNavDisabled,
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableQuickSyncDecoding),
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.EnableDxva),
- userSettingService.GetUserSetting<VideoScaler>(ASUserSettingConstants.ScalingMode) == VideoScaler.BicubicCl);
+ string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task), encodeQueueTask.Configuration);
this.logBuffer = new StringBuilder();
this.logBuffer.AppendLine(String.Format("CLI Query: {0}", query));
this.logBuffer.AppendLine();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 08394b88c..61bb1b575 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -29,11 +29,6 @@ namespace HandBrake.ApplicationServices.Services #region Private Variables
/// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// Gets the Process ID
/// </summary>
private int processId;
@@ -55,18 +50,6 @@ namespace HandBrake.ApplicationServices.Services #endregion
- /// <summary>
- /// Initializes a new instance of the <see cref="Encode"/> class.
- /// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public Encode(IUserSettingService userSettingService)
- : base(userSettingService)
- {
- this.userSettingService = userSettingService;
- }
-
#region Properties
/// <summary>
@@ -130,19 +113,10 @@ namespace HandBrake.ApplicationServices.Services string query = this.currentTask.Task.IsPreviewEncode
? QueryGeneratorUtility.GeneratePreviewQuery(
new EncodeTask(this.currentTask.Task),
+ encodeQueueTask.Configuration,
this.currentTask.Task.PreviewEncodeDuration,
- this.currentTask.Task.PreviewEncodeStartAt,
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
- encodeQueueTask.Configuration.IsDvdNavDisabled,
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableQuickSyncDecoding))
- : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
- encodeQueueTask.Configuration.IsDvdNavDisabled,
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableQuickSyncDecoding),
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.EnableDxva),
- userSettingService.GetUserSetting<VideoScaler>(ASUserSettingConstants.ScalingMode) == VideoScaler.BicubicCl);
+ this.currentTask.Task.PreviewEncodeStartAt)
+ : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task), encodeQueueTask.Configuration);
ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, query)
{
@@ -177,7 +151,7 @@ namespace HandBrake.ApplicationServices.Services }
// Set the Process Priority
- switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority))
+ switch (encodeQueueTask.Configuration.ProcessPriority)
{
case "Realtime":
this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs index 17cf2e7f8..61c99eab0 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs @@ -105,7 +105,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="destination">
/// The destination.
/// </param>
- void ProcessLogs(string destination);
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ void ProcessLogs(string destination, HBConfiguration configuration);
/// <summary>
/// Shutdown the service.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs index d1049ba49..f102d0d36 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs @@ -82,16 +82,13 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="title">
/// int title number. 0 for scan all
/// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
/// <param name="postAction">
/// The post Action.
/// </param>
/// <param name="configuration">
/// The configuraiton.
/// </param>
- void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction, HBConfiguration configuration);
+ void Scan(string sourcePath, int title, Action<bool> postAction, HBConfiguration configuration);
/// <summary>
/// Kill the scan
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs index 9351ab03d..367555418 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs @@ -63,8 +63,11 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="destination">
/// The destination.
/// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
[OperationContract]
- void ProcessEncodeLogs(string destination);
+ void ProcessEncodeLogs(string destination, HBConfiguration configuration);
/// <summary>
/// Stop and Encode
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 744bbc890..f97355ad5 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -37,11 +37,6 @@ namespace HandBrake.ApplicationServices.Services private static readonly object logLock = new object();
/// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// The instance.
/// </summary>
private IHandBrakeInstance instance;
@@ -66,14 +61,8 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Initializes a new instance of the <see cref="LibEncode"/> class.
/// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public LibEncode(IUserSettingService userSettingService)
- : base(userSettingService)
+ public LibEncode()
{
- this.userSettingService = userSettingService;
-
HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
}
@@ -218,7 +207,7 @@ namespace HandBrake.ApplicationServices.Services this.InvokeEncodeStarted(EventArgs.Empty);
// Set the Process Priority
- switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority))
+ switch (job.Configuration.ProcessPriority)
{
case "Realtime":
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index 6a372f228..28754e15c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -48,11 +48,6 @@ namespace HandBrake.ApplicationServices.Services static readonly object LogLock = new object();
/// <summary>
- /// The user setting service.
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// Log data from HandBrakeInstance
/// </summary>
private readonly StringBuilder logging;
@@ -92,15 +87,11 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Initializes a new instance of the <see cref="LibScan"/> class.
/// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public LibScan(IUserSettingService userSettingService)
+ public LibScan()
{
logging = new StringBuilder();
header = GeneralUtilities.CreateCliLogHeader();
- this.userSettingService = userSettingService;
try
{
@@ -170,16 +161,13 @@ namespace HandBrake.ApplicationServices.Services /// <param name="title">
/// int title number. 0 for scan all
/// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
/// <param name="postAction">
/// The post Action.
/// </param>
/// <param name="configuraiton">
/// The configuraiton.
/// </param>
- public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction, HBConfiguration configuraiton)
+ public void Scan(string sourcePath, int title, Action<bool> postAction, HBConfiguration configuraiton)
{
// Try to cleanup any previous scan instances.
if (instance != null)
@@ -227,7 +215,7 @@ namespace HandBrake.ApplicationServices.Services instance.ScanCompleted += this.InstanceScanCompleted;
// Start the scan on a back
- this.ScanSource(sourcePath, title, previewCount, configuraiton);
+ this.ScanSource(sourcePath, title, configuraiton.PreviewScanCount, configuraiton);
}
/// <summary>
@@ -286,7 +274,7 @@ namespace HandBrake.ApplicationServices.Services TimeSpan minDuration =
TimeSpan.FromSeconds(
- this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration));
+ configuraiton.MinScanDuration);
HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index eb173c5b3..1ade60d74 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -484,7 +484,7 @@ namespace HandBrake.ApplicationServices.Services }
// Handling Log Data
- this.EncodeService.ProcessLogs(this.LastProcessedJob.Task.Destination);
+ this.EncodeService.ProcessLogs(this.LastProcessedJob.Task.Destination, this.LastProcessedJob.Configuration);
// Move onto the next job.
if (this.IsProcessing)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index 0fd2ef4b1..e7f4990bc 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -79,9 +79,12 @@ namespace HandBrake.ApplicationServices.Services /// <param name="destination">
/// The destination.
/// </param>
- public void ProcessEncodeLogs(string destination)
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ public void ProcessEncodeLogs(string destination, HBConfiguration configuration)
{
- encodeService.ProcessLogs(destination);
+ encodeService.ProcessLogs(destination, configuration);
}
@@ -102,8 +105,7 @@ namespace HandBrake.ApplicationServices.Services Console.WriteLine("Service Started. Waiting for Clients...");
// Setup the services we are going to use.
- encodeService = new LibEncode(new UserSettingService()); // TODO this needs wired up with castle
-
+ encodeService = new LibEncode();
shutdownFlag = new ManualResetEvent(false);
shutdownFlag.WaitOne();
}
|