summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Worker/ApiRouter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.Worker/ApiRouter.cs')
-rw-r--r--win/CS/HandBrake.Worker/ApiRouter.cs52
1 files changed, 24 insertions, 28 deletions
diff --git a/win/CS/HandBrake.Worker/ApiRouter.cs b/win/CS/HandBrake.Worker/ApiRouter.cs
index 876680848..79b0ad262 100644
--- a/win/CS/HandBrake.Worker/ApiRouter.cs
+++ b/win/CS/HandBrake.Worker/ApiRouter.cs
@@ -14,34 +14,40 @@ namespace HandBrake.Worker
using System.Net;
using HandBrake.Interop.Interop;
+ using HandBrake.Interop.Interop.Json.State;
using HandBrake.Interop.Utilities;
using Newtonsoft.Json;
public class ApiRouter
{
+ private readonly JsonSerializerSettings jsonNetSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
private HandBrakeInstance handbrakeInstance;
- public string GetVersionInfo(HttpListenerRequest request)
+ public string Initialise(HttpListenerRequest request)
{
- JsonSerializerSettings settings =
- new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
+ if (this.handbrakeInstance == null)
+ {
+ this.handbrakeInstance = new HandBrakeInstance();
+ }
+
+ // TODO support verbosity
+ this.handbrakeInstance.Initialize(1);
+
+ return null;
+ }
- string versionInfo = JsonConvert.SerializeObject((object)VersionHelper.GetVersion(), Formatting.Indented, settings);
+ public string GetVersionInfo(HttpListenerRequest request)
+ {
+ string versionInfo = JsonConvert.SerializeObject(VersionHelper.GetVersion(), Formatting.Indented, this.jsonNetSettings);
return versionInfo;
}
public string StartEncode(HttpListenerRequest request)
{
- if (this.handbrakeInstance == null)
- {
- this.handbrakeInstance = new HandBrakeInstance();
- }
+ string requestPostData = GetRequestPostData(request);
- string requestPostData = ApiRouter.GetRequestPostData(request);
-
- this.handbrakeInstance.Initialize(1);
this.handbrakeInstance.StartEncode(requestPostData);
return null;
@@ -49,30 +55,21 @@ namespace HandBrake.Worker
public string StopEncode(HttpListenerRequest request)
{
- if (this.handbrakeInstance != null)
- {
- this.handbrakeInstance.StopEncode();
- }
+ this.handbrakeInstance?.StopEncode();
return (string)null;
}
public string PauseEncode(HttpListenerRequest request)
{
- if (this.handbrakeInstance != null)
- {
- this.handbrakeInstance.PauseEncode();
- }
+ this.handbrakeInstance?.PauseEncode();
return null;
}
public string ResumeEncode(HttpListenerRequest request)
{
- if (this.handbrakeInstance != null)
- {
- this.handbrakeInstance.ResumeEncode();
- }
+ this.handbrakeInstance?.ResumeEncode();
return null;
}
@@ -81,7 +78,10 @@ namespace HandBrake.Worker
{
if (this.handbrakeInstance != null)
{
- return null;
+ JsonState statusJson = this.handbrakeInstance.GetEncodeProgress();
+ string versionInfo = JsonConvert.SerializeObject(statusJson, Formatting.Indented, this.jsonNetSettings);
+
+ return versionInfo;
}
return null;
@@ -108,8 +108,4 @@ namespace HandBrake.Worker
}
}
}
-
- public class strixng
- {
- }
}