/// <summary>\r
/// Start the WCF Service\r
/// </summary>\r
- void Start();\r
+ /// <param name="port">\r
+ /// The port.\r
+ /// </param>\r
+ void Start(string port);\r
\r
/// <summary>\r
/// Stop the WCF Service\r
/// <summary>\r
/// Start the service\r
/// </summary>\r
- public void Start()\r
+ public void Start(string port)\r
{\r
- using (this.host = new ServiceHost(typeof(ServerService), new Uri("net.tcp://localhost:8000")))\r
+ using (this.host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))\r
{\r
// Setup a listener\r
this.host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");\r
this.host.Open();\r
- Console.WriteLine("::: HandBrake Server :::");\r
- Console.WriteLine("Service Started");\r
+ Console.WriteLine("::: HandBrake Isolation Server:::");\r
+ Console.WriteLine("Service Started. Waiting for Clients...");\r
\r
// Setup the services we are going to use.\r
scanService = new ScanService(new UserSettingService()); // TODO this needs wired up with castle\r
namespace HandBrake.Server\r
{\r
using System;\r
+ using System.Linq;\r
\r
using HandBrake.ApplicationServices.Services;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
/// </param>\r
static void Main(string[] args)\r
{\r
- IServerService server = new ServerService();\r
- server.Start();\r
+ if (args.Count() != 1)\r
+ {\r
+ Console.WriteLine("Invalid Arguments");\r
+ Console.ReadLine();\r
+ }\r
+ else\r
+ {\r
+ IServerService server = new ServerService();\r
+ server.Start(args[0]);\r
+ }\r
}\r
}\r
}\r
/// </summary>\r
private readonly IErrorService errorService;\r
\r
+ /// <summary>\r
+ /// The user setting service.\r
+ /// </summary>\r
+ private readonly IUserSettingService userSettingService;\r
+\r
/// <summary>\r
/// Gets or sets the pipe factory.\r
/// DuplexChannelFactory is necessary for Callbacks.\r
/// <param name="errorService">\r
/// The error service.\r
/// </param>\r
- public BackgroundServiceConnector(IErrorService errorService)\r
+ /// <param name="userSettingService">\r
+ /// The user Setting Service.\r
+ /// </param>\r
+ public BackgroundServiceConnector(IErrorService errorService, IUserSettingService userSettingService)\r
{\r
this.errorService = errorService;\r
+ this.userSettingService = userSettingService;\r
}\r
\r
/// <summary>\r
/// </summary>\r
public void Connect()\r
{\r
+ string port = this.userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);\r
+\r
if (backgroundProcess == null)\r
{\r
- // backgroundProcess = Process.Start("HandBrake.Server.exe");\r
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(\r
+ "HandBrake.Server.exe", port)\r
+ {\r
+ UseShellExecute = false,\r
+ CreateNoWindow = false,\r
+ };\r
+\r
+ backgroundProcess = new Process { StartInfo = processStartInfo };\r
+ backgroundProcess.Start();\r
}\r
\r
ThreadPool.QueueUserWorkItem(delegate\r
pipeFactory = new DuplexChannelFactory<IServerService>(\r
new InstanceContext(this),\r
new NetTcpBinding(),\r
- new EndpointAddress("net.tcp://127.0.0.1:8000/IHbService"));\r
+ new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));\r
\r
// Connect and Subscribe to the Server\r
Service = pipeFactory.CreateChannel();\r
/// <param name="errorService">\r
/// The error Service.\r
/// </param>\r
- public IsolatedEncodeService(IErrorService errorService)\r
- : base(errorService)\r
+ /// <param name="userSettingService">\r
+ /// The user Setting Service.\r
+ /// </param>\r
+ public IsolatedEncodeService(IErrorService errorService, IUserSettingService userSettingService)\r
+ : base(errorService, userSettingService)\r
{\r
try\r
{\r
/// <param name="errorService">\r
/// The error Service.\r
/// </param>\r
- public IsolatedScanService(IErrorService errorService) : base(errorService)\r
+ /// <param name="userSettingService">\r
+ /// The user Setting Service.\r
+ /// </param>\r
+ public IsolatedScanService(IErrorService errorService, IUserSettingService userSettingService)\r
+ : base(errorService, userSettingService)\r
{\r
try\r
{\r
/// </summary>\r
public const string VLC_Path = "VLC_Path";\r
\r
+ /// <summary>\r
+ /// The enable process isolation.\r
+ /// </summary>\r
+ public const string EnableProcessIsolation = "EnableProcessIsolation";\r
+\r
+ /// <summary>\r
+ /// The server port.\r
+ /// </summary>\r
+ public const string ServerPort = "ServerPort";\r
+\r
#endregion\r
}\r
}
\ No newline at end of file
/// Initializes a new instance of the <see cref="MainViewModel"/> class.\r
/// The viewmodel for HandBrakes main window.\r
/// </summary>\r
- /// <param name="windowManager">\r
- /// The window manager.\r
- /// </param>\r
/// <param name="userSettingService">\r
/// The User Setting Service\r
/// </param>\r
/// <param name="driveDetectService">\r
/// The drive Detect Service.\r
/// </param>\r
- public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,\r
+ public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,\r
IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService)\r
{\r
GeneralUtilities.SetInstanceId();\r
this.SourceMenu = this.GenerateSourceMenu();\r
\r
this.driveDetectService.StartDetection(this.DriveTrayChanged);\r
+\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation))\r
+ {\r
+ this.EnableIsolationServices();\r
+ }\r
}\r
\r
/// <summary>\r
/// The test isolation services.\r
/// Swaps out the implementation of IScan to the IsolatedScanService version.\r
/// </summary>\r
- public void TestIsolationServices()\r
+ public void EnableIsolationServices()\r
{\r
// Unhook the old services\r
this.scanService.ScanStared -= this.ScanStared;\r
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
\r
// Replace the Services\r
- this.scanService = new IsolatedScanService(this.errorService);\r
- this.encodeService = new IsolatedEncodeService(this.errorService);\r
+ this.scanService = new IsolatedScanService(this.errorService, this.userSettingService);\r
+ this.encodeService = new IsolatedEncodeService(this.errorService, this.userSettingService);\r
this.queueProcessor.SwapEncodeService(this.encodeService);\r
\r
// Add the new Event Hooks\r
using Caliburn.Micro;\r
\r
using HandBrake.ApplicationServices;\r
+ using HandBrake.ApplicationServices.Exceptions;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
using HandBrake.ApplicationServices.Utilities;\r
\r
/// </summary>\r
private UpdateCheckInformation updateInfo;\r
\r
+ /// <summary>\r
+ /// The enable process isolation.\r
+ /// </summary>\r
+ private bool enableProcessIsolation;\r
+\r
+ /// <summary>\r
+ /// The server port.\r
+ /// </summary>\r
+ private int serverPort;\r
+\r
#endregion\r
\r
#region Constructors and Destructors\r
/// <summary>\r
/// Initializes a new instance of the <see cref="OptionsViewModel"/> class.\r
/// </summary>\r
- /// <param name="windowManager">\r
- /// The window manager.\r
- /// </param>\r
/// <param name="userSettingService">\r
/// The user Setting Service.\r
/// </param>\r
/// <param name="updateService">\r
/// The update Service.\r
/// </param>\r
- public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IShellViewModel shellViewModel, IUpdateService updateService )\r
+ public OptionsViewModel(IUserSettingService userSettingService, IShellViewModel shellViewModel, IUpdateService updateService )\r
{\r
this.Title = "Options";\r
this.userSettingService = userSettingService;\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether ClearQueueOnEncodeCompleted.\r
+ /// </summary>\r
+ public bool EnableProcessIsolation\r
+ {\r
+ get\r
+ {\r
+ return this.enableProcessIsolation;\r
+ }\r
+ set\r
+ {\r
+ this.enableProcessIsolation = value;\r
+ this.NotifyOfPropertyChange(() => this.EnableProcessIsolation);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the server port.\r
+ /// </summary>\r
+ public int ServerPort\r
+ {\r
+ get\r
+ {\r
+ return this.serverPort;\r
+ }\r
+ set\r
+ {\r
+ this.serverPort = value;\r
+ this.NotifyOfPropertyChange(() => this.ServerPort);\r
+ }\r
+ }\r
+\r
#endregion\r
\r
#endregion\r
// Min Title Length\r
this.MinLength = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration);\r
\r
- // Use Experimental dvdnav\r
+ // Use dvdnav\r
this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav);\r
+\r
+ int port;\r
+ int.TryParse(userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort), out port);\r
+ this.ServerPort = port;\r
+ this.EnableProcessIsolation = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);\r
}\r
\r
/// <summary>\r
}\r
\r
userSettingService.SetUserSetting(ASUserSettingConstants.DisableLibDvdNav, this.DisableLibdvdNav);\r
+ userSettingService.SetUserSetting(UserSettingConstants.EnableProcessIsolation, this.EnableProcessIsolation);\r
+ userSettingService.SetUserSetting(UserSettingConstants.ServerPort, this.ServerPort.ToString());\r
}\r
\r
/// <summary>\r
<MenuItem Header="Debug" Foreground="Transparent" >\r
<MenuItem Header="Show CLI Equiv" Micro:Message.Attach="[Event Click] = [Action ShowCliQuery]" />\r
<MenuItem Header="Debug Scan Log" Micro:Message.Attach="[Event Click] = [Action DebugScanLog]" />\r
- <MenuItem Header="Test Isolation Service" Micro:Message.Attach="[Event Click] = [Action TestIsolationServices]" />\r
+ <MenuItem Header="Test Isolation Service" Micro:Message.Attach="[Event Click] = [Action EnableIsolationServices]" />\r
</MenuItem>\r
</Menu>\r
\r
</StackPanel>\r
\r
</StackPanel>\r
+\r
+\r
+ <StackPanel Orientation="Vertical" Margin="0,10,0,20">\r
+\r
+ <TextBlock Text="Experimental Features" Grid.Column="0" FontSize="14" Margin="0,0,0,10"/>\r
+ \r
+ <TextBlock Text="These options are for developer testing of features that are currently in progress!!!!" FontWeight="Bold" Margin="0,0,0,10" />\r
+\r
+ <StackPanel Orientation="Vertical" Grid.Column="1" Margin="20,0,0,0">\r
+ <CheckBox Content="Enable Process Isolation (Run Scans and Encodes via an intermediate service)" IsChecked="{Binding EnableProcessIsolation}" />\r
+\r
+ <StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Column="1">\r
+ <TextBlock Text="Server Port:" VerticalAlignment="Center" />\r
+ <TextBox Width="50" MaxLength="5" Text="{Binding ServerPort}" />\r
+ </StackPanel>\r
+ </StackPanel>\r
+\r
+ </StackPanel>\r
</StackPanel>\r
\r
<StackPanel Name="Updates" Orientation="Vertical" Margin="10,10,0,0"\r
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
</value>\r
</item>\r
+\r
+ <item>\r
+ <key>\r
+ <string>ServerPort</string>\r
+ </key>\r
+ <value>\r
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">8000</anyType>\r
+ </value>\r
+ </item>\r
+ <item>\r
+ <key>\r
+ <string>EnableProcessIsolation</string>\r
+ </key>\r
+ <value>\r
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
+ </value>\r
+ </item>\r
</dictionary>
\ No newline at end of file