// </summary>
// --------------------------------------------------------------------------------------------------------------------
-
namespace HandBrake.Worker
{
+ using System.IO;
+ using System.Net;
+
using HandBrake.Interop.Interop;
using HandBrake.Interop.Utilities;
+
using Newtonsoft.Json;
- using System;
- using System.IO;
- using System.Net;
public class ApiRouter
{
public string GetVersionInfo(HttpListenerRequest request)
{
- return string.Format(JsonConvert.SerializeObject((object)VersionHelper.GetVersion(), Formatting.Indented, new JsonSerializerSettings()
- {
- NullValueHandling = NullValueHandling.Ignore
- }), Array.Empty<object>());
+ JsonSerializerSettings settings =
+ new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
+
+ string versionInfo = JsonConvert.SerializeObject((object)VersionHelper.GetVersion(), Formatting.Indented, settings);
+
+ return versionInfo;
}
public string StartEncode(HttpListenerRequest request)
{
if (this.handbrakeInstance == null)
+ {
this.handbrakeInstance = new HandBrakeInstance();
+ }
+
string requestPostData = ApiRouter.GetRequestPostData(request);
+
this.handbrakeInstance.Initialize(1);
this.handbrakeInstance.StartEncode(requestPostData);
- return (string)null;
+
+ return null;
}
public string StopEncode(HttpListenerRequest request)
{
if (this.handbrakeInstance != null)
+ {
this.handbrakeInstance.StopEncode();
+ }
+
return (string)null;
}
public string PauseEncode(HttpListenerRequest request)
{
if (this.handbrakeInstance != null)
+ {
this.handbrakeInstance.PauseEncode();
- return (string)null;
+ }
+
+ return null;
}
public string ResumeEncode(HttpListenerRequest request)
{
if (this.handbrakeInstance != null)
+ {
this.handbrakeInstance.ResumeEncode();
- return (string)null;
+ }
+
+ return null;
}
public string PollEncodeProgress(HttpListenerRequest request)
{
- if (this.handbrakeInstance == null)
- ;
- return (string)null;
+ if (this.handbrakeInstance != null)
+ {
+ return null;
+ }
+
+ return null;
}
public string SetConfiguration(HttpListenerRequest request)
{
- return (string)null;
+ return null;
}
private static string GetRequestPostData(HttpListenerRequest request)
{
if (!request.HasEntityBody)
- return (string)null;
+ {
+ return null;
+ }
+
using (Stream inputStream = request.InputStream)
{
using (StreamReader streamReader = new StreamReader(inputStream, request.ContentEncoding))
+ {
return streamReader.ReadToEnd();
+ }
}
}
}
+
+ public class strixng
+ {
+ }
}
(c) =>
{
var context = c as HttpListenerContext;
+ if (context == null)
+ {
+ return;
+ }
+
try
{
- string requestType = context.Request.HttpMethod;
string path = context.Request.RawUrl.TrimStart('/');
- Func<HttpListenerRequest, string> actionToPerform;
- if (apiHandlers.TryGetValue(path, out actionToPerform))
+ if (this.apiHandlers.TryGetValue(path, out var actionToPerform))
{
string rstr = actionToPerform(context.Request);
byte[] buf = Encoding.UTF8.GetBytes(rstr);
}
finally
{
- // always close the stream
context?.Response.OutputStream.Close();
}
},
using System;
using System.Collections.Generic;
using System.Net;
- using HandBrake.Interop.Utilities;
- using Newtonsoft.Json;
public class Program
{
return apiHandlers;
}
-
- public static string GetVersionInfo(HttpListenerRequest request)
- {
- string version = VersionHelper.GetVersion();
- JsonSerializerSettings settings = new JsonSerializerSettings
- {
- NullValueHandling = NullValueHandling.Ignore,
- };
-
- string versionJson = JsonConvert.SerializeObject(version, Formatting.Indented, settings);
-
- return string.Format(versionJson);
- }
}
}