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;
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<ContentResponse> DecodeAsync(string ContentType, byte[] Data, Encoding Encoding,
99 KeyValuePair<string, string>[] Fields, Uri BaseUri, ICodecProgress Progress)
100 {
101 return Task.FromResult(new ContentResponse(ContentType, Data, Data));
102 }
103
110 public bool TryGetContentType(string FileExtension, out string ContentType)
111 {
112 switch (FileExtension.ToLower())
113 {
114 case "au":
115 case "snd":
116 ContentType = "audio/basic";
117 return true;
118
119 case "mid":
120 case "rmi":
121 ContentType = "audio/mid";
122 return true;
123
124 case "mp3":
125 ContentType = "audio/mpeg";
126 return true;
127
128 case "ogg":
129 case "oga":
130 ContentType = "audio/ogg";
131 return true;
132
133 case "aif":
134 case "aifc":
135 case "aiff":
136 ContentType = "audio/x-aiff";
137 return true;
138
139 case "m3u":
140 ContentType = "audio/x-mpegurl";
141 return true;
142
143 case "ra":
144 case "ram":
145 ContentType = "audio/x-pn-realaudio";
146 return true;
147
148 case "wav":
149 ContentType = "audio/x-wav";
150 return true;
151
152 default:
153 ContentType = string.Empty;
154 return false;
155 }
156 }
157
164 public bool TryGetFileExtension(string ContentType, out string FileExtension)
165 {
166 switch (ContentType.ToLower())
167 {
168 case "audio/basic":
169 FileExtension = "snd";
170 return true;
171
172 case "audio/mid":
173 FileExtension = "mid";
174 return true;
175
176 case "audio/mpeg":
177 FileExtension = "mp3";
178 return true;
179
180 case "audio/ogg":
181 FileExtension = "oga";
182 return true;
183
184 case "audio/x-aiff":
185 FileExtension = "aiff";
186 return true;
187
188 case "audio/x-mpegurl":
189 FileExtension = "m3u";
190 return true;
191
192 case "audio/x-pn-realaudio":
193 FileExtension = "ra";
194 return true;
195
196 case "audio/x-wav":
197 FileExtension = "wav";
198 return true;
199
200 default:
201 FileExtension = string.Empty;
202 return false;
203 }
204 }
205
206 }
207}
Binary audio decoder. Is used to identify audio content, but does not have actual decoding of corresp...
Definition: AudioDecoder.cs:13
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
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
Definition: AudioDecoder.cs:98
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
Contains information about a response to a content request.
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