diff options
author | sr55 <[email protected]> | 2012-09-01 21:55:29 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-09-01 21:55:29 +0000 |
commit | ccd60c79e7bbe7e961885c8d7eb24a6536aeb670 (patch) | |
tree | 71d09543361e930ee1106498544e2248df4b28c6 | |
parent | c387255346f64661db1119b644c88311db67ba57 (diff) |
WinGui: Further work in the process isolation service.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4927 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/ServerService.cs | 8 | ||||
-rw-r--r-- | win/CS/HandBrake.Server/Program.cs | 13 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs | 25 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs | 6 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/UserSettingConstants.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 16 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 57 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/OptionsView.xaml | 18 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/defaultsettings.xml | 17 |
12 files changed, 158 insertions, 26 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs index 49eedffa5..60d9d0b57 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs @@ -63,7 +63,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// <summary>
/// Start the WCF Service
/// </summary>
- void Start();
+ /// <param name="port">
+ /// The port.
+ /// </param>
+ void Start(string port);
/// <summary>
/// Stop the WCF Service
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index 9984ade21..277a7c5b3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -146,15 +146,15 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Start the service
/// </summary>
- public void Start()
+ public void Start(string port)
{
- using (this.host = new ServiceHost(typeof(ServerService), new Uri("net.tcp://localhost:8000")))
+ using (this.host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))
{
// Setup a listener
this.host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");
this.host.Open();
- Console.WriteLine("::: HandBrake Server :::");
- Console.WriteLine("Service Started");
+ Console.WriteLine("::: HandBrake Isolation Server:::");
+ Console.WriteLine("Service Started. Waiting for Clients...");
// Setup the services we are going to use.
scanService = new ScanService(new UserSettingService()); // TODO this needs wired up with castle
diff --git a/win/CS/HandBrake.Server/Program.cs b/win/CS/HandBrake.Server/Program.cs index baf39e692..3ec5e2248 100644 --- a/win/CS/HandBrake.Server/Program.cs +++ b/win/CS/HandBrake.Server/Program.cs @@ -1,6 +1,7 @@ namespace HandBrake.Server
{
using System;
+ using System.Linq;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -18,8 +19,16 @@ /// </param>
static void Main(string[] args)
{
- IServerService server = new ServerService();
- server.Start();
+ if (args.Count() != 1)
+ {
+ Console.WriteLine("Invalid Arguments");
+ Console.ReadLine();
+ }
+ else
+ {
+ IServerService server = new ServerService();
+ server.Start(args[0]);
+ }
}
}
}
diff --git a/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs index 0d08f2dca..db175b45a 100644 --- a/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs +++ b/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs @@ -36,6 +36,11 @@ namespace HandBrakeWPF.Isolation 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,9 +61,13 @@ namespace HandBrakeWPF.Isolation /// <param name="errorService">
/// The error service.
/// </param>
- public BackgroundServiceConnector(IErrorService errorService)
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public BackgroundServiceConnector(IErrorService errorService, IUserSettingService userSettingService)
{
this.errorService = errorService;
+ this.userSettingService = userSettingService;
}
/// <summary>
@@ -91,9 +100,19 @@ namespace HandBrakeWPF.Isolation /// </summary>
public void Connect()
{
+ string port = this.userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
+
if (backgroundProcess == null)
{
- // backgroundProcess = Process.Start("HandBrake.Server.exe");
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(
+ "HandBrake.Server.exe", port)
+ {
+ UseShellExecute = false,
+ CreateNoWindow = false,
+ };
+
+ backgroundProcess = new Process { StartInfo = processStartInfo };
+ backgroundProcess.Start();
}
ThreadPool.QueueUserWorkItem(delegate
@@ -103,7 +122,7 @@ namespace HandBrakeWPF.Isolation pipeFactory = new DuplexChannelFactory<IServerService>(
new InstanceContext(this),
new NetTcpBinding(),
- new EndpointAddress("net.tcp://127.0.0.1:8000/IHbService"));
+ new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));
// Connect and Subscribe to the Server
Service = pipeFactory.CreateChannel();
diff --git a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs index 3c5363c28..504024b43 100644 --- a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs @@ -34,8 +34,11 @@ namespace HandBrakeWPF.Isolation /// <param name="errorService">
/// The error Service.
/// </param>
- public IsolatedEncodeService(IErrorService errorService)
- : base(errorService)
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public IsolatedEncodeService(IErrorService errorService, IUserSettingService userSettingService)
+ : base(errorService, userSettingService)
{
try
{
diff --git a/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs b/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs index 608b00c21..b50f1b3ea 100644 --- a/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs +++ b/win/CS/HandBrakeWPF/Isolation/IsolatedScanService.cs @@ -60,7 +60,11 @@ namespace HandBrakeWPF.Isolation /// <param name="errorService">
/// The error Service.
/// </param>
- public IsolatedScanService(IErrorService errorService) : base(errorService)
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public IsolatedScanService(IErrorService errorService, IUserSettingService userSettingService)
+ : base(errorService, userSettingService)
{
try
{
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 9397a3e6c..865847d87 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -161,6 +161,16 @@ namespace HandBrakeWPF /// </summary>
public const string VLC_Path = "VLC_Path";
+ /// <summary>
+ /// The enable process isolation.
+ /// </summary>
+ public const string EnableProcessIsolation = "EnableProcessIsolation";
+
+ /// <summary>
+ /// The server port.
+ /// </summary>
+ public const string ServerPort = "ServerPort";
+
#endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 59d442393..a6ae77489 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -166,9 +166,6 @@ namespace HandBrakeWPF.ViewModels /// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// The viewmodel for HandBrakes main window.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
/// <param name="userSettingService">
/// The User Setting Service
/// </param>
@@ -193,7 +190,7 @@ namespace HandBrakeWPF.ViewModels /// <param name="driveDetectService">
/// The drive Detect Service.
/// </param>
- public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
+ public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService)
{
GeneralUtilities.SetInstanceId();
@@ -808,6 +805,11 @@ namespace HandBrakeWPF.ViewModels this.SourceMenu = this.GenerateSourceMenu();
this.driveDetectService.StartDetection(this.DriveTrayChanged);
+
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation))
+ {
+ this.EnableIsolationServices();
+ }
}
/// <summary>
@@ -1181,7 +1183,7 @@ namespace HandBrakeWPF.ViewModels /// The test isolation services.
/// Swaps out the implementation of IScan to the IsolatedScanService version.
/// </summary>
- public void TestIsolationServices()
+ public void EnableIsolationServices()
{
// Unhook the old services
this.scanService.ScanStared -= this.ScanStared;
@@ -1190,8 +1192,8 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
// Replace the Services
- this.scanService = new IsolatedScanService(this.errorService);
- this.encodeService = new IsolatedEncodeService(this.errorService);
+ 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
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 119cb9d10..963abdf60 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -22,6 +22,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
@@ -338,6 +339,16 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private UpdateCheckInformation updateInfo;
+ /// <summary>
+ /// The enable process isolation.
+ /// </summary>
+ private bool enableProcessIsolation;
+
+ /// <summary>
+ /// The server port.
+ /// </summary>
+ private int serverPort;
+
#endregion
#region Constructors and Destructors
@@ -345,9 +356,6 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Initializes a new instance of the <see cref="OptionsViewModel"/> class.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
/// <param name="userSettingService">
/// The user Setting Service.
/// </param>
@@ -357,7 +365,7 @@ namespace HandBrakeWPF.ViewModels /// <param name="updateService">
/// The update Service.
/// </param>
- public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IShellViewModel shellViewModel, IUpdateService updateService )
+ public OptionsViewModel(IUserSettingService userSettingService, IShellViewModel shellViewModel, IUpdateService updateService )
{
this.Title = "Options";
this.userSettingService = userSettingService;
@@ -1313,6 +1321,38 @@ namespace HandBrakeWPF.ViewModels }
}
+ /// <summary>
+ /// Gets or sets a value indicating whether ClearQueueOnEncodeCompleted.
+ /// </summary>
+ public bool EnableProcessIsolation
+ {
+ get
+ {
+ return this.enableProcessIsolation;
+ }
+ set
+ {
+ this.enableProcessIsolation = value;
+ this.NotifyOfPropertyChange(() => this.EnableProcessIsolation);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the server port.
+ /// </summary>
+ public int ServerPort
+ {
+ get
+ {
+ return this.serverPort;
+ }
+ set
+ {
+ this.serverPort = value;
+ this.NotifyOfPropertyChange(() => this.ServerPort);
+ }
+ }
+
#endregion
#endregion
@@ -1601,8 +1641,13 @@ namespace HandBrakeWPF.ViewModels // Min Title Length
this.MinLength = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration);
- // Use Experimental dvdnav
+ // Use dvdnav
this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav);
+
+ int port;
+ int.TryParse(userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort), out port);
+ this.ServerPort = port;
+ this.EnableProcessIsolation = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
}
/// <summary>
@@ -1817,6 +1862,8 @@ namespace HandBrakeWPF.ViewModels }
userSettingService.SetUserSetting(ASUserSettingConstants.DisableLibDvdNav, this.DisableLibdvdNav);
+ userSettingService.SetUserSetting(UserSettingConstants.EnableProcessIsolation, this.EnableProcessIsolation);
+ userSettingService.SetUserSetting(UserSettingConstants.ServerPort, this.ServerPort.ToString());
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index c7f6c14c4..fdf204744 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -134,7 +134,7 @@ <MenuItem Header="Debug" Foreground="Transparent" >
<MenuItem Header="Show CLI Equiv" Micro:Message.Attach="[Event Click] = [Action ShowCliQuery]" />
<MenuItem Header="Debug Scan Log" Micro:Message.Attach="[Event Click] = [Action DebugScanLog]" />
- <MenuItem Header="Test Isolation Service" Micro:Message.Attach="[Event Click] = [Action TestIsolationServices]" />
+ <MenuItem Header="Test Isolation Service" Micro:Message.Attach="[Event Click] = [Action EnableIsolationServices]" />
</MenuItem>
</Menu>
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index f8a853476..7c3ead9cf 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -331,6 +331,24 @@ </StackPanel>
</StackPanel>
+
+
+ <StackPanel Orientation="Vertical" Margin="0,10,0,20">
+
+ <TextBlock Text="Experimental Features" Grid.Column="0" FontSize="14" Margin="0,0,0,10"/>
+
+ <TextBlock Text="These options are for developer testing of features that are currently in progress!!!!" FontWeight="Bold" Margin="0,0,0,10" />
+
+ <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}" />
+
+ <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}" />
+ </StackPanel>
+ </StackPanel>
+
+ </StackPanel>
</StackPanel>
<StackPanel Name="Updates" Orientation="Vertical" Margin="10,10,0,0"
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index 6bd00ae0d..03dbccef2 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -440,4 +440,21 @@ <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>ServerPort</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">8000</anyType>
+ </value>
+ </item>
+ <item>
+ <key>
+ <string>EnableProcessIsolation</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 |