15deb0bb6SMatthias Ringwald /* 25deb0bb6SMatthias Ringwald * Copyright (C) 2022 BlueKitchen GmbH 35deb0bb6SMatthias Ringwald * 45deb0bb6SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 55deb0bb6SMatthias Ringwald * modification, are permitted provided that the following conditions 65deb0bb6SMatthias Ringwald * are met: 75deb0bb6SMatthias Ringwald * 85deb0bb6SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 95deb0bb6SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 105deb0bb6SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 115deb0bb6SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 125deb0bb6SMatthias Ringwald * documentation and/or other materials provided with the distribution. 135deb0bb6SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 145deb0bb6SMatthias Ringwald * contributors may be used to endorse or promote products derived 155deb0bb6SMatthias Ringwald * from this software without specific prior written permission. 165deb0bb6SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 175deb0bb6SMatthias Ringwald * personal benefit and not for any commercial purpose or for 185deb0bb6SMatthias Ringwald * monetary gain. 195deb0bb6SMatthias Ringwald * 205deb0bb6SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 215deb0bb6SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 225deb0bb6SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 235deb0bb6SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 245deb0bb6SMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 255deb0bb6SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 265deb0bb6SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 275deb0bb6SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 285deb0bb6SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 295deb0bb6SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 305deb0bb6SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 315deb0bb6SMatthias Ringwald * SUCH DAMAGE. 325deb0bb6SMatthias Ringwald * 335deb0bb6SMatthias Ringwald * Please inquire about commercial licensing options at 345deb0bb6SMatthias Ringwald * [email protected] 355deb0bb6SMatthias Ringwald * 365deb0bb6SMatthias Ringwald */ 375deb0bb6SMatthias Ringwald 385deb0bb6SMatthias Ringwald /** 395deb0bb6SMatthias Ringwald * @title LE Audio Util 405deb0bb6SMatthias Ringwald * 415deb0bb6SMatthias Ringwald */ 425deb0bb6SMatthias Ringwald 435deb0bb6SMatthias Ringwald #ifndef LE_AUDIO_UTIL_H 445deb0bb6SMatthias Ringwald #define LE_AUDIO_UTIL_H 455deb0bb6SMatthias Ringwald 465deb0bb6SMatthias Ringwald #include <stdint.h> 475deb0bb6SMatthias Ringwald #include "le_audio.h" 48597c9a4eSMilanka Ringwald #include "btstack_lc3.h" 495deb0bb6SMatthias Ringwald 505deb0bb6SMatthias Ringwald #if defined __cplusplus 515deb0bb6SMatthias Ringwald extern "C" { 525deb0bb6SMatthias Ringwald #endif 535deb0bb6SMatthias Ringwald 5454461c80SMatthias Ringwald uint16_t le_audio_util_virtual_memcpy_helper( 555deb0bb6SMatthias Ringwald const uint8_t * field_data, uint16_t field_len, uint16_t field_offset, 565deb0bb6SMatthias Ringwald uint8_t * buffer, uint16_t buffer_size, uint16_t buffer_offset); 575deb0bb6SMatthias Ringwald 5854461c80SMatthias Ringwald uint16_t le_audio_util_metadata_virtual_memcpy(const le_audio_metadata_t * metadata, uint8_t metadata_length, uint16_t * records_offset, uint8_t * buffer, uint16_t buffer_size, uint16_t buffer_offset); 595deb0bb6SMatthias Ringwald 6054461c80SMatthias Ringwald uint16_t le_audio_util_metadata_parse(uint8_t * buffer, uint8_t buffer_size, le_audio_metadata_t * metadata); 615deb0bb6SMatthias Ringwald 6254461c80SMatthias Ringwald uint16_t le_audio_util_metadata_serialize(le_audio_metadata_t * metadata, uint8_t * event, uint16_t event_size); 635deb0bb6SMatthias Ringwald 64fd6b825bSMatthias Ringwald uint16_t le_audio_util_metadata_serialize_using_mask(le_audio_metadata_t * metadata, uint8_t * tlv_buffer, uint16_t tlv_buffer_size); 65fd6b825bSMatthias Ringwald 66597c9a4eSMilanka Ringwald 67*09d23cbeSMilanka Ringwald btstack_lc3_frame_duration_t le_audio_util_get_btstack_lc3_frame_duration(le_audio_codec_frame_duration_index_t frame_duration_index); 68*09d23cbeSMilanka Ringwald 69*09d23cbeSMilanka Ringwald uint16_t le_audio_get_frame_duration_us(le_audio_codec_frame_duration_index_t frame_duration_index); 70*09d23cbeSMilanka Ringwald le_audio_codec_frame_duration_index_t le_audio_get_frame_duration_index(uint16_t frame_duration_us); 71*09d23cbeSMilanka Ringwald 72*09d23cbeSMilanka Ringwald 73*09d23cbeSMilanka Ringwald uint32_t le_audio_get_sampling_frequency_hz(le_audio_codec_sampling_frequency_index_t sampling_frequency_index); 74*09d23cbeSMilanka Ringwald le_audio_codec_sampling_frequency_index_t le_audio_get_sampling_frequency_index(uint32_t sampling_frequency_hz); 75597c9a4eSMilanka Ringwald 765deb0bb6SMatthias Ringwald #if defined __cplusplus 775deb0bb6SMatthias Ringwald } 785deb0bb6SMatthias Ringwald #endif 795deb0bb6SMatthias Ringwald 805deb0bb6SMatthias Ringwald #endif 815deb0bb6SMatthias Ringwald 82