diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/ServerService.cs')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/ServerService.cs | 267 |
1 files changed, 206 insertions, 61 deletions
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
|