1*2e624289SMatthias Ringwald /* 2*2e624289SMatthias Ringwald * Copyright (C) 2022 BlueKitchen GmbH 3*2e624289SMatthias Ringwald * 4*2e624289SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*2e624289SMatthias Ringwald * modification, are permitted provided that the following conditions 6*2e624289SMatthias Ringwald * are met: 7*2e624289SMatthias Ringwald * 8*2e624289SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*2e624289SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*2e624289SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*2e624289SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*2e624289SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*2e624289SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*2e624289SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*2e624289SMatthias Ringwald * from this software without specific prior written permission. 16*2e624289SMatthias Ringwald * 17*2e624289SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 18*2e624289SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19*2e624289SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20*2e624289SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 21*2e624289SMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22*2e624289SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23*2e624289SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24*2e624289SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25*2e624289SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26*2e624289SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27*2e624289SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28*2e624289SMatthias Ringwald * SUCH DAMAGE. 29*2e624289SMatthias Ringwald * 30*2e624289SMatthias Ringwald */ 31*2e624289SMatthias Ringwald 32*2e624289SMatthias Ringwald /** 33*2e624289SMatthias Ringwald * @title Broadcast Audio Source Endpoint AD Parser 34*2e624289SMatthias Ringwald */ 35*2e624289SMatthias Ringwald 36*2e624289SMatthias Ringwald #ifndef LE_AUDIO_BASE_PARSER_H 37*2e624289SMatthias Ringwald #define LE_AUDIO_BASE_PARSER_H 38*2e624289SMatthias Ringwald 39*2e624289SMatthias Ringwald #include <stdint.h> 40*2e624289SMatthias Ringwald 41*2e624289SMatthias Ringwald #if defined __cplusplus 42*2e624289SMatthias Ringwald extern "C" { 43*2e624289SMatthias Ringwald #endif 44*2e624289SMatthias Ringwald 45*2e624289SMatthias Ringwald typedef struct { 46*2e624289SMatthias Ringwald const uint8_t * buffer; 47*2e624289SMatthias Ringwald uint16_t size; 48*2e624289SMatthias Ringwald uint8_t subgroup_index; 49*2e624289SMatthias Ringwald uint8_t subgroup_count; 50*2e624289SMatthias Ringwald uint16_t subgroup_offset; 51*2e624289SMatthias Ringwald uint8_t subgroup_codec_specific_configuration_len; 52*2e624289SMatthias Ringwald uint8_t subgroup_metadata_len; 53*2e624289SMatthias Ringwald uint8_t bis_index; 54*2e624289SMatthias Ringwald uint8_t bis_count; 55*2e624289SMatthias Ringwald uint16_t bis_offset; 56*2e624289SMatthias Ringwald } le_audio_base_parser_t; 57*2e624289SMatthias Ringwald 58*2e624289SMatthias Ringwald /** 59*2e624289SMatthias Ringwald * Initialize BASE 60*2e624289SMatthias Ringwald * @param parser 61*2e624289SMatthias Ringwald * @param buffer to setup BASE 62*2e624289SMatthias Ringwald * @param size of buffer 63*2e624289SMatthias Ringwald * @param presentation_delay_us 64*2e624289SMatthias Ringwald * @return valid BASE struct found 65*2e624289SMatthias Ringwald */ 66*2e624289SMatthias Ringwald bool le_audio_base_parser_init(le_audio_base_parser_t * parser, const uint8_t * buffer, uint16_t size); 67*2e624289SMatthias Ringwald 68*2e624289SMatthias Ringwald /** 69*2e624289SMatthias Ringwald * Get number of subgroups in BASE 70*2e624289SMatthias Ringwald * @param parser 71*2e624289SMatthias Ringwald * @return 72*2e624289SMatthias Ringwald */ 73*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_get_num_subgroups(le_audio_base_parser_t * parser); 74*2e624289SMatthias Ringwald 75*2e624289SMatthias Ringwald /** 76*2e624289SMatthias Ringwald * Get Pressentation Delay in us 77*2e624289SMatthias Ringwald * @param parser 78*2e624289SMatthias Ringwald * @return 79*2e624289SMatthias Ringwald */ 80*2e624289SMatthias Ringwald uint32_t le_audio_base_parser_get_presentation_delay(le_audio_base_parser_t * parser); 81*2e624289SMatthias Ringwald 82*2e624289SMatthias Ringwald /** 83*2e624289SMatthias Ringwald * Get Num BIS for current subgroup 84*2e624289SMatthias Ringwald * @param parser 85*2e624289SMatthias Ringwald * @return 86*2e624289SMatthias Ringwald */ 87*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_subgroup_get_num_bis(le_audio_base_parser_t * parser); 88*2e624289SMatthias Ringwald 89*2e624289SMatthias Ringwald /** 90*2e624289SMatthias Ringwald * Get Codec ID for current subgroup 91*2e624289SMatthias Ringwald * @param parser 92*2e624289SMatthias Ringwald * @return true if successful 93*2e624289SMatthias Ringwald */ 94*2e624289SMatthias Ringwald const uint8_t * le_audio_base_parser_subgroup_get_codec_id(le_audio_base_parser_t * parser); 95*2e624289SMatthias Ringwald 96*2e624289SMatthias Ringwald /** 97*2e624289SMatthias Ringwald * Get Codec Specific Configuration Length for current subgroup 98*2e624289SMatthias Ringwald * @param parser 99*2e624289SMatthias Ringwald * @return 100*2e624289SMatthias Ringwald */ 101*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_subgroup_get_codec_specific_configuration_length(le_audio_base_parser_t * parser); 102*2e624289SMatthias Ringwald 103*2e624289SMatthias Ringwald /** 104*2e624289SMatthias Ringwald * Get Codec Specific Configuration for current subgroup 105*2e624289SMatthias Ringwald * @param parser 106*2e624289SMatthias Ringwald * @return 107*2e624289SMatthias Ringwald */ 108*2e624289SMatthias Ringwald const uint8_t * le_audio_base_parser_subgroup_get_codec_specific_configuration(le_audio_base_parser_t * parser); 109*2e624289SMatthias Ringwald 110*2e624289SMatthias Ringwald /** 111*2e624289SMatthias Ringwald * Get Metadata Length for current subgroup 112*2e624289SMatthias Ringwald * @param parser 113*2e624289SMatthias Ringwald * @return 114*2e624289SMatthias Ringwald */ 115*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_subgroup_get_metadata_length(le_audio_base_parser_t * parser); 116*2e624289SMatthias Ringwald 117*2e624289SMatthias Ringwald /** 118*2e624289SMatthias Ringwald * Get Metadata for current subgroup 119*2e624289SMatthias Ringwald * @param parser 120*2e624289SMatthias Ringwald * @return 121*2e624289SMatthias Ringwald */ 122*2e624289SMatthias Ringwald const uint8_t * le_audio_base_subgroup_parser_get_metadata(le_audio_base_parser_t * parser); 123*2e624289SMatthias Ringwald 124*2e624289SMatthias Ringwald /** 125*2e624289SMatthias Ringwald * Process next subgroup 126*2e624289SMatthias Ringwald * @param parser 127*2e624289SMatthias Ringwald */ 128*2e624289SMatthias Ringwald void le_audio_base_parser_subgroup_next(le_audio_base_parser_t * parser); 129*2e624289SMatthias Ringwald 130*2e624289SMatthias Ringwald /** 131*2e624289SMatthias Ringwald * Get BIS Index for current BIS 132*2e624289SMatthias Ringwald * @param parser 133*2e624289SMatthias Ringwald * @return 134*2e624289SMatthias Ringwald */ 135*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_bis_get_index(le_audio_base_parser_t * parser); 136*2e624289SMatthias Ringwald 137*2e624289SMatthias Ringwald /** 138*2e624289SMatthias Ringwald * Get Codec Specific Configuration Length for current BIS 139*2e624289SMatthias Ringwald * @param parser 140*2e624289SMatthias Ringwald * @return 141*2e624289SMatthias Ringwald */ 142*2e624289SMatthias Ringwald uint8_t le_audio_base_parser_bis_get_codec_specific_configuration_length(le_audio_base_parser_t * parser); 143*2e624289SMatthias Ringwald 144*2e624289SMatthias Ringwald /** 145*2e624289SMatthias Ringwald * Get Codec Specific Configuration for current BIS 146*2e624289SMatthias Ringwald * @param parser 147*2e624289SMatthias Ringwald * @return 148*2e624289SMatthias Ringwald */ 149*2e624289SMatthias Ringwald const uint8_t * le_audio_base_bis_parser_get_codec_specific_configuration(le_audio_base_parser_t * parser); 150*2e624289SMatthias Ringwald 151*2e624289SMatthias Ringwald /** 152*2e624289SMatthias Ringwald * Process next BIS 153*2e624289SMatthias Ringwald * @param parser 154*2e624289SMatthias Ringwald */ 155*2e624289SMatthias Ringwald void le_audio_base_parser_bis_next(le_audio_base_parser_t * parser); 156*2e624289SMatthias Ringwald 157*2e624289SMatthias Ringwald #if defined __cplusplus 158*2e624289SMatthias Ringwald } 159*2e624289SMatthias Ringwald #endif 160*2e624289SMatthias Ringwald 161*2e624289SMatthias Ringwald #endif // BASE_BUILDER_H 162