summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-09-25 15:23:17 +0000
committersr55 <[email protected]>2012-09-25 15:23:17 +0000
commit83af0dca6f4ecc16d5a4dcc6b6ccd97b707f7156 (patch)
tree5deeb98145f9fccd54ccf05007a06702e9197271 /win/CS/HandBrake.ApplicationServices
parentc9c4474cc265ea02f25fc5e94b161705402ab807 (diff)
WinGui: LibHb Encode and Scan support (off by default for the moment until I have time to test this and tidy up some of the code) Can be turned on in preferences.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4980 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs214
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs185
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs216
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs8
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs18
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScanServiceWrapper.cs18
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs21
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibScan.cs20
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs8
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs11
-rw-r--r--win/CS/HandBrake.ApplicationServices/ServicesWindsorInstaller.cs4
15 files changed, 732 insertions, 19 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 463ccc4ca..402448984 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -20,12 +20,12 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Debug\</OutputPath>
+ <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Release\</OutputPath>
+ <OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
@@ -33,12 +33,12 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
+ <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
+ <OutputPath>bin\Release\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
@@ -105,7 +105,12 @@
<Compile Include="EventArgs\ScanCompletedEventArgs.cs" />
<Compile Include="EventArgs\ScanProgressEventArgs.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
+ <Compile Include="Isolation\BackgroundServiceConnector.cs" />
+ <Compile Include="Isolation\IsolatedEncodeService.cs" />
+ <Compile Include="Isolation\IsolatedScanService.cs" />
+ <Compile Include="Services\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IHbServiceCallback.cs" />
+ <Compile Include="Services\Interfaces\IScanServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IServerService.cs" />
<Compile Include="Services\ServerService.cs" />
<Compile Include="Utilities\Converters.cs" />
@@ -185,7 +190,6 @@
<ProjectReference Include="..\HandBrake.Interop\HandBrakeInterop\HandBrakeInterop.csproj">
<Project>{F0A61F62-2C3B-4A87-AFF4-0C4256253DA1}</Project>
<Name>HandBrakeInterop</Name>
- <EmbedInteropTypes>False</EmbedInteropTypes>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
new file mode 100644
index 000000000..4044e8a61
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
@@ -0,0 +1,214 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="BackgroundServiceConnector.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>
+// Background Service Connector.
+// HandBrake has the ability to connect to a service app that will control HandBrakeCLI or Libhb.
+// This acts as process isolation.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Isolation
+{
+ using System;
+ using System.Diagnostics;
+ using System.ServiceModel;
+ using System.Threading;
+
+ using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ /// <summary>
+ /// Background Service Connector.
+ /// HandBrake has the ability to connect to a service app that will control HandBrakeCLI or Libhb.
+ /// This acts as process isolation.
+ /// </summary>
+ public class BackgroundServiceConnector : IHbServiceCallback, IDisposable
+ {
+ #region Constants and Fields
+
+ /// <summary>
+ /// Gets or sets the pipe factory.
+ /// DuplexChannelFactory is necessary for Callbacks.
+ /// </summary>
+ private static DuplexChannelFactory<IServerService> pipeFactory;
+
+ /// <summary>
+ /// The background process.
+ /// </summary>
+ private static Process backgroundProcess;
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets a value indicating whether is connected.
+ /// </summary>
+ public bool IsConnected { get; set; }
+
+ /// <summary>
+ /// Gets or sets the service.
+ /// </summary>
+ public IServerService Service { get; set; }
+
+ #endregion
+
+ #region Public Server Management Methods
+
+ /// <summary>
+ /// The can connect.
+ /// </summary>
+ /// <returns>
+ /// The System.Boolean.
+ /// </returns>
+ public bool CanConnect()
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// The connect.
+ /// </summary>
+ /// <param name="port">
+ /// The port.
+ /// </param>
+ public void Connect(string port)
+ {
+ if (backgroundProcess == null)
+ {
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(
+ "HandBrake.Server.exe", port)
+ {
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ RedirectStandardOutput = true,
+ };
+
+ backgroundProcess = new Process { StartInfo = processStartInfo };
+ backgroundProcess.Start();
+ }
+
+ // When the process writes out a line, it's pipe server is ready and can be contacted for
+ // work. Reading line blocks until this happens.
+ backgroundProcess.StandardOutput.ReadLine();
+
+ ThreadPool.QueueUserWorkItem(delegate
+ {
+ try
+ {
+ pipeFactory = new DuplexChannelFactory<IServerService>(
+ new InstanceContext(this),
+ new NetTcpBinding(),
+ new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));
+
+ // Connect and Subscribe to the Server
+ this.Service = pipeFactory.CreateChannel();
+ this.Service.Subscribe();
+ this.IsConnected = true;
+ }
+ catch (Exception exc)
+ {
+ throw new GeneralApplicationException("Unable to connect to background worker process", "Please restart HandBrake", exc);
+ }
+ });
+ }
+
+ /// <summary>
+ /// The disconnect.
+ /// </summary>
+ public void Shutdown()
+ {
+ try
+ {
+ if (backgroundProcess != null && !backgroundProcess.HasExited)
+ {
+ this.Service.Unsubscribe();
+ }
+ }
+ catch (Exception exc)
+ {
+ throw new GeneralApplicationException("Unable to disconnect to background worker process",
+ "It may have already close. Check for any left over HandBrake.Server.exe processes", exc);
+ }
+ }
+
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region IDisposable
+
+ /// <summary>
+ /// The dispose.
+ /// </summary>
+ public void Dispose()
+ {
+ this.Service.Unsubscribe();
+ }
+
+ #endregion
+
+ #region IHbServiceCallback
+
+ /// <summary>
+ /// The scan completed.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public virtual void ScanCompletedCallback(ScanCompletedEventArgs eventArgs)
+ {
+ }
+
+ /// <summary>
+ /// The scan progress.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public virtual void ScanProgressCallback(ScanProgressEventArgs eventArgs)
+ {
+ }
+
+ /// <summary>
+ /// The scan started callback.
+ /// </summary>
+ public virtual void ScanStartedCallback()
+ {
+ }
+
+ /// <summary>
+ /// The encode progress callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event Args.
+ /// </param>
+ public virtual void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)
+ {
+ }
+
+ /// <summary>
+ /// The encode completed callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event Args.
+ /// </param>
+ public virtual void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)
+ {
+ }
+
+ /// <summary>
+ /// The encode started callback.
+ /// </summary>
+ public virtual void EncodeStartedCallback()
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
new file mode 100644
index 000000000..6806e2844
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
@@ -0,0 +1,185 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IsolatedEncodeService.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>
+// Isolated Scan Service
+// This is an implementation of the IEncode implementation that runs scans on a seperate process
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Isolation
+{
+ using System;
+ using System.Threading;
+
+ using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ /// <summary>
+ /// Isolated Scan Service.
+ /// This is an implementation of the IEncode implementation that runs scans on a seperate process
+ /// </summary>
+ public class IsolatedEncodeService : BackgroundServiceConnector, IEncode
+ {
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IsolatedEncodeService"/> class.
+ /// </summary>
+ /// <param name="port">
+ /// The port.
+ /// </param>
+ public IsolatedEncodeService(string port)
+ {
+ try
+ {
+ if (this.CanConnect())
+ {
+ this.Connect(port);
+ }
+ }
+ catch (Exception exception)
+ {
+ throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
+ }
+ }
+
+ #endregion
+
+ #region Events
+
+ /// <summary>
+ /// The encode completed.
+ /// </summary>
+ public event EncodeCompletedStatus EncodeCompleted;
+
+ /// <summary>
+ /// The encode started.
+ /// </summary>
+ public event EventHandler EncodeStarted;
+
+ /// <summary>
+ /// The encode status changed.
+ /// </summary>
+ public event EncodeProgessStatus EncodeStatusChanged;
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ public string ActivityLog
+ {
+ get
+ {
+ return this.IsConnected ? this.Service.EncodeActivityLog : "Unable to connect to background worker service ...";
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether IsEncoding.
+ /// </summary>
+ public bool IsEncoding
+ {
+ get
+ {
+ return this.IsConnected && this.Service.IsEncoding;
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ /// <summary>
+ /// The encode completed callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public override void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)
+ {
+ if (this.EncodeCompleted != null)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.EncodeCompleted(this, eventArgs); });
+ }
+
+ base.EncodeCompletedCallback(eventArgs);
+ }
+
+ /// <summary>
+ /// The encode progress callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public override void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)
+ {
+ if (this.EncodeStatusChanged != null)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.EncodeStatusChanged(this, eventArgs); });
+ }
+
+ base.EncodeProgressCallback(eventArgs);
+ }
+
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region IEncode
+
+ /// <summary>
+ /// Copy the log file to the desired destinations
+ /// </summary>
+ /// <param name="destination">
+ /// The destination.
+ /// </param>
+ public void ProcessLogs(string destination)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination); });
+ }
+
+ /// <summary>
+ /// Attempt to Safely kill a DirectRun() CLI
+ /// NOTE: This will not work with a MinGW CLI
+ /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html
+ /// </summary>
+ public void SafelyStop()
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
+ }
+
+ /// <summary>
+ /// Start with a LibHb EncodeJob Object
+ /// </summary>
+ /// <param name="job">
+ /// The job.
+ /// </param>
+ /// <param name="enableLogging">
+ /// The enable Logging.
+ /// </param>
+ public void Start(QueueTask job, bool enableLogging)
+ {
+ ThreadPool.QueueUserWorkItem(
+ delegate { this.Service.StartEncode(job, enableLogging); });
+ }
+
+ /// <summary>
+ /// Kill the CLI process
+ /// </summary>
+ public void Stop()
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
+ }
+
+ #endregion
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs
new file mode 100644
index 000000000..dcef0cc44
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs
@@ -0,0 +1,216 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IsolatedScanService.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>
+// Isolated Scan Service
+// This is an implementation of the IScan implementation that runs scans on a seperate process
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Isolation
+{
+ using System;
+ using System.Threading;
+
+ using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
+ using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ /// <summary>
+ /// Isolated Scan Service.
+ /// This is an implementation of the IScan implementation that runs scans on a seperate process
+ /// </summary>
+ public class IsolatedScanService : BackgroundServiceConnector, IScan
+ {
+ #region Constants and Fields
+
+ /// <summary>
+ /// The post action.
+ /// </summary>
+ private Action<bool> postScanAction;
+
+ #endregion
+
+ #region Events
+
+ /// <summary>
+ /// The scan completed.
+ /// </summary>
+ public event ScanCompletedStatus ScanCompleted;
+
+ /// <summary>
+ /// The scan stared.
+ /// </summary>
+ public event EventHandler ScanStared;
+
+ /// <summary>
+ /// The scan status changed.
+ /// </summary>
+ public event ScanProgessStatus ScanStatusChanged;
+
+ #endregion
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IsolatedScanService"/> class.
+ /// </summary>
+ /// <param name="port">
+ /// The port.
+ /// </param>
+ public IsolatedScanService(string port)
+ {
+ try
+ {
+ if (this.CanConnect())
+ {
+ this.Connect(port);
+ }
+ }
+ catch (Exception exception)
+ {
+ throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
+ }
+ }
+
+ #region Properties
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ public string ActivityLog
+ {
+ get
+ {
+ return this.Service.ScanActivityLog;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether IsScanning.
+ /// </summary>
+ public bool IsScanning
+ {
+ get
+ {
+ return this.Service.IsScanning;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Souce Data.
+ /// </summary>
+ public Source SouceData
+ {
+ get
+ {
+ return this.Service.SouceData;
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ /// <summary>
+ /// The scan completed callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public override void ScanCompletedCallback(ScanCompletedEventArgs eventArgs)
+ {
+ if (this.postScanAction != null)
+ {
+ this.postScanAction(true);
+ }
+
+ if (this.ScanCompleted != null)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.ScanCompleted(this, eventArgs); });
+ }
+
+ base.ScanCompletedCallback(eventArgs);
+ }
+
+ /// <summary>
+ /// The scan progress callback.
+ /// </summary>
+ /// <param name="eventArgs">
+ /// The event args.
+ /// </param>
+ public override void ScanProgressCallback(ScanProgressEventArgs eventArgs)
+ {
+ if (this.ScanStatusChanged != null)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.ScanStatusChanged(this, eventArgs); });
+ }
+
+ base.ScanProgressCallback(eventArgs);
+ }
+
+ /// <summary>
+ /// The scan started callback.
+ /// </summary>
+ public override void ScanStartedCallback()
+ {
+ if (this.ScanStared != null)
+ {
+ ThreadPool.QueueUserWorkItem(delegate { this.ScanStared(this, EventArgs.Empty); });
+ }
+
+ base.ScanStartedCallback();
+ }
+
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region IScan
+
+ /// <summary>
+ /// Take a Scan Log file, and process it as if it were from the CLI.
+ /// </summary>
+ /// <param name="path">
+ /// The path to the log file.
+ /// </param>
+ public void DebugScanLog(string path)
+ {
+ throw new NotImplementedException("Not available in process isolation mode!");
+ }
+
+ /// <summary>
+ /// Scan a Source Path.
+ /// Title 0: scan all
+ /// </summary>
+ /// <param name="sourcePath">
+ /// Path to the file to scan
+ /// </param>
+ /// <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>
+ public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
+ {
+ this.postScanAction = postAction;
+ this.Service.ScanSource(sourcePath, title, previewCount);
+ }
+
+ /// <summary>
+ /// Kill the scan
+ /// </summary>
+ public void Stop()
+ {
+ this.Service.StopScan();
+ }
+
+ #endregion
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
index fa21353ed..49ff66bd2 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
@@ -264,6 +264,14 @@ namespace HandBrake.ApplicationServices.Services
//}*/
}
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ // Nothing to do.
+ }
+
#endregion
#region Private Helper Methods
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
index 426cad897..eddc49d9b 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
@@ -96,5 +96,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// The destination.
/// </param>
void ProcessLogs(string destination);
+
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ void Shutdown();
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs
new file mode 100644
index 000000000..95f20e455
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IEncodeServiceWrapper.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>
+// IEncodeServiceWrapper Interface
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Interfaces
+{
+ /// <summary>
+ /// EncodeServiceWrapper Interface
+ /// </summary>
+ public interface IEncodeServiceWrapper : IEncode
+ {
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
index b695bab49..dd5746387 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
@@ -34,7 +34,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// <summary>
/// Gets the IEncodeService instance.
/// </summary>
- IEncode EncodeService { get; }
+ IEncodeServiceWrapper EncodeService { get; }
/// <summary>
/// Gets the IQueueManager instance.
@@ -64,6 +64,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// <param name="service">
/// The service.
/// </param>
- void SwapEncodeService(IEncode service);
+ void SwapEncodeService(IEncodeServiceWrapper service);
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
index cd69084eb..59213e5d0 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
@@ -101,5 +101,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// The path to the log file.
/// </param>
void DebugScanLog(string path);
+
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ void Shutdown();
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScanServiceWrapper.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScanServiceWrapper.cs
new file mode 100644
index 000000000..febe4aa29
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScanServiceWrapper.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IScanServiceWrapper.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>
+// ScanServiceWrapper Interface
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Interfaces
+{
+ /// <summary>
+ /// ScanServiceWrapper Interface
+ /// </summary>
+ public interface IScanServiceWrapper : IScan
+ {
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
index 404a47fac..5c3deb80f 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
@@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Services
using System;
using System.Diagnostics;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Base;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -163,7 +164,7 @@ namespace HandBrake.ApplicationServices.Services
}
catch (Exception exc)
{
- this.Invoke_encodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured in EncodeService.Run()"));
+ this.Invoke_encodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured."));
}
}
@@ -184,7 +185,15 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
public override void Stop(Exception exc)
{
- this.instance.StopEncode();
+ try
+ {
+ this.IsEncoding = false;
+ this.instance.StopEncode();
+ }
+ catch(Exception)
+ {
+ // Do Nothing.
+ }
this.Invoke_encodeCompleted(
exc == null
@@ -202,6 +211,14 @@ namespace HandBrake.ApplicationServices.Services
throw new NotImplementedException("This Method is not used in the LibEncode service. You should use the Stop() method instead! ");
}
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ // Nothing to do for this implementation.
+ }
+
#region HandBrakeInstance Event Handlers.
/// <summary>
/// Log a message
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
index 73f5fca57..c3598d922 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
@@ -183,6 +183,14 @@ namespace HandBrake.ApplicationServices.Services
throw new NotImplementedException("Only Available when using the CLI mode. Not LibHB");
}
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ // Nothing to do for this implementation.
+ }
+
#endregion
#region Private Methods
@@ -205,7 +213,8 @@ namespace HandBrake.ApplicationServices.Services
{
this.logging.Clear();
- string source = sourcePath.ToString().EndsWith("\\") ? sourcePath.ToString() : "\"" + sourcePath + "\"";
+ string source = sourcePath.ToString().EndsWith("\\") ? string.Format("\"{0}\\\\\"", sourcePath.ToString().TrimEnd('\\'))
+ : "\"" + sourcePath + "\"";
currentSourceScanPath = source;
IsScanning = true;
@@ -240,7 +249,14 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
private void InstanceScanCompleted(object sender, EventArgs e)
{
- this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = currentSourceScanPath};
+ // TODO -> Might be a better place to fix this.
+ string path = currentSourceScanPath;
+ if (currentSourceScanPath.Contains("\""))
+ {
+ path = currentSourceScanPath.Trim('\"');
+ }
+
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path };
IsScanning = false;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index bbb085916..29eba5172 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -43,7 +43,7 @@ namespace HandBrake.ApplicationServices.Services
/// <exception cref="ArgumentNullException">
/// Services are not setup
/// </exception>
- public QueueProcessor(IQueueManager queueManager, IEncode encodeService, IUserSettingService userSettingService)
+ public QueueProcessor(IQueueManager queueManager, IEncodeServiceWrapper encodeService, IUserSettingService userSettingService)
{
this.userSettingService = userSettingService;
this.QueueManager = queueManager;
@@ -147,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Gets the IEncodeService instance.
/// </summary>
- public IEncode EncodeService { get; private set; }
+ public IEncodeServiceWrapper EncodeService { get; private set; }
/// <summary>
/// Gets the IQueueManager instance.
@@ -188,7 +188,7 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="service">
/// The service.
/// </param>
- public void SwapEncodeService(IEncode service)
+ public void SwapEncodeService(IEncodeServiceWrapper service)
{
this.EncodeService = service;
}
@@ -260,8 +260,8 @@ namespace HandBrake.ApplicationServices.Services
QueueTask job = this.QueueManager.GetNextJobForProcessing();
if (job != null)
{
- this.EncodeService.Start(job, true);
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
+ this.EncodeService.Start(job, true);
}
else
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
index 9eb05eb39..e2ce19ff0 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -16,8 +16,6 @@ namespace HandBrake.ApplicationServices.Services
using System.Threading;
using System.Windows.Forms;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Parsing;
@@ -194,6 +192,15 @@ namespace HandBrake.ApplicationServices.Services
throw new GeneralApplicationException("Debug Run Failed", string.Empty, e);
}
}
+
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ // Nothing to do for this implementation.
+ }
+
#endregion
#region Private Methods
diff --git a/win/CS/HandBrake.ApplicationServices/ServicesWindsorInstaller.cs b/win/CS/HandBrake.ApplicationServices/ServicesWindsorInstaller.cs
index 6d5b40ef6..d2e0f0bb7 100644
--- a/win/CS/HandBrake.ApplicationServices/ServicesWindsorInstaller.cs
+++ b/win/CS/HandBrake.ApplicationServices/ServicesWindsorInstaller.cs
@@ -33,8 +33,8 @@ namespace HandBrake.ApplicationServices
container.Register(Component.For<IQueueManager>().ImplementedBy<QueueManager>());
container.Register(Component.For<IQueueProcessor>().ImplementedBy<QueueProcessor>());
container.Register(Component.For<IUserSettingService>().ImplementedBy<UserSettingService>());
- container.Register(Component.For<IScan>().ImplementedBy<ScanService>());
- container.Register(Component.For<IEncode>().ImplementedBy<Encode>());
+ // container.Register(Component.For<IScan>().ImplementedBy<ScanService>());
+ // container.Register(Component.For<IEncode>().ImplementedBy<Encode>());
}
#endregion