Logic to detemine the mime type from the content. By default the following mime types are supported (audio/aac, audio/mpeg, audio/vnd.wave, audio/ogg, audio/flac). You can register your own custom detection logic to cover additional file types.
More...
#include <MimeDetector.h>
|
| | MimeDetector (bool setupDefault=true) |
| |
| bool | begin () |
| | Sets is_first to true.
|
| |
| void | clear () |
| | Clears all mime rules and resets the actual selection.
|
| |
| void | end () |
| | Clears the actual mime and resets the state.
|
| |
| const char * | mime () |
| |
| void | setCheck (const char *mime, bool(*check)(uint8_t *start, size_t len), bool isActvie=true) |
| | adds/updates the checking logic for the indicated mime
|
| |
| void | setDefaultMime (const char *mime) |
| | Provides the default mime type if no mime could be determined.
|
| |
| int | setMimeActive (const char *mimePrefix, bool active) |
| | sets the mime rules active or inactive
|
| |
| void | setMimeCallback (void(*callback)(const char *)) |
| |
| size_t | write (uint8_t *data, size_t len) |
| | write the header to determine the mime
|
| |
|
| static bool | checkAAC (uint8_t *start, size_t len) |
| |
| static bool | checkAACExt (uint8_t *start, size_t len) |
| |
| static bool | checkDSF (uint8_t *start, size_t len) |
| | DSF (DSD Stream File): starts with "DSD " magic.
|
| |
| static bool | checkFLAC (uint8_t *start, size_t len) |
| |
| static bool | checkM4A (uint8_t *header, size_t len) |
| |
| static bool | checkMP2T (uint8_t *start, size_t len) |
| | MPEG-2 TS Byte Stream Format.
|
| |
| static bool | checkMP3 (uint8_t *start, size_t len) |
| |
| static bool | checkMP3Ext (uint8_t *start, size_t len) |
| |
| static bool | checkOGG (uint8_t *start, size_t len) |
| |
| static bool | checkOggFLAC (uint8_t *start, size_t len) |
| |
| static bool | checkOggOpus (uint8_t *start, size_t len) |
| | Checks for OGG Opus format.
|
| |
| static bool | checkOggVorbis (uint8_t *start, size_t len) |
| | Checks for OGG Vorbis format.
|
| |
| static bool | checkSID (uint8_t *start, size_t len) |
| | Commodore 64 SID File.
|
| |
| static bool | checkWAV (uint8_t *start, size_t len) |
| |
| static bool | checkWAV_ADPCM (uint8_t *start, size_t len) |
| |
|
| void | determineMime (void *data, size_t len) |
| | Update the mime type.
|
| |
| const char * | lookupMime (uint8_t *data, size_t len) |
| | Default logic which supports aac, mp3, wav and ogg.
|
| |
Logic to detemine the mime type from the content. By default the following mime types are supported (audio/aac, audio/mpeg, audio/vnd.wave, audio/ogg, audio/flac). You can register your own custom detection logic to cover additional file types.
Please note that the distinction between mp3 and aac is difficult and might fail in some cases. FLAC detection supports both native FLAC and OGG FLAC formats.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ MimeDetector()
◆ begin()
◆ checkAAC()
| static bool checkAAC |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkAACExt()
| static bool checkAACExt |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkDSF()
| static bool checkDSF |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
DSF (DSD Stream File): starts with "DSD " magic.
◆ checkFLAC()
| static bool checkFLAC |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkM4A()
| static bool checkM4A |
( |
uint8_t * |
header, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkMP2T()
| static bool checkMP2T |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkMP3()
| static bool checkMP3 |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkMP3Ext()
| static bool checkMP3Ext |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkOGG()
| static bool checkOGG |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkOggFLAC()
| static bool checkOggFLAC |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkOggOpus()
| static bool checkOggOpus |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
Checks for OGG Opus format.
Detects OGG containers that contain Opus-encoded audio data. Opus in OGG streams typically have "OpusHead" as the codec identifier in the first page of the stream.
- Parameters
-
| start | Pointer to the data buffer |
| len | Length of the data buffer |
- Returns
- true if OGG Opus format is detected, false otherwise
◆ checkOggVorbis()
| static bool checkOggVorbis |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
Checks for OGG Vorbis format.
Detects OGG containers that contain Vorbis-encoded audio data. Vorbis in OGG streams have "\x01vorbis" as the codec identifier in the first page of the stream.
- Parameters
-
| start | Pointer to the data buffer |
| len | Length of the data buffer |
- Returns
- true if OGG Vorbis format is detected, false otherwise
◆ checkSID()
| static bool checkSID |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkWAV()
| static bool checkWAV |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ checkWAV_ADPCM()
| static bool checkWAV_ADPCM |
( |
uint8_t * |
start, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ clear()
Clears all mime rules and resets the actual selection.
◆ determineMime()
| void determineMime |
( |
void * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineprotected |
◆ end()
Clears the actual mime and resets the state.
◆ lookupMime()
| const char * lookupMime |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineprotected |
Default logic which supports aac, mp3, wav and ogg.
◆ mime()
Provides the actual mime type, that was determined from the first available data
Implements MimeSource.
◆ setCheck()
| void setCheck |
( |
const char * |
mime, |
|
|
bool(*)(uint8_t *start, size_t len) |
check, |
|
|
bool |
isActvie = true |
|
) |
| |
|
inline |
adds/updates the checking logic for the indicated mime
◆ setDefaultMime()
| void setDefaultMime |
( |
const char * |
mime | ) |
|
|
inline |
Provides the default mime type if no mime could be determined.
◆ setMimeActive()
| int setMimeActive |
( |
const char * |
mimePrefix, |
|
|
bool |
active |
|
) |
| |
|
inline |
sets the mime rules active or inactive
◆ setMimeCallback()
| void setMimeCallback |
( |
void(*)(const char *) |
callback | ) |
|
|
inline |
◆ write()
| size_t write |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inline |
write the header to determine the mime
◆ actual_mime
| const char* actual_mime = nullptr |
|
protected |
◆ checks
◆ default_mime
| const char* default_mime = nullptr |
|
protected |
◆ is_first
◆ notifyMimeCallback
| void(* notifyMimeCallback) (const char *mime) = nullptr |
|
protected |
The documentation for this class was generated from the following file: