mirror of
https://github.com/codedread/bitjs
synced 2025-10-06 02:39:55 +02:00
Add a couple audio file formats to sniffer
This commit is contained in:
parent
e815252ae1
commit
557a40e810
3 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* File Sniffer.
|
||||
* Makes an attempt to resolve a byte stream into a MIME type.
|
||||
*
|
||||
* Licensed under the MIT License
|
||||
*
|
||||
|
@ -9,7 +10,6 @@
|
|||
// A selection from https://en.wikipedia.org/wiki/List_of_file_signatures.
|
||||
// Mapping of MIME type to magic numbers. Each file type can have multiple signatures.
|
||||
// '??' is used as a placeholder value.
|
||||
// TODO: Add audio/video formats?
|
||||
const fileSignatures = {
|
||||
// Document formats.
|
||||
'application/pdf': [[0x25, 0x50, 0x44, 0x46, 0x2d]],
|
||||
|
@ -24,8 +24,15 @@ const fileSignatures = {
|
|||
'image/jpeg': [[0xFF, 0xD8, 0xFF]],
|
||||
'image/png': [[0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]],
|
||||
'image/webp': [[0x52, 0x49, 0x46, 0x46, '??', '??', '??', '??', 0x57, 0x45, 0x42, 0x50]],
|
||||
// Audio/Video formats.
|
||||
'application/ogg': [[0x4F, 0x67, 0x67, 0x53]],
|
||||
'audio/mpeg': [[0xFF, 0xFB], [0xFF, 0xF3], [0xFF, 0xF2], [0x49, 0x44, 0x33]],
|
||||
};
|
||||
|
||||
// TODO: Eventually add support for various container formats so that:
|
||||
// * an OGG container can be resolved to OGG Audio, OGG Video
|
||||
// * an HEIF container can be resolved to AVIF, HEIC
|
||||
|
||||
class Node {
|
||||
/** @param {number} value */
|
||||
constructor(value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue