summaryrefslogtreecommitdiffstats
path: root/win/CS
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
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')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs (renamed from win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs)105
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs (renamed from win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs)31
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs (renamed from win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs)33
-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
-rw-r--r--win/CS/HandBrake10.sln8
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj10
-rw-r--r--win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedEncodeService.cs24
-rw-r--r--win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedScanService.cs24
-rw-r--r--win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs257
-rw-r--r--win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs243
-rw-r--r--win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs5
-rw-r--r--win/CS/HandBrakeWPF/UserSettingConstants.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs54
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs23
-rw-r--r--win/CS/HandBrakeWPF/Views/Images/warningsmall.pngbin0 -> 618 bytes
-rw-r--r--win/CS/HandBrakeWPF/Views/OptionsView.xaml3
-rw-r--r--win/CS/HandBrakeWPF/defaultsettings.xml8
28 files changed, 715 insertions, 254 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/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
index 13bf132ee..4044e8a61 100644
--- a/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
@@ -9,7 +9,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrakeWPF.Isolation
+namespace HandBrake.ApplicationServices.Isolation
{
using System;
using System.Diagnostics;
@@ -17,10 +17,9 @@ namespace HandBrakeWPF.Isolation
using System.Threading;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Services.Interfaces;
- using HandBrakeWPF.Services.Interfaces;
-
/// <summary>
/// Background Service Connector.
/// HandBrake has the ability to connect to a service app that will control HandBrakeCLI or Libhb.
@@ -31,16 +30,6 @@ namespace HandBrakeWPF.Isolation
#region Constants and Fields
/// <summary>
- /// The error service.
- /// </summary>
- private readonly IErrorService errorService;
-
- /// <summary>
- /// The user setting service.
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// Gets or sets the pipe factory.
/// DuplexChannelFactory is necessary for Callbacks.
/// </summary>
@@ -56,21 +45,6 @@ namespace HandBrakeWPF.Isolation
#region Properties
/// <summary>
- /// Initializes a new instance of the <see cref="BackgroundServiceConnector"/> class.
- /// </summary>
- /// <param name="errorService">
- /// The error service.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public BackgroundServiceConnector(IErrorService errorService, IUserSettingService userSettingService)
- {
- this.errorService = errorService;
- this.userSettingService = userSettingService;
- }
-
- /// <summary>
/// Gets or sets a value indicating whether is connected.
/// </summary>
public bool IsConnected { get; set; }
@@ -98,10 +72,11 @@ namespace HandBrakeWPF.Isolation
/// <summary>
/// The connect.
/// </summary>
- public void Connect()
+ /// <param name="port">
+ /// The port.
+ /// </param>
+ public void Connect(string port)
{
- string port = this.userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
-
if (backgroundProcess == null)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo(
@@ -130,13 +105,13 @@ namespace HandBrakeWPF.Isolation
new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));
// Connect and Subscribe to the Server
- Service = pipeFactory.CreateChannel();
- Service.Subscribe();
- IsConnected = true;
+ this.Service = pipeFactory.CreateChannel();
+ this.Service.Subscribe();
+ this.IsConnected = true;
}
catch (Exception exc)
{
- Caliburn.Micro.Execute.OnUIThread(() => this.errorService.ShowError("Unable to connect to background worker service", "Please restart HandBrake", exc));
+ throw new GeneralApplicationException("Unable to connect to background worker process", "Please restart HandBrake", exc);
}
});
}
@@ -144,74 +119,24 @@ namespace HandBrakeWPF.Isolation
/// <summary>
/// The disconnect.
/// </summary>
- public void Disconnect()
+ public void Shutdown()
{
try
{
if (backgroundProcess != null && !backgroundProcess.HasExited)
{
- Service.Unsubscribe();
+ this.Service.Unsubscribe();
}
}
catch (Exception exc)
{
- this.errorService.ShowError("Unable to disconnect from service", "It may have already close. Check for any left over HandBrake.Server.exe processes", 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 Public Service Methods
-
- ///// <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)
- //{
- // ThreadPool.QueueUserWorkItem(delegate { this.Service.ScanSource(path, title, previewCount); });
- //}
-
- ///// <summary>
- ///// The stop scan.
- ///// </summary>
- //public void StopScan()
- //{
- // ThreadPool.QueueUserWorkItem(delegate { this.Service.StopScan(); });
- //}
-
- ///// <summary>
- ///// Start an Encode
- ///// </summary>
- ///// <param name="job">
- ///// The job.
- ///// </param>
- ///// <param name="enableLogging">
- ///// The enable logging.
- ///// </param>
- //public void StartEncode(QueueTask job, bool enableLogging)
- //{
- // ThreadPool.QueueUserWorkItem(delegate { this.Service.StartEncode(job, enableLogging); });
- //}
-
- ///// <summary>
- ///// Stop an Encode
- ///// </summary>
- //public void StopEncode()
- //{
- // ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
- //}
-
- #endregion
-
#region Implemented Interfaces
#region IDisposable
@@ -221,7 +146,7 @@ namespace HandBrakeWPF.Isolation
/// </summary>
public void Dispose()
{
- Service.Unsubscribe();
+ this.Service.Unsubscribe();
}
#endregion
diff --git a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
index 322d30f9f..6806e2844 100644
--- a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
@@ -8,49 +8,42 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrakeWPF.Isolation
+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;
- using HandBrakeWPF.Isolation.Interfaces;
- using HandBrakeWPF.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, IIsolatedEncodeService
+ public class IsolatedEncodeService : BackgroundServiceConnector, IEncode
{
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="IsolatedEncodeService"/> class.
/// </summary>
- /// <param name="errorService">
- /// The error Service.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
+ /// <param name="port">
+ /// The port.
/// </param>
- public IsolatedEncodeService(IErrorService errorService, IUserSettingService userSettingService)
- : base(errorService, userSettingService)
+ public IsolatedEncodeService(string port)
{
try
{
if (this.CanConnect())
{
- this.Connect();
+ this.Connect(port);
}
}
catch (Exception exception)
{
- errorService.ShowError(
- "Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
+ throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
}
}
@@ -149,7 +142,7 @@ namespace HandBrakeWPF.Isolation
/// </param>
public void ProcessLogs(string destination)
{
- ThreadPool.QueueUserWorkItem(delegate { Service.ProcessEncodeLogs(destination); });
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination); });
}
/// <summary>
@@ -159,7 +152,7 @@ namespace HandBrakeWPF.Isolation
/// </summary>
public void SafelyStop()
{
- ThreadPool.QueueUserWorkItem(delegate { Service.StopEncode(); });
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
}
/// <summary>
@@ -174,7 +167,7 @@ namespace HandBrakeWPF.Isolation
public void Start(QueueTask job, bool enableLogging)
{
ThreadPool.QueueUserWorkItem(
- delegate { Service.StartEncode(job, enableLogging); });
+ delegate { this.Service.StartEncode(job, enableLogging); });
}
/// <summary>
@@ -182,7 +175,7 @@ namespace HandBrakeWPF.Isolation
/// </summary>
public void Stop()
{
- ThreadPool.QueueUserWorkItem(delegate { Service.StopEncode(); });
+ ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
}
#endregion
diff --git a/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs
index b50f1b3ea..dcef0cc44 100644
--- a/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs
@@ -8,23 +8,21 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrakeWPF.Isolation
+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;
- using HandBrakeWPF.Isolation.Interfaces;
- using HandBrakeWPF.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, IIsolatedScanService
+ public class IsolatedScanService : BackgroundServiceConnector, IScan
{
#region Constants and Fields
@@ -57,26 +55,21 @@ namespace HandBrakeWPF.Isolation
/// <summary>
/// Initializes a new instance of the <see cref="IsolatedScanService"/> class.
/// </summary>
- /// <param name="errorService">
- /// The error Service.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
+ /// <param name="port">
+ /// The port.
/// </param>
- public IsolatedScanService(IErrorService errorService, IUserSettingService userSettingService)
- : base(errorService, userSettingService)
+ public IsolatedScanService(string port)
{
try
{
if (this.CanConnect())
{
- this.Connect();
+ this.Connect(port);
}
}
catch (Exception exception)
{
- errorService.ShowError(
- "Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
+ throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
}
}
@@ -89,7 +82,7 @@ namespace HandBrakeWPF.Isolation
{
get
{
- return Service.ScanActivityLog;
+ return this.Service.ScanActivityLog;
}
}
@@ -100,7 +93,7 @@ namespace HandBrakeWPF.Isolation
{
get
{
- return Service.IsScanning;
+ return this.Service.IsScanning;
}
}
@@ -111,7 +104,7 @@ namespace HandBrakeWPF.Isolation
{
get
{
- return Service.SouceData;
+ return this.Service.SouceData;
}
}
@@ -205,7 +198,7 @@ namespace HandBrakeWPF.Isolation
public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
{
this.postScanAction = postAction;
- Service.ScanSource(sourcePath, title, previewCount);
+ this.Service.ScanSource(sourcePath, title, previewCount);
}
/// <summary>
@@ -213,7 +206,7 @@ namespace HandBrakeWPF.Isolation
/// </summary>
public void Stop()
{
- Service.StopScan();
+ this.Service.StopScan();
}
#endregion
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
diff --git a/win/CS/HandBrake10.sln b/win/CS/HandBrake10.sln
index 97de9a5d0..4878465ae 100644
--- a/win/CS/HandBrake10.sln
+++ b/win/CS/HandBrake10.sln
@@ -44,12 +44,14 @@ Global
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|Mixed Platforms.Build.0 = Debug|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|x64.ActiveCfg = Debug|x64
+ {DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|x64.Build.0 = Debug|x64
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|x86.ActiveCfg = Debug|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Debug|x86.Build.0 = Debug|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|Any CPU.ActiveCfg = Release|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|Mixed Platforms.ActiveCfg = Release|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|Mixed Platforms.Build.0 = Release|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|x64.ActiveCfg = Release|x64
+ {DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|x64.Build.0 = Release|x64
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|x86.ActiveCfg = Release|x86
{DADE66CB-0E12-4959-ADE5-0ACD31D27C59}.Release|x86.Build.0 = Release|x86
{F0A61F62-2C3B-4A87-AFF4-0C4256253DA1}.Debug|Any CPU.ActiveCfg = Debug|x86
@@ -69,13 +71,15 @@ Global
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|Any CPU.ActiveCfg = Debug|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|x64.ActiveCfg = Debug|x86
+ {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|x64.ActiveCfg = Debug|x64
+ {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|x64.Build.0 = Debug|x64
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|x86.ActiveCfg = Debug|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Debug|x86.Build.0 = Debug|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|Any CPU.ActiveCfg = Release|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|Mixed Platforms.ActiveCfg = Release|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|Mixed Platforms.Build.0 = Release|x86
- {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|x64.ActiveCfg = Release|x86
+ {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|x64.ActiveCfg = Release|x64
+ {36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|x64.Build.0 = Release|x64
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|x86.ActiveCfg = Release|x86
{36847BA0-6814-41E1-B1C3-1D9D874418E9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index dcaf10f3d..bae0eff7a 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -55,7 +55,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x64\Debug\</OutputPath>
+ <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
@@ -128,18 +128,15 @@
<Compile Include="Converters\Options\OptionsTabConverter.cs" />
<Compile Include="Converters\Subtitles\SubtitlesQueueDisplayConverter.cs" />
<Compile Include="Converters\Video\VideoEncoderConverter.cs" />
- <Compile Include="Isolation\BackgroundServiceConnector.cs" />
- <Compile Include="Isolation\IsolatedEncodeService.cs" />
- <Compile Include="Isolation\Interfaces\IIsolatedEncodeService.cs" />
- <Compile Include="Isolation\Interfaces\IIsolatedScanService.cs" />
- <Compile Include="Isolation\IsolatedScanService.cs" />
<Compile Include="Services\DriveDetectService.cs" />
+ <Compile Include="Services\EncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IDriveDetectService.cs" />
<Compile Include="Model\ShellWindow.cs" />
<Compile Include="Model\SourceMenuItem.cs" />
<Compile Include="Model\UpdateCheckInformation.cs" />
<Compile Include="Model\DownloadStatus.cs" />
<Compile Include="Services\Interfaces\IUpdateService.cs" />
+ <Compile Include="Services\ScanServiceWrapper.cs" />
<Compile Include="Services\UpdateService.cs" />
<Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon>
@@ -368,6 +365,7 @@
<Content Include="defaultsettings.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <Resource Include="Views\Images\warningsmall.png" />
<Resource Include="Views\Images\Refresh.ico" />
<Resource Include="Views\Images\Complete.png" />
<Resource Include="Views\Images\Working0.png" />
diff --git a/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedEncodeService.cs b/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedEncodeService.cs
deleted file mode 100644
index fb9912ccf..000000000
--- a/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedEncodeService.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IIsolatedEncodeService.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>
-// The Isolated Encode Service interface.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Isolation.Interfaces
-{
- using HandBrake.ApplicationServices.Services.Interfaces;
-
- /// <summary>
- /// The Isolated Encode Service interface.
- /// </summary>
- public interface IIsolatedEncodeService : IEncode
- {
- /// <summary>
- /// The disconnect.
- /// </summary>
- void Disconnect();
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedScanService.cs b/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedScanService.cs
deleted file mode 100644
index 7b94deb58..000000000
--- a/win/CS/HandBrakeWPF/Isolation/Interfaces/IIsolatedScanService.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IIsolatedScanService.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>
-// The Isolated Scan Service interface.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Isolation.Interfaces
-{
- using HandBrake.ApplicationServices.Services.Interfaces;
-
- /// <summary>
- /// The Isolated Scan Service interface.
- /// </summary>
- public interface IIsolatedScanService : IScan
- {
- /// <summary>
- /// The disconnect.
- /// </summary>
- void Disconnect();
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs
new file mode 100644
index 000000000..79d79164f
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs
@@ -0,0 +1,257 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="EncodeServiceWrapper.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>
+// We have multiple implementations of IEncode. This is a wrapper class for the GUI so that the
+// implementation used is controllable via user settings.
+// Over time, this class will go away when the LibHB and process isolation code matures.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services
+{
+ using System;
+
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Exceptions;
+ using HandBrake.ApplicationServices.Isolation;
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Interfaces;
+
+ using EncodeCompletedEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs;
+ using EncodeProgressEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs;
+
+ /// <summary>
+ /// We have multiple implementations of Iencode. This is a wrapper class for the GUI so that the
+ /// implementation used is controllable via user settings.
+ /// Over time, this class will go away when the LibHB and process isolation code matures.
+ /// </summary>
+ public class EncodeServiceWrapper : IEncodeServiceWrapper
+ {
+ #region Constants and Fields
+
+ /// <summary>
+ /// The encode service.
+ /// </summary>
+ private readonly IEncode encodeService;
+
+ #endregion
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EncodeServiceWrapper"/> class.
+ /// </summary>
+ /// <param name="userSettingService">
+ /// The user setting service.
+ /// </param>
+ public EncodeServiceWrapper(IUserSettingService userSettingService)
+ {
+ var useLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb);
+ var useProcessIsolation =
+ userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
+ var port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
+
+ if (useLibHb)
+ {
+ try
+ {
+ if (useProcessIsolation)
+ {
+ this.encodeService = new IsolatedEncodeService(port);
+ }
+ else
+ {
+ IHandBrakeInstance handBrakeInstance = IoC.Get<IHandBrakeInstance>();
+ this.encodeService = new LibEncode(userSettingService, handBrakeInstance);
+ }
+ }
+ catch (Exception exc)
+ {
+ // Try to recover from errors.
+ userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false);
+ throw new GeneralApplicationException(
+ "Unable to initialise LibHB or Background worker service",
+ "Falling back to using HandBrakeCLI.exe. Setting has been reset",
+ exc);
+ }
+ }
+ else
+ {
+ this.encodeService = new Encode(userSettingService);
+ }
+
+ this.encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
+ this.encodeService.EncodeStarted += this.EncodeServiceEncodeStarted;
+ this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
+ }
+
+ #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.encodeService.ActivityLog;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether IsEncoding.
+ /// </summary>
+ public bool IsEncoding
+ {
+ get
+ {
+ return this.encodeService.IsEncoding;
+ }
+ }
+
+ #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)
+ {
+ this.encodeService.ProcessLogs(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()
+ {
+ this.encodeService.SafelyStop();
+ }
+
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ this.encodeService.Shutdown();
+ this.encodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;
+ this.encodeService.EncodeStarted -= this.EncodeServiceEncodeStarted;
+ this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
+ }
+
+ /// <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)
+ {
+ this.encodeService.Start(job, enableLogging);
+ }
+
+ /// <summary>
+ /// Kill the CLI process
+ /// </summary>
+ public void Stop()
+ {
+ this.encodeService.Stop();
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// The encode service_ encode completed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EncodeCompletedEventArgs.
+ /// </param>
+ private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
+ {
+ if (EncodeCompleted != null)
+ {
+ this.EncodeCompleted(sender, e);
+ }
+ }
+
+ /// <summary>
+ /// The encode service_ encode started.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void EncodeServiceEncodeStarted(object sender, EventArgs e)
+ {
+ if (EncodeStarted != null)
+ {
+ this.EncodeStarted(sender, e);
+ }
+ }
+
+ /// <summary>
+ /// The encode service_ encode status changed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EncodeProgressEventArgs.
+ /// </param>
+ private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e)
+ {
+ if (EncodeStatusChanged != null)
+ {
+ this.EncodeStatusChanged(sender, e);
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs
new file mode 100644
index 000000000..a25213a6b
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs
@@ -0,0 +1,243 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ScanServiceWrapper.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>
+// We have multiple implementations of IScan. This is a wrapper class for the GUI so that the
+// implementation used is controllable via user settings.
+// Over time, this class will go away when the LibHB and process isolation code matures.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services
+{
+ using System;
+
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Exceptions;
+ using HandBrake.ApplicationServices.Isolation;
+ using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Interfaces;
+
+ /// <summary>
+ /// We have multiple implementations of IScan. This is a wrapper class for the GUI so that the
+ /// implementation used is controllable via user settings.
+ /// Over time, this class will go away when the LibHB and process isolation code matures.
+ /// </summary>
+ public class ScanServiceWrapper : IScanServiceWrapper
+ {
+ #region Constants and Fields
+
+ /// <summary>
+ /// The scan service.
+ /// </summary>
+ private readonly IScan scanService;
+
+ #endregion
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScanServiceWrapper"/> class.
+ /// </summary>
+ /// <param name="userSettingService">
+ /// The user setting service.
+ /// </param>
+ public ScanServiceWrapper(IUserSettingService userSettingService)
+ {
+ var useLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb);
+ var useProcessIsolation =
+ userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
+ string port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
+
+ if (useLibHb)
+ {
+ try
+ {
+ if (useProcessIsolation)
+ {
+ this.scanService = new IsolatedScanService(port);
+ }
+ else
+ {
+ IHandBrakeInstance handBrakeInstance = IoC.Get<IHandBrakeInstance>();
+ this.scanService = new LibScan(userSettingService, handBrakeInstance);
+ }
+ }
+ catch(Exception exc)
+ {
+ // Try to recover from errors.
+ userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false);
+ throw new GeneralApplicationException("Unable to initialise LibHB or Background worker service", "Falling back to using HandBrakeCLI.exe. Setting has been reset", exc);
+ }
+ }
+ else
+ {
+ this.scanService = new ScanService(userSettingService);
+ }
+
+ this.scanService.ScanCompleted += this.ScanServiceScanCompleted;
+ this.scanService.ScanStared += this.ScanServiceScanStared;
+ this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
+ }
+
+ /// <summary>
+ /// The scan service scan status changed event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The ScanProgressEventArgs.
+ /// </param>
+ private void ScanServiceScanStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs e)
+ {
+ this.ScanStatusChanged(sender, e);
+ }
+
+ /// <summary>
+ /// The scan service scan stared event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void ScanServiceScanStared(object sender, EventArgs e)
+ {
+ this.ScanStared(sender, e);
+ }
+
+ /// <summary>
+ /// The scan service scan completed event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The ScanCompletedEventArgs
+ /// </param>
+ private void ScanServiceScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)
+ {
+ this.ScanCompleted(sender, e);
+ }
+
+ #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
+
+ #region Properties
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ public string ActivityLog
+ {
+ get
+ {
+ return this.scanService.ActivityLog;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether IsScanning.
+ /// </summary>
+ public bool IsScanning
+ {
+ get
+ {
+ return this.scanService.IsScanning;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Souce Data.
+ /// </summary>
+ public Source SouceData
+ {
+ get
+ {
+ return this.scanService.SouceData;
+ }
+ }
+
+ #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)
+ {
+ this.scanService.DebugScanLog(path);
+ }
+
+ /// <summary>
+ /// Shutdown the service.
+ /// </summary>
+ public void Shutdown()
+ {
+ this.scanService.Shutdown();
+ }
+
+ /// <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.scanService.Scan(sourcePath, title, previewCount, postAction);
+ }
+
+ /// <summary>
+ /// Kill the scan
+ /// </summary>
+ public void Stop()
+ {
+ this.scanService.Stop();
+ }
+
+ #endregion
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
index dadae2026..e34f98ada 100644
--- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
+++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
@@ -21,6 +21,8 @@ namespace HandBrakeWPF.Startup
using Castle.Windsor;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop;
using ViewModels;
using ViewModels.Interfaces;
@@ -49,11 +51,14 @@ namespace HandBrakeWPF.Startup
// Initialise the ApplicationServices IWindsorInstaller
this.windsorContainer.Register(Component.For<IWindsorInstaller>().ImplementedBy<ServicesWindsorInstaller>());
+ this.windsorContainer.Register(Component.For<IWindsorInstaller>().ImplementedBy<InteropWindsorInstaller>());
this.windsorContainer.Install(windsorContainer.ResolveAll<IWindsorInstaller>());
// Services
this.windsorContainer.Register(Component.For<IUpdateService>().ImplementedBy<UpdateService>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IDriveDetectService>().ImplementedBy<DriveDetectService>().LifeStyle.Is(LifestyleType.Singleton));
+ this.windsorContainer.Register(Component.For<IScanServiceWrapper>().ImplementedBy<ScanServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));
+ this.windsorContainer.Register(Component.For<IEncodeServiceWrapper>().ImplementedBy<EncodeServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));
// Shell
this.windsorContainer.Register(Component.For<IErrorService>().ImplementedBy<ErrorService>().LifeStyle.Is(LifestyleType.Singleton));
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs
index 77cd9ab8f..440b65bf5 100644
--- a/win/CS/HandBrakeWPF/UserSettingConstants.cs
+++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs
@@ -176,6 +176,11 @@ namespace HandBrakeWPF
/// </summary>
public const string EnableDebugFeatures = "EnableDebugFeatures";
+ /// <summary>
+ /// Enable the use of LibHb instead of HandBrakeCLI
+ /// </summary>
+ public const string EnableLibHb = "EnableLibHb";
+
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 86c8d3a14..a0e9d62c2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -29,8 +29,6 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.Commands;
using HandBrakeWPF.Helpers;
- using HandBrakeWPF.Isolation;
- using HandBrakeWPF.Isolation.Interfaces;
using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -85,12 +83,12 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// The Source Scan Service.
/// </summary>
- private IScan scanService;
+ private readonly IScanServiceWrapper scanService;
/// <summary>
/// The Encode Service
/// </summary>
- private IEncode encodeService;
+ private readonly IEncodeServiceWrapper encodeService;
/// <summary>
/// HandBrakes Main Window Title
@@ -191,7 +189,7 @@ namespace HandBrakeWPF.ViewModels
/// <param name="driveDetectService">
/// The drive Detect Service.
/// </param>
- public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
+ public MainViewModel(IUserSettingService userSettingService, IScanServiceWrapper scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,
IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService)
{
GeneralUtilities.SetInstanceId();
@@ -817,11 +815,6 @@ namespace HandBrakeWPF.ViewModels
this.SourceMenu = this.GenerateSourceMenu();
this.driveDetectService.StartDetection(this.DriveTrayChanged);
-
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation))
- {
- this.EnableIsolationServices();
- }
}
/// <summary>
@@ -832,19 +825,8 @@ namespace HandBrakeWPF.ViewModels
// Shutdown Service
this.driveDetectService.Close();
- IIsolatedScanService isolatedScanService = this.scanService as IsolatedScanService;
- if (isolatedScanService != null)
- {
- // Kill any background services for this instance of HandBrake.
- isolatedScanService.Disconnect();
- }
-
- IIsolatedEncodeService isolatedEncodeService = this.encodeService as IIsolatedEncodeService;
- if (isolatedEncodeService != null)
- {
- // Kill any background services for this instance of HandBrake.
- isolatedEncodeService.Disconnect();
- }
+ this.scanService.Shutdown();
+ this.encodeService.Shutdown();
// Unsubscribe from Events.
this.scanService.ScanStared -= this.ScanStared;
@@ -977,7 +959,6 @@ namespace HandBrakeWPF.ViewModels
this.errorService.ShowMessageBox("There are jobs on the queue with the same destination path. Please choose a different path for this job.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
}
-
if (!this.IsEncoding)
{
this.ProgramStatusLabel = string.Format("{0} Encodes Pending", this.queueProcessor.QueueManager.Count);
@@ -1111,7 +1092,6 @@ namespace HandBrakeWPF.ViewModels
return;
}
-
if (File.Exists(this.Destination))
{
MessageBoxResult result = this.errorService.ShowMessageBox("The current file already exists, do you wish to overwrite it?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
@@ -1200,30 +1180,6 @@ namespace HandBrakeWPF.ViewModels
}
}
- /// <summary>
- /// The test isolation services.
- /// Swaps out the implementation of IScan to the IsolatedScanService version.
- /// </summary>
- public void EnableIsolationServices()
- {
- // Unhook the old services
- this.scanService.ScanStared -= this.ScanStared;
- this.scanService.ScanCompleted -= this.ScanCompleted;
- this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
- this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
-
- // Replace the Services
- this.scanService = new IsolatedScanService(this.errorService, this.userSettingService);
- this.encodeService = new IsolatedEncodeService(this.errorService, this.userSettingService);
- this.queueProcessor.SwapEncodeService(this.encodeService);
-
- // Add the new Event Hooks
- this.scanService.ScanStared += this.ScanStared;
- this.scanService.ScanCompleted += this.ScanCompleted;
- this.scanService.ScanStatusChanged += this.ScanStatusChanged;
- this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
- }
-
#endregion
#region Main Window Public Methods
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 7b65a5ef8..1bd773bc0 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -354,6 +354,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool enableDebugFeatures;
+ /// <summary>
+ /// Backing field for EnableLibHb
+ /// </summary>
+ private bool enableLibHb;
+
#endregion
#region Constructors and Destructors
@@ -1374,6 +1379,22 @@ namespace HandBrakeWPF.ViewModels
}
}
+ /// <summary>
+ /// Gets or sets a value indicating whether enable lib hb.
+ /// </summary>
+ public bool EnableLibHb
+ {
+ get
+ {
+ return this.enableLibHb;
+ }
+ set
+ {
+ this.enableLibHb = value;
+ this.NotifyOfPropertyChange(() => this.EnableLibHb);
+ }
+ }
+
#endregion
#endregion
@@ -1670,6 +1691,7 @@ namespace HandBrakeWPF.ViewModels
this.ServerPort = port;
this.EnableProcessIsolation = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
this.EnableDebugFeatures = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableDebugFeatures);
+ this.EnableLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb);
}
/// <summary>
@@ -1887,6 +1909,7 @@ namespace HandBrakeWPF.ViewModels
userSettingService.SetUserSetting(UserSettingConstants.EnableProcessIsolation, this.EnableProcessIsolation);
userSettingService.SetUserSetting(UserSettingConstants.ServerPort, this.ServerPort.ToString());
userSettingService.SetUserSetting(UserSettingConstants.EnableDebugFeatures, this.EnableDebugFeatures);
+ userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, this.EnableLibHb);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Views/Images/warningsmall.png b/win/CS/HandBrakeWPF/Views/Images/warningsmall.png
new file mode 100644
index 000000000..78f246f04
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Views/Images/warningsmall.png
Binary files differ
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
index d0135db47..4412c7bfb 100644
--- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
@@ -337,7 +337,8 @@
<StackPanel Orientation="Vertical" Grid.Column="1" Margin="20,0,0,0">
<CheckBox Content="Enable Process Isolation (Run Scans and Encodes via an intermediate service)" IsChecked="{Binding EnableProcessIsolation}" />
-
+ <CheckBox Content="Enable LibHB (uses hb.dll instead of HandBrakeCLI.exe)" Margin="0,5,0,0" IsChecked="{Binding EnableLibHb}" />
+
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Column="1">
<TextBlock Text="Server Port:" VerticalAlignment="Center" />
<TextBox Width="50" MaxLength="5" Text="{Binding ServerPort}" />
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml
index 0c995c9e9..80a1e6e2c 100644
--- a/win/CS/HandBrakeWPF/defaultsettings.xml
+++ b/win/CS/HandBrakeWPF/defaultsettings.xml
@@ -465,4 +465,12 @@
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
</value>
</item>
+ <item>
+ <key>
+ <string>EnableLibHb</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
+ </value>
+ </item>
</dictionary> \ No newline at end of file