Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AudioDecoder.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading.Tasks;
6
8{
13 {
17 public AudioDecoder()
18 {
19 }
20
24 public static readonly string[] AudioContentTypes = new string[]
25 {
26 "audio/basic",
27 "audio/mid",
28 "audio/mpeg",
29 "audio/ogg",
30 "audio/x-aiff",
31 "audio/x-mpegurl",
32 "audio/x-pn-realaudio",
33 "audio/x-pn-realaudio",
34 "audio/x-wav"
35 };
36
40 public static readonly string[] AudioFileExtensions = new string[]
41 {
42 "au",
43 "snd",
44 "mid",
45 "rmi",
46 "mp3",
47 "ogg",
48 "oga",
49 "aif",
50 "aifc",
51 "aiff",
52 "m3u",
53 "ra",
54 "ram",
55 "wav"
56 };
57
61 public string[] ContentTypes => AudioContentTypes;
62
67
74 public bool Decodes(string ContentType, out Grade Grade)
75 {
76 if (ContentType.StartsWith("audio/"))
77 {
78 Grade = Grade.Barely;
79 return true;
80 }
81 else
82 {
83 Grade = Grade.NotAtAll;
84 return false;
85 }
86 }
87
98 public Task<object> DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair<string, string>[] Fields, Uri BaseUri)
99 {
100 return Task.FromResult<object>(Data);
101 }
102
109 public bool TryGetContentType(string FileExtension, out string ContentType)
110 {
111 switch (FileExtension.ToLower())
112 {
113 case "au":
114 case "snd":
115 ContentType = "audio/basic";
116 return true;
117
118 case "mid":
119 case "rmi":
120 ContentType = "audio/mid";
121 return true;
122
123 case "mp3":
124 ContentType = "audio/mpeg";
125 return true;
126
127 case "ogg":
128 case "oga":
129 ContentType = "audio/ogg";
130 return true;
131
132 case "aif":
133 case "aifc":
134 case "aiff":
135 ContentType = "audio/x-aiff";
136 return true;
137
138 case "m3u":
139 ContentType = "audio/x-mpegurl";
140 return true;
141
142 case "ra":
143 case "ram":
144 ContentType = "audio/x-pn-realaudio";
145 return true;
146
147 case "wav":
148 ContentType = "audio/x-wav";
149 return true;
150
151 default:
152 ContentType = string.Empty;
153 return false;
154 }
155 }
156
163 public bool TryGetFileExtension(string ContentType, out string FileExtension)
164 {
165 switch (ContentType.ToLower())
166 {
167 case "audio/basic":
168 FileExtension = "snd";
169 return true;
170
171 case "audio/mid":
172 FileExtension = "mid";
173 return true;
174
175 case "audio/mpeg":
176 FileExtension = "mp3";
177 return true;
178
179 case "audio/ogg":
180 FileExtension = "oga";
181 return true;
182
183 case "audio/x-aiff":
184 FileExtension = "aiff";
185 return true;
186
187 case "audio/x-mpegurl":
188 FileExtension = "m3u";
189 return true;
190
191 case "audio/x-pn-realaudio":
192 FileExtension = "ra";
193 return true;
194
195 case "audio/x-wav":
196 FileExtension = "wav";
197 return true;
198
199 default:
200 FileExtension = string.Empty;
201 return false;
202 }
203 }
204
205 }
206}
Binary audio decoder. Is used to identify audio content, but does not have actual decoding of corresp...
Definition: AudioDecoder.cs:13
Task< object > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
Definition: AudioDecoder.cs:98
string[] ContentTypes
Supported content types.
Definition: AudioDecoder.cs:61
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
static readonly string[] AudioFileExtensions
Audio content types.
Definition: AudioDecoder.cs:40
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
string[] FileExtensions
Supported file extensions.
Definition: AudioDecoder.cs:66
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
Definition: AudioDecoder.cs:74
AudioDecoder()
Binary audio decoder. Is used to identify audio content, but does not have actual decoding of corresp...
Definition: AudioDecoder.cs:17
static readonly string[] AudioContentTypes
Audio content types.
Definition: AudioDecoder.cs:24
Basic interface for Internet Content decoders. A class implementing this interface and having a defau...
Grade
Grade enumeration
Definition: Grade.cs:7