1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /*------------------------------------------------------------------------------
17  *
18  *  This file exposes a public interface to allow clients to invoke aptX
19  *  encoding on 4 new PCM samples, generating 2 new codeword (one for the
20  *  left channel and one for the right channel).
21  *
22  *----------------------------------------------------------------------------*/
23 
24 #ifndef APTXBTENC_H
25 #define APTXBTENC_H
26 
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef _DLLEXPORT
34 #define APTXBTENCEXPORT __declspec(dllexport)
35 #else
36 #define APTXBTENCEXPORT
37 #endif
38 
39 /* SizeofAptxbtenc returns the size (in byte) of the memory
40  * allocation required to store the state of the encoder */
41 APTXBTENCEXPORT int SizeofAptxbtenc(void);
42 
43 /* aptxbtenc_version can be used to extract the version number
44  * of the aptX encoder */
45 APTXBTENCEXPORT const char* aptxbtenc_version(void);
46 
47 /* aptxbtenc_init is used to initialise the encoder structure.
48  * _state should be a pointer to the encoder structure (stereo).
49  * endian represent the endianness of the output data
50  * (0=little endian. Big endian otherwise)
51  * The function returns 1 if an error occurred during the initialisation.
52  * The function returns 0 if no error occurred during the initialisation. */
53 APTXBTENCEXPORT int aptxbtenc_init(void* _state, short endian);
54 
55 /* aptxbtenc_setsync_mode is used to initialise the sync mode in the encoder
56  * state structure. _state should be a pointer to the encoder structure (stereo,
57  * though strictly-speaking it is dual channel). 'sync_mode' is an enumerated
58  * type  {stereo=0, dualmono=1, no_sync=2} The function returns 0 if no error
59  * occurred during the initialisation. */
60 APTXBTENCEXPORT int aptxbtenc_setsync_mode(void* _state, int32_t sync_mode);
61 
62 /* StereoEncode will take 8 audio samples (16-bit per sample)
63  * and generate one 32-bit codeword with autosync inserted. */
64 APTXBTENCEXPORT int aptxbtenc_encodestereo(void* _state, void* _pcmL,
65                                            void* _pcmR, void* _buffer);
66 
67 #ifdef __cplusplus
68 }  //  /extern "C"
69 #endif
70 
71 #endif  // APTXBTENC_H
72