xref: /btstack/src/le-audio/le_audio_base_builder.h (revision 5c0702ea97b430a761a6bc354d1271bec1774822)
1 /*
2  * Copyright (C) 2022 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
21  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  */
31 
32 /**
33  * @title Broadcast Audio Source Endpoint AD Builder
34  */
35 
36 #ifndef BASE_BUILDER_H
37 #define BASE_BUILDER_H
38 
39 #include <stdint.h>
40 #include "btstack_lc3.h"
41 
42 #if defined __cplusplus
43 extern "C" {
44 #endif
45 
46 typedef struct {
47     uint8_t * buffer;
48     uint16_t  size;
49     uint16_t len;
50     uint16_t subgroup_offset;
51     uint16_t bis_offset;
52 } base_builder_t;
53 
54 /**
55  * Initialize BASE
56  * @param builder
57  * @param buffer to setup BASE
58  * @param size of buffer
59  * @param presentation_delay_us
60  */
61 void le_audio_base_builder_init(base_builder_t * builder, uint8_t * buffer, uint16_t size, uint32_t presentation_delay_us);
62 
63 /**
64  * Add subgroup to current BASE
65  * @param builder
66  * @param codec_id of 5 bytes
67  * @param codec_specific_configuration_length
68  * @param codec_specific_configuration
69  * @param metadata_length
70  * @param metadata
71  */
72 void le_audio_base_builder_add_subgroup(base_builder_t * builder,
73                                         const uint8_t * codec_id,
74                                         uint8_t codec_specific_configuration_length, const uint8_t * codec_specific_configuration,
75                                         uint8_t metadata_length, const uint8_t * metadata);
76 
77 /**
78  * Add BIS to current BASE
79  * @param builder
80  * @param bis_index
81  * @param codec_specific_configuration_length
82  * @param codec_specific_configuration
83  */
84 void le_audio_base_builder_add_bis(base_builder_t * builder,
85                                    uint8_t bis_index,
86                                    uint8_t codec_specific_configuration_length,
87                                    const uint8_t * codec_specific_configuration);
88 
89 /**
90  * Get Size of BASE for Periodic Advertising
91  * @param builder
92  * @return
93  */
94 uint16_t le_audio_base_builder_get_ad_data_size(const base_builder_t * builder);
95 
96 #if defined __cplusplus
97 }
98 #endif
99 
100 #endif // BASE_BUILDER_H
101