int a2dp_source_stream_send_media_payload(uint16_t a2dp_cid, uint8_t local_seid, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames, uint8_t marker){ avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context); if (!stream_endpoint) { log_error("A2DP source: no stream_endpoint with seid %d", local_seid); return 0; } if (a2dp_source_context.avdtp_cid != a2dp_cid){ log_error("A2DP source: a2dp cid 0x%02x not known, expected 0x%02x", a2dp_cid, a2dp_source_context.avdtp_cid); return 0; } if (stream_endpoint->l2cap_media_cid == 0){ log_error("A2DP source: no media connection for seid %d", local_seid); return 0; } int size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); int offset = 0; l2cap_reserve_packet_buffer(); uint8_t * media_packet = l2cap_get_outgoing_buffer(); //int size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); a2dp_source_setup_media_header(media_packet, size, &offset, marker, stream_endpoint->sequence_number); a2dp_source_copy_media_payload(media_packet, size, &offset, storage, num_bytes_to_copy, num_frames); stream_endpoint->sequence_number++; l2cap_send_prepared(stream_endpoint->l2cap_media_cid, offset); return size; }
static int avdtp_source_stream_send_media_payload(uint8_t local_seid, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames, uint8_t marker){ avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context); if (!stream_endpoint) { log_error("no stream_endpoint found for seid %d", local_seid); return 0; } if (stream_endpoint->l2cap_media_cid == 0){ log_error("no media cid found for seid %d", local_seid); return 0; } int size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); int offset = 0; // HACK / PTS requests ERTM although we did not offer it in L2CAP Information Request. Withouth ERTM support, default MTU of 48 will be used, but that's to // small for a 44.1kHz/16/8/Stereo/bitpool 53 sbc frame of 119 bytes (+ media info) size = 0x290; l2cap_reserve_packet_buffer(); uint8_t * media_packet = l2cap_get_outgoing_buffer(); //int size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); a2dp_source_setup_media_header(media_packet, size, &offset, marker, stream_endpoint->sequence_number); a2dp_source_copy_media_payload(media_packet, size, &offset, storage, num_bytes_to_copy, num_frames); stream_endpoint->sequence_number++; l2cap_send_prepared(stream_endpoint->l2cap_media_cid, offset); return size; }