Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VideoDecoder.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading.Tasks;
6
8{
13 {
17 public VideoDecoder()
18 {
19 }
20
24 public static readonly string[] VideoContentTypes = new string[]
25 {
26 "video/mp4",
27 "video/mpeg",
28 "video/ogg",
29 "video/quicktime",
30 "video/webm",
31 "video/3gpp",
32 "video/3gpp2",
33 "video/x-la-asf",
34 "video/x-ms-asf",
35 "video/x-msvideo",
36 "video/x-sgi-movie",
37 "video/x-flv",
38 "video/x-ms-wmv"
39 };
40
44 public static readonly string[] VideoFileExtensions = new string[]
45 {
46 "mp4",
47 "m4a",
48 "m4p",
49 "m4b",
50 "m4r",
51 "m4v",
52 "mp2",
53 "mpa",
54 "mpe",
55 "mpeg",
56 "mpg",
57 "mpv2",
58 "ogv",
59 "mov",
60 "qt",
61 "webm",
62 "lsf",
63 "lsx",
64 "asf",
65 "asr",
66 "asx",
67 "avi",
68 "movie",
69 "3gp",
70 "3g2",
71 "flv",
72 "wmv"
73 };
74
78 public string[] ContentTypes => VideoContentTypes;
79
84
91 public bool Decodes(string ContentType, out Grade Grade)
92 {
93 if (ContentType.StartsWith("video/"))
94 {
95 Grade = Grade.Barely;
96 return true;
97 }
98 else
99 {
100 Grade = Grade.NotAtAll;
101 return false;
102 }
103 }
104
115 public Task<object> DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair<string, string>[] Fields, Uri BaseUri)
116 {
117 return Task.FromResult<object>(Data);
118 }
119
126 public bool TryGetContentType(string FileExtension, out string ContentType)
127 {
128 switch (FileExtension.ToLower())
129 {
130 case "mp4":
131 case "m4a":
132 case "m4p":
133 case "m4b":
134 case "m4r":
135 case "m4v":
136 ContentType = "video/mp4";
137 return true;
138
139 case "mp2":
140 case "mpa":
141 case "mpe":
142 case "mpeg":
143 case "mpg":
144 case "mpv2":
145 ContentType = "video/mpeg";
146 return true;
147
148 case "ogv":
149 ContentType = "video/ogg";
150 return true;
151
152 case "mov":
153 case "qt":
154 ContentType = "video/quicktime";
155 return true;
156
157 case "webm":
158 ContentType = "video/webm";
159 return true;
160
161 case "lsf":
162 case "lsx":
163 ContentType = "video/x-la-asf";
164 return true;
165
166 case "asf":
167 case "asr":
168 case "asx":
169 ContentType = "video/x-ms-asf";
170 return true;
171
172 case "avi":
173 ContentType = "video/x-msvideo";
174 return true;
175
176 case "movie":
177 ContentType = "video/x-sgi-movie";
178 return true;
179
180 case "3gp":
181 ContentType = "video/3gpp";
182 return true;
183
184 case "3g2":
185 ContentType = "video/3gpp2";
186 return true;
187
188 case "flv":
189 ContentType = "video/x-flv";
190 return true;
191
192 case "wmv":
193 ContentType = "video/x-wmv";
194 return true;
195
196 default:
197 ContentType = string.Empty;
198 return false;
199 }
200 }
201
208 public bool TryGetFileExtension(string ContentType, out string FileExtension)
209 {
210 switch (ContentType.ToLower())
211 {
212 case "video/mp4":
213 FileExtension = "mp4";
214 return true;
215
216 case "video/mpeg":
217 FileExtension = "mpg";
218 return true;
219
220 case "video/ogg":
221 FileExtension = "ogv";
222 return true;
223
224 case "video/quicktime":
225 FileExtension = "mov";
226 return true;
227
228 case "video/webm":
229 FileExtension = "webm";
230 return true;
231
232 case "video/x-la-asf":
233 FileExtension = "lsf";
234 return true;
235
236 case "video/x-ms-asf":
237 FileExtension = "asf";
238 return true;
239
240 case "video/x-msvideo":
241 FileExtension = "avi";
242 return true;
243
244 case "video/x-sgi-movie":
245 FileExtension = "movie";
246 return true;
247
248 case "video/3gpp":
249 FileExtension = "3gp";
250 return true;
251
252 case "video/3gpp2":
253 FileExtension = "3g2";
254 return true;
255
256 case "video/x-flv":
257 FileExtension = "flv";
258 return true;
259
260 case "video/x-wmv":
261 FileExtension = "wmv";
262 return true;
263
264 default:
265 FileExtension = string.Empty;
266 return false;
267 }
268 }
269
270 }
271}
Binary video decoder. Is used to identify video content, but does not have actual decoding of corresp...
Definition: VideoDecoder.cs:13
static readonly string[] VideoFileExtensions
Video content types.
Definition: VideoDecoder.cs:44
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
Definition: VideoDecoder.cs:91
VideoDecoder()
Binary video decoder. Is used to identify video content, but does not have actual decoding of corresp...
Definition: VideoDecoder.cs:17
static readonly string[] VideoContentTypes
Video content types.
Definition: VideoDecoder.cs:24
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
string[] FileExtensions
Supported file extensions.
Definition: VideoDecoder.cs:83
string[] ContentTypes
Supported content types.
Definition: VideoDecoder.cs:78
Task< object > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
Basic interface for Internet Content decoders. A class implementing this interface and having a defau...
Grade
Grade enumeration
Definition: Grade.cs:7