-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathadts_parser.h
76 lines (60 loc) · 1.39 KB
/
adts_parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Created by wlanjie on 2018/3/15.
//
#ifndef MP4_ADTSPARSER_H
#define MP4_ADTSPARSER_H
#include "types.h"
#include "bit_stream.h"
namespace mp4 {
class AdtsHeader {
public:
AdtsHeader(const UI08* bytes);
Result check();
unsigned int id;
unsigned int protectionAbsent;
unsigned int profileObjectType;
unsigned int samplingFrequencyIndex;
unsigned channelConfiguration;
unsigned int frameLength;
unsigned int rawDataBlocks;
static bool matchFixed(unsigned char* a, unsigned char* b);
};
typedef enum {
AAC_STANDARD_MPEG2,
AAC_STANDARD_MPEG4
} AacStandard;
typedef enum {
AAC_PROFILE_MAIN,
AAC_PROFILE_LC,
AAC_PROFILE_SSR,
AAC_PROFILE_LTP,
} AacProfile;
typedef struct {
AacStandard standard;
AacProfile profile;
unsigned int samplingFrequencyIndex;
UI32 samplingFrequency;
unsigned int channelConfiguration;
unsigned frameLength;
} AacFrameInfo;
typedef struct {
BitStream* source;
AacFrameInfo info;
} AacFrame;
class AdtsParser {
public:
AdtsParser();
~AdtsParser();
Result reset();
Result feed(const UI08* buffer, Size* bufferSize, Flags flags = 0);
Result findFrame(AacFrame& frame);
Result skip(Size size);
Size getBytesFree();
Size getBytesAvailable();
private:
Result findHeader(UI08* header);
BitStream bits;
Cardinal frameCount;
};
}
#endif //MP4_ADTSPARSER_H