arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
HeaderParserAAC.h
1#pragma once
2#include "AudioTools/AudioCodecs/CodecADTS.h"
3#include "AudioTools/CoreAudio/AudioBasic/StrView.h"
4
5namespace audio_tools {
6
17 public:
20 bool isValid(const uint8_t* data, int len) {
21 if (len < 7) return false;
22 parser.begin();
23 // regular validation
24 if (!parser.parse((uint8_t*)data)) return false;
25 // check if we have a valid 2nd frame
26 if (len > getFrameLength()) {
27 int pos = findSyncWord(data, len, getFrameLength());
28 if (pos == -1) return false;
29 }
30 return true;
31 }
32
33 int getSampleRate() { return parser.getSampleRate(); }
34
35 uint8_t getChannels() { return parser.data().channel_cfg; }
36
38 int getFrameLength() { return parser.getFrameLength(); }
39
41 int findSyncWord(const uint8_t* buf, int nBytes, int start = 0) {
42 return parser.findSyncWord(buf, nBytes, start);
43 }
44
45 ADTSParser::ADTSHeader getHeader() { return parser.data(); }
46
47 protected:
48 ADTSParser parser;
49};
50
51} // namespace audio_tools
AAC header parser to check if the data is a valid ADTS aac which can extract some relevant audio info...
Definition HeaderParserAAC.h:16
int findSyncWord(const uint8_t *buf, int nBytes, int start=0)
Finds the mp3/aac sync word.
Definition HeaderParserAAC.h:41
int getFrameLength()
Determines the frame length.
Definition HeaderParserAAC.h:38
bool isValid(const uint8_t *data, int len)
Definition HeaderParserAAC.h:20
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
Definition CodecADTS.h:20