Skip to content

Commit

Permalink
Call the on_packet function only if it set, if not set behave normally
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed Aug 29, 2024
1 parent a813574 commit 023fcea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 023fcea

Please sign in to comment.