avdtp: source sends audio at const. speed

This commit is contained in:
Milanka Ringwald 2017-03-20 16:27:24 +01:00 committed by Matthias Ringwald
parent e033427c27
commit fa84a2d42f
3 changed files with 16 additions and 15 deletions

View File

@ -440,26 +440,26 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
//send sbc
uint8_t rtp_version = 2;
uint8_t padding = 0;
uint8_t extention = 0;
uint8_t extension = 0;
uint8_t csrc_count = 0;
uint8_t marker = 0;
uint8_t payload_type = 0;
uint8_t payload_type = 0x60;
uint16_t sequence_number = stream_endpoint->sequence_number;
uint32_t timestamp = btstack_run_loop_get_time_ms();
uint32_t ssrc = 0;
uint32_t ssrc = 0x11223344;
// rtp header (min size 12B)
int pos = 0;
int mtu = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid);
uint8_t media_packet[mtu];
media_packet[pos++] = (rtp_version << 7) && (padding << 6) && (padding << 5) && (extention << 4) && csrc_count;
media_packet[pos++] = (marker << 7) && payload_type;
little_endian_store_16(media_packet, pos, sequence_number);
media_packet[pos++] = (rtp_version << 6) | (padding << 5) | (extension << 4) | csrc_count;
media_packet[pos++] = (marker << 1) | payload_type;
big_endian_store_16(media_packet, pos, sequence_number);
pos += 2;
little_endian_store_32(media_packet, pos, timestamp);
big_endian_store_32(media_packet, pos, timestamp);
pos += 4;
little_endian_store_32(media_packet, pos, ssrc); // only used for multicast
big_endian_store_32(media_packet, pos, ssrc); // only used for multicast
pos += 4;
// media payload
@ -483,7 +483,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
num_frames++;
// printf("send sbc frame: timestamp %d, seq. nr %d\n", timestamp, stream_endpoint->sequence_number);
}
media_packet[sbc_header_index] = (fragmentation << 7) && (starting_packet << 6) && (last_packet << 5) && num_frames;
media_packet[sbc_header_index] = (fragmentation << 7) | (starting_packet << 6) | (last_packet << 5) | num_frames;
stream_endpoint->sequence_number++;
l2cap_send(stream_endpoint->l2cap_media_cid, media_packet, pos);
if (btstack_ring_buffer_bytes_available(&stream_endpoint->sbc_ring_buffer)){

View File

@ -271,7 +271,7 @@ typedef struct {
int right_phase;
} paTestData;
static uint32_t fill_audio_ring_buffer_timeout = 25; //ms
static uint32_t fill_audio_ring_buffer_timeout = 50; //ms
static paTestData sin_data;
static int total_num_samples = 0;
static char * wav_filename = "test_output_sine.wav";

View File

@ -88,8 +88,9 @@ typedef struct {
// pts: static bd_addr_t remote = {0x00, 0x1B, 0xDC, 0x08, 0x0A, 0xA5};
// mac 2013: static bd_addr_t remote = {0x84, 0x38, 0x35, 0x65, 0xd1, 0x15};
// phone 2013: static bd_addr_t remote = {0xD8, 0xBB, 0x2C, 0xDF, 0xF0, 0xF2};
// minijambox:
static bd_addr_t remote = { 0x00, 0x21, 0x3c, 0xac, 0xf7, 0x38};
// minijambox: static bd_addr_t remote = {0x00, 0x21, 0x3c, 0xac, 0xf7, 0x38};
// head phones:
static bd_addr_t remote = {0x00, 0x18, 0x09, 0x28, 0x50, 0x18};
// bt dongle: -u 02-04-01
// static bd_addr_t remote = {0x00, 0x15, 0x83, 0x5F, 0x9D, 0x46};
@ -323,19 +324,19 @@ static void show_usage(void){
static const uint8_t media_sbc_codec_capabilities[] = {
0xFF,//(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
0xFF,//(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS,
2, 53
2, 35
};
static const uint8_t media_sbc_codec_configuration[] = {
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS,
2, 53
2, 35
};
static const uint8_t media_sbc_codec_reconfiguration[] = {
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_SNR,
2, 53
2, 35
};
static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){