Skip to content

Commit

Permalink
Add support for AAC and VOC audio formats
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Jul 10, 2019
1 parent ed39f93 commit 80f938c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions internal/matchers/audio.go
Expand Up @@ -57,3 +57,13 @@ func Au(in []byte) bool {
func Amr(in []byte) bool {
return len(in) > 5 && bytes.Equal(in[:5], []byte("\x23\x21\x41\x4D\x52"))
}

// Aac matches an Advanced Audio Coding file.
func Aac(in []byte) bool {
return bytes.HasPrefix(in, []byte{0xFF, 0xF1}) || bytes.HasPrefix(in, []byte{0xFF, 0xF9})
}

// Voc matches a Creative Voice file.
func Voc(in []byte) bool {
return bytes.HasPrefix(in, []byte("Creative Voice File"))
}
2 changes: 2 additions & 0 deletions mime_test.go
Expand Up @@ -84,6 +84,8 @@ var files = map[string]*node{
"ogg.ogg": ogg,
"amr.amr": amr,
"mpc.mpc": musePack,
"aac.aac": aac,
"voc.voc": voc,
"m4a.m4a": m4a,
"m4b.m4b": aMp4,

Expand Down
4 changes: 3 additions & 1 deletion supported_mimes.md
@@ -1,4 +1,4 @@
## 110 Supported MIME types
## 112 Supported MIME types
This file is automatically generated when running tests. Do not edit manually.

Extension | MIME type
Expand Down Expand Up @@ -66,6 +66,8 @@ Extension | MIME type
**flv** | video/x-flv
**mkv** | video/x-matroska
**asf** | video/x-ms-asf
**aac** | audio/aac
**voc** | audio/x-unknown
**mp4** | audio/mp4
**m4a** | audio/x-m4a
**txt** | text/plain
Expand Down
Binary file added testdata/aac.aac
Binary file not shown.
Binary file added testdata/voc.voc
Binary file not shown.
6 changes: 4 additions & 2 deletions tree.go
Expand Up @@ -9,8 +9,8 @@ var root = newNode("application/octet-stream", "", matchers.True,
sevenZ, zip, pdf, xls, ppt, doc, ps, psd, ogg, png, jpg, gif, webp, exe, elf,
ar, tar, xar, bz2, fits, tiff, bmp, ico, mp3, flac, midi, ape, musePack, amr,
wav, aiff, au, mpeg, quickTime, mqv, mp4, webM, threeGP, threeG2, avi, flv,
mkv, asf, aMp4, m4a, txt, gzip, class, swf, crx, woff, woff2, wasm, shx, dbf,
dcm, rar, djvu, mobi, lit, bpg, sqlite3, dwg,
mkv, asf, aac, voc, aMp4, m4a, txt, gzip, class, swf, crx, woff, woff2, wasm,
shx, dbf, dcm, rar, djvu, mobi, lit, bpg, sqlite3, dwg,
)

// The list of nodes appended to the root node
Expand Down Expand Up @@ -78,6 +78,8 @@ var (
aiff = newNode("audio/aiff", "aiff", matchers.Aiff)
au = newNode("audio/basic", "au", matchers.Au)
amr = newNode("audio/amr", "amr", matchers.Amr)
aac = newNode("audio/aac", "aac", matchers.Aac)
voc = newNode("audio/x-unknown", "voc", matchers.Voc)
aMp4 = newNode("audio/mp4", "mp4", matchers.AMp4)
m4a = newNode("audio/x-m4a", "m4a", matchers.M4a)
mp4 = newNode("video/mp4", "mp4", matchers.Mp4)
Expand Down

0 comments on commit 80f938c

Please sign in to comment.