From 1efc8b60497c616272b8753d22a3ca7abcf2b999 Mon Sep 17 00:00:00 2001 From: Aaro Altonen Date: Thu, 3 Sep 2020 08:28:24 +0300 Subject: [PATCH] Store pointer to the datagram in the rtp_frame structure Auxiliary handlers may need access to the original block of memory (such as SRTP) so instead of relaying that parameter to every handler, store pointer to the block inside the RTP frame. The pointer is valid as long as the packet is being processed and the last handler should set it to nullptr. Some changes to the public frame should be made because a lot of the fields in the frames used by uvgRTP are not important outside the library. --- include/frame.hh | 3 +++ src/rtp.cc | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/frame.hh b/include/frame.hh index 9b1a6f5..accb67b 100644 --- a/include/frame.hh +++ b/include/frame.hh @@ -81,6 +81,9 @@ namespace uvg_rtp { uint8_t *probation; uint8_t *payload; + uint8_t *dgram; /* pointer to the UDP datagram (for internal use only) */ + size_t dgram_size; /* size of the UDP datagram */ + rtp_format_t format; int type; sockaddr_in src_addr; diff --git a/src/rtp.cc b/src/rtp.cc index 585a502..fc07f40 100644 --- a/src/rtp.cc +++ b/src/rtp.cc @@ -216,6 +216,9 @@ rtp_error_t uvg_rtp::rtp::packet_handler(ssize_t size, void *packet, int flags, (*out)->padding_len = padding_len; } - (*out)->payload = (uint8_t *)memdup(ptr, (*out)->payload_len); + (*out)->payload = (uint8_t *)memdup(ptr, (*out)->payload_len); + (*out)->dgram = (uint8_t *)packet; + (*out)->dgram_size = size; + return RTP_PKT_MODIFIED; }