mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 02:42:33 +00:00
hfp ag: update choose codec
This commit is contained in:
parent
db770bf93a
commit
df327ff315
@ -129,6 +129,14 @@ int send_str_over_rfcomm(uint16_t cid, char * command){
|
||||
return 1;
|
||||
}
|
||||
|
||||
int hfp_supports_codec(uint8_t codec, int codecs_nr, uint16_t * codecs){
|
||||
int i;
|
||||
for (i = 0; i < codecs_nr; i++){
|
||||
if (codecs[i] == codec) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void hfp_set_codec(hfp_connection_t * hfp_connection, uint8_t *packet, uint16_t size){
|
||||
// parse available codecs
|
||||
|
@ -644,6 +644,7 @@ void hfp_reset_context_flags(hfp_connection_t * connection);
|
||||
void hfp_release_audio_connection(hfp_connection_t * connection);
|
||||
|
||||
void hfp_setup_synchronous_connection(hfp_connection_t * connection);
|
||||
int hfp_supports_codec(uint8_t codec, int codecs_nr, uint16_t * codecs);
|
||||
|
||||
const char * hfp_hf_feature(int index);
|
||||
const char * hfp_ag_feature(int index);
|
||||
|
@ -518,19 +518,13 @@ static int hfp_ag_set_response_and_hold(uint16_t cid, int state){
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t hfp_ag_suggest_codec(hfp_connection_t *hfp_connection){
|
||||
int i,j;
|
||||
uint8_t codec = HFP_CODEC_CVSD;
|
||||
for (i = 0; i < hfp_codecs_nr; i++){
|
||||
for (j = 0; j < hfp_connection->remote_codecs_nr; j++){
|
||||
if (hfp_connection->remote_codecs[j] == hfp_codecs[i]){
|
||||
codec = hfp_connection->remote_codecs[j];
|
||||
continue;
|
||||
}
|
||||
if (hfp_supports_codec(HFP_CODEC_MSBC, hfp_codecs_nr, (uint16_t *)hfp_codecs)){
|
||||
if (hfp_supports_codec(HFP_CODEC_MSBC, hfp_connection->remote_codecs_nr, (uint16_t *)(hfp_connection->remote_codecs))){
|
||||
return HFP_CODEC_MSBC;
|
||||
}
|
||||
}
|
||||
return codec;
|
||||
return HFP_CODEC_CVSD;
|
||||
}
|
||||
|
||||
static int codecs_exchange_state_machine(hfp_connection_t * hfp_connection){
|
||||
|
@ -139,13 +139,6 @@ static void hfp_hf_emit_enhanced_call_status(btstack_packet_handler_t callback,
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static int hfp_hf_supports_codec(uint8_t codec){
|
||||
int i;
|
||||
for (i = 0; i < hfp_codecs_nr; i++){
|
||||
if (hfp_codecs[i] == codec) return 1;
|
||||
}
|
||||
return HFP_CODEC_CVSD;
|
||||
}
|
||||
static int has_codec_negotiation_feature(hfp_connection_t * hfp_connection){
|
||||
int hf = get_bit(hfp_supported_features, HFP_HFSF_CODEC_NEGOTIATION);
|
||||
int ag = get_bit(hfp_connection->remote_supported_features, HFP_AGSF_CODEC_NEGOTIATION);
|
||||
@ -523,7 +516,7 @@ static int codecs_exchange_state_machine(hfp_connection_t * hfp_connection){
|
||||
break;
|
||||
|
||||
case HFP_CMD_AG_SUGGESTED_CODEC:
|
||||
if (hfp_hf_supports_codec(hfp_connection->suggested_codec)){
|
||||
if (hfp_supports_codec(hfp_connection->suggested_codec, hfp_codecs_nr, (uint16_t *)hfp_codecs)){
|
||||
hfp_connection->codec_confirmed = hfp_connection->suggested_codec;
|
||||
hfp_connection->ok_pending = 1;
|
||||
hfp_connection->codecs_state = HFP_CODECS_HF_CONFIRMED_CODEC;
|
||||
|
Loading…
x
Reference in New Issue
Block a user