github.com/status-im/status-go@v1.1.0/protocol/audio/type.go (about) 1 package audio 2 3 import ( 4 "github.com/status-im/status-go/protocol/protobuf" 5 ) 6 7 func aac(buf []byte) bool { 8 return len(buf) > 1 && 9 ((buf[0] == 0xFF && buf[1] == 0xF1) || 10 (buf[0] == 0xFF && buf[1] == 0xF9)) 11 } 12 13 func amr(buf []byte) bool { 14 return len(buf) > 11 && 15 buf[0] == 0x23 && buf[1] == 0x21 && 16 buf[2] == 0x41 && buf[3] == 0x4D && 17 buf[4] == 0x52 && buf[5] == 0x0A 18 } 19 20 func Type(buf []byte) protobuf.AudioMessage_AudioType { 21 switch { 22 case aac(buf): 23 return protobuf.AudioMessage_AAC 24 case amr(buf): 25 return protobuf.AudioMessage_AMR 26 default: 27 return protobuf.AudioMessage_UNKNOWN_AUDIO_TYPE 28 } 29 }