a2dp.c (edc66e936ab3a2673246aba13c74990fb983b8fa) a2dp.c (6d3263ec491c8c502d2f33782fd7ae497db4ee9d)
1/*
2 * Copyright (C) 2022 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 480 unchanged lines hidden (view full) ---

489void a2dp_config_process_avdtp_event_handler(avdtp_role_t role, uint8_t *packet, uint16_t size) {
490 uint16_t cid;
491 avdtp_connection_t * connection;
492 a2dp_config_process_t * config_process;
493 uint8_t signal_identifier;
494 uint8_t status;
495 uint8_t local_seid;
496 uint8_t remote_seid;
1/*
2 * Copyright (C) 2022 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 480 unchanged lines hidden (view full) ---

489void a2dp_config_process_avdtp_event_handler(avdtp_role_t role, uint8_t *packet, uint16_t size) {
490 uint16_t cid;
491 avdtp_connection_t * connection;
492 a2dp_config_process_t * config_process;
493 uint8_t signal_identifier;
494 uint8_t status;
495 uint8_t local_seid;
496 uint8_t remote_seid;
497 bool outgoing_active;
497
498 switch (hci_event_avdtp_meta_get_subevent_code(packet)){
499 case AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED:
500 cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
501 connection = avdtp_get_connection_for_avdtp_cid(cid);
502 btstack_assert(connection != NULL);
503 config_process = a2dp_config_process_for_role(role, connection);
504

--- 250 unchanged lines hidden (view full) ---

755 a2dp_config_process_handle_media_configuration(role, packet, local_seid);
756 a2dp_replace_subevent_id_and_emit_for_role(role, packet, size,
757 A2DP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION);
758 break;
759 case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
760 cid = avdtp_subevent_streaming_connection_established_get_avdtp_cid(packet);
761 connection = avdtp_get_connection_for_avdtp_cid(cid);
762 btstack_assert(connection != NULL);
498
499 switch (hci_event_avdtp_meta_get_subevent_code(packet)){
500 case AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED:
501 cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
502 connection = avdtp_get_connection_for_avdtp_cid(cid);
503 btstack_assert(connection != NULL);
504 config_process = a2dp_config_process_for_role(role, connection);
505

--- 250 unchanged lines hidden (view full) ---

756 a2dp_config_process_handle_media_configuration(role, packet, local_seid);
757 a2dp_replace_subevent_id_and_emit_for_role(role, packet, size,
758 A2DP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION);
759 break;
760 case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
761 cid = avdtp_subevent_streaming_connection_established_get_avdtp_cid(packet);
762 connection = avdtp_get_connection_for_avdtp_cid(cid);
763 btstack_assert(connection != NULL);
763 config_process = a2dp_config_process_for_role(role, connection);
764
764
765 if (config_process->state != A2DP_W4_OPEN_STREAM_WITH_SEID) break;
766
765 config_process = a2dp_config_process_for_role(role, connection);
766 outgoing_active = config_process->outgoing_active;
767 config_process->outgoing_active = false;
768 status = avdtp_subevent_streaming_connection_established_get_status(packet);
769 if (status != ERROR_CODE_SUCCESS){
770 log_info("A2DP source streaming connection could not be established, avdtp_cid 0x%02x, status 0x%02x ---", cid, status);
767 config_process->outgoing_active = false;
768 status = avdtp_subevent_streaming_connection_established_get_status(packet);
769 if (status != ERROR_CODE_SUCCESS){
770 log_info("A2DP source streaming connection could not be established, avdtp_cid 0x%02x, status 0x%02x ---", cid, status);
771 config_process->state = A2DP_CONNECTED;
772 // suppress event if streaming wasn't requested by us
773 if (outgoing_active == false){
774 break;
775 }
771 } else {
772 log_info("A2DP source streaming connection established --- avdtp_cid 0x%02x, local seid 0x%02x, remote seid 0x%02x", cid,
773 avdtp_subevent_streaming_connection_established_get_local_seid(packet),
774 avdtp_subevent_streaming_connection_established_get_remote_seid(packet));
775 config_process->state = A2DP_STREAMING_OPENED;
776 }
777 a2dp_replace_subevent_id_and_emit_for_role(role, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED);
778 break;

--- 265 unchanged lines hidden ---
776 } else {
777 log_info("A2DP source streaming connection established --- avdtp_cid 0x%02x, local seid 0x%02x, remote seid 0x%02x", cid,
778 avdtp_subevent_streaming_connection_established_get_local_seid(packet),
779 avdtp_subevent_streaming_connection_established_get_remote_seid(packet));
780 config_process->state = A2DP_STREAMING_OPENED;
781 }
782 a2dp_replace_subevent_id_and_emit_for_role(role, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED);
783 break;

--- 265 unchanged lines hidden ---