diff options
author | sr55 <[email protected]> | 2013-11-19 21:55:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-11-19 21:55:44 +0000 |
commit | f83ab26ab8e1d2ce277f0c12f23b5753bf63d763 (patch) | |
tree | f59a860b5a06effcdccc57dfa83629d171536864 /win/CS/HandBrake.ApplicationServices | |
parent | ca8fe7c1fe8abf869d4c53e31124c5f0b1aa8dfa (diff) |
WinGui: Started work on API improvements in the Application services dll. Removing the concept of user settings and replacing it with a Configuration object.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5896 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
15 files changed, 110 insertions, 81 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs index f5ca3bef5..a03bf58d9 100644 --- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs +++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs @@ -45,11 +45,6 @@ namespace HandBrake.ApplicationServices public const string HandBrakeBuild = "HandBrakeBuild";
/// <summary>
- /// Disable Libdvdnav
- /// </summary>
- public const string DisableLibDvdNav = "DisableLibDvdNav";
-
- /// <summary>
/// Min Title Scan Duration
/// </summary>
public const string MinScanDuration = "MinTitleScanDuration";
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 473ae6893..e9386ac37 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -97,6 +97,7 @@ <Compile Include="Isolation\BackgroundServiceConnector.cs" />
<Compile Include="Isolation\IsolatedEncodeService.cs" />
<Compile Include="LibHb\AudioVideoHelpers.cs" />
+ <Compile Include="Model\HBConfiguration.cs" />
<Compile Include="Model\VideoScaler.cs" />
<Compile Include="Services\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IHbServiceCallback.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs index 2f29d7054..bc31544a4 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs @@ -173,13 +173,10 @@ namespace HandBrake.ApplicationServices.Isolation /// <param name="job">
/// The job.
/// </param>
- /// <param name="enableLogging">
- /// The enable Logging.
- /// </param>
- public void Start(QueueTask job, bool enableLogging)
+ public void Start(QueueTask job)
{
ThreadPool.QueueUserWorkItem(
- delegate { this.Service.StartEncode(job, enableLogging); });
+ delegate { this.Service.StartEncode(job); });
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs new file mode 100644 index 000000000..35d07dcfc --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs @@ -0,0 +1,27 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="HBConfiguration.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// HandBrakes Configuration options
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Model
+{
+ /// <summary>
+ /// HandBrakes configuration options
+ /// </summary>
+ public class HBConfiguration
+ {
+ /// <summary>
+ /// Gets or sets a value indicating whether is logging enabled.
+ /// </summary>
+ public bool IsLoggingEnabled { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether is dvd nav disabled.
+ /// </summary>
+ public bool IsDvdNavDisabled { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs index 84e9eee9f..68f32011a 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs @@ -38,14 +38,25 @@ namespace HandBrake.ApplicationServices.Model }
/// <summary>
- /// Gets or sets ScannedSource.
+ /// Initializes a new instance of the <see cref="QueueTask"/> class.
/// </summary>
- public Source ScannedSource { get; set; }
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ public QueueTask(EncodeTask task, HBConfiguration configuration)
+ {
+ this.Task = task;
+ this.Configuration = configuration;
+ this.Status = QueueItemStatus.Waiting;
+ }
/// <summary>
- /// Gets or sets a value indicating whether if this is a user or GUI generated query
+ /// Gets or sets ScannedSource.
/// </summary>
- public bool CustomQuery { get; set; }
+ public Source ScannedSource { get; set; }
/// <summary>
/// Gets or sets Status.
@@ -65,10 +76,15 @@ namespace HandBrake.ApplicationServices.Model }
/// <summary>
- /// Gets or sets the Encode Task.
+ /// Gets the task.
/// </summary>
public EncodeTask Task { get; set; }
+ /// <summary>
+ /// Gets the configuration.
+ /// </summary>
+ public HBConfiguration Configuration { get; set; }
+
#endregion
/// <summary>
@@ -82,7 +98,7 @@ namespace HandBrake.ApplicationServices.Model /// </returns>
protected bool Equals(QueueTask other)
{
- return Equals(this.ScannedSource, other.ScannedSource) && this.CustomQuery.Equals(other.CustomQuery) && Equals(this.Task, other.Task) && this.status == other.status;
+ return Equals(this.ScannedSource, other.ScannedSource) && Equals(this.Task, other.Task) && this.status == other.status;
}
/// <summary>
@@ -125,7 +141,6 @@ namespace HandBrake.ApplicationServices.Model unchecked
{
int hashCode = (this.ScannedSource != null ? this.ScannedSource.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ this.CustomQuery.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Task != null ? this.Task.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int)this.status;
return hashCode;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 58f67401e..f1a94a05b 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -323,13 +323,12 @@ namespace HandBrake.ApplicationServices.Services.Base string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav),
+ encodeQueueTask.Configuration.IsDvdNavDisabled,
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableQuickSyncDecoding),
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.EnableDxva),
userSettingService.GetUserSetting<VideoScaler>(ASUserSettingConstants.ScalingMode) == VideoScaler.BicubicCl);
this.logBuffer = new StringBuilder();
this.logBuffer.AppendLine(String.Format("CLI Query: {0}", query));
- this.logBuffer.AppendLine(String.Format("User Query: {0}", encodeQueueTask.CustomQuery));
this.logBuffer.AppendLine();
// Clear the current Encode Logs)
@@ -346,7 +345,6 @@ namespace HandBrake.ApplicationServices.Services.Base this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
this.fileWriter.WriteLine(header);
this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
- this.fileWriter.WriteLine(string.Format("User Query: {0}", encodeQueueTask.CustomQuery));
this.fileWriter.WriteLine();
}
catch (Exception)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 5ad95d08e..08394b88c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -96,10 +96,7 @@ namespace HandBrake.ApplicationServices.Services /// <param name="encodeQueueTask">
/// The encodeQueueTask.
/// </param>
- /// <param name="enableLogging">
- /// Enable Logging. When Disabled we onlt parse Standard Ouput for progress info. Standard Error log data is ignored.
- /// </param>
- public void Start(QueueTask encodeQueueTask, bool enableLogging)
+ public void Start(QueueTask encodeQueueTask)
{
try
{
@@ -111,7 +108,7 @@ namespace HandBrake.ApplicationServices.Services this.IsEncoding = true;
this.currentTask = encodeQueueTask;
- if (enableLogging)
+ if (encodeQueueTask.Configuration.IsLoggingEnabled)
{
try
{
@@ -137,12 +134,12 @@ namespace HandBrake.ApplicationServices.Services this.currentTask.Task.PreviewEncodeStartAt,
userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav),
+ 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),
- userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav),
+ encodeQueueTask.Configuration.IsDvdNavDisabled,
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableQuickSyncDecoding),
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.EnableDxva),
userSettingService.GetUserSetting<VideoScaler>(ASUserSettingConstants.ScalingMode) == VideoScaler.BicubicCl);
@@ -150,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, query)
{
RedirectStandardOutput = true,
- RedirectStandardError = enableLogging,
+ RedirectStandardError = encodeQueueTask.Configuration.IsLoggingEnabled,
UseShellExecute = false,
CreateNoWindow = true
};
@@ -161,7 +158,7 @@ namespace HandBrake.ApplicationServices.Services this.startTime = DateTime.Now;
- if (enableLogging)
+ if (encodeQueueTask.Configuration.IsLoggingEnabled)
{
this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
this.HbProcess.BeginErrorReadLine();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs index 8d70247f7..17cf2e7f8 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs @@ -82,10 +82,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="job">
/// The job.
/// </param>
- /// <param name="enableLogging">
- /// The enable Logging.
- /// </param>
- void Start(QueueTask job, bool enableLogging);
+ void Start(QueueTask job);
/// <summary>
/// The pause.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs index 785728582..d1049ba49 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs @@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces using System;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
/// <summary>
@@ -87,7 +88,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="postAction">
/// The post Action.
/// </param>
- void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction);
+ /// <param name="configuration">
+ /// The configuraiton.
+ /// </param>
+ void Scan(string sourcePath, int title, int previewCount, 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 9aa1f1cb7..9351ab03d 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs @@ -54,11 +54,8 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <param name="job">
/// The job.
/// </param>
- /// <param name="enableLogging">
- /// The enable logging.
- /// </param>
[OperationContract]
- void StartEncode(QueueTask job, bool enableLogging);
+ void StartEncode(QueueTask job);
/// <summary>
/// The process encode logs.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index f6da448ac..744bbc890 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -95,14 +95,11 @@ namespace HandBrake.ApplicationServices.Services /// <param name="job">
/// The job.
/// </param>
- /// <param name="enableLogging">
- /// The enable Logging.
- /// </param>
- public void Start(QueueTask job, bool enableLogging)
+ public void Start(QueueTask job)
{
// Setup
this.startTime = DateTime.Now;
- this.loggingEnabled = enableLogging;
+ this.loggingEnabled = job.Configuration.IsLoggingEnabled;
this.currentTask = job;
// Create a new HandBrake instance
@@ -123,7 +120,7 @@ namespace HandBrake.ApplicationServices.Services this.IsEncoding = true;
// Enable logging if required.
- if (enableLogging)
+ if (job.Configuration.IsLoggingEnabled)
{
try
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index 7064cc643..6a372f228 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Services using System.Text;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -175,7 +176,10 @@ namespace HandBrake.ApplicationServices.Services /// <param name="postAction">
/// The post Action.
/// </param>
- public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
+ /// <param name="configuraiton">
+ /// The configuraiton.
+ /// </param>
+ public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction, HBConfiguration configuraiton)
{
// Try to cleanup any previous scan instances.
if (instance != null)
@@ -223,7 +227,7 @@ namespace HandBrake.ApplicationServices.Services instance.ScanCompleted += this.InstanceScanCompleted;
// Start the scan on a back
- this.ScanSource(sourcePath, title, previewCount);
+ this.ScanSource(sourcePath, title, previewCount, configuraiton);
}
/// <summary>
@@ -263,7 +267,10 @@ namespace HandBrake.ApplicationServices.Services /// <param name="previewCount">
/// The preview Count.
/// </param>
- private void ScanSource(object sourcePath, int title, int previewCount)
+ /// <param name="configuraiton">
+ /// The configuraiton.
+ /// </param>
+ private void ScanSource(object sourcePath, int title, int previewCount, HBConfiguration configuraiton)
{
try
{
@@ -281,7 +288,7 @@ namespace HandBrake.ApplicationServices.Services TimeSpan.FromSeconds(
this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration));
- HandBrakeUtils.SetDvdNav(!this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));
+ HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index d80a485ec..eb173c5b3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -581,7 +581,7 @@ namespace HandBrake.ApplicationServices.Services if (job != null)
{
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
- this.EncodeService.Start(job, true);
+ this.EncodeService.Start(job);
}
else
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index ab0acd596..0fd2ef4b1 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -115,16 +115,13 @@ namespace HandBrake.ApplicationServices.Services /// <param name="job">
/// The job.
/// </param>
- /// <param name="enableLogging">
- /// The enable logging.
- /// </param>
- public void StartEncode(QueueTask job, bool enableLogging)
+ public void StartEncode(QueueTask job)
{
Console.WriteLine("Starting Source Encode for: " + job.Task.Source);
encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
encodeService.EncodeStarted += this.encodeService_EncodeStarted;
encodeService.EncodeStatusChanged += this.encodeService_EncodeStatusChanged;
- encodeService.Start(job, enableLogging);
+ encodeService.Start(job);
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 5dee88426..30c1e9eb7 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -957,24 +957,24 @@ namespace HandBrake.ApplicationServices.Utilities {
query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
}
- } - } - - // QSV Only - if (task.VideoEncoder == VideoEncoder.QuickSync) - { - query += string.Format(" --qsv-preset={0}", task.QsvPreset.ToString().ToLower()); - } - - // options that apply to all encoders - if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions)) - { - query += string.Format(" -x {0}", task.AdvancedEncoderOptions); - } - - // Options that apply to both x264 and QuickSync - if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264) - { + }
+ }
+
+ // QSV Only
+ if (task.VideoEncoder == VideoEncoder.QuickSync)
+ {
+ query += string.Format(" --qsv-preset={0}", task.QsvPreset.ToString().ToLower());
+ }
+
+ // options that apply to all encoders
+ if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))
+ {
+ query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
+ }
+
+ // Options that apply to both x264 and QuickSync
+ if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264)
+ {
// when using x264 with the advanced panel, the H.264 profile/level widgets are disabled
if (!(task.VideoEncoder == VideoEncoder.X264 && task.ShowAdvancedTab))
{
@@ -985,15 +985,15 @@ namespace HandBrake.ApplicationServices.Utilities if (task.H264Profile != x264Profile.None)
{
query += string.Format(
- " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty)); - } - } - } - - return query; - } - - /// <summary> + " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));
+ }
+ }
+ }
+
+ return query;
+ }
+
+ /// <summary>
/// Generate the Command Line Arguments for any additional advanced options.
/// </summary>
/// <param name="verbosity">
|