mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
avdtp: move stream start/stop to the app code
This commit is contained in:
parent
af2a1430b5
commit
f68a5d67c5
@ -495,9 +495,6 @@ void avdtp_set_configuration(uint16_t con_handle, uint8_t int_seid, uint8_t acp_
|
||||
void avdtp_reconfigure(uint16_t con_handle, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
|
||||
void avdtp_suspend(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t * context);
|
||||
|
||||
void avdtp_source_stream_data_start(uint16_t con_handle);
|
||||
void avdtp_source_stream_data_stop(uint16_t con_handle);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -365,7 +365,7 @@ static void test_fill_audio_ring_buffer_timeout_handler(btstack_timer_source_t *
|
||||
//
|
||||
}
|
||||
|
||||
static void test_fill_audio_ring_buffer_timer_start(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
void avdtp_fill_audio_ring_buffer_timer_start(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
btstack_run_loop_remove_timer(&stream_endpoint->fill_audio_ring_buffer_timer);
|
||||
btstack_run_loop_set_timer_handler(&stream_endpoint->fill_audio_ring_buffer_timer, test_fill_audio_ring_buffer_timeout_handler);
|
||||
btstack_run_loop_set_timer_context(&stream_endpoint->fill_audio_ring_buffer_timer, stream_endpoint);
|
||||
@ -373,39 +373,10 @@ static void test_fill_audio_ring_buffer_timer_start(avdtp_stream_endpoint_t * st
|
||||
btstack_run_loop_add_timer(&stream_endpoint->fill_audio_ring_buffer_timer);
|
||||
}
|
||||
|
||||
static void test_fill_audio_ring_buffer_timer_stop(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
void avdtp_fill_audio_ring_buffer_timer_stop(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
btstack_run_loop_remove_timer(&stream_endpoint->fill_audio_ring_buffer_timer);
|
||||
}
|
||||
|
||||
void avdtp_source_stream_data_start(uint16_t con_handle){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_l2cap_cid(con_handle, &avdtp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint found for 0x%02x", con_handle);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING){
|
||||
printf("stream_endpoint in wrong state %d\n", stream_endpoint->state);
|
||||
return;
|
||||
}
|
||||
|
||||
test_fill_audio_ring_buffer_timer_start(stream_endpoint);
|
||||
}
|
||||
|
||||
void avdtp_source_stream_data_stop(uint16_t con_handle){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_l2cap_cid(con_handle, &avdtp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
log_error("no stream_endpoint found");
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||
printf("stream_endpoint in wrong state %d\n", stream_endpoint->state);
|
||||
return;
|
||||
}
|
||||
// TODO: initialize randomly sequence number
|
||||
stream_endpoint->sequence_number = 0;
|
||||
test_fill_audio_ring_buffer_timer_stop(stream_endpoint);
|
||||
}
|
||||
|
||||
void avdtp_source_init(void){
|
||||
avdtp_source_context.stream_endpoints = NULL;
|
||||
avdtp_source_context.connections = NULL;
|
||||
|
@ -165,8 +165,8 @@ void avdtp_source_stop_stream(uint16_t con_handle, uint8_t acp_seid);
|
||||
|
||||
avdtp_stream_endpoint_t * avdtp_source_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type);
|
||||
|
||||
void avdtp_source_stream_data_start(uint16_t con_handle);
|
||||
void avdtp_source_stream_data_stop(uint16_t con_handle);
|
||||
void avdtp_fill_audio_ring_buffer_timer_start(avdtp_stream_endpoint_t * stream_endpoint);
|
||||
void avdtp_fill_audio_ring_buffer_timer_stop(avdtp_stream_endpoint_t * stream_endpoint);
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -62,7 +62,7 @@ SBC_ENCODER += \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_sbc_bludroid.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp_msbc.c \
|
||||
|
||||
AVDTP_SINK += \
|
||||
AVDTP += \
|
||||
avdtp_util.c \
|
||||
avdtp.c \
|
||||
avdtp_initiator.c \
|
||||
@ -77,27 +77,27 @@ CORE_OBJ = $(CORE:.c=.o)
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
SBC_DECODER_OBJ = $(SBC_DECODER:.c=.o)
|
||||
SBC_ENCODER_OBJ = $(SBC_ENCODER:.c=.o)
|
||||
AVDTP_SINK_OBJ = $(AVDTP_SINK:.c=.o)
|
||||
AVDTP_OBJ = $(AVDTP:.c=.o)
|
||||
|
||||
all: ${AVDTP_TESTS}
|
||||
|
||||
avdtp_sink_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_SINK_OBJ} avdtp_sink_test.o
|
||||
avdtp_sink_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_OBJ} avdtp_sink_test.o
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
avdtp_source_demo: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_SINK_OBJ} avdtp_source_demo.o
|
||||
avdtp_source_demo: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_OBJ} avdtp_source_demo.o
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
portaudio_test: btstack_util.o hci_dump.o wav_util.o btstack_ring_buffer.o portaudio_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
|
||||
sine_encode_decode_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_SINK_OBJ} sine_encode_decode_test.c
|
||||
sine_encode_decode_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_OBJ} sine_encode_decode_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
sine_encode_decode_ring_buffer_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_SINK_OBJ} sine_encode_decode_ring_buffer_test.c
|
||||
sine_encode_decode_ring_buffer_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_OBJ} sine_encode_decode_ring_buffer_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
sine_encode_decode_performance_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_SINK_OBJ} sine_encode_decode_performance_test.c
|
||||
sine_encode_decode_performance_test: ${CORE_OBJ} ${COMMON_OBJ} ${SBC_DECODER_OBJ} ${SBC_ENCODER_OBJ} ${AVDTP_OBJ} sine_encode_decode_performance_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
|
||||
|
@ -452,6 +452,32 @@ static uint8_t media_sbc_codec_capabilities[] = {
|
||||
// 2, 53
|
||||
// };
|
||||
|
||||
static void avdtp_source_stream_data_start(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint found for 0x%02x", con_handle);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING){
|
||||
printf("stream_endpoint in wrong state %d\n", stream_endpoint->state);
|
||||
return;
|
||||
}
|
||||
avdtp_fill_audio_ring_buffer_timer_start(stream_endpoint);
|
||||
}
|
||||
|
||||
static void avdtp_source_stream_data_stop(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
if (!stream_endpoint) {
|
||||
log_error("no stream_endpoint found");
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||
printf("stream_endpoint in wrong state %d\n", stream_endpoint->state);
|
||||
return;
|
||||
}
|
||||
// TODO: initialize randomly sequence number
|
||||
stream_endpoint->sequence_number = 0;
|
||||
avdtp_fill_audio_ring_buffer_timer_stop(stream_endpoint);
|
||||
}
|
||||
|
||||
static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){
|
||||
UNUSED(ds);
|
||||
UNUSED(callback_type);
|
||||
@ -502,11 +528,11 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
break;
|
||||
case 'x':
|
||||
printf("start streaming sine\n");
|
||||
avdtp_source_stream_data_start(media_con_handle);
|
||||
avdtp_source_stream_data_start(local_stream_endpoint);
|
||||
break;
|
||||
case 'X':
|
||||
printf("stop streaming sine\n");
|
||||
avdtp_source_stream_data_stop(media_con_handle);
|
||||
avdtp_source_stream_data_stop(local_stream_endpoint);
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
@ -546,7 +572,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
// Initialize SDP
|
||||
sdp_init();
|
||||
memset(sdp_avdtp_source_service_buffer, 0, sizeof(sdp_avdtp_source_service_buffer));
|
||||
a2dp_sink_create_sdp_record(sdp_avdtp_source_service_buffer, 0x10002, 1, NULL, NULL);
|
||||
a2dp_source_create_sdp_record(sdp_avdtp_source_service_buffer, 0x10002, 1, NULL, NULL);
|
||||
sdp_register_service(sdp_avdtp_source_service_buffer);
|
||||
|
||||
gap_set_local_name(device_name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user