Skip to content

Commit

Permalink
Merge pull request #111 from ela34/rtp_on_packet
Browse files Browse the repository at this point in the history
Call the on_packet function only if it set, if not set behave normally
  • Loading branch information
sepfy authored Aug 31, 2024
2 parents ff900a9 + 0389182 commit 78fc109
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 78fc109

Please sign in to comment.