From 03891827431ad0fe47ebe4daff20b067bd8fd646 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 30 Aug 2024 11:25:17 +0200 Subject: [PATCH] Call the on_packet function only if it set, if not set behave normally --- src/rtp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rtp.c b/src/rtp.c index 637e3b1..c03bcae 100644 --- a/src/rtp.c +++ b/src/rtp.c @@ -240,8 +240,10 @@ int rtp_encoder_encode(RtpEncoder *rtp_encoder, uint8_t *buf, size_t size) { static int rtp_decode_generic(RtpDecoder *rtp_decoder, uint8_t *buf, size_t size) { RtpPacket *rtp_packet = (RtpPacket*)buf; - rtp_decoder->on_packet(rtp_packet->payload, size - sizeof(RtpHeader), rtp_decoder->user_data); - return size; + if (rtp_decoder->on_packet != NULL) + rtp_decoder->on_packet(rtp_packet->payload, size - sizeof(RtpHeader), rtp_decoder->user_data); + // even if there is no callback set, assume everything is ok for caller and do not return an error + return (int) size; } void rtp_decoder_init(RtpDecoder *rtp_decoder, MediaCodec codec, RtpOnPacket on_packet, void *user_data) {