diff options
author | sr55 <[email protected]> | 2012-08-22 20:11:18 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-08-22 20:11:18 +0000 |
commit | cbe5f09e69c95df3be3b38de06c2b7bd6b5bd949 (patch) | |
tree | 298b9b143b38433e16854089f6afe9d5d59cbe7e /win/CS/HandBrake.ApplicationServices | |
parent | d363a3f1c5f19df252ba1ac118c7bb3bf2bf4e7c (diff) |
WinGui: Initial Work to wire up Encode Process Isolation.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4914 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
12 files changed, 373 insertions, 87 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs index 12f3af2e9..44a66cac7 100644 --- a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs +++ b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs @@ -10,10 +10,12 @@ namespace HandBrake.ApplicationServices.EventArgs
{
using System;
+ using System.Runtime.Serialization;
/// <summary>
/// Encode Progress Event Args
/// </summary>
+ [DataContractAttribute]
public class EncodeCompletedEventArgs : EventArgs
{
/// <summary>
@@ -38,16 +40,19 @@ namespace HandBrake.ApplicationServices.EventArgs /// <summary>
/// Gets or sets a value indicating whether Successful.
/// </summary>
+ [DataMember]
public bool Successful { get; set; }
/// <summary>
/// Gets or sets Exception.
/// </summary>
+ [DataMember]
public Exception Exception { get; set; }
/// <summary>
/// Gets or sets ErrorInformation.
/// </summary>
+ [DataMember]
public string ErrorInformation { get; set; }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs index f4c7e9446..37cb76f25 100644 --- a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs +++ b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs @@ -10,45 +10,54 @@ namespace HandBrake.ApplicationServices.EventArgs
{
using System;
+ using System.Runtime.Serialization;
/// <summary>
/// Encode Progress Event Args
/// </summary>
+ [DataContractAttribute]
public class EncodeProgressEventArgs : EventArgs
{
/// <summary>
/// Gets or sets PercentComplete.
/// </summary>
+ [DataMember]
public float PercentComplete { get; set; }
/// <summary>
/// Gets or sets CurrentFrameRate.
/// </summary>
+ [DataMember]
public float CurrentFrameRate { get; set; }
/// <summary>
/// Gets or sets AverageFrameRate.
/// </summary>
+ [DataMember]
public float AverageFrameRate { get; set; }
/// <summary>
/// Gets or sets EstimatedTimeLeft.
/// </summary>
+ [DataMember]
public TimeSpan EstimatedTimeLeft { get; set; }
/// <summary>
/// Gets or sets Task.
/// </summary>
+ [DataMember]
public int Task { get; set; }
/// <summary>
/// Gets or sets TaskCount.
/// </summary>
+ [DataMember]
public int TaskCount { get; set; }
/// <summary>
/// Gets or sets ElapsedTime.
/// </summary>
+ [DataMember]
public TimeSpan ElapsedTime { get; set; }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index e20215bcf..36b9002bc 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -13,8 +13,6 @@ namespace HandBrake.ApplicationServices.Services.Base using System.IO;
using System.Text;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
@@ -31,17 +29,22 @@ namespace HandBrake.ApplicationServices.Services.Base /// <summary>
/// A Lock for the filewriter
/// </summary>
- private static readonly object fileWriterLock = new object();
+ private static readonly object FileWriterLock = new object();
/// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
+ private readonly IUserSettingService userSettingService;
/// <summary>
/// Windows 7 API Pack wrapper
/// </summary>
- private Win7 windowsSeven = new Win7();
+ private readonly Win7 windowsSeven = new Win7();
+
+ /// <summary>
+ /// The Log File Header
+ /// </summary>
+ private readonly StringBuilder header = GeneralUtilities.CreateCliLogHeader();
/// <summary>
/// The Log Buffer
@@ -53,18 +56,17 @@ namespace HandBrake.ApplicationServices.Services.Base /// </summary>
private StreamWriter fileWriter;
- /// <summary>
- /// The Log File Header
- /// </summary>
- private StringBuilder header = GeneralUtilities.CreateCliLogHeader();
-
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="EncodeBase"/> class.
/// </summary>
- public EncodeBase()
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public EncodeBase(IUserSettingService userSettingService)
{
+ this.userSettingService = userSettingService;
this.logBuffer = new StringBuilder();
}
@@ -310,7 +312,7 @@ namespace HandBrake.ApplicationServices.Services.Base this.LogBuffer.AppendLine(message);
}
- lock (fileWriterLock)
+ lock (FileWriterLock)
{
if (this.fileWriter != null && this.fileWriter.BaseStream.CanWrite)
{
@@ -341,7 +343,7 @@ namespace HandBrake.ApplicationServices.Services.Base {
try
{
- lock (fileWriterLock)
+ lock (FileWriterLock)
{
if (this.fileWriter != null)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index f0f1b656b..98827a6e3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -15,8 +15,6 @@ namespace HandBrake.ApplicationServices.Services using System.Threading;
using System.Windows.Forms;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Base;
@@ -35,7 +33,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
+ private readonly IUserSettingService userSettingService;
/// <summary>
/// Gets The Process Handle
@@ -62,8 +60,13 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Initializes a new instance of the <see cref="Encode"/> class.
/// </summary>
- public Encode()
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public Encode(IUserSettingService userSettingService)
+ : base(userSettingService)
{
+ this.userSettingService = userSettingService;
this.EncodeStarted += this.EncodeEncodeStarted;
GrowlCommunicator.Register();
}
@@ -116,7 +119,7 @@ namespace HandBrake.ApplicationServices.Services if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
- Win32.PreventSleep();
+ // Win32.PreventSleep();
}
// Make sure the path exists, attempt to create it if it doesn't
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs index afb7ca5c3..1d10e3062 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs @@ -42,5 +42,29 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// </summary>
[OperationContract(IsOneWay = true)]
void ScanStartedCallback();
+
+ /// <summary>
+ /// The encode progress callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event Args.
+ /// </param>
+ [OperationContract(IsOneWay = true)]
+ void EncodeProgressCallback(EncodeProgressEventArgs eventArgs);
+
+ /// <summary>
+ /// The encode completed callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event Args.
+ /// </param>
+ [OperationContract(IsOneWay = true)]
+ void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs);
+
+ /// <summary>
+ /// The encode started callback.
+ /// </summary>
+ [OperationContract(IsOneWay = true)]
+ void EncodeStartedCallback();
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs index 22cf365b0..b695bab49 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs @@ -56,5 +56,14 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Requests a pause of the encode queue.
/// </summary>
void Pause();
+
+ /// <summary>
+ /// Swap encode service.
+ /// Temp method until Castle is hooked up.
+ /// </summary>
+ /// <param name="service">
+ /// The service.
+ /// </param>
+ void SwapEncodeService(IEncode service);
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs index 22156e6fc..49eedffa5 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs @@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces using System.Runtime.Serialization;
using System.ServiceModel;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
/// <summary>
@@ -24,7 +25,13 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Gets the activity log.
/// </summary>
[DataMember]
- string ActivityLog { get; }
+ string ScanActivityLog { get; }
+
+ /// <summary>
+ /// Gets the activity log.
+ /// </summary>
+ [DataMember]
+ string EncodeActivityLog { get; }
/// <summary>
/// Gets the souce data.
@@ -38,8 +45,20 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <summary>
/// Gets a value indicating whether is scanning.
/// </summary>
- [DataMember]
- bool IsScanning { get; }
+ bool IsScanning
+ {
+ [OperationContract]
+ get;
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether is encoding.
+ /// </summary>
+ bool IsEncoding
+ {
+ [OperationContract]
+ get;
+ }
/// <summary>
/// Start the WCF Service
@@ -67,6 +86,33 @@ namespace HandBrake.ApplicationServices.Services.Interfaces void ScanSource(string path, int title, int previewCount);
/// <summary>
+ /// Start and Encode
+ /// </summary>
+ /// <param name="job">
+ /// The job.
+ /// </param>
+ /// <param name="enableLogging">
+ /// The enable logging.
+ /// </param>
+ [OperationContract]
+ void StartEncode(QueueTask job, bool enableLogging);
+
+ /// <summary>
+ /// The process encode logs.
+ /// </summary>
+ /// <param name="destination">
+ /// The destination.
+ /// </param>
+ [OperationContract]
+ void ProcessEncodeLogs(string destination);
+
+ /// <summary>
+ /// Stop and Encode
+ /// </summary>
+ [OperationContract]
+ void StopEncode();
+
+ /// <summary>
/// Stop the scan.
/// </summary>
[OperationContract]
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 086305f4e..3ae06bbfd 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -40,7 +40,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
+ private readonly IUserSettingService userSettingService;
/// <summary>
/// The Start time of the current Encode;
@@ -62,8 +62,14 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Initializes a new instance of the <see cref="LibEncode"/> class.
/// </summary>
- public LibEncode()
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public LibEncode(IUserSettingService userSettingService)
+ : base(userSettingService)
{
+ this.userSettingService = userSettingService;
+
// Setup the HandBrake Instance
this.instance = IoC.Get<IHandBrakeInstance>();
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index cd1ff226d..f90aa0ef4 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -11,7 +11,6 @@ namespace HandBrake.ApplicationServices.Services {
using System;
using System.Diagnostics;
- using System.IO;
using System.Windows.Forms;
using Caliburn.Micro;
@@ -181,6 +180,18 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
+ /// Swap encode service.
+ /// Temp method until Castle is hooked up.
+ /// </summary>
+ /// <param name="service">
+ /// The service.
+ /// </param>
+ public void SwapEncodeService(IEncode service)
+ {
+ this.EncodeService = service;
+ }
+
+ /// <summary>
/// After an encode is complete, move onto the next job.
/// </summary>
/// <param name="sender">
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index 025b7c432..9984ade21 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -16,13 +16,15 @@ namespace HandBrake.ApplicationServices.Services using System.Windows;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// HandBrake WCF Service
/// </summary>
- [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Single)]
+ [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true,
+ ConcurrencyMode = ConcurrencyMode.Single)]
public class ServerService : IServerService
{
#region Constants and Fields
@@ -33,6 +35,11 @@ namespace HandBrake.ApplicationServices.Services private static readonly List<IHbServiceCallback> Subscribers = new List<IHbServiceCallback>();
/// <summary>
+ /// The encode service.
+ /// </summary>
+ private static IEncode encodeService;
+
+ /// <summary>
/// The scan service.
/// </summary>
private static IScan scanService;
@@ -44,46 +51,48 @@ namespace HandBrake.ApplicationServices.Services #endregion
- #region Implemented Interfaces
-
- #region IServerService
+ #region Properties
/// <summary>
- /// The scan source.
+ /// Gets the activity log.
/// </summary>
- /// <param name="path">
- /// The path.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- public void ScanSource(string path, int title, int previewCount)
+ [DataMember]
+ public string ActivityLog
{
- Console.WriteLine("Starting Source Scan for: " + path);
- scanService.ScanStared += this.ScanStaredHandler;
- scanService.ScanStatusChanged += this.ScanStatusChangedHandler;
- scanService.ScanCompleted += this.ScanCompletedHandler;
-
- scanService.Scan(path, title, previewCount, null);
+ get
+ {
+ return scanService.ActivityLog;
+ }
}
/// <summary>
/// Gets the activity log.
/// </summary>
+ public string EncodeActivityLog { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating whether is encoding.
+ /// </summary>
+ public bool IsEncoding { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating whether is scanning.
+ /// </summary>
[DataMember]
- public string ActivityLog
+ public bool IsScanning
{
get
{
- return scanService.ActivityLog;
-
+ return scanService.IsScanning;
}
}
/// <summary>
+ /// Gets the activity log.
+ /// </summary>
+ public string ScanActivityLog { get; private set; }
+
+ /// <summary>
/// Gets the souce data.
/// </summary>
[DataMember]
@@ -95,16 +104,43 @@ namespace HandBrake.ApplicationServices.Services }
}
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region IServerService
+
/// <summary>
- /// Gets a value indicating whether is scanning.
+ /// The process encode logs.
/// </summary>
- [DataMember]
- public bool IsScanning
+ /// <param name="destination">
+ /// The destination.
+ /// </param>
+ public void ProcessEncodeLogs(string destination)
{
- get
- {
- return scanService.IsScanning;
- }
+ encodeService.ProcessLogs(destination);
+ }
+
+ /// <summary>
+ /// The scan source.
+ /// </summary>
+ /// <param name="path">
+ /// The path.
+ /// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="previewCount">
+ /// The preview Count.
+ /// </param>
+ public void ScanSource(string path, int title, int previewCount)
+ {
+ Console.WriteLine("Starting Source Scan for: " + path);
+ scanService.ScanStared += this.ScanStaredHandler;
+ scanService.ScanStatusChanged += this.ScanStatusChangedHandler;
+ scanService.ScanCompleted += this.ScanCompletedHandler;
+
+ scanService.Scan(path, title, previewCount, null);
}
/// <summary>
@@ -121,12 +157,31 @@ namespace HandBrake.ApplicationServices.Services Console.WriteLine("Service Started");
// Setup the services we are going to use.
- scanService = new ScanService(new UserSettingService());
+ scanService = new ScanService(new UserSettingService()); // TODO this needs wired up with castle
+ encodeService = new Encode(new UserSettingService());
Console.ReadLine();
}
}
/// <summary>
+ /// Start and Encode
+ /// </summary>
+ /// <param name="job">
+ /// The job.
+ /// </param>
+ /// <param name="enableLogging">
+ /// The enable logging.
+ /// </param>
+ public void StartEncode(QueueTask job, bool enableLogging)
+ {
+ 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);
+ }
+
+ /// <summary>
/// Stop this service
/// </summary>
public void Stop()
@@ -139,6 +194,14 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
+ /// Stop and Encode
+ /// </summary>
+ public void StopEncode()
+ {
+ encodeService.Stop();
+ }
+
+ /// <summary>
/// Stop the scan.
/// </summary>
public void StopScan()
@@ -222,17 +285,17 @@ namespace HandBrake.ApplicationServices.Services {
Subscribers.ForEach(
delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
- Console.WriteLine("Scan Completed Callback");
- callback.ScanCompletedCallback(e);
- }
- else
- {
- Subscribers.Remove(callback);
- }
- });
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Scan Completed Callback");
+ callback.ScanCompletedCallback(e);
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
scanService.ScanStared -= this.ScanStaredHandler;
scanService.ScanStatusChanged -= this.ScanStatusChangedHandler;
@@ -252,17 +315,17 @@ namespace HandBrake.ApplicationServices.Services {
Subscribers.ForEach(
delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
- {
- Console.WriteLine("Scan Started Callback");
- callback.ScanStartedCallback();
- }
- else
{
- Subscribers.Remove(callback);
- }
- });
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Scan Started Callback");
+ callback.ScanStartedCallback();
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
}
/// <summary>
@@ -278,17 +341,99 @@ namespace HandBrake.ApplicationServices.Services {
Subscribers.ForEach(
delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
- Console.WriteLine("Scan Changed Callback");
- callback.ScanProgressCallback(e);
- }
- else
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Scan Changed Callback");
+ callback.ScanProgressCallback(e);
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
+ }
+
+ /// <summary>
+ /// The encode service_ encode completed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
+ {
+ encodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;
+ encodeService.EncodeStarted -= this.encodeService_EncodeStarted;
+ encodeService.EncodeStatusChanged -= this.encodeService_EncodeStatusChanged;
+
+ Subscribers.ForEach(
+ delegate(IHbServiceCallback callback)
{
- Subscribers.Remove(callback);
- }
- });
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Encode Completed Callback");
+ callback.EncodeCompletedCallback(e);
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
+ }
+
+ /// <summary>
+ /// The encode service_ encode started.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void encodeService_EncodeStarted(object sender, EventArgs e)
+ {
+ Subscribers.ForEach(
+ delegate(IHbServiceCallback callback)
+ {
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Encode Started Callback");
+ callback.EncodeStartedCallback();
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
+ }
+
+ /// <summary>
+ /// The encode service_ encode status changed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void encodeService_EncodeStatusChanged(object sender, EncodeProgressEventArgs e)
+ {
+ Subscribers.ForEach(
+ delegate(IHbServiceCallback callback)
+ {
+ if (((ICommunicationObject)callback).State == CommunicationState.Opened)
+ {
+ Console.WriteLine("Encode Status Callback");
+ callback.EncodeProgressCallback(e);
+ }
+ else
+ {
+ Subscribers.Remove(callback);
+ }
+ });
}
#endregion
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 4b50eef1a..b28de2264 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -19,6 +19,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
@@ -31,7 +32,7 @@ namespace HandBrake.ApplicationServices.Utilities /// <summary>
/// Backing field for the user settings service.
/// </summary>
- private static readonly IUserSettingService UserSettingService = IoC.Get<IUserSettingService>();
+ private static IUserSettingService UserSettingService;
/// <summary>
/// Generate a CLI Query for an EncodeTask Model object
@@ -44,6 +45,19 @@ namespace HandBrake.ApplicationServices.Utilities /// </returns>
public static string GenerateQuery(EncodeTask task)
{
+ // TODO Remove this quick hack
+ if (UserSettingService == null)
+ {
+ try
+ {
+ UserSettingService = IoC.Get<IUserSettingService>();
+ }
+ catch (Exception exc)
+ {
+ UserSettingService = new UserSettingService();
+ }
+ }
+
string query = string.Empty;
query += SourceQuery(task, null, null);
query += DestinationQuery(task);
@@ -69,6 +83,19 @@ namespace HandBrake.ApplicationServices.Utilities /// </returns>
public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview)
{
+ // TODO Remove this quick hack
+ if (UserSettingService == null)
+ {
+ try
+ {
+ UserSettingService = IoC.Get<IUserSettingService>();
+ }
+ catch (Exception exc)
+ {
+ UserSettingService = new UserSettingService();
+ }
+ }
+
string query = string.Empty;
query += SourceQuery(task, duration, startAtPreview);
query += DestinationQuery(task);
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index e16274fe6..c13511580 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -10,7 +10,6 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
- using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
|