diff options
author | sr55 <[email protected]> | 2018-06-10 13:46:17 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2018-06-10 13:46:17 +0100 |
commit | dd89061cef5a1f586ae5d8637bdedf2fc00c5d83 (patch) | |
tree | 7a6ce9f2741806135daf19a4be07f00be924a2fa /win/CS/HandBrakeWPF/Instance | |
parent | f40358afcf1cd4f3aa3301389b86db191c5cee2e (diff) |
WinGui: Stub the RemoteInstance implementation of IEncodeInstance.
Diffstat (limited to 'win/CS/HandBrakeWPF/Instance')
-rw-r--r-- | win/CS/HandBrakeWPF/Instance/RemoteInstance.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs new file mode 100644 index 000000000..bfefb6caf --- /dev/null +++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs @@ -0,0 +1,88 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="RemoteInstance.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> +// An Implementation of IEncodeInstance that works with a remote process rather than locally in-process. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Instance +{ + using System; + using System.Diagnostics; + + using HandBrake.Interop.Interop.EventArgs; + using HandBrake.Interop.Interop.Interfaces; + using HandBrake.Interop.Interop.Json.Encode; + + public class RemoteInstance : IEncodeInstance + { + private Process workerProcess; + + public event EventHandler<EncodeCompletedEventArgs> EncodeCompleted; + + public event EventHandler<EncodeProgressEventArgs> EncodeProgress; + + public void PauseEncode() + { + throw new NotImplementedException(); + } + + public void ResumeEncode() + { + throw new NotImplementedException(); + } + + public void StartEncode(JsonEncodeObject jobToStart) + { + throw new NotImplementedException(); + } + + public void StopEncode() + { + throw new NotImplementedException(); + } + + protected virtual void OnEncodeCompleted(EncodeCompletedEventArgs e) + { + this.EncodeCompleted?.Invoke(this, e); + } + + protected virtual void OnEncodeProgress(EncodeProgressEventArgs e) + { + this.EncodeProgress?.Invoke(this, e); + } + + private void StartServer() + { + if (this.workerProcess == null || this.workerProcess.HasExited) + { + this.workerProcess = new Process(); + + // TODO Take default port from preferences, then find a usable port thereafter. + this.workerProcess.StartInfo = + new ProcessStartInfo("HandBrake.Worker.exe", "--port=8080") + { + WindowStyle = ProcessWindowStyle.Normal + }; + + this.workerProcess.Start(); + this.workerProcess.Exited += this.WorkerProcess_Exited; + } + } + + private void WorkerProcess_Exited(object sender, EventArgs e) + { + Debug.WriteLine("Worker Process has exited"); + } + + private void StopServer() + { + if (this.workerProcess != null && !this.workerProcess.HasExited) + { + this.workerProcess.Kill(); + } + } + } +} |