avdtp.c (137e295454a439f2a0681b9d5aea03a654f67f53) avdtp.c (48ce193c1bb43973676c530932628af0332bfb28)
1/*
2 * Copyright (C) 2016 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

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

1079 }
1080 }
1081
1082 connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED;
1083 l2cap_disconnect(connection->l2cap_signaling_cid, 0);
1084 return ERROR_CODE_SUCCESS;
1085}
1086
1/*
2 * Copyright (C) 2016 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

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

1079 }
1080 }
1081
1082 connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED;
1083 l2cap_disconnect(connection->l2cap_signaling_cid, 0);
1084 return ERROR_CODE_SUCCESS;
1085}
1086
1087
1088#ifdef ENABLE_AVDTP_ACCEPTOR_EXPLICIT_START_STREAM_CONFIRMATION
1089static uint8_t avdtp_handle_explicit_start_stream_confirmation(uint16_t avdtp_cid, uint8_t local_seid, bool accept_stream_requested){
1090 avdtp_connection_t * connection = avdtp_get_connection_for_avdtp_cid(avdtp_cid);
1091 if (!connection){
1092 log_error("avdtp_media_connect: no connection for signaling cid 0x%02x found", avdtp_cid);
1093 return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
1094 }
1095
1096 if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) {
1097 log_error("avdtp_media_connect: wrong connection state %d", connection->state);
1098 return ERROR_CODE_COMMAND_DISALLOWED;
1099 }
1100
1101 avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid);
1102 if (!stream_endpoint) {
1103 log_error("avdtp_media_connect: no stream_endpoint with seid %d found", local_seid);
1104 return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
1105 }
1106
1107 if (stream_endpoint->acceptor_config_state != AVDTP_ACCEPTOR_W4_USER_CONFIRM_START_STREAM){
1108 return ERROR_CODE_COMMAND_DISALLOWED;
1109 }
1110
1111 if (accept_stream_requested){
1112 stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ACCEPT_START_STREAM;
1113 } else {
1114 stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_START_STREAM;
1115 }
1116 avdtp_request_can_send_now_acceptor(connection);
1117 return ERROR_CODE_SUCCESS;
1118}
1119
1120uint8_t avdtp_start_stream_accept(uint16_t avdtp_cid, uint8_t local_seid){
1121 return avdtp_handle_explicit_start_stream_confirmation(avdtp_cid, local_seid, true);
1122}
1123
1124uint8_t avdtp_start_stream_reject(uint16_t avdtp_cid, uint8_t local_seid){
1125 return avdtp_handle_explicit_start_stream_confirmation(avdtp_cid, local_seid, false);
1126}
1127#endif
1128
1087uint8_t avdtp_open_stream(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid){
1088 avdtp_connection_t * connection = avdtp_get_connection_for_avdtp_cid(avdtp_cid);
1089 if (!connection){
1090 log_error("avdtp_media_connect: no connection for signaling cid 0x%02x found", avdtp_cid);
1091 return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
1092 }
1093
1094 if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) {

--- 488 unchanged lines hidden ---
1129uint8_t avdtp_open_stream(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid){
1130 avdtp_connection_t * connection = avdtp_get_connection_for_avdtp_cid(avdtp_cid);
1131 if (!connection){
1132 log_error("avdtp_media_connect: no connection for signaling cid 0x%02x found", avdtp_cid);
1133 return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
1134 }
1135
1136 if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) {

--- 488 unchanged lines hidden ---