From dd89061cef5a1f586ae5d8637bdedf2fc00c5d83 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 10 Jun 2018 13:46:17 +0100 Subject: WinGui: Stub the RemoteInstance implementation of IEncodeInstance. --- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 + win/CS/HandBrakeWPF/Instance/RemoteInstance.cs | 88 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Instance/RemoteInstance.cs (limited to 'win') diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 0131e9297..1c1d4da42 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -153,6 +153,7 @@ + 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 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// An Implementation of IEncodeInstance that works with a remote process rather than locally in-process. +// +// -------------------------------------------------------------------------------------------------------------------- + +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 EncodeCompleted; + + public event EventHandler 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(); + } + } + } +} -- cgit v1.2.3