a2dp_source_demo: use avdtp_source_stream_send_media_payload_rtp

This commit is contained in:
Matthias Ringwald 2021-01-07 10:28:54 +01:00
parent 3790661c7f
commit 00925309b4
2 changed files with 7 additions and 3 deletions

View File

@ -375,7 +375,10 @@ static void a2dp_demo_send_media_packet(void){
int num_bytes_in_frame = btstack_sbc_encoder_sbc_buffer_length();
int bytes_in_storage = media_tracker.sbc_storage_count;
uint8_t num_frames = bytes_in_storage / num_bytes_in_frame;
a2dp_source_stream_send_media_payload(media_tracker.a2dp_cid, media_tracker.local_seid, media_tracker.sbc_storage, bytes_in_storage, num_frames, 0);
// Prepend SBC Header
media_tracker.sbc_storage[0] = num_frames; // (fragmentation << 7) | (starting_packet << 6) | (last_packet << 5) | num_frames;
avdtp_source_stream_send_media_payload_rtp(media_tracker.a2dp_cid, media_tracker.local_seid, 0, media_tracker.sbc_storage, bytes_in_storage + 1);
media_tracker.sbc_storage_count = 0;
media_tracker.sbc_ready_to_send = 0;
}
@ -449,7 +452,8 @@ static int a2dp_demo_fill_sbc_audio_buffer(a2dp_media_sending_context_t * contex
uint8_t * sbc_frame = btstack_sbc_encoder_sbc_buffer();
total_num_bytes_read += num_audio_samples_per_sbc_buffer;
memcpy(&context->sbc_storage[context->sbc_storage_count], sbc_frame, sbc_frame_size);
// first byte in sbc storage contains sbc media header
memcpy(&context->sbc_storage[1 + context->sbc_storage_count], sbc_frame, sbc_frame_size);
context->sbc_storage_count += sbc_frame_size;
context->samples_ready -= num_audio_samples_per_sbc_buffer;
}

View File

@ -235,7 +235,7 @@ uint8_t avdtp_source_stream_send_media_payload_rtp(uint16_t avdtp_cid, uint8_t l
l2cap_reserve_packet_buffer();
uint8_t * media_packet = l2cap_get_outgoing_buffer();
avdtp_source_setup_media_header(media_packet, marker, stream_endpoint->sequence_number);
(void)memcpy(&media_packet[AVDTP_MEDIA_PAYLOAD_HEADER_SIZE +1], payload, payload_size);
(void)memcpy(&media_packet[AVDTP_MEDIA_PAYLOAD_HEADER_SIZE], payload, payload_size);
stream_endpoint->sequence_number++;
return l2cap_send_prepared(stream_endpoint->l2cap_media_cid, packet_size);
}