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;
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<ContentResponse> DecodeAsync(string ContentType, byte[] Data, Encoding Encoding,
116 KeyValuePair<string, string>[] Fields, Uri BaseUri, ICodecProgress Progress)
117 {
118 return Task.FromResult(new ContentResponse(ContentType, Data, Data));
119 }
120
127 public bool TryGetContentType(string FileExtension, out string ContentType)
128 {
129 switch (FileExtension.ToLower())
130 {
131 case "mp4":
132 case "m4a":
133 case "m4p":
134 case "m4b":
135 case "m4r":
136 case "m4v":
137 ContentType = "video/mp4";
138 return true;
139
140 case "mp2":
141 case "mpa":
142 case "mpe":
143 case "mpeg":
144 case "mpg":
145 case "mpv2":
146 ContentType = "video/mpeg";
147 return true;
148
149 case "ogv":
150 ContentType = "video/ogg";
151 return true;
152
153 case "mov":
154 case "qt":
155 ContentType = "video/quicktime";
156 return true;
157
158 case "webm":
159 ContentType = "video/webm";
160 return true;
161
162 case "lsf":
163 case "lsx":
164 ContentType = "video/x-la-asf";
165 return true;
166
167 case "asf":
168 case "asr":
169 case "asx":
170 ContentType = "video/x-ms-asf";
171 return true;
172
173 case "avi":
174 ContentType = "video/x-msvideo";
175 return true;
176
177 case "movie":
178 ContentType = "video/x-sgi-movie";
179 return true;
180
181 case "3gp":
182 ContentType = "video/3gpp";
183 return true;
184
185 case "3g2":
186 ContentType = "video/3gpp2";
187 return true;
188
189 case "flv":
190 ContentType = "video/x-flv";
191 return true;
192
193 case "wmv":
194 ContentType = "video/x-wmv";
195 return true;
196
197 default:
198 ContentType = string.Empty;
199 return false;
200 }
201 }
202
209 public bool TryGetFileExtension(string ContentType, out string FileExtension)
210 {
211 switch (ContentType.ToLower())
212 {
213 case "video/mp4":
214 FileExtension = "mp4";
215 return true;
216
217 case "video/mpeg":
218 FileExtension = "mpg";
219 return true;
220
221 case "video/ogg":
222 FileExtension = "ogv";
223 return true;
224
225 case "video/quicktime":
226 FileExtension = "mov";
227 return true;
228
229 case "video/webm":
230 FileExtension = "webm";
231 return true;
232
233 case "video/x-la-asf":
234 FileExtension = "lsf";
235 return true;
236
237 case "video/x-ms-asf":
238 FileExtension = "asf";
239 return true;
240
241 case "video/x-msvideo":
242 FileExtension = "avi";
243 return true;
244
245 case "video/x-sgi-movie":
246 FileExtension = "movie";
247 return true;
248
249 case "video/3gpp":
250 FileExtension = "3gp";
251 return true;
252
253 case "video/3gpp2":
254 FileExtension = "3g2";
255 return true;
256
257 case "video/x-flv":
258 FileExtension = "flv";
259 return true;
260
261 case "video/x-wmv":
262 FileExtension = "wmv";
263 return true;
264
265 default:
266 FileExtension = string.Empty;
267 return false;
268 }
269 }
270
271 }
272}
Contains information about a response to a content request.
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.
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
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
Interface for reporting progress about an encoding or decoding.
Basic interface for Internet Content decoders. A class implementing this interface and having a defau...
Grade
Grade enumeration
Definition: Grade.cs:7