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 /* Initialize codec, returns codec info data and set sample_spec, 30 * for_encoding is true when codec_info is used for encoding, 31 * for_backchannel is true when codec_info is used for backchannel */ 32 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); 33 /* Deinitialize and release codec info data in codec_info */ 34 void (*deinit)(void *codec_info); 35 /* Reset internal state of codec info data in codec_info, returns 36 * a negative value on failure */ 37 int (*reset)(void *codec_info); 38 39 /* Get read block size for codec, it is minimal size of buffer 40 * needed to decode read_link_mtu bytes of encoded data */ 41 size_t (*get_read_block_size)(void *codec_info, size_t read_link_mtu); 42 /* Get write block size for codec, it is maximal size of buffer 43 * which can produce at most write_link_mtu bytes of encoded data */ 44 size_t (*get_write_block_size)(void *codec_info, size_t write_link_mtu); 45 /* Get encoded block size for codec to hold one encoded frame. 46 * Note HFP mSBC codec encoded block may not fit into one MTU and is sent out in chunks. */ 47 size_t (*get_encoded_block_size)(void *codec_info, size_t input_size); 48 49 /* Reduce encoder bitrate for codec, returns new write block size or zero 50 * if not changed, called when socket is not accepting encoded data fast 51 * enough */ 52 size_t (*reduce_encoder_bitrate)(void *codec_info, size_t write_link_mtu); 53 54 /* Increase encoder bitrate for codec, returns new write block size or zero 55 * if not changed, called periodically when socket is keeping up with 56 * encoded data */ 57 size_t (*increase_encoder_bitrate)(void *codec_info, size_t write_link_mtu); 58 59 /* Encode input_buffer of input_size to output_buffer of output_size, 60 * returns size of filled ouput_buffer and set processed to size of 61 * processed input_buffer */ 62 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); 63 /* Decode input_buffer of input_size to output_buffer of output_size, 64 * returns size of filled ouput_buffer and set processed to size of 65 * processed input_buffer */ 66 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); 67 } pa_bt_codec; 68