xref: /btstack/src/le-audio/le_audio_base_builder.h (revision 0f7e8cae038aa9786ac66a32580f63137ad93b7f)
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 LE_AUDIO_BASE_BUILDER_H
37 #define LE_AUDIO_BASE_BUILDER_H
38 
39 #include <stdint.h>
40 
41 #if defined __cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct {
46     uint8_t * buffer;
47     uint16_t  size;
48     uint16_t len;
49     uint16_t subgroup_offset;
50     uint16_t bis_offset;
51 } le_audio_base_builder_t;
52 
53 /**
54  * Initialize BASE
55  * @param builder
56  * @param buffer to setup BASE
57  * @param size of buffer
58  * @param presentation_delay_us
59  */
60 void le_audio_base_builder_init(le_audio_base_builder_t * builder, uint8_t * buffer, uint16_t size, uint32_t presentation_delay_us);
61 
62 /**
63  * Add subgroup to current BASE
64  * @param builder
65  * @param codec_id of 5 bytes
66  * @param codec_specific_configuration_length
67  * @param codec_specific_configuration
68  * @param metadata_length
69  * @param metadata
70  */
71 void le_audio_base_builder_add_subgroup(le_audio_base_builder_t * builder,
72                                         const uint8_t * codec_id,
73                                         uint8_t codec_specific_configuration_length, const uint8_t * codec_specific_configuration,
74                                         uint8_t metadata_length, const uint8_t * metadata);
75 
76 /**
77  * Add BIS to current BASE
78  * @param builder
79  * @param bis_index
80  * @param codec_specific_configuration_length
81  * @param codec_specific_configuration
82  */
83 void le_audio_base_builder_add_bis(le_audio_base_builder_t * builder,
84                                    uint8_t bis_index,
85                                    uint8_t codec_specific_configuration_length,
86                                    const uint8_t * codec_specific_configuration);
87 
88 /**
89  * Get Size of BASE for Periodic Advertising
90  * @param builder
91  * @return
92  */
93 uint16_t le_audio_base_builder_get_ad_data_size(const le_audio_base_builder_t * builder);
94 
95 #if defined __cplusplus
96 }
97 #endif
98 
99 #endif // LE_AUDIO_BASE_BUILDER_H
100