blob: 8766808489d534b37af32cde964a67e009c6b050 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ApiRouter.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>
// This is a service worker for the HandBrake app. It allows us to run encodes / scans in a seperate process easily.
// All API's expose the ApplicationServices models as JSON.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrake.Worker
{
using System.IO;
using System.Net;
using HandBrake.Interop.Interop;
using HandBrake.Interop.Utilities;
using Newtonsoft.Json;
public class ApiRouter
{
private HandBrakeInstance handbrakeInstance;
public string GetVersionInfo(HttpListenerRequest request)
{
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 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 null;
}
public string ResumeEncode(HttpListenerRequest request)
{
if (this.handbrakeInstance != null)
{
this.handbrakeInstance.ResumeEncode();
}
return null;
}
public string PollEncodeProgress(HttpListenerRequest request)
{
if (this.handbrakeInstance != null)
{
return null;
}
return null;
}
public string SetConfiguration(HttpListenerRequest request)
{
return null;
}
private static string GetRequestPostData(HttpListenerRequest request)
{
if (!request.HasEntityBody)
{
return null;
}
using (Stream inputStream = request.InputStream)
{
using (StreamReader streamReader = new StreamReader(inputStream, request.ContentEncoding))
{
return streamReader.ReadToEnd();
}
}
}
}
public class strixng
{
}
}
|