avdtp_source.c (21f2491df42b3c97a35c6e6cf252a9454eafec6b) | avdtp_source.c (42780893c294d82e06e6ee0b370d0c83e51fe660) |
---|---|
1 2/* 3 * Copyright (C) 2016 BlueKitchen GmbH 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 174 unchanged lines hidden (view full) --- 183 media_packet[pos++] = (marker << 7) | payload_type; 184 big_endian_store_16(media_packet, pos, sequence_number); 185 pos += 2; 186 big_endian_store_32(media_packet, pos, timestamp); 187 pos += 4; 188 big_endian_store_32(media_packet, pos, ssrc); // only used for multicast 189} 190 | 1 2/* 3 * Copyright (C) 2016 BlueKitchen GmbH 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 174 unchanged lines hidden (view full) --- 183 media_packet[pos++] = (marker << 7) | payload_type; 184 big_endian_store_16(media_packet, pos, sequence_number); 185 pos += 2; 186 big_endian_store_32(media_packet, pos, timestamp); 187 pos += 4; 188 big_endian_store_32(media_packet, pos, ssrc); // only used for multicast 189} 190 |
191uint8_t avdtp_source_stream_send_media_payload_rtp(uint16_t avdtp_cid, uint8_t local_seid, uint8_t marker, const uint8_t * payload, uint16_t payload_size){ | 191uint8_t 192avdtp_source_stream_send_media_payload_rtp(uint16_t avdtp_cid, uint8_t local_seid, uint8_t marker, uint32_t timestamp, 193 const uint8_t *payload, uint16_t payload_size) { |
192 UNUSED(avdtp_cid); 193 194 avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); 195 if (!stream_endpoint) { 196 log_error("avdtp source: no stream_endpoint with seid %d", local_seid); 197 return 0; 198 } 199 200 if (stream_endpoint->l2cap_media_cid == 0){ 201 log_error("avdtp source: no media connection for seid %d", local_seid); 202 return 0; 203 } 204 205 uint32_t buffer_size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); 206 uint32_t packet_size = AVDTP_MEDIA_PAYLOAD_HEADER_SIZE + payload_size; 207 if (packet_size > buffer_size) return ERROR_CODE_MEMORY_CAPACITY_EXCEEDED; 208 l2cap_reserve_packet_buffer(); 209 uint8_t * media_packet = l2cap_get_outgoing_buffer(); | 194 UNUSED(avdtp_cid); 195 196 avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); 197 if (!stream_endpoint) { 198 log_error("avdtp source: no stream_endpoint with seid %d", local_seid); 199 return 0; 200 } 201 202 if (stream_endpoint->l2cap_media_cid == 0){ 203 log_error("avdtp source: no media connection for seid %d", local_seid); 204 return 0; 205 } 206 207 uint32_t buffer_size = l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid); 208 uint32_t packet_size = AVDTP_MEDIA_PAYLOAD_HEADER_SIZE + payload_size; 209 if (packet_size > buffer_size) return ERROR_CODE_MEMORY_CAPACITY_EXCEEDED; 210 l2cap_reserve_packet_buffer(); 211 uint8_t * media_packet = l2cap_get_outgoing_buffer(); |
210 uint32_t timestamp = btstack_run_loop_get_time_ms(); | |
211 avdtp_source_setup_media_header(media_packet, marker, stream_endpoint->sequence_number, timestamp); 212 (void)memcpy(&media_packet[AVDTP_MEDIA_PAYLOAD_HEADER_SIZE], payload, payload_size); 213 stream_endpoint->sequence_number++; 214 return l2cap_send_prepared(stream_endpoint->l2cap_media_cid, (uint16_t) packet_size); 215} 216 217uint8_t avdtp_source_stream_send_media_packet(uint16_t avdtp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size){ 218 UNUSED(avdtp_cid); --- 45 unchanged lines hidden --- | 212 avdtp_source_setup_media_header(media_packet, marker, stream_endpoint->sequence_number, timestamp); 213 (void)memcpy(&media_packet[AVDTP_MEDIA_PAYLOAD_HEADER_SIZE], payload, payload_size); 214 stream_endpoint->sequence_number++; 215 return l2cap_send_prepared(stream_endpoint->l2cap_media_cid, (uint16_t) packet_size); 216} 217 218uint8_t avdtp_source_stream_send_media_packet(uint16_t avdtp_cid, uint8_t local_seid, const uint8_t * packet, uint16_t size){ 219 UNUSED(avdtp_cid); --- 45 unchanged lines hidden --- |