nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
sw_codec_select.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
20#ifndef _SW_CODEC_SELECT_H_
21#define _SW_CODEC_SELECT_H_
22
23#include <zephyr/kernel.h>
24#include <zephyr/net_buf.h>
25#include "device_location.h"
26
27#if (CONFIG_SW_CODEC_LC3)
28#define LC3_MAX_FRAME_SIZE_US 10000
29#define LC3_ENC_MONO_FRAME_SIZE \
30 (CONFIG_LC3_BITRATE_MAX * LC3_MAX_FRAME_SIZE_US / (8 * USEC_PER_SEC))
31#define LC3_PCM_NUM_BYTES_MONO \
32 (CONFIG_AUDIO_SAMPLE_RATE_HZ * CONFIG_AUDIO_BIT_DEPTH_OCTETS * LC3_MAX_FRAME_SIZE_US / \
33 USEC_PER_SEC)
34#define LC3_ENC_TIME_US 3000
35#define LC3_DEC_TIME_US 1500
36#else
37#define LC3_ENC_MONO_FRAME_SIZE 0
38#define LC3_PCM_NUM_BYTES_MONO 0
39#define LC3_ENC_TIME_US 0
40#define LC3_DEC_TIME_US 0
41#endif /* CONFIG_SW_CODEC_LC3 */
42
43/* Max will be used when multiple codecs are supported */
44#define ENC_MAX_FRAME_SIZE MAX(LC3_ENC_MONO_FRAME_SIZE, 0)
45#define ENC_MULTI_CHAN_MAX_FRAME_SIZE (LC3_ENC_MONO_FRAME_SIZE * CONFIG_AUDIO_ENCODE_CHANNELS_MAX)
46#define ENC_TIME_US MAX(LC3_ENC_TIME_US, 0)
47#define DEC_TIME_US MAX(LC3_DEC_TIME_US, 0)
48#define PCM_NUM_BYTES_MONO MAX(LC3_PCM_NUM_BYTES_MONO, 0)
49#define PCM_NUM_BYTES_MULTI_CHAN \
50 (PCM_NUM_BYTES_MONO * MAX(CONFIG_AUDIO_DECODE_CHANNELS_MAX, CONFIG_AUDIO_OUTPUT_CHANNELS))
51
59
64 /* Array of encoder channel handles. */
65 struct lc3_encoder_handle *lc3_enc_channel[CONFIG_AUDIO_ENCODE_CHANNELS_MAX];
66};
67
72 /* Array of decoder channel handles. */
73 struct lc3_decoder_handle *lc3_dec_channel[CONFIG_AUDIO_DECODE_CHANNELS_MAX];
74};
75
80 bool enabled;
82 uint8_t num_ch;
83 enum bt_audio_location audio_loc;
86};
87
92 bool enabled;
93 uint8_t num_ch;
94 enum bt_audio_location audio_loc;
97};
98
108
116
128int sw_codec_encode(struct net_buf *audio_frame_in, struct net_buf *audio_frame_out);
129
141int sw_codec_decode(struct net_buf const *const audio_frame_in,
142 struct net_buf *const audio_frame_out);
143
153int sw_codec_uninit(struct sw_codec_config sw_codec_cfg);
154
164int sw_codec_init(struct sw_codec_config sw_codec_cfg);
165
170#endif /* _SW_CODEC_SELECT_H_ */
Audio location assignment.
int sw_codec_init(struct sw_codec_config sw_codec_cfg)
Initialize the software codec and statically or dynamically allocate memory to be used,...
bool sw_codec_is_initialized(void)
Check if the software codec is initialized.
int sw_codec_decode(struct net_buf const *const audio_frame_in, struct net_buf *const audio_frame_out)
Decode encoded data and output PCM data.
int sw_codec_uninit(struct sw_codec_config sw_codec_cfg)
Uninitialize the software codec and free the allocated space.
int sw_codec_encode(struct net_buf *audio_frame_in, struct net_buf *audio_frame_out)
Encode PCM data and output encoded data.
sw_codec_select
Software codec selection enumeration.
Definition sw_codec_select.h:55
@ SW_CODEC_LC3
Definition sw_codec_select.h:57
@ SW_CODEC_NONE
Definition sw_codec_select.h:56
struct lc3_decoder_handle * lc3_dec_channel[CONFIG_AUDIO_DECODE_CHANNELS_MAX]
Definition sw_codec_select.h:73
Private decoder context.
Definition sw_codec_select.h:71
struct lc3_encoder_handle * lc3_enc_channel[CONFIG_AUDIO_ENCODE_CHANNELS_MAX]
Definition sw_codec_select.h:65
Private encoder context.
Definition sw_codec_select.h:63
struct sw_codec_decoder decoder
Definition sw_codec_select.h:104
struct sw_codec_encoder encoder
Definition sw_codec_select.h:105
enum sw_codec_select sw_codec
Definition sw_codec_select.h:103
bool initialized
Definition sw_codec_select.h:106
Sw_codec configuration structure.
Definition sw_codec_select.h:102
uint8_t num_ch
Definition sw_codec_select.h:93
bool enabled
Definition sw_codec_select.h:92
struct lc3_decoder_context lc3_ctx
Definition sw_codec_select.h:96
uint32_t sample_rate_hz
Definition sw_codec_select.h:95
enum bt_audio_location audio_loc
Definition sw_codec_select.h:94
Software codec decoder configuration structure.
Definition sw_codec_select.h:91
uint8_t num_ch
Definition sw_codec_select.h:82
struct lc3_encoder_context lc3_ctx
Definition sw_codec_select.h:85
int bitrate
Definition sw_codec_select.h:81
bool enabled
Definition sw_codec_select.h:80
enum bt_audio_location audio_loc
Definition sw_codec_select.h:83
uint32_t sample_rate_hz
Definition sw_codec_select.h:84
Software codec encoder configuration structure.
Definition sw_codec_select.h:79