From e121d2c5be276f876255e6df06f1b0f54866d6af Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 15 Mar 2022 16:12:15 +0100 Subject: [PATCH] avdtp: add avdtp_get_source_stream_endpoint_for_media_codec_and_type --- src/classic/avdtp.c | 9 +++++++-- src/classic/avdtp.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 91eee04cf..39801ba07 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -147,12 +147,12 @@ avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_seid(uint16_t seid){ return NULL; } -avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec(avdtp_media_codec_type_t codec_type){ +avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec_and_type(avdtp_media_codec_type_t codec_type, avdtp_sep_type_t sep_type){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, avdtp_get_stream_endpoints()); while (btstack_linked_list_iterator_has_next(&it)){ avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t *)btstack_linked_list_iterator_next(&it); - if (stream_endpoint->sep.type != AVDTP_SOURCE) continue; + if (stream_endpoint->sep.type != sep_type) continue; if (stream_endpoint->sep.media_type != AVDTP_AUDIO) continue; if (stream_endpoint->sep.capabilities.media_codec.media_codec_type != codec_type) continue; if (stream_endpoint->sep.in_use) continue; @@ -161,6 +161,11 @@ avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec(avdtp return NULL; } +avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec(avdtp_media_codec_type_t codec_type){ + return avdtp_get_source_stream_endpoint_for_media_codec_and_type(codec_type, AVDTP_SOURCE); +} + + avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec_other(uint32_t vendor_id, uint16_t codec_id){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, avdtp_get_stream_endpoints()); diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index d9ce55290..e5e96faf2 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -618,6 +618,7 @@ btstack_linked_list_t * avdtp_get_stream_endpoints(void); avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_seid(uint16_t seid); avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec(avdtp_media_codec_type_t codec_type); avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec_other(uint32_t vendor_id, uint16_t codec_id); +avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec_and_type(avdtp_media_codec_type_t codec_type, avdtp_sep_type_t sep_type); btstack_packet_handler_t avdtp_packet_handler_for_stream_endpoint(const avdtp_stream_endpoint_t *stream_endpoint); void avdtp_emit_sink_and_source(uint8_t * packet, uint16_t size);