nrfxlib API 2.7.99
Loading...
Searching...
No Matches
LC3API.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 T2 Software, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: LicenseRef-T2-LC3
5 */
6
10#ifndef _LC3APIH_
11#define _LC3APIH_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/******************************************************************************
18* Includes
19******************************************************************************/
20#include "osal.h"
21
25/******************************************************************************
26* Definitions
27******************************************************************************/
28
32#define LC3_ERROR_OFFSET (-5000)
33#define LC3_RESULT_NO_ERROR (0)
34#define LC3_RESULT_INVALID_PARAMETER ((LC3_ERROR_OFFSET)-1)
35#define LC3_RESULT_INSUFFICIENT_RESOURCES ((LC3_ERROR_OFFSET)-2)
36#define LC3_RESULT_NOT_INITIALIZED ((LC3_ERROR_OFFSET)-3)
37#define LC3_RESULT_UNKNOWN_ERROR ((LC3_ERROR_OFFSET)-4)
38#define LC3_RESULT_INVALID_BITRATE ((LC3_ERROR_OFFSET)-5)
39#define LC3_RESULT_INPUT_BUFFER_TOO_SMALL ((LC3_ERROR_OFFSET)-6)
40#define LC3_RESULT_OUTPUT_BUFFER_TOO_SMALL ((LC3_ERROR_OFFSET)-7)
41#define LC3_RESULT_INVALID_BITSPERSAMPLE ((LC3_ERROR_OFFSET)-8)
42#define LC3_RESULT_INVALID_SAMPLERATE ((LC3_ERROR_OFFSET)-9)
43#define LC3_RESULT_BITERRORCONDITION ((LC3_ERROR_OFFSET)-10)
44#define LC3_RESULT_FEATURE_NOT_SUPPORTED ((LC3_ERROR_OFFSET)-11)
45#define LC3_RESULT_STILL_IN_USE ((LC3_ERROR_OFFSET)-12)
46#define LC3_RESULT_ALREADY_INITIALIZED ((LC3_ERROR_OFFSET)-13)
52#define LC3_SAMPLE_RATE_NONE (0x00)
53#define LC3_SAMPLE_RATE_8_KHZ (0x01)
54#define LC3_SAMPLE_RATE_16_KHZ (0x02)
55#define LC3_SAMPLE_RATE_24_KHZ (0x04)
56#define LC3_SAMPLE_RATE_32_KHZ (0x08)
57#define LC3_SAMPLE_RATE_441_KHZ (0x10)
58#define LC3_SAMPLE_RATE_48_KHZ (0x20)
59#define LC3_SAMPLE_RATE_ALL (0x1F)
62/******************************************************************************
63* Module Typedefs
64******************************************************************************/
65
67typedef void * LC3EncoderHandle_t;
68
70typedef void * LC3DecoderHandle_t;
71
78typedef enum
79{
84
89typedef enum
90{
94
104typedef struct
105{
106 const void *PCMData;
107 uint16_t PCMDataLength;
108 uint32_t encodeBitrate;
109 uint16_t bytesRead;
111
119typedef struct
120{
121 uint8_t *outputData;
123 uint16_t bytesWritten;
125
136typedef enum
137{
141
150typedef struct
151{
152 const uint8_t *inputData;
156
167typedef struct
168{
169 void *PCMData;
170 uint16_t PCMDataLength;
171 uint16_t bytesWritten;
172 uint16_t PLCCounter;
174
175
176/******************************************************************************
177* Function Prototypes
178******************************************************************************/
238int32_t OSALCALL LC3Initialize(uint8_t encoderSampleRates, uint8_t decoderSampleRates, LC3FrameSizeConfig_t frameSizeConfig, uint8_t uniqueSessions, uint8_t *buffer, uint32_t *bufferSize);
239
240
256
257
294LC3EncoderHandle_t OSALCALL LC3EncodeSessionOpen(uint16_t sampleRate, uint8_t bitsPerSample, LC3FrameSize_t frameSize, uint8_t *buffer, uint16_t *bufferSize, int32_t *result);
295
296
309int32_t OSALCALL LC3EncodeSessionData(LC3EncoderHandle_t encodeHandle, LC3EncodeInput_t *encodeInput, LC3EncodeOutput_t *encodeOutput);
310
311
321
322
359LC3DecoderHandle_t OSALCALL LC3DecodeSessionOpen(uint16_t sampleRate, uint8_t bitsPerSample, LC3FrameSize_t frameSize, uint8_t *buffer, uint16_t *bufferSize, int32_t *result);
360
361
384int32_t OSALCALL LC3DecodeSessionData(LC3DecoderHandle_t decodeHandle, LC3DecodeInput_t *decodeInput, LC3DecodeOutput_t *decodeOutput);
385
386
396
397
413uint16_t OSALCALL LC3BitstreamBuffersize(uint16_t sampleRate, uint32_t maxBitRate, LC3FrameSize_t frameSize, int32_t *result);
414
415
429uint16_t OSALCALL LC3PCMBuffersize(uint16_t sampleRate, uint8_t bitDepth, LC3FrameSize_t frameSize, int32_t *result);
430 /* LC3 */
432
433#ifdef __cplusplus
434};
435#endif
436
437#endif /* _LC3APIH_ */
void LC3DecodeSessionClose(LC3DecoderHandle_t decodeHandle)
Closes an LC3 Decoder session.
uint16_t LC3PCMBuffersize(uint16_t sampleRate, uint8_t bitDepth, LC3FrameSize_t frameSize, int32_t *result)
Calculates the buffer size required for PCM data.
LC3FrameSize_t
Session Frame Size.
Definition: LC3API.h:90
@ LC3FrameSize10Ms
10 msec frame size.
Definition: LC3API.h:91
@ LC3FrameSize7_5Ms
7.5 msec frame size.
Definition: LC3API.h:92
int32_t LC3EncodeSessionData(LC3EncoderHandle_t encodeHandle, LC3EncodeInput_t *encodeInput, LC3EncodeOutput_t *encodeOutput)
Encodes a frame of data using LC3.
int32_t LC3DecodeSessionData(LC3DecoderHandle_t decodeHandle, LC3DecodeInput_t *decodeInput, LC3DecodeOutput_t *decodeOutput)
Decodes a frame of data using LC3.
uint16_t LC3BitstreamBuffersize(uint16_t sampleRate, uint32_t maxBitRate, LC3FrameSize_t frameSize, int32_t *result)
Calculates the buffer size required for bit stream data.
int32_t LC3Deinitialize(void)
Deinitializes the LC3 Codec.
LC3DecoderHandle_t LC3DecodeSessionOpen(uint16_t sampleRate, uint8_t bitsPerSample, LC3FrameSize_t frameSize, uint8_t *buffer, uint16_t *bufferSize, int32_t *result)
Opens and initializes an LC3 Decoder session.
void * LC3DecoderHandle_t
LC3 decoder handle type.
Definition: LC3API.h:70
void * LC3EncoderHandle_t
LC3 encoder handle type.
Definition: LC3API.h:67
LC3BFI_t
Bad Frame Indicator (BFI).
Definition: LC3API.h:137
@ BadFrame
Definition: LC3API.h:139
@ GoodFrame
Definition: LC3API.h:138
LC3FrameSizeConfig_t
Frame Size for configuration.
Definition: LC3API.h:79
@ LC3FrameSizeBothConfig
7.5 and 10 msec frame size.
Definition: LC3API.h:82
@ LC3FrameSize7_5MsConfig
7.5 msec frame size.
Definition: LC3API.h:81
@ LC3FrameSize10MsConfig
10 msec frame size.
Definition: LC3API.h:80
void LC3EncodeSessionClose(LC3EncoderHandle_t encodeHandle)
Closes an LC3 Encoder session.
LC3EncoderHandle_t LC3EncodeSessionOpen(uint16_t sampleRate, uint8_t bitsPerSample, LC3FrameSize_t frameSize, uint8_t *buffer, uint16_t *bufferSize, int32_t *result)
Opens and initializes an LC3 Encoder session.
int32_t LC3Initialize(uint8_t encoderSampleRates, uint8_t decoderSampleRates, LC3FrameSizeConfig_t frameSizeConfig, uint8_t uniqueSessions, uint8_t *buffer, uint32_t *bufferSize)
Initializes the LC3 Codec.
#define OSALCALL
OSAL calling convention.
Definition: osal_types.h:15
uint16_t inputDataLength
Number of data bytes in the encoded frame.
Definition: LC3API.h:153
LC3BFI_t badFrameIndicator
Frame condition as detected by device.
Definition: LC3API.h:154
const uint8_t * inputData
Pointer to the input LC3 data to decode.
Definition: LC3API.h:152
LC3 decoder input bit stream structure.
Definition: LC3API.h:151
uint16_t PLCCounter
Number of successive frames to which PLC has been applied.
Definition: LC3API.h:172
uint16_t PCMDataLength
Output buffer size in bytes.
Definition: LC3API.h:170
void * PCMData
Output buffer pointer.
Definition: LC3API.h:169
uint16_t bytesWritten
Number of bytes written to the output buffer.
Definition: LC3API.h:171
LC3 decoder output PCM structure.
Definition: LC3API.h:168
uint16_t PCMDataLength
Length of PCM data in bytes.
Definition: LC3API.h:107
const void * PCMData
Pointer to the PCM data to encode.
Definition: LC3API.h:106
uint16_t bytesRead
Number of PCM data bytes read.
Definition: LC3API.h:109
uint32_t encodeBitrate
Bit rate, in bits per second, at which to encode frame.
Definition: LC3API.h:108
LC3 encoder input PCM data structure.
Definition: LC3API.h:105
uint16_t outputDataLength
Output buffer size in bytes.
Definition: LC3API.h:122
uint8_t * outputData
Output buffer pointer.
Definition: LC3API.h:121
uint16_t bytesWritten
Number of bit stream bytes written.
Definition: LC3API.h:123
LC3 encoder output data structure.
Definition: LC3API.h:120