<Compile Include="Interop\Model\Subtitles.cs" />\r
<Compile Include="Interop\Model\VideoQualityLimits.cs" />\r
<Compile Include="Interop\Model\VideoRangeType.cs" />\r
- <Compile Include="Isolation\BackgroundServiceConnector.cs" />\r
- <Compile Include="Isolation\IsolatedEncodeService.cs" />\r
<Compile Include="Services\Encode\Factories\VideoProfileFactory.cs" />\r
<Compile Include="Services\Encode\Factories\VideoPresetFactory.cs" />\r
<Compile Include="Services\Encode\Factories\VideoLevelFactory.cs" />\r
<Compile Include="Model\VideoScaler.cs" />\r
<Compile Include="Services\Encode\EventArgs\EncodeCompletedEventArgs.cs" />\r
<Compile Include="Services\Encode\EventArgs\EncodeProgressEventArgs.cs" />\r
- <Compile Include="Services\Encode\Interfaces\IEncodeServiceWrapper.cs" />\r
<Compile Include="Services\Encode\Model\Models\Video\VideoLevel.cs" />\r
<Compile Include="Services\Encode\Model\Models\Video\VideoPreset.cs" />\r
<Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />\r
+++ /dev/null
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="BackgroundServiceConnector.cs" company="HandBrake Project (http://handbrake.fr)">\r
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-// Background Service Connector.\r
-// HandBrake has the ability to connect to a service app that will control Libhb.\r
-// This acts as process isolation.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Isolation\r
-{\r
- using System;\r
- using System.Diagnostics;\r
- using System.ServiceModel;\r
- using System.Threading;\r
-\r
- using HandBrake.ApplicationServices.Exceptions;\r
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;\r
- using HandBrake.ApplicationServices.Services.Interfaces;\r
-\r
- /// <summary>\r
- /// Background Service Connector.\r
- /// HandBrake has the ability to connect to a service app that will control Libhb. \r
- /// This acts as process isolation.\r
- /// </summary>\r
- public class BackgroundServiceConnector : IHbServiceCallback, IDisposable\r
- {\r
- #region Constants and Fields\r
-\r
- /// <summary>\r
- /// Gets or sets the pipe factory.\r
- /// DuplexChannelFactory is necessary for Callbacks.\r
- /// </summary>\r
- private static DuplexChannelFactory<IServerService> pipeFactory;\r
-\r
- /// <summary>\r
- /// The background process.\r
- /// </summary>\r
- private static Process backgroundProcess;\r
-\r
- #endregion\r
-\r
- #region Properties\r
-\r
- /// <summary>\r
- /// Gets or sets a value indicating whether is connected.\r
- /// </summary>\r
- public bool IsConnected { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the service.\r
- /// </summary>\r
- public IServerService Service { get; set; }\r
-\r
- #endregion\r
-\r
- #region Public Server Management Methods\r
-\r
- /// <summary>\r
- /// The can connect.\r
- /// </summary>\r
- /// <returns>\r
- /// The System.Boolean.\r
- /// </returns>\r
- public bool CanConnect()\r
- {\r
- return true;\r
- }\r
-\r
- /// <summary>\r
- /// The connect.\r
- /// </summary>\r
- /// <param name="port">\r
- /// The port.\r
- /// </param>\r
- public void Connect(string port)\r
- {\r
- if (backgroundProcess == null)\r
- {\r
- ProcessStartInfo processStartInfo = new ProcessStartInfo(\r
- "HandBrake.Server.exe", port)\r
- {\r
- UseShellExecute = false, \r
- CreateNoWindow = true, \r
- RedirectStandardOutput = true, \r
- };\r
-\r
- backgroundProcess = new Process { StartInfo = processStartInfo };\r
- backgroundProcess.Start();\r
- }\r
-\r
- // When the process writes out a line, it's pipe server is ready and can be contacted for\r
- // work. Reading line blocks until this happens.\r
- backgroundProcess.StandardOutput.ReadLine();\r
-\r
- ThreadPool.QueueUserWorkItem(delegate\r
- {\r
- try\r
- {\r
- pipeFactory = new DuplexChannelFactory<IServerService>(\r
- new InstanceContext(this), \r
- new NetTcpBinding(), \r
- new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));\r
-\r
- // Connect and Subscribe to the Server\r
- this.Service = pipeFactory.CreateChannel();\r
- this.Service.Subscribe();\r
- this.IsConnected = true;\r
- }\r
- catch (Exception exc)\r
- {\r
- throw new GeneralApplicationException("Unable to connect to background worker process", "Please restart HandBrake", exc);\r
- }\r
- });\r
- }\r
-\r
- /// <summary>\r
- /// The disconnect.\r
- /// </summary>\r
- public void Shutdown()\r
- {\r
- try\r
- {\r
- if (backgroundProcess != null && !backgroundProcess.HasExited)\r
- {\r
- this.Service.Unsubscribe();\r
- }\r
- }\r
- catch (Exception exc)\r
- {\r
- throw new GeneralApplicationException("Unable to disconnect to background worker process", \r
- "It may have already close. Check for any left over HandBrake.Server.exe processes", exc);\r
- }\r
- }\r
-\r
- #endregion\r
-\r
- #region Implemented Interfaces\r
-\r
- /// <summary>\r
- /// The dispose.\r
- /// </summary>\r
- public void Dispose()\r
- {\r
- this.Service.Unsubscribe();\r
- }\r
-\r
- /// <summary>\r
- /// The encode progress callback.\r
- /// </summary>\r
- /// <param name="eventArgs">\r
- /// The event Args.\r
- /// </param>\r
- public virtual void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)\r
- {\r
- }\r
-\r
- /// <summary>\r
- /// The encode completed callback.\r
- /// </summary>\r
- /// <param name="eventArgs">\r
- /// The event Args.\r
- /// </param>\r
- public virtual void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)\r
- {\r
- }\r
-\r
- /// <summary>\r
- /// The encode started callback.\r
- /// </summary>\r
- public virtual void EncodeStartedCallback()\r
- {\r
- }\r
-\r
- #endregion\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="IsolatedEncodeService.cs" company="HandBrake Project (http://handbrake.fr)">\r
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-// Isolated Scan Service\r
-// This is an implementation of the IEncode implementation that runs scans on a seperate process\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Isolation\r
-{\r
- using System;\r
- using System.Threading;\r
-\r
- using HandBrake.ApplicationServices.Exceptions;\r
- using HandBrake.ApplicationServices.Model;\r
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;\r
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;\r
-\r
- /// <summary>\r
- /// Isolated Scan Service. \r
- /// This is an implementation of the IEncode implementation that runs scans on a seperate process\r
- /// </summary>\r
- public class IsolatedEncodeService : BackgroundServiceConnector, IEncode\r
- {\r
- #region Constructors and Destructors\r
-\r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="IsolatedEncodeService"/> class. \r
- /// </summary>\r
- /// <param name="port">\r
- /// The port.\r
- /// </param>\r
- public IsolatedEncodeService(string port)\r
- {\r
- try\r
- {\r
- if (this.CanConnect())\r
- {\r
- this.Connect(port);\r
- }\r
- }\r
- catch (Exception exception)\r
- {\r
- throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);\r
- }\r
- }\r
-\r
- #endregion\r
-\r
- #region Events\r
-\r
- /// <summary>\r
- /// The encode completed.\r
- /// </summary>\r
- public event EncodeCompletedStatus EncodeCompleted;\r
-\r
- /// <summary>\r
- /// The encode started.\r
- /// </summary>\r
- public event EventHandler EncodeStarted;\r
-\r
- /// <summary>\r
- /// The encode status changed.\r
- /// </summary>\r
- public event EncodeProgessStatus EncodeStatusChanged;\r
-\r
- #endregion\r
-\r
- #region Properties\r
-\r
- /// <summary>\r
- /// Gets ActivityLog.\r
- /// </summary>\r
- public string ActivityLog\r
- {\r
- get\r
- {\r
- return this.IsConnected ? this.Service.EncodeActivityLog : "Unable to connect to background worker service ...";\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets the log index.\r
- /// </summary>\r
- public int LogIndex\r
- {\r
- get\r
- {\r
- return -1;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a value indicating whether can pause.\r
- /// </summary>\r
- public bool CanPause\r
- {\r
- get\r
- {\r
- return false; // TODO make this work.\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a value indicating whether is pasued.\r
- /// </summary>\r
- public bool IsPasued { get; private set; }\r
-\r
- /// <summary>\r
- /// Gets a value indicating whether IsEncoding.\r
- /// </summary>\r
- public bool IsEncoding\r
- {\r
- get\r
- {\r
- return this.IsConnected && this.Service.IsEncoding;\r
- }\r
- }\r
-\r
- #endregion\r
-\r
- #region Public Methods\r
-\r
- /// <summary>\r
- /// The encode completed callback.\r
- /// </summary>\r
- /// <param name="eventArgs">\r
- /// The event args.\r
- /// </param>\r
- public override void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)\r
- {\r
- if (this.EncodeCompleted != null)\r
- {\r
- ThreadPool.QueueUserWorkItem(delegate { this.EncodeCompleted(this, eventArgs); });\r
- }\r
-\r
- base.EncodeCompletedCallback(eventArgs);\r
- }\r
-\r
- /// <summary>\r
- /// The encode progress callback.\r
- /// </summary>\r
- /// <param name="eventArgs">\r
- /// The event args.\r
- /// </param>\r
- public override void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)\r
- {\r
- if (this.EncodeStatusChanged != null)\r
- {\r
- ThreadPool.QueueUserWorkItem(delegate { this.EncodeStatusChanged(this, eventArgs); });\r
- }\r
-\r
- base.EncodeProgressCallback(eventArgs);\r
- }\r
-\r
- #endregion\r
-\r
- #region Implemented Interfaces\r
-\r
- #region IEncode\r
-\r
- /// <summary>\r
- /// Copy the log file to the desired destinations\r
- /// </summary>\r
- /// <param name="destination">\r
- /// The destination.\r
- /// </param>\r
- /// <param name="configuration">\r
- /// The configuration.\r
- /// </param>\r
- public void ProcessLogs(string destination, HBConfiguration configuration)\r
- {\r
- ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination, configuration); });\r
- }\r
-\r
- /// <summary>\r
- /// Start with a LibHb EncodeJob Object\r
- /// </summary>\r
- /// <param name="job">\r
- /// The job.\r
- /// </param>\r
- public void Start(QueueTask job)\r
- {\r
- ThreadPool.QueueUserWorkItem(\r
- delegate { this.Service.StartEncode(job); });\r
- }\r
-\r
- /// <summary>\r
- /// The pause.\r
- /// </summary>\r
- public void Pause()\r
- {\r
- }\r
-\r
- /// <summary>\r
- /// The resume.\r
- /// </summary>\r
- public void Resume()\r
- {\r
- }\r
-\r
- /// <summary>\r
- /// Kill the CLI process\r
- /// </summary>\r
- public void Stop()\r
- {\r
- ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });\r
- }\r
-\r
- #endregion\r
-\r
- #endregion\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="IEncodeServiceWrapper.cs" company="HandBrake Project (http://handbrake.fr)">\r
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-// IEncodeServiceWrapper Interface\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Services.Encode.Interfaces\r
-{\r
- /// <summary>\r
- /// EncodeServiceWrapper Interface\r
- /// </summary>\r
- public interface IEncodeServiceWrapper : IEncode\r
- {\r
- }\r
-}\r
/// <summary>\r
/// Gets the IEncodeService instance.\r
/// </summary>\r
- IEncodeServiceWrapper EncodeService { get; }\r
+ IEncode EncodeService { get; }\r
\r
/// <summary>\r
/// Gets a value indicating whether IsProcessing.\r
/// <exception cref="ArgumentNullException">\r
/// Services are not setup\r
/// </exception>\r
- public QueueProcessor(IEncodeServiceWrapper encodeService)\r
+ public QueueProcessor(IEncode encodeService)\r
{\r
this.EncodeService = encodeService;\r
\r
/// <summary>\r
/// Gets the IEncodeService instance.\r
/// </summary>\r
- public IEncodeServiceWrapper EncodeService { get; private set; }\r
+ public IEncode EncodeService { get; private set; }\r
\r
/// <summary>\r
/// Gets a value indicating whether IsProcessing.\r
using System;\r
\r
using HandBrake.ApplicationServices.Exceptions;\r
- using HandBrake.ApplicationServices.Isolation;\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Services.Encode;\r
using HandBrake.ApplicationServices.Services.Encode.EventArgs;\r
using HandBrake.ApplicationServices.Services.Encode.Interfaces;\r
\r
- using HandBrakeWPF.Services.Interfaces;\r
-\r
/// <summary>\r
/// We have multiple implementations of Iencode. This is a wrapper class for the GUI so that the \r
/// implementation used is controllable via user settings.\r
/// Over time, this class will go away when the LibHB and process isolation code matures.\r
/// </summary>\r
- public class EncodeServiceWrapper : IEncodeServiceWrapper\r
+ public class EncodeServiceWrapper : IEncode\r
{\r
#region Constants and Fields\r
\r
/// <summary>\r
/// Initializes a new instance of the <see cref="EncodeServiceWrapper"/> class.\r
/// </summary>\r
- /// <param name="userSettingService">\r
- /// The user setting service.\r
- /// </param>\r
- public EncodeServiceWrapper(IUserSettingService userSettingService)\r
+ public EncodeServiceWrapper()\r
{\r
- var useProcessIsolation =\r
- userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);\r
- var port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);\r
-\r
try\r
{\r
- if (useProcessIsolation)\r
- {\r
- this.encodeService = new IsolatedEncodeService(port);\r
- }\r
- else\r
- {\r
- this.encodeService = new LibEncode();\r
- }\r
+ this.encodeService = new LibEncode();\r
}\r
catch (Exception exc)\r
{\r
// Try to recover from errors.\r
throw new GeneralApplicationException(\r
- "Unable to initialise LibHB or Background worker service",\r
- "HandBrake will not be able to operate correctly.",\r
+ "Unable to initialise LibHB or Background worker service", \r
+ "HandBrake will not be able to operate correctly.", \r
exc);\r
}\r
\r
/// <param name="userSettingService">\r
/// The user Setting Service.\r
/// </param>\r
- public NotificationService(IEncodeServiceWrapper encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService)\r
+ public NotificationService(IEncode encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService)\r
{\r
this.userSettingService = userSettingService;\r
// encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;\r
// Services\r
this.windsorContainer.Register(Component.For<IUpdateService>().ImplementedBy<UpdateService>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<IScan>().ImplementedBy<LibScan>().LifeStyle.Is(LifestyleType.Singleton));\r
- this.windsorContainer.Register(Component.For<IEncodeServiceWrapper>().ImplementedBy<EncodeServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));\r
+ this.windsorContainer.Register(Component.For<IEncode>().ImplementedBy<EncodeServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<INotificationService>().ImplementedBy<NotificationService>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<IPrePostActionService>().ImplementedBy<PrePostActionService>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<IUserSettingService>().ImplementedBy<UserSettingService>());\r
/// </summary>\r
public const string VLCPath = "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
/// <summary>\r
/// Growl Encodes\r
/// </summary>\r
/// <summary>\r
/// Backing field for the encodeService service\r
/// </summary>\r
- private readonly IEncodeServiceWrapper encodeService;\r
+ private readonly IEncode encodeService;\r
\r
/// <summary>\r
/// Backing field for the Scan Service\r
/// <param name="scanService">\r
/// The scan service.\r
/// </param>\r
- public LogViewModel(IEncodeServiceWrapper encodeService, IScan scanService)\r
+ public LogViewModel(IEncode encodeService, IScan scanService)\r
{\r
this.encodeService = encodeService;\r
this.scanService = scanService;\r
/// <summary>\r
/// The Encode Service\r
/// </summary>\r
- private readonly IEncodeServiceWrapper encodeService;\r
+ private readonly IEncode encodeService;\r
\r
/// <summary>\r
/// Windows 7 API Pack wrapper\r
/// The when Done Service.\r
/// *** Leave in Constructor. *** \r
/// </param>\r
- public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,\r
+ public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,\r
IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, INotificationService notificationService,\r
IPrePostActionService whenDoneService)\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
/// <summary>\r
/// The show advanced tab backing field.\r
/// </summary>\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
/// <summary>\r
/// Gets or sets a value indicating whether enable lib hb.\r
/// </summary>\r
\r
// Use dvdnav\r
this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(UserSettingConstants.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(UserSettingConstants.DisableLibDvdNav, this.DisableLibdvdNav);\r
- userSettingService.SetUserSetting(UserSettingConstants.EnableProcessIsolation, this.EnableProcessIsolation);\r
- userSettingService.SetUserSetting(UserSettingConstants.ServerPort, this.ServerPort.ToString(CultureInfo.InvariantCulture));\r
}\r
\r
/// <summary>\r
/// <summary>\r
/// Backing field for the encode service.\r
/// </summary>\r
- private readonly IEncodeServiceWrapper encodeService;\r
+ private readonly IEncode encodeService;\r
\r
/// <summary>\r
/// The error service\r
\r
// Live Preview\r
this.userSettingService = userSettingService;\r
- this.encodeService = new EncodeServiceWrapper(userSettingService); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point\r
+ this.encodeService = new EncodeServiceWrapper(); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point\r
\r
this.Title = "Preview";\r
this.Percentage = "0.00%";\r
\r
</StackPanel>\r
\r
-\r
- <StackPanel Orientation="Vertical" Margin="0,10,0,20" Visibility="Visible">\r
-\r
- <TextBlock Text="Encode Engine" FontSize="14" Margin="0,0,0,10" Visibility="Collapsed"/>\r
-\r
- <StackPanel Orientation="Vertical" Margin="20,0,0,0">\r
-\r
-\r
- <CheckBox Content="Enable Process Isolation (Run Encodes via an intermediate service)" Margin="20,10,0,0" IsChecked="{Binding EnableProcessIsolation}" Visibility="Collapsed" />\r
- <StackPanel Orientation="Horizontal" Margin="0,10,0,0" Visibility="Collapsed">\r
- <TextBlock Text="Server Port:" VerticalAlignment="Center" />\r
- <TextBox Width="50" MaxLength="5" Text="{Binding ServerPort}" />\r
- </StackPanel>\r
-\r
- </StackPanel>\r
- </StackPanel>\r
</StackPanel>\r
\r
<StackPanel Name="Updates" Orientation="Vertical" Margin="10,10,0,0"\r