summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-03-01 17:53:54 +0000
committersr55 <[email protected]>2015-03-01 17:53:54 +0000
commit5cce72f890bc7b6075a55aa4364b8817c22f11c0 (patch)
treec049480c710828c2e5d6375dfcfa03faa48a5f56 /win/CS/HandBrake.ApplicationServices
parent6106f068ddc39e4d8aca10f42dc955cfae183360 (diff)
WinGui: Removing the Isolation code as it's not used, and planned for libhb instead.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6958 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj3
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs179
-rw-r--r--win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs216
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs18
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs4
6 files changed, 3 insertions, 419 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index fccf0154e..7b0c96fd8 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -201,8 +201,6 @@
<Compile Include="Interop\Model\Subtitles.cs" />
<Compile Include="Interop\Model\VideoQualityLimits.cs" />
<Compile Include="Interop\Model\VideoRangeType.cs" />
- <Compile Include="Isolation\BackgroundServiceConnector.cs" />
- <Compile Include="Isolation\IsolatedEncodeService.cs" />
<Compile Include="Services\Encode\Factories\VideoProfileFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoPresetFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoLevelFactory.cs" />
@@ -213,7 +211,6 @@
<Compile Include="Model\VideoScaler.cs" />
<Compile Include="Services\Encode\EventArgs\EncodeCompletedEventArgs.cs" />
<Compile Include="Services\Encode\EventArgs\EncodeProgressEventArgs.cs" />
- <Compile Include="Services\Encode\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoLevel.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoPreset.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
deleted file mode 100644
index 0fa7c2474..000000000
--- a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="BackgroundServiceConnector.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Background Service Connector.
-// HandBrake has the ability to connect to a service app that will control Libhb.
-// This acts as process isolation.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Isolation
-{
- using System;
- using System.Diagnostics;
- using System.ServiceModel;
- using System.Threading;
-
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Interfaces;
-
- /// <summary>
- /// Background Service Connector.
- /// HandBrake has the ability to connect to a service app that will control Libhb.
- /// This acts as process isolation.
- /// </summary>
- public class BackgroundServiceConnector : IHbServiceCallback, IDisposable
- {
- #region Constants and Fields
-
- /// <summary>
- /// Gets or sets the pipe factory.
- /// DuplexChannelFactory is necessary for Callbacks.
- /// </summary>
- private static DuplexChannelFactory<IServerService> pipeFactory;
-
- /// <summary>
- /// The background process.
- /// </summary>
- private static Process backgroundProcess;
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets a value indicating whether is connected.
- /// </summary>
- public bool IsConnected { get; set; }
-
- /// <summary>
- /// Gets or sets the service.
- /// </summary>
- public IServerService Service { get; set; }
-
- #endregion
-
- #region Public Server Management Methods
-
- /// <summary>
- /// The can connect.
- /// </summary>
- /// <returns>
- /// The System.Boolean.
- /// </returns>
- public bool CanConnect()
- {
- return true;
- }
-
- /// <summary>
- /// The connect.
- /// </summary>
- /// <param name="port">
- /// The port.
- /// </param>
- public void Connect(string port)
- {
- if (backgroundProcess == null)
- {
- ProcessStartInfo processStartInfo = new ProcessStartInfo(
- "HandBrake.Server.exe", port)
- {
- UseShellExecute = false,
- CreateNoWindow = true,
- RedirectStandardOutput = true,
- };
-
- backgroundProcess = new Process { StartInfo = processStartInfo };
- backgroundProcess.Start();
- }
-
- // When the process writes out a line, it's pipe server is ready and can be contacted for
- // work. Reading line blocks until this happens.
- backgroundProcess.StandardOutput.ReadLine();
-
- ThreadPool.QueueUserWorkItem(delegate
- {
- try
- {
- pipeFactory = new DuplexChannelFactory<IServerService>(
- new InstanceContext(this),
- new NetTcpBinding(),
- new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));
-
- // Connect and Subscribe to the Server
- this.Service = pipeFactory.CreateChannel();
- this.Service.Subscribe();
- this.IsConnected = true;
- }
- catch (Exception exc)
- {
- throw new GeneralApplicationException("Unable to connect to background worker process", "Please restart HandBrake", exc);
- }
- });
- }
-
- /// <summary>
- /// The disconnect.
- /// </summary>
- public void Shutdown()
- {
- try
- {
- if (backgroundProcess != null && !backgroundProcess.HasExited)
- {
- this.Service.Unsubscribe();
- }
- }
- catch (Exception exc)
- {
- throw new GeneralApplicationException("Unable to disconnect to background worker process",
- "It may have already close. Check for any left over HandBrake.Server.exe processes", exc);
- }
- }
-
- #endregion
-
- #region Implemented Interfaces
-
- /// <summary>
- /// The dispose.
- /// </summary>
- public void Dispose()
- {
- this.Service.Unsubscribe();
- }
-
- /// <summary>
- /// The encode progress callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event Args.
- /// </param>
- public virtual void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)
- {
- }
-
- /// <summary>
- /// The encode completed callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event Args.
- /// </param>
- public virtual void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)
- {
- }
-
- /// <summary>
- /// The encode started callback.
- /// </summary>
- public virtual void EncodeStartedCallback()
- {
- }
-
- #endregion
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
deleted file mode 100644
index a98941b1f..000000000
--- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IsolatedEncodeService.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Isolated Scan Service
-// This is an implementation of the IEncode implementation that runs scans on a seperate process
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Isolation
-{
- using System;
- using System.Threading;
-
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;
-
- /// <summary>
- /// Isolated Scan Service.
- /// This is an implementation of the IEncode implementation that runs scans on a seperate process
- /// </summary>
- public class IsolatedEncodeService : BackgroundServiceConnector, IEncode
- {
- #region Constructors and Destructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="IsolatedEncodeService"/> class.
- /// </summary>
- /// <param name="port">
- /// The port.
- /// </param>
- public IsolatedEncodeService(string port)
- {
- try
- {
- if (this.CanConnect())
- {
- this.Connect(port);
- }
- }
- catch (Exception exception)
- {
- throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
- }
- }
-
- #endregion
-
- #region Events
-
- /// <summary>
- /// The encode completed.
- /// </summary>
- public event EncodeCompletedStatus EncodeCompleted;
-
- /// <summary>
- /// The encode started.
- /// </summary>
- public event EventHandler EncodeStarted;
-
- /// <summary>
- /// The encode status changed.
- /// </summary>
- public event EncodeProgessStatus EncodeStatusChanged;
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- public string ActivityLog
- {
- get
- {
- return this.IsConnected ? this.Service.EncodeActivityLog : "Unable to connect to background worker service ...";
- }
- }
-
- /// <summary>
- /// Gets the log index.
- /// </summary>
- public int LogIndex
- {
- get
- {
- return -1;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether can pause.
- /// </summary>
- public bool CanPause
- {
- get
- {
- return false; // TODO make this work.
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether is pasued.
- /// </summary>
- public bool IsPasued { get; private set; }
-
- /// <summary>
- /// Gets a value indicating whether IsEncoding.
- /// </summary>
- public bool IsEncoding
- {
- get
- {
- return this.IsConnected && this.Service.IsEncoding;
- }
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// The encode completed callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public override void EncodeCompletedCallback(EncodeCompletedEventArgs eventArgs)
- {
- if (this.EncodeCompleted != null)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.EncodeCompleted(this, eventArgs); });
- }
-
- base.EncodeCompletedCallback(eventArgs);
- }
-
- /// <summary>
- /// The encode progress callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public override void EncodeProgressCallback(EncodeProgressEventArgs eventArgs)
- {
- if (this.EncodeStatusChanged != null)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.EncodeStatusChanged(this, eventArgs); });
- }
-
- base.EncodeProgressCallback(eventArgs);
- }
-
- #endregion
-
- #region Implemented Interfaces
-
- #region IEncode
-
- /// <summary>
- /// Copy the log file to the desired destinations
- /// </summary>
- /// <param name="destination">
- /// The destination.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- public void ProcessLogs(string destination, HBConfiguration configuration)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination, configuration); });
- }
-
- /// <summary>
- /// Start with a LibHb EncodeJob Object
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- public void Start(QueueTask job)
- {
- ThreadPool.QueueUserWorkItem(
- delegate { this.Service.StartEncode(job); });
- }
-
- /// <summary>
- /// The pause.
- /// </summary>
- public void Pause()
- {
- }
-
- /// <summary>
- /// The resume.
- /// </summary>
- public void Resume()
- {
- }
-
- /// <summary>
- /// Kill the CLI process
- /// </summary>
- public void Stop()
- {
- ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); });
- }
-
- #endregion
-
- #endregion
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs
deleted file mode 100644
index 6163bcffc..000000000
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <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.Encode.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 7cb0ef7b6..4e5b51d93 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
@@ -55,7 +55,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// <summary>
/// Gets the IEncodeService instance.
/// </summary>
- IEncodeServiceWrapper EncodeService { get; }
+ IEncode EncodeService { get; }
/// <summary>
/// Gets a value indicating whether IsProcessing.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index 991b2132e..ba6a3a92e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -66,7 +66,7 @@ namespace HandBrake.ApplicationServices.Services
/// <exception cref="ArgumentNullException">
/// Services are not setup
/// </exception>
- public QueueProcessor(IEncodeServiceWrapper encodeService)
+ public QueueProcessor(IEncode encodeService)
{
this.EncodeService = encodeService;
@@ -143,7 +143,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Gets the IEncodeService instance.
/// </summary>
- public IEncodeServiceWrapper EncodeService { get; private set; }
+ public IEncode EncodeService { get; private set; }
/// <summary>
/// Gets a value indicating whether IsProcessing.