mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-04 13:20:44 +00:00
avdtp: source sends audio at const. speed
This commit is contained in:
parent
e033427c27
commit
fa84a2d42f
@ -440,26 +440,26 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
|||||||
//send sbc
|
//send sbc
|
||||||
uint8_t rtp_version = 2;
|
uint8_t rtp_version = 2;
|
||||||
uint8_t padding = 0;
|
uint8_t padding = 0;
|
||||||
uint8_t extention = 0;
|
uint8_t extension = 0;
|
||||||
uint8_t csrc_count = 0;
|
uint8_t csrc_count = 0;
|
||||||
uint8_t marker = 0;
|
uint8_t marker = 0;
|
||||||
uint8_t payload_type = 0;
|
uint8_t payload_type = 0x60;
|
||||||
uint16_t sequence_number = stream_endpoint->sequence_number;
|
uint16_t sequence_number = stream_endpoint->sequence_number;
|
||||||
uint32_t timestamp = btstack_run_loop_get_time_ms();
|
uint32_t timestamp = btstack_run_loop_get_time_ms();
|
||||||
uint32_t ssrc = 0;
|
uint32_t ssrc = 0x11223344;
|
||||||
|
|
||||||
// rtp header (min size 12B)
|
// rtp header (min size 12B)
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int mtu = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid);
|
int mtu = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid);
|
||||||
|
|
||||||
uint8_t media_packet[mtu];
|
uint8_t media_packet[mtu];
|
||||||
media_packet[pos++] = (rtp_version << 7) && (padding << 6) && (padding << 5) && (extention << 4) && csrc_count;
|
media_packet[pos++] = (rtp_version << 6) | (padding << 5) | (extension << 4) | csrc_count;
|
||||||
media_packet[pos++] = (marker << 7) && payload_type;
|
media_packet[pos++] = (marker << 1) | payload_type;
|
||||||
little_endian_store_16(media_packet, pos, sequence_number);
|
big_endian_store_16(media_packet, pos, sequence_number);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
little_endian_store_32(media_packet, pos, timestamp);
|
big_endian_store_32(media_packet, pos, timestamp);
|
||||||
pos += 4;
|
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;
|
pos += 4;
|
||||||
|
|
||||||
// media payload
|
// media payload
|
||||||
@ -483,7 +483,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
|||||||
num_frames++;
|
num_frames++;
|
||||||
// printf("send sbc frame: timestamp %d, seq. nr %d\n", timestamp, stream_endpoint->sequence_number);
|
// 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++;
|
stream_endpoint->sequence_number++;
|
||||||
l2cap_send(stream_endpoint->l2cap_media_cid, media_packet, pos);
|
l2cap_send(stream_endpoint->l2cap_media_cid, media_packet, pos);
|
||||||
if (btstack_ring_buffer_bytes_available(&stream_endpoint->sbc_ring_buffer)){
|
if (btstack_ring_buffer_bytes_available(&stream_endpoint->sbc_ring_buffer)){
|
||||||
|
@ -271,7 +271,7 @@ typedef struct {
|
|||||||
int right_phase;
|
int right_phase;
|
||||||
} paTestData;
|
} 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 paTestData sin_data;
|
||||||
static int total_num_samples = 0;
|
static int total_num_samples = 0;
|
||||||
static char * wav_filename = "test_output_sine.wav";
|
static char * wav_filename = "test_output_sine.wav";
|
||||||
|
@ -88,8 +88,9 @@ typedef struct {
|
|||||||
// pts: static bd_addr_t remote = {0x00, 0x1B, 0xDC, 0x08, 0x0A, 0xA5};
|
// 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};
|
// 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};
|
// phone 2013: static bd_addr_t remote = {0xD8, 0xBB, 0x2C, 0xDF, 0xF0, 0xF2};
|
||||||
// minijambox:
|
// minijambox: static bd_addr_t remote = {0x00, 0x21, 0x3c, 0xac, 0xf7, 0x38};
|
||||||
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
|
// bt dongle: -u 02-04-01
|
||||||
// static bd_addr_t remote = {0x00, 0x15, 0x83, 0x5F, 0x9D, 0x46};
|
// 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[] = {
|
static const uint8_t media_sbc_codec_capabilities[] = {
|
||||||
0xFF,//(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
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,
|
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[] = {
|
static const uint8_t media_sbc_codec_configuration[] = {
|
||||||
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
||||||
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS,
|
(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[] = {
|
static const uint8_t media_sbc_codec_reconfiguration[] = {
|
||||||
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
||||||
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_SNR,
|
(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){
|
static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user