@@ -61,6 +61,8 @@ class MimeDetector : public MimeSource {
61
61
setCheck (" audio/vnd.wave" , checkWAV);
62
62
setCheck (" audio/flac" , checkFLAC);
63
63
setCheck (" audio/ogg; codecs=flac" , checkOggFLAC);
64
+ setCheck (" audio/ogg; codecs=opus" , checkOggOpus);
65
+ setCheck (" audio/ogg; codec=vorbis" , checkOggVorbis);
64
66
setCheck (" audio/ogg" , checkOGG);
65
67
setCheck (" video/MP2T" , checkMP2T);
66
68
setCheck (" audio/prs.sid" , checkSID);
@@ -177,6 +179,60 @@ class MimeDetector : public MimeSource {
177
179
return false ;
178
180
}
179
181
182
+ /* *
183
+ * @brief Checks for OGG Opus format
184
+ *
185
+ * Detects OGG containers that contain Opus-encoded audio data.
186
+ * Opus in OGG streams typically have "OpusHead" as the codec identifier
187
+ * in the first page of the stream.
188
+ *
189
+ * @param start Pointer to the data buffer
190
+ * @param len Length of the data buffer
191
+ * @return true if OGG Opus format is detected, false otherwise
192
+ */
193
+ static bool checkOggOpus (uint8_t * start, size_t len) {
194
+ // Check for OGG Opus - OGG container with Opus content
195
+ // OGG starts with "OggS" and contains Opus codec identifier
196
+ if (len >= 32 && memcmp (start, " OggS" , 4 ) == 0 ) {
197
+ // Look for Opus signature within the first OGG page
198
+ // Opus in OGG typically has "OpusHead" as the codec identifier
199
+ for (size_t i = 4 ; i < len - 8 && i < 80 ; i++) {
200
+ if (memcmp (start + i, " OpusHead" , 8 ) == 0 ) {
201
+ return true ;
202
+ }
203
+ }
204
+ }
205
+
206
+ return false ;
207
+ }
208
+
209
+ /* *
210
+ * @brief Checks for OGG Vorbis format
211
+ *
212
+ * Detects OGG containers that contain Vorbis-encoded audio data.
213
+ * Vorbis in OGG streams have "\x01vorbis" as the codec identifier
214
+ * in the first page of the stream.
215
+ *
216
+ * @param start Pointer to the data buffer
217
+ * @param len Length of the data buffer
218
+ * @return true if OGG Vorbis format is detected, false otherwise
219
+ */
220
+ static bool checkOggVorbis (uint8_t * start, size_t len) {
221
+ // Check for OGG Vorbis - OGG container with Vorbis content
222
+ // OGG starts with "OggS" and contains Vorbis codec identifier
223
+ if (len >= 32 && memcmp (start, " OggS" , 4 ) == 0 ) {
224
+ // Look for Vorbis signature within the first OGG page
225
+ // Vorbis in OGG has "\x01vorbis" as the codec identifier
226
+ for (size_t i = 4 ; i < len - 7 && i < 80 ; i++) {
227
+ if (start[i] == 0x01 && memcmp (start + i + 1 , " vorbis" , 6 ) == 0 ) {
228
+ return true ;
229
+ }
230
+ }
231
+ }
232
+
233
+ return false ;
234
+ }
235
+
180
236
// / MPEG-2 TS Byte Stream Format
181
237
static bool checkMP2T (uint8_t * start, size_t len) {
182
238
if (len < 189 ) return start[0 ] == 0x47 ;
0 commit comments