void a2dpHandleSdpRegisterCfm(A2DP *a2dp, const CL_SDP_REGISTER_CFM_T *cfm) { a2dp->sep.configured_service_caps_size--; if (cfm->status==success) { /* Register the l2cap psm if all service records have been registered */ if (!a2dp->sep.configured_service_caps_size) a2dpRegisterL2cap(a2dp); } else { /* Send indication that the initialisation failed */ a2dpSendInitCfmToClient(a2dp, a2dp_sdp_fail, 0); } }
void a2dpHandleL2capRegisterCfm(A2DP *a2dp, const CL_L2CAP_REGISTER_CFM_T *cfm) { /* Send a confirmation message to the client regardless of the outcome */ a2dpSendInitCfmToClient(a2dp, (cfm->status == success) ? a2dp_success : a2dp_l2cap_fail, a2dp->sep.sep_list); }
void A2dpInit(Task clientTask, uint16 role, service_record_type *service_records, uint16 size_seps, sep_data_type *seps, uint16 linkloss_timeout) { /* Initialise the task data */ if ( !a2dp ) { uint8 device_id; a2dp = PanicUnlessNew(A2DP); memset( a2dp, 0, sizeof(A2DP) ); for (device_id=0; device_id<A2DP_MAX_REMOTE_DEVICES_DEFAULT; device_id++) { a2dpInitialiseRemoteDevice(&a2dp->remote_conn[device_id],device_id); } PRINT(("sizeof(A2DP)=0x%u\n", sizeof(A2DP))); /* Set the handler function */ a2dp->task.handler = a2dpProfileHandler; /* Set up the lib client */ a2dp->clientTask = clientTask; a2dp->linkloss_timeout = linkloss_timeout; a2dp->max_remote_devs = A2DP_MAX_REMOTE_DEVICES_DEFAULT; a2dp->profile_role = role; blockInit(); if ( seps && size_seps && validateSeps(seps, size_seps) ) { for (device_id=0; device_id<A2DP_MAX_REMOTE_DEVICES; device_id++) { sep_data_type *sep_list = (sep_data_type *)PanicNull( blockAdd( device_id, data_block_sep_list, size_seps, sizeof(sep_data_type) ) ); memmove( sep_list, (sep_data_type *)seps, size_seps*sizeof(sep_data_type) ); } } else { a2dpSendInitCfmToClient(a2dp_invalid_parameters); return; } /* Used to count the number of SDP records registered. Decremented again by a2dpHandleSdpRegisterCfm() and will kick off a call to a2dpRegisterL2cap() when it hits zero - i.e. all CFM messages for SDP regsitering process have been received. */ a2dp->sdp_register_outstanding = 0; if (service_records) { if (service_records->size_service_record_a && service_records->service_record_a) { /* Client has supplied their own record so register it without checking */ ConnectionRegisterServiceRecord(&a2dp->task, service_records->size_service_record_a, service_records->service_record_a); a2dp->sdp_register_outstanding++; } if (service_records->size_service_record_b && service_records->service_record_b) { /* Client has supplied their own record so register it without checking */ ConnectionRegisterServiceRecord(&a2dp->task, service_records->size_service_record_b, service_records->service_record_b); a2dp->sdp_register_outstanding++; } } else { /* Client using default library record */ if (role & A2DP_INIT_ROLE_SINK) { ConnectionRegisterServiceRecord(&a2dp->task, sizeof(a2dp_sink_service_record), a2dp_sink_service_record); PRINT(("Register Sink Service Rec\n")); a2dp->sdp_register_outstanding++; } if (role & A2DP_INIT_ROLE_SOURCE) { ConnectionRegisterServiceRecord(&a2dp->task, sizeof(a2dp_source_service_record), a2dp_source_service_record); PRINT(("Register Source Service Rec\n")); a2dp->sdp_register_outstanding++; } } if ( a2dp->sdp_register_outstanding==0 ) { /* Skip the service record registering if the user doesn't require any at this point. */ a2dpRegisterL2cap(); } } }