From 84cef9b82a8541ede0821c1c12479c3ffd159a51 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 23 Feb 2021 18:38:48 +0100 Subject: [PATCH] avdtp_source: add avdtp_get_source_stream_endpoint_for_media_codec_other --- src/classic/avdtp.c | 17 +++++++++++++++++ src/classic/avdtp.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 2c8321b78..40df80fe6 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -147,12 +147,29 @@ avdtp_stream_endpoint_t * avdtp_get_source_stream_endpoint_for_media_codec(avdtp 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.media_type != AVDTP_AUDIO) continue; if (stream_endpoint->sep.capabilities.media_codec.media_codec_type != codec_type) continue; return stream_endpoint; } return NULL; } +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()); + 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.media_type != AVDTP_AUDIO) continue; + if (stream_endpoint->sep.capabilities.media_codec.media_codec_type != AVDTP_CODEC_NON_A2DP) continue; + if (stream_endpoint->sep.capabilities.media_codec.media_codec_information_len < 6) continue; + if (little_endian_read_32(stream_endpoint->sep.capabilities.media_codec.media_codec_information, 0) != vendor_id) continue; + if (little_endian_read_32(stream_endpoint->sep.capabilities.media_codec.media_codec_information, 4) != codec_id) continue; + return stream_endpoint; + } + return NULL; +} + avdtp_connection_t * avdtp_get_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid){ btstack_linked_list_iterator_t it; diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index 90048169a..854d08784 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -602,6 +602,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); 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);