xref: /btstack/src/classic/avdtp_initiator.c (revision 881a49d59a07b24d6e642b29c1b67e7e92358514)
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
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 #define __BTSTACK_FILE__ "avdtp_initiator.c"
39 
40 #include <stdint.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 
45 #include "btstack.h"
46 #include "classic/avdtp.h"
47 #include "classic/avdtp_util.h"
48 #include "classic/avdtp_initiator.h"
49 
50 static int avdtp_initiator_send_signaling_cmd(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t transaction_label){
51     uint8_t command[2];
52     command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_CMD_MSG);
53     command[1] = (uint8_t)identifier;
54     return l2cap_send(cid, command, sizeof(command));
55 }
56 
57 static int avdtp_initiator_send_signaling_cmd_with_seid(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t transaction_label, uint8_t sep_id){
58     uint8_t command[3];
59     command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_CMD_MSG);
60     command[1] = (uint8_t)identifier;
61     command[2] = sep_id << 2;
62     return l2cap_send(cid, command, sizeof(command));
63 }
64 
65 static int avdtp_initiator_send_signaling_cmd_delay_report(uint16_t cid, uint8_t transaction_label, uint8_t sep_id, uint16_t delay_ms){
66     uint8_t command[5];
67     command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_CMD_MSG);
68     command[1] = AVDTP_SI_DELAYREPORT;
69     command[2] = sep_id << 2;
70     big_endian_store_16(command, 3, delay_ms);
71     return l2cap_send(cid, command, sizeof(command));
72 }
73 
74 void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_t *packet, uint16_t size, int offset, avdtp_context_t * context){
75     // int status = 0;
76     avdtp_stream_endpoint_t * stream_endpoint = NULL;
77 
78     avdtp_sep_t sep;
79     if (connection->initiator_connection_state == AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER) {
80         connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE;
81     } else {
82         stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->remote_seid, context);
83         if (!stream_endpoint){
84             stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context);
85         }
86         if (!stream_endpoint) return;
87         sep.seid = connection->remote_seid;
88 
89         if (stream_endpoint->initiator_config_state != AVDTP_INITIATOR_W4_ANSWER) return;
90         stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
91     }
92 
93     switch (connection->signaling_packet.message_type){
94         case AVDTP_RESPONSE_ACCEPT_MSG:
95             switch (connection->signaling_packet.signal_identifier){
96                 case AVDTP_SI_DISCOVER:{
97                     if (connection->signaling_packet.transaction_label != connection->initiator_transaction_label){
98                         log_info("    unexpected transaction label, got %d, expected %d", connection->signaling_packet.transaction_label, connection->initiator_transaction_label);
99                         // status = BAD_HEADER_FORMAT;
100                         break;
101                     }
102 
103                     if (size == 3){
104                         log_info("    ERROR code %02x", packet[offset]);
105                         break;
106                     }
107 
108                     int i;
109                     for (i = offset; i < size; i += 2){
110                         sep.seid = packet[i] >> 2;
111                         offset++;
112                         if (sep.seid < 0x01 || sep.seid > 0x3E){
113                             log_info("    invalid sep id");
114                             // status = BAD_ACP_SEID;
115                             break;
116                         }
117                         sep.in_use = (packet[i] >> 1) & 0x01;
118                         sep.media_type = (avdtp_media_type_t)(packet[i+1] >> 4);
119                         sep.type = (avdtp_sep_type_t)((packet[i+1] >> 3) & 0x01);
120                         avdtp_signaling_emit_sep(context->avdtp_callback, connection->avdtp_cid, sep);
121                     }
122                     avdtp_signaling_emit_sep_done(context->avdtp_callback, connection->avdtp_cid);
123                     break;
124                 }
125 
126                 case AVDTP_SI_GET_CAPABILITIES:
127                 case AVDTP_SI_GET_ALL_CAPABILITIES:
128                     sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset);
129                     avdtp_emit_capabilities(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, &sep.capabilities, sep.registered_service_categories);
130                     break;
131                 case AVDTP_SI_DELAYREPORT:
132                     break;
133                 case AVDTP_SI_GET_CONFIGURATION:
134                     // sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, packet+offset, size-offset);
135                     // if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
136                     //     switch (sep.configuration.media_codec.media_codec_type){
137                     //         case AVDTP_CODEC_SBC:
138                     //             avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid,
139                     //                 sep.configuration.media_codec.media_type, sep.configuration.media_codec.media_codec_information);
140                     //             break;
141                     //         default:
142                     //             avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid,  connection->remote_seid, sep.configuration.media_codec);
143                     //             break;
144                     //     }
145                     // }
146                     break;
147 
148                 case AVDTP_SI_RECONFIGURE:
149                     if (!stream_endpoint){
150                         log_error("AVDTP_SI_RECONFIGURE: stream endpoint is null");
151                         break;
152                     }
153                     sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+4, connection->signaling_packet.size-4);
154                     // TODO check if configuration is supported
155 
156                     if (!is_avdtp_remote_seid_registered(stream_endpoint)){
157                         stream_endpoint->remote_sep = sep;
158                         log_info("INT: update seid %d, to %p", stream_endpoint->remote_sep.seid, stream_endpoint);
159                     }
160                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
161                     break;
162 
163                 case AVDTP_SI_SET_CONFIGURATION:{
164                     avdtp_configuration_timer_stop(connection);
165                     if (!stream_endpoint){
166                         log_error("AVDTP_SI_SET_CONFIGURATION: stream endpoint is null");
167                         break;
168                     }
169                     sep.configured_service_categories = stream_endpoint->remote_configuration_bitmap;
170                     sep.configuration = stream_endpoint->remote_configuration;
171                     sep.in_use = 1;
172 
173                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
174                     stream_endpoint->remote_sep = sep;
175                     stream_endpoint->connection = connection;
176 
177                     log_info("INT: configured remote seid %d, to %p", stream_endpoint->remote_sep.seid, stream_endpoint);
178 
179                     switch (stream_endpoint->media_codec_type){
180                         case AVDTP_CODEC_SBC:
181                             avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid,
182                                 stream_endpoint->media_type, stream_endpoint->media_codec_sbc_info);
183                             break;
184                         default:
185                             // TODO: we don\t have codec info to emit config
186                             avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid,  connection->remote_seid, sep.configuration.media_codec);
187                             break;
188                     }
189                     break;
190                 }
191 
192                 case AVDTP_SI_OPEN:
193                     if (!stream_endpoint){
194                         log_error("AVDTP_SI_OPEN: stream endpoint is null");
195                         break;
196                     }
197                     if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
198                         log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
199                         return;
200                     }
201                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED;
202                     connection->local_seid = stream_endpoint->sep.seid;
203                     l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
204                     return;
205                 case AVDTP_SI_START:
206                     if (!stream_endpoint){
207                         log_error("AVDTP_SI_START: stream endpoint is null");
208                         break;
209                     }
210                     if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
211                         log_error("AVDTP_SI_START in wrong stream endpoint state");
212                         return;
213                     }
214                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
215                     break;
216                 case AVDTP_SI_SUSPEND:
217                     if (!stream_endpoint){
218                         log_error("AVDTP_SI_SUSPEND: stream endpoint is null");
219                         break;
220                     }
221                     if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
222                         log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
223                         return;
224                     }
225                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
226                     break;
227                 case AVDTP_SI_CLOSE:
228                     if (!stream_endpoint){
229                         log_error("AVDTP_SI_CLOSE: stream endpoint is null");
230                         break;
231                     }
232                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
233                     break;
234                 case AVDTP_SI_ABORT:
235                     if (!stream_endpoint){
236                         log_error("AVDTP_SI_ABORT: stream endpoint is null");
237                         break;
238                     }
239                     stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
240                     break;
241 
242                 default:
243                     log_info("    AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
244                     break;
245             }
246             avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, 0, connection->signaling_packet.signal_identifier);
247             connection->initiator_transaction_label++;
248             break;
249         case AVDTP_RESPONSE_REJECT_MSG:
250             switch (connection->signaling_packet.signal_identifier){
251                 case AVDTP_SI_SET_CONFIGURATION:
252                     connection->is_initiator = 0;
253                     log_info("Received reject for set configuration, role changed from initiator to acceptor. Start timer.");
254                     avdtp_configuration_timer_start(connection);
255                     break;
256                 default:
257                     break;
258             }
259             log_info("    AVDTP_RESPONSE_REJECT_MSG signal %d", connection->signaling_packet.signal_identifier);
260             avdtp_signaling_emit_reject(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->signaling_packet.signal_identifier);
261             return;
262         case AVDTP_GENERAL_REJECT_MSG:
263             log_info("    AVDTP_GENERAL_REJECT_MSG signal %d", connection->signaling_packet.signal_identifier);
264             avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->signaling_packet.signal_identifier);
265             return;
266         default:
267             break;
268     }
269 }
270 
271 void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, avdtp_context_t * context){
272     int sent = 1;
273     switch (connection->initiator_connection_state){
274         case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS:
275             log_info("INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS");
276             connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
277             avdtp_initiator_send_signaling_cmd(connection->l2cap_signaling_cid, AVDTP_SI_DISCOVER, connection->initiator_transaction_label);
278             break;
279         case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES:
280             log_info("INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES");
281             connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
282             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CAPABILITIES, connection->initiator_transaction_label, connection->remote_seid);
283             break;
284         case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES:
285             log_info("INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES");
286             connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
287             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_ALL_CAPABILITIES, connection->initiator_transaction_label, connection->remote_seid);
288             break;
289         case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CONFIGURATION:
290             log_info("INT: AVDTP_INITIATOR_W4_GET_CONFIGURATION");
291             connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
292             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->remote_seid);
293             break;
294         case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_DELAY_REPORT:
295             log_info("INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_DELAY_REPORT");
296             connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
297             avdtp_initiator_send_signaling_cmd_delay_report(connection->l2cap_signaling_cid, connection->initiator_transaction_label,
298                 connection->remote_seid, connection->delay_ms);
299             break;
300         default:
301             sent = 0;
302             break;
303     }
304 
305     if (sent) return;
306     sent = 1;
307 
308     avdtp_stream_endpoint_t * stream_endpoint = NULL;
309 
310     stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->remote_seid, context);
311     if (!stream_endpoint){
312         stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context);
313     }
314     if (!stream_endpoint) return;
315 
316     avdtp_initiator_stream_endpoint_state_t stream_endpoint_state = stream_endpoint->initiator_config_state;
317     stream_endpoint->initiator_config_state = AVDTP_INITIATOR_W4_ANSWER;
318 
319     if (stream_endpoint->start_stream){
320         stream_endpoint->start_stream = 0;
321         if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_OPENED){
322             connection->local_seid = stream_endpoint->sep.seid;
323             connection->remote_seid = stream_endpoint->remote_sep.seid;
324             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_START, connection->initiator_transaction_label++, connection->remote_seid);
325             return;
326         }
327         return;
328     }
329 
330     if (stream_endpoint->stop_stream){
331         stream_endpoint->stop_stream = 0;
332         if (stream_endpoint->state >= AVDTP_STREAM_ENDPOINT_OPENED){
333             connection->local_seid = stream_endpoint->sep.seid;
334             connection->remote_seid = stream_endpoint->remote_sep.seid;
335             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_CLOSE, connection->initiator_transaction_label++, connection->remote_seid);
336             return;
337         }
338     }
339 
340     if (stream_endpoint->abort_stream){
341         stream_endpoint->abort_stream = 0;
342         switch (stream_endpoint->state){
343             case AVDTP_STREAM_ENDPOINT_CONFIGURED:
344             case AVDTP_STREAM_ENDPOINT_CLOSING:
345             case AVDTP_STREAM_ENDPOINT_OPENED:
346             case AVDTP_STREAM_ENDPOINT_STREAMING:
347                 connection->local_seid = stream_endpoint->sep.seid;
348                 connection->remote_seid = stream_endpoint->remote_sep.seid;
349                 stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
350                 avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_ABORT, connection->initiator_transaction_label++, connection->remote_seid);
351                 return;
352             default:
353                 break;
354         }
355     }
356 
357     if (stream_endpoint->suspend_stream){
358         stream_endpoint->suspend_stream = 0;
359         if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_STREAMING){
360             connection->local_seid = stream_endpoint->sep.seid;
361             connection->remote_seid = stream_endpoint->remote_sep.seid;
362             stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
363             avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_SUSPEND, connection->initiator_transaction_label, connection->remote_seid);
364             return;
365         }
366     }
367 
368     if (stream_endpoint->send_stream){
369         stream_endpoint->send_stream = 0;
370         if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_STREAMING){
371             stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
372             avdtp_streaming_emit_can_send_media_packet_now(context->avdtp_callback, stream_endpoint->l2cap_media_cid, stream_endpoint->sep.seid, stream_endpoint->sequence_number);
373             return;
374         }
375     }
376 
377     switch (stream_endpoint_state){
378         case AVDTP_INITIATOR_W2_SET_CONFIGURATION:
379         case AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID:{
380             if (stream_endpoint_state == AVDTP_INITIATOR_W2_SET_CONFIGURATION && !connection->is_initiator){
381                 log_info("initiator SM stop sending SET_CONFIGURATION cmd: current role is acceptor");
382                 connection->is_configuration_initiated_locally = 0;
383                 break;
384             }
385             log_info("initiator SM prepare SET_CONFIGURATION cmd");
386             connection->is_configuration_initiated_locally = 1;
387             log_info("INT: AVDTP_INITIATOR_W2_(RE)CONFIGURATION bitmap, int seid %d, acp seid %d", connection->local_seid, connection->remote_seid);
388             // log_info_hexdump(  connection->remote_capabilities.media_codec.media_codec_information,  connection->remote_capabilities.media_codec.media_codec_information_len);
389             connection->signaling_packet.acp_seid = connection->remote_seid;
390             connection->signaling_packet.int_seid = connection->local_seid;
391 
392             connection->signaling_packet.signal_identifier = AVDTP_SI_SET_CONFIGURATION;
393             stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURATION_SUBSTATEMACHINE;
394             if (stream_endpoint_state == AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID){
395                 connection->signaling_packet.signal_identifier = AVDTP_SI_RECONFIGURE;
396             }
397 
398             avdtp_prepare_capabilities(&connection->signaling_packet, connection->initiator_transaction_label, stream_endpoint->remote_configuration_bitmap, stream_endpoint->remote_configuration, connection->signaling_packet.signal_identifier);
399             l2cap_reserve_packet_buffer();
400             uint8_t * out_buffer = l2cap_get_outgoing_buffer();
401             uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer);
402             if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
403                 stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND;
404                 log_info("INT: fragmented");
405             }
406             l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
407             break;
408         }
409         case AVDTP_INITIATOR_FRAGMENTATED_COMMAND:{
410             l2cap_reserve_packet_buffer();
411             uint8_t * out_buffer = l2cap_get_outgoing_buffer();
412             uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer);
413             if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
414                 stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND;
415                 log_info("INT: fragmented");
416             }
417             l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
418             break;
419         }
420         case AVDTP_INITIATOR_W2_OPEN_STREAM:
421             switch (stream_endpoint->state){
422                 case AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM:
423                     log_info("INT: AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM");
424                     avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_OPEN, connection->initiator_transaction_label, connection->remote_seid);
425                     break;
426                 default:
427                     sent = 0;
428                     break;
429             }
430             break;
431         default:
432             sent = 0;
433             break;
434     }
435 
436     // check fragmentation
437     if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
438         avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid);
439     }
440 }
441