faad2_sys/
lib.rs

1pub use std::os::raw::{c_char, c_int, c_long, c_uchar, c_ushort, c_ulong, c_void};
2
3pub type NeAACDecHandle = *mut c_void;
4
5pub const FAAD_FMT_16BIT: c_uchar = 1;
6pub const FAAD_FMT_24BIT: c_uchar = 2;
7pub const FAAD_FMT_32BIT: c_uchar = 3;
8pub const FAAD_FMT_FLOAT: c_uchar = 4;
9pub const FAAD_FMT_DOUBLE: c_uchar = 5;
10
11#[repr(C)]
12#[allow(non_snake_case)]
13pub struct mp4AudioSpecificConfig {
14    /* Audio Specific Info */
15    pub objectTypeIndex: c_uchar,
16    pub samplingFrequencyIndex: c_uchar,
17    pub samplingFrequency: c_ulong,
18    pub channelsConfiguration: c_uchar,
19
20    /* GA Specific Info */
21    pub frameLengthFlag: c_uchar,
22    pub dependsOnCoreCoder: c_uchar,
23    pub coreCoderDelay: c_ushort,
24    pub extensionFlag: c_uchar,
25    pub aacSectionDataResilienceFlag: c_uchar,
26    pub aacScalefactorDataResilienceFlag: c_uchar,
27    pub aacSpectralDataResilienceFlag: c_uchar,
28    pub epConfig: c_uchar,
29
30    pub sbr_present_flag: c_char,
31    pub forceUpSampling: c_char,
32    pub downSampledSBR: c_char,
33}
34
35#[repr(C)]
36#[allow(non_snake_case)]
37pub struct NeAACDecConfiguration {
38    pub defObjectType: c_uchar,
39    pub defSampleRate: c_ulong,
40    pub outputFormat: c_uchar,
41    pub downMatrix: c_uchar,
42    pub useOldADTSFormat: c_uchar,
43    pub dontUpSampleImplicitSBR: c_uchar,
44}
45
46#[repr(C)]
47#[allow(non_snake_case)]
48pub struct NeAACDecFrameInfo
49{
50    pub bytesconsumed: c_ulong,
51    pub samples: c_ulong,
52    pub channels: c_uchar,
53    pub error: c_uchar,
54    pub samplerate: c_ulong,
55
56    /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
57    pub sbr: c_uchar,
58
59    /* MPEG-4 ObjectType */
60    pub object_type: c_uchar,
61
62    /* AAC header type; MP4 will be signalled as RAW also */
63    pub header_type: c_uchar,
64
65    /* multichannel configuration */
66    pub num_front_channels: c_uchar,
67    pub num_side_channels: c_uchar,
68    pub num_back_channels: c_uchar,
69    pub num_lfe_channels: c_uchar,
70    pub channel_position: [c_uchar; 64],
71
72    /* PS: 0: off, 1: on */
73    pub ps: c_uchar,
74}
75
76extern "C" {
77    pub fn NeAACDecGetErrorMessage(
78        errcode: c_uchar,
79    ) -> *const c_char;
80
81    pub fn NeAACDecGetCapabilities() -> c_ulong;
82
83    pub fn NeAACDecOpen() -> NeAACDecHandle;
84
85    pub fn NeAACDecGetCurrentConfiguration(
86        decoder: NeAACDecHandle,
87    ) -> *mut NeAACDecConfiguration;
88
89    pub fn NeAACDecSetConfiguration(
90        decoder: NeAACDecHandle,
91        config: *mut NeAACDecConfiguration,
92    ) -> c_uchar;
93
94    /* Init the library based on info from the AAC file (ADTS/ADIF) */
95    pub fn NeAACDecInit(
96        decoder: NeAACDecHandle,
97        buffer: *mut c_uchar,
98        buffer_size: c_ulong,
99        samplerate: *mut c_ulong,
100        channels: *mut c_uchar,
101    ) -> c_ulong;
102
103    /* Init the library using a DecoderSpecificInfo */
104    pub fn NeAACDecInit2(
105        decoder: NeAACDecHandle,
106        buffer: *const c_uchar,
107        SizeOfDecoderSpecificInfo: c_ulong,
108        samplerate: *mut c_ulong,
109        channels: *mut c_uchar,
110    ) -> c_uchar;
111
112    /* Init the library for DRM */
113    pub fn NeAACDecInitDRM(
114        decoder: *mut NeAACDecHandle,
115        samplerate: c_ulong,
116        channels: c_uchar,
117    ) -> c_uchar;
118
119    pub fn NeAACDecPostSeekReset(
120        decoder: NeAACDecHandle,
121        frame: c_long,
122    );
123
124    pub fn NeAACDecClose(
125        decoder: NeAACDecHandle,
126    );
127
128    pub fn NeAACDecDecode(
129        decoder: NeAACDecHandle,
130        hInfo: *mut NeAACDecFrameInfo,
131        buffer: *const c_uchar,
132        buffer_size: c_ulong,
133    ) -> *mut c_void;
134
135    pub fn NeAACDecDecode2(
136        decoder: NeAACDecHandle,
137        hInfo: *mut NeAACDecFrameInfo,
138        buffer: *const c_uchar,
139        buffer_size: c_ulong,
140        sample_buffer: *mut *mut c_void,
141        sample_buffer_size: c_ulong,
142    ) -> *mut c_void;
143
144    pub fn NeAACDecAudioSpecificConfig(
145        pBuffer: *mut c_uchar,
146        buffer_size: c_ulong,
147        mp4ASC: *mut mp4AudioSpecificConfig,
148    ) -> c_uchar;
149
150    pub fn NeAACDecGetVersion(id: *mut *const c_char, copyright: *mut *const c_char) -> c_int;
151}