From 5695c5cc37b8db322f6aa7f1c552ccf2ff6fe008 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 21 Dec 2020 22:45:52 +0100 Subject: [PATCH] avdtp_source, a2dp_source: allow to send media packets without RTP header --- src/classic/a2dp_source.c | 4 ++++ src/classic/a2dp_source.h | 10 ++++++++++ src/classic/avdtp_source.c | 18 ++++++++++++++++++ src/classic/avdtp_source.h | 10 ++++++++++ 4 files changed, 42 insertions(+) diff --git a/src/classic/a2dp_source.c b/src/classic/a2dp_source.c index 490afc581..a193195ba 100644 --- a/src/classic/a2dp_source.c +++ b/src/classic/a2dp_source.c @@ -805,6 +805,10 @@ int a2dp_source_stream_send_media_payload(uint16_t avdtp_cid, uint8_t local_seid return avdtp_source_stream_send_media_payload(avdtp_cid, local_seid, storage, num_bytes_to_copy, num_frames, marker); } +uint8_t a2dp_source_stream_send_media_packet(uint16_t a2dp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size){ + return avdtp_source_stream_send_media_packet(a2dp_cid, local_seid, packet, size); +} + static void avdtp_config_sbc_store(uint8_t * config, uint16_t sampling_frequency, avdtp_sbc_channel_mode_t channel_mode, uint8_t block_length, uint8_t subbands, avdtp_sbc_allocation_method_t allocation_method, uint8_t min_bitpool_value, uint8_t max_bitpool_value) { config[0] = (sampling_frequency << 4) | channel_mode; diff --git a/src/classic/a2dp_source.h b/src/classic/a2dp_source.h index 58771e473..e04986126 100644 --- a/src/classic/a2dp_source.h +++ b/src/classic/a2dp_source.h @@ -174,6 +174,16 @@ int a2dp_max_media_payload_size(uint16_t a2dp_cid, uint8_t local_seid); */ int a2dp_source_stream_send_media_payload(uint16_t a2dp_cid, uint8_t local_seid, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames, uint8_t marker); +/** + * @brief Send media packet + * @param a2dp_cid A2DP channel identifyer. + * @param local_seid ID of a local stream endpoint. + * @param packet + * @param size + * @return status + */ +uint8_t a2dp_source_stream_send_media_packet(uint16_t a2dp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size); + /** * @brief Select and configure SBC endpoint * @param a2dp_cid A2DP channel identifier. diff --git a/src/classic/avdtp_source.c b/src/classic/avdtp_source.c index 384a49b1b..1a6270495 100644 --- a/src/classic/avdtp_source.c +++ b/src/classic/avdtp_source.c @@ -235,6 +235,24 @@ int avdtp_source_stream_send_media_payload(uint16_t avdtp_cid, uint8_t local_sei return size; } +uint8_t avdtp_source_stream_send_media_packet(uint16_t avdtp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size){ + UNUSED(avdtp_cid); + + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); + if (!stream_endpoint) { + log_error("avdtp source: no stream_endpoint with seid %d", local_seid); + return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; + } + + if (stream_endpoint->l2cap_media_cid == 0){ + log_error("avdtp source: no media connection for seid %d", local_seid); + return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; + } + + return l2cap_send(stream_endpoint->l2cap_media_cid, (uint8_t*) packet, size); +} + + void avdtp_source_stream_endpoint_request_can_send_now(uint16_t avdtp_cid, uint8_t local_seid){ UNUSED(avdtp_cid); diff --git a/src/classic/avdtp_source.h b/src/classic/avdtp_source.h index 7f23653ae..6de153a71 100644 --- a/src/classic/avdtp_source.h +++ b/src/classic/avdtp_source.h @@ -249,6 +249,16 @@ void avdtp_source_finalize_stream_endpoint(avdtp_stream_endpoint_t * stream_endp */ int avdtp_source_stream_send_media_payload(uint16_t avdtp_cid, uint8_t local_seid, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames, uint8_t marker); +/** + * @brief Send media packet. + * @param avdtp_cid AVDTP channel identifyer. + * @param local_seid ID of a local stream endpoint. + * @param packet + * @param size + * @return status + */ +uint8_t avdtp_source_stream_send_media_packet(uint16_t avdtp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size); + /** * @brief Request to send a media packet. Packet can be then sent on reception of AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW event. * @param avdtp_cid AVDTP channel identifyer.