1 #pragma once 2 3 /*** 4 This file is part of PulseAudio. 5 6 PulseAudio is free software; you can redistribute it and/or modify 7 it under the terms of the GNU Lesser General Public License as 8 published by the Free Software Foundation; either version 2.1 of the 9 License, or (at your option) any later version. 10 11 PulseAudio is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 18 ***/ 19 20 #include <pulsecore/core.h> 21 22 typedef struct pa_bt_codec { 23 /* Unique name of the codec, lowercase and without whitespaces, used for 24 * constructing identifier, D-Bus paths, ... */ 25 const char *name; 26 /* Human readable codec description */ 27 const char *description; 28 29 /* True if codec is bi-directional and supports backchannel */ 30 bool support_backchannel; 31 32 /* Initialize codec, returns codec info data and set sample_spec, 33 * for_encoding is true when codec_info is used for encoding, 34 * for_backchannel is true when codec_info is used for backchannel */ 35 void *(*init)(bool for_encoding, bool for_backchannel, const uint8_t *config_buffer, uint8_t config_size, pa_sample_spec *sample_spec, pa_core *core); 36 /* Deinitialize and release codec info data in codec_info */ 37 void (*deinit)(void *codec_info); 38 /* Reset internal state of codec info data in codec_info, returns 39 * a negative value on failure */ 40 int (*reset)(void *codec_info); 41 42 /* Get read block size for codec, it is minimal size of buffer 43 * needed to decode read_link_mtu bytes of encoded data */ 44 size_t (*get_read_block_size)(void *codec_info, size_t read_link_mtu); 45 /* Get write block size for codec, it is maximal size of buffer 46 * which can produce at most write_link_mtu bytes of encoded data */ 47 size_t (*get_write_block_size)(void *codec_info, size_t write_link_mtu); 48 /* Get encoded block size for codec to hold one encoded frame. 49 * Note HFP mSBC codec encoded block may not fit into one MTU and is sent out in chunks. */ 50 size_t (*get_encoded_block_size)(void *codec_info, size_t input_size); 51 52 /* Reduce encoder bitrate for codec, returns new write block size or zero 53 * if not changed, called when socket is not accepting encoded data fast 54 * enough */ 55 size_t (*reduce_encoder_bitrate)(void *codec_info, size_t write_link_mtu); 56 57 /* Increase encoder bitrate for codec, returns new write block size or zero 58 * if not changed, called periodically when socket is keeping up with 59 * encoded data */ 60 size_t (*increase_encoder_bitrate)(void *codec_info, size_t write_link_mtu); 61 62 /* Encode input_buffer of input_size to output_buffer of output_size, 63 * returns size of filled ouput_buffer and set processed to size of 64 * processed input_buffer */ 65 size_t (*encode_buffer)(void *codec_info, uint32_t timestamp, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed); 66 /* Decode input_buffer of input_size to output_buffer of output_size, 67 * returns size of filled ouput_buffer and set processed to size of 68 * processed input_buffer */ 69 size_t (*decode_buffer)(void *codec_info, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed); 70 71 /* Get volume factor which needs to be applied to output samples */ 72 double (*get_source_output_volume_factor_dB)(void *codec_info); 73 } pa_bt_codec; 74