• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef fooa2dpcodechfoo
2 #define fooa2dpcodechfoo
3 
4 /***
5   This file is part of PulseAudio.
6 
7   Copyright 2018-2019 Pali Rohár <pali.rohar@gmail.com>
8 
9   PulseAudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13 
14   PulseAudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   General Public License for more details.
18 
19   You should have received a copy of the GNU Lesser General Public
20   License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
21 ***/
22 
23 #include <pulsecore/core.h>
24 
25 #include "bt-codec-api.h"
26 
27 #define MAX_A2DP_CAPS_SIZE 254
28 #define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
29 
30 typedef struct pa_a2dp_codec_capabilities {
31     uint8_t size;
32     uint8_t buffer[]; /* max size is 254 bytes */
33 } pa_a2dp_codec_capabilities;
34 
35 typedef struct pa_a2dp_codec_id {
36     uint8_t codec_id;
37     uint32_t vendor_id;
38     uint16_t vendor_codec_id;
39 } pa_a2dp_codec_id;
40 
41 typedef struct pa_a2dp_endpoint_conf {
42     /* A2DP codec id */
43     pa_a2dp_codec_id id;
44 
45     /* True if codec is bi-directional and supports backchannel */
46     bool support_backchannel;
47 
48     /* Returns true if the codec can be supported on the system */
49     bool (*can_be_supported)(bool for_encoding);
50 
51     /* Returns true if codec accepts capabilities, for_encoding is true when
52      * capabilities are used for encoding */
53     bool (*can_accept_capabilities)(const uint8_t *capabilities_buffer, uint8_t capabilities_size, bool for_encoding);
54     /* Choose remote endpoint based on capabilities from hash map
55      * (const char *endpoint -> const pa_a2dp_codec_capabilities *capability)
56      * and returns corresponding endpoint key (or NULL when there is no valid),
57      * for_encoder is true when capabilities hash map is used for encoding */
58     const char *(*choose_remote_endpoint)(const pa_hashmap *capabilities_hashmap, const pa_sample_spec *default_sample_spec, bool for_encoding);
59     /* Fill codec capabilities, returns size of filled buffer */
60     uint8_t (*fill_capabilities)(uint8_t capabilities_buffer[MAX_A2DP_CAPS_SIZE]);
61     /* Validate codec configuration, returns true on success */
62     bool (*is_configuration_valid)(const uint8_t *config_buffer, uint8_t config_size);
63     /* Fill preferred codec configuration, returns size of filled buffer or 0 on failure */
64     uint8_t (*fill_preferred_configuration)(const pa_sample_spec *default_sample_spec, const uint8_t *capabilities_buffer, uint8_t capabilities_size, uint8_t config_buffer[MAX_A2DP_CAPS_SIZE]);
65 
66     /* Bluetooth codec */
67     pa_bt_codec bt_codec;
68 } pa_a2dp_endpoint_conf;
69 
70 #endif
71