avdtp sink: delay report

This commit is contained in:
Milanka Ringwald 2018-04-24 14:38:54 +02:00
parent 12b7c8ec5c
commit 19af95b439
3 changed files with 61 additions and 2 deletions

View File

@ -62,6 +62,15 @@ static int avdtp_initiator_send_signaling_cmd_with_seid(uint16_t cid, avdtp_sign
return l2cap_send(cid, command, sizeof(command));
}
static int avdtp_initiator_send_signaling_cmd_delay_report(uint16_t cid, uint8_t transaction_label, uint8_t sep_id, uint16_t delay_ms){
uint8_t command[5];
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_CMD_MSG);
command[1] = AVDTP_SI_DELAYREPORT;
command[2] = sep_id << 2;
big_endian_store_16(command, 3, delay_ms);
return l2cap_send(cid, command, sizeof(command));
}
void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_t *packet, uint16_t size, int offset, avdtp_context_t * context){
// int status = 0;
avdtp_stream_endpoint_t * stream_endpoint = NULL;
@ -119,7 +128,8 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset);
avdtp_emit_capabilities(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, &sep.capabilities, sep.registered_service_categories);
break;
case AVDTP_SI_DELAYREPORT:
break;
case AVDTP_SI_GET_CONFIGURATION:
// sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, packet+offset, size-offset);
// if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
@ -176,7 +186,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, sep.configuration.media_codec);
break;
}
break;
}
@ -229,6 +238,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
}
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
break;
default:
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
break;
@ -281,6 +291,12 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->remote_seid);
break;
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_DELAY_REPORT:
log_info("INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_DELAY_REPORT");
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
avdtp_initiator_send_signaling_cmd_delay_report(connection->l2cap_signaling_cid, connection->initiator_transaction_label,
connection->remote_seid, connection->delay_ms);
break;
default:
sent = 0;
break;
@ -341,6 +357,8 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
if (stream_endpoint->suspend_stream){
stream_endpoint->suspend_stream = 0;
if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_STREAMING){
connection->local_seid = stream_endpoint->sep.seid;
connection->remote_seid = stream_endpoint->remote_sep.seid;
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_SUSPEND, connection->initiator_transaction_label, connection->remote_seid);
return;

View File

@ -193,3 +193,35 @@ uint8_t avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t local_seid, uint8_t r
return avdtp_reconfigure(avdtp_cid, local_seid, remote_seid, configured_services_bitmap, configuration, avdtp_sink_context);
}
uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay_ms){
avdtp_connection_t * connection = avdtp_connection_for_avdtp_cid(avdtp_cid, avdtp_sink_context);
if (!connection){
log_error("delay_report: no connection for signaling cid 0x%02x found", avdtp_cid);
return AVDTP_CONNECTION_DOES_NOT_EXIST;
}
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED ||
connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) {
log_error("delay_report: connection in wrong state, state %d, initiator state %d", connection->state, connection->initiator_connection_state);
return AVDTP_CONNECTION_IN_WRONG_STATE;
}
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(local_seid, avdtp_sink_context);
if (!stream_endpoint) {
log_error("delay_report: no stream_endpoint with seid %d found", local_seid);
return AVDTP_SEID_DOES_NOT_EXIST;
}
if (stream_endpoint->state < AVDTP_STREAM_ENDPOINT_CONFIGURED){
log_error("Stream endpoint seid %d in wrong state %d", local_seid, stream_endpoint->state);
return AVDTP_STREAM_ENDPOINT_IN_WRONG_STATE;
}
connection->initiator_transaction_label++;
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_DELAY_REPORT;
connection->delay_ms = delay_ms * 10;
connection->local_seid = local_seid;
connection->remote_seid = stream_endpoint->remote_sep.seid;
avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid);
return ERROR_CODE_SUCCESS;
}

View File

@ -164,6 +164,15 @@ uint8_t avdtp_sink_stop_stream(uint16_t avdtp_cid, uint8_t local_seid);
*/
uint8_t avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t local_seid);
/**
* @brief Suspend stream
* @param local_seid
* @param delay_ms
*/
uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay_ms);
// AVDTP_SI_DELAYREPORT
/* API_END */