From 830bb18b173a1c68720eb0df2ed860daea7d4c7e Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 19 Nov 2013 22:30:26 +0000 Subject: 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 --- .../ASUserSettingConstants.cs | 50 ---------------------- .../Isolation/IsolatedEncodeService.cs | 7 ++- .../Model/HBConfiguration.cs | 50 ++++++++++++++++++++++ .../Services/Base/EncodeBase.cs | 35 +++++---------- .../Services/Encode.cs | 34 ++------------- .../Services/Interfaces/IEncode.cs | 5 ++- .../Services/Interfaces/IScan.cs | 5 +-- .../Services/Interfaces/IServerService.cs | 5 ++- .../Services/LibEncode.cs | 15 +------ .../Services/LibScan.cs | 20 ++------- .../Services/QueueProcessor.cs | 2 +- .../Services/ServerService.cs | 10 +++-- .../Utilities/QueryGeneratorUtility.cs | 46 +++++--------------- 13 files changed, 102 insertions(+), 182 deletions(-) (limited to 'win/CS/HandBrake.ApplicationServices') diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs index a03bf58d9..bea0a8844 100644 --- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs +++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs @@ -14,64 +14,14 @@ namespace HandBrake.ApplicationServices /// public class ASUserSettingConstants { - /// - /// The Verbosity - /// - public const string Verbosity = "Verbosity"; - - /// - /// Process Priority - /// - public const string ProcessPriority = "ProcessPriority"; - - /// - /// Save Log Directory - /// - public const string SaveLogToCopyDirectory = "SaveLogToCopyDirectory"; - - /// - /// Save log with video - /// - public const string SaveLogWithVideo = "SaveLogWithVideo"; - - /// - /// Save copy of the log to a directory - /// - public const string SaveLogCopyDirectory = "SaveLogCopyDirectory"; - /// /// HandBrakes build /// public const string HandBrakeBuild = "HandBrakeBuild"; - /// - /// Min Title Scan Duration - /// - public const string MinScanDuration = "MinTitleScanDuration"; - - /// - /// Preview Scan Count - /// - public const string PreviewScanCount = "previewScanCount"; - /// /// Clear completed items from the queue automatically. /// public const string ClearCompletedFromQueue = "ClearCompletedFromQueue"; - - /// - /// The disable quick sync decoding. - /// - public const string DisableQuickSyncDecoding = "DisableQuickSyncDecoding"; - - /// - /// The enable dxva. - /// - public const string EnableDxva = "EnableDxva"; - - /// - /// The scaling mode. - /// - public const string ScalingMode = "ScalingMode"; } } diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs index bc31544a4..32dc494d7 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs @@ -162,9 +162,12 @@ namespace HandBrake.ApplicationServices.Isolation /// /// The destination. /// - public void ProcessLogs(string destination) + /// + /// The configuration. + /// + public void ProcessLogs(string destination, HBConfiguration configuration) { - ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination); }); + ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination, configuration); }); } /// diff --git a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs index 35d07dcfc..04b6efab6 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs @@ -23,5 +23,55 @@ namespace HandBrake.ApplicationServices.Model /// Gets or sets a value indicating whether is dvd nav disabled. /// public bool IsDvdNavDisabled { get; set; } + + /// + /// Gets or sets a value indicating whether disable quick sync decoding. + /// + public bool DisableQuickSyncDecoding { get; set; } + + /// + /// Gets or sets a value indicating whether enable dxva. + /// + public bool EnableDxva { get; set; } + + /// + /// Gets or sets the scaling mode. + /// + public VideoScaler ScalingMode { get; set; } + + /// + /// Gets or sets the preview scan count. + /// + public int PreviewScanCount { get; set; } + + /// + /// Gets or sets the verbosity. + /// + public int Verbosity { get; set; } + + /// + /// Gets or sets the min scan duration. + /// + public int MinScanDuration { get; set; } + + /// + /// Gets or sets the process priority. + /// + public string ProcessPriority { get; set; } + + /// + /// Gets or sets a value indicating whether save log to copy directory. + /// + public bool SaveLogToCopyDirectory { get; set; } + + /// + /// Gets or sets a value indicating whether save log with video. + /// + public bool SaveLogWithVideo{ get; set; } + + /// + /// Gets or sets the save log copy directory. + /// + public string SaveLogCopyDirectory { get; set; } } } 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 @@ -33,11 +33,6 @@ namespace HandBrake.ApplicationServices.Services.Base /// private static readonly object FileWriterLock = new object(); - /// - /// The User Setting Service - /// - private readonly IUserSettingService userSettingService; - /// /// The Log File Header /// @@ -58,16 +53,10 @@ namespace HandBrake.ApplicationServices.Services.Base /// /// Initializes a new instance of the class. /// - /// - /// The user Setting Service. - /// - 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 /// /// The Destination File Path /// - public void ProcessLogs(string destination) + /// + /// The configuration. + /// + 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(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(ASUserSettingConstants.SaveLogCopyDirectory)) && - this.userSettingService.GetUserSetting(ASUserSettingConstants.SaveLogToCopyDirectory)) + if (Directory.Exists(configuration.SaveLogCopyDirectory) && configuration.SaveLogToCopyDirectory) { File.Copy( - tempLogFile, Path.Combine(this.userSettingService.GetUserSetting(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(ASUserSettingConstants.PreviewScanCount), - userSettingService.GetUserSetting(ASUserSettingConstants.Verbosity), - encodeQueueTask.Configuration.IsDvdNavDisabled, - userSettingService.GetUserSetting(ASUserSettingConstants.DisableQuickSyncDecoding), - userSettingService.GetUserSetting(ASUserSettingConstants.EnableDxva), - userSettingService.GetUserSetting(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 @@ -28,11 +28,6 @@ namespace HandBrake.ApplicationServices.Services { #region Private Variables - /// - /// The User Setting Service - /// - private readonly IUserSettingService userSettingService; - /// /// Gets the Process ID /// @@ -55,18 +50,6 @@ namespace HandBrake.ApplicationServices.Services #endregion - /// - /// Initializes a new instance of the class. - /// - /// - /// The user Setting Service. - /// - public Encode(IUserSettingService userSettingService) - : base(userSettingService) - { - this.userSettingService = userSettingService; - } - #region Properties /// @@ -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(ASUserSettingConstants.PreviewScanCount), - userSettingService.GetUserSetting(ASUserSettingConstants.Verbosity), - encodeQueueTask.Configuration.IsDvdNavDisabled, - userSettingService.GetUserSetting(ASUserSettingConstants.DisableQuickSyncDecoding)) - : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task), - userSettingService.GetUserSetting(ASUserSettingConstants.PreviewScanCount), - userSettingService.GetUserSetting(ASUserSettingConstants.Verbosity), - encodeQueueTask.Configuration.IsDvdNavDisabled, - userSettingService.GetUserSetting(ASUserSettingConstants.DisableQuickSyncDecoding), - userSettingService.GetUserSetting(ASUserSettingConstants.EnableDxva), - userSettingService.GetUserSetting(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(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 /// /// The destination. /// - void ProcessLogs(string destination); + /// + /// The configuration. + /// + void ProcessLogs(string destination, HBConfiguration configuration); /// /// 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 /// /// int title number. 0 for scan all /// - /// - /// The preview Count. - /// /// /// The post Action. /// /// /// The configuraiton. /// - void Scan(string sourcePath, int title, int previewCount, Action postAction, HBConfiguration configuration); + void Scan(string sourcePath, int title, Action postAction, HBConfiguration configuration); /// /// 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 /// /// The destination. /// + /// + /// The configuration. + /// [OperationContract] - void ProcessEncodeLogs(string destination); + void ProcessEncodeLogs(string destination, HBConfiguration configuration); /// /// 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 @@ -36,11 +36,6 @@ namespace HandBrake.ApplicationServices.Services /// private static readonly object logLock = new object(); - /// - /// The User Setting Service - /// - private readonly IUserSettingService userSettingService; - /// /// The instance. /// @@ -66,14 +61,8 @@ namespace HandBrake.ApplicationServices.Services /// /// Initializes a new instance of the class. /// - /// - /// The user Setting Service. - /// - 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(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 @@ -47,11 +47,6 @@ namespace HandBrake.ApplicationServices.Services /// static readonly object LogLock = new object(); - /// - /// The user setting service. - /// - private readonly IUserSettingService userSettingService; - /// /// Log data from HandBrakeInstance /// @@ -92,15 +87,11 @@ namespace HandBrake.ApplicationServices.Services /// /// Initializes a new instance of the class. /// - /// - /// The user Setting Service. - /// - public LibScan(IUserSettingService userSettingService) + public LibScan() { logging = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader(); - this.userSettingService = userSettingService; try { @@ -170,16 +161,13 @@ namespace HandBrake.ApplicationServices.Services /// /// int title number. 0 for scan all /// - /// - /// The preview Count. - /// /// /// The post Action. /// /// /// The configuraiton. /// - public void Scan(string sourcePath, int title, int previewCount, Action postAction, HBConfiguration configuraiton) + public void Scan(string sourcePath, int title, Action 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); } /// @@ -286,7 +274,7 @@ namespace HandBrake.ApplicationServices.Services TimeSpan minDuration = TimeSpan.FromSeconds( - this.userSettingService.GetUserSetting(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 /// /// The destination. /// - public void ProcessEncodeLogs(string destination) + /// + /// The configuration. + /// + 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(); } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 30c1e9eb7..5552f1941 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -34,28 +34,13 @@ namespace HandBrake.ApplicationServices.Utilities /// /// The task. /// - /// - /// The preview Scan Count. - /// - /// - /// The verbosity. - /// - /// - /// The disable Lib Dvd Nav. - /// - /// - /// The disable Qsv Decode. - /// - /// - /// The enable Hwd. - /// - /// - /// The enable Open CL. + /// + /// The configuration. /// /// /// A Cli Query /// - public static string GenerateQuery(EncodeTask task, int previewScanCount, int verbosity, bool disableLibDvdNav, bool disableQsvDecode, bool enableHwd, bool enableOpenCL) + public static string GenerateQuery(EncodeTask task, HBConfiguration configuration) { if (string.IsNullOrEmpty(task.Source)) { @@ -63,9 +48,9 @@ namespace HandBrake.ApplicationServices.Utilities } string query = string.Empty; - query += SourceQuery(task, null, null, previewScanCount); + query += SourceQuery(task, null, null, configuration.PreviewScanCount); query += DestinationQuery(task); - query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav, disableQsvDecode, enableHwd, enableOpenCL); + query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, configuration.EnableDxva, configuration.ScalingMode == VideoScaler.BicubicCl); return query; } @@ -76,33 +61,24 @@ namespace HandBrake.ApplicationServices.Utilities /// /// The task. /// + /// + /// The configuration. + /// /// /// The duration. /// /// /// The start At Preview. /// - /// - /// The preview Scan Count. - /// - /// - /// The verbosity. - /// - /// - /// The disable Lib Dvd Nav. - /// - /// - /// The disable Qsv Decode. - /// /// /// A Cli query suitable for generating a preview video. /// - public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview, int previewScanCount, int verbosity, bool disableLibDvdNav, bool disableQsvDecode) + public static string GeneratePreviewQuery(EncodeTask task, HBConfiguration configuration, int duration, string startAtPreview) { string query = string.Empty; - query += SourceQuery(task, duration, startAtPreview, previewScanCount); + query += SourceQuery(task, duration, startAtPreview, configuration.PreviewScanCount); query += DestinationQuery(task); - query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav, disableQsvDecode, false, false); + query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, false, false); return query; } -- cgit v1.2.3