diff --git a/channels/chan_sip.c b/channels/chan_sip.c index e21e9670a3..b02d0a7e1e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4800,10 +4800,12 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) /* Initialize the temporary RTP structures we use to evaluate the offer from the peer */ newaudiortp = alloca(ast_rtp_alloc_size()); memset(newaudiortp, 0, ast_rtp_alloc_size()); + ast_rtp_new_init(newaudiortp); ast_rtp_pt_clear(newaudiortp); newvideortp = alloca(ast_rtp_alloc_size()); memset(newvideortp, 0, ast_rtp_alloc_size()); + ast_rtp_new_init(newvideortp); ast_rtp_pt_clear(newvideortp); /* Update our last rtprx when we receive an SDP, too */ diff --git a/include/asterisk/rtp.h b/include/asterisk/rtp.h index a93f39261f..2edff8cadb 100644 --- a/include/asterisk/rtp.h +++ b/include/asterisk/rtp.h @@ -223,6 +223,7 @@ int ast_rtcp_send_h261fur(void *data); char *ast_rtp_get_quality(struct ast_rtp *rtp); /*! \brief Return RTCP quality string */ void ast_rtp_init(void); /*! Initialize RTP subsystem */ int ast_rtp_reload(void); /*! reload rtp configuration */ +void ast_rtp_new_init(struct ast_rtp *rtp); /*! Set codec preference */ int ast_rtp_codec_setpref(struct ast_rtp *rtp, struct ast_codec_pref *prefs); diff --git a/main/rtp.c b/main/rtp.c index 88ad606da2..b3fbf684a5 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1860,6 +1860,23 @@ static struct ast_rtcp *ast_rtcp_new(void) return rtcp; } +/*! + * \brief Initialize a new RTP structure. + * + */ +void ast_rtp_new_init(struct ast_rtp *rtp) +{ + ast_mutex_init(&rtp->bridge_lock); + + rtp->them.sin_family = AF_INET; + rtp->us.sin_family = AF_INET; + rtp->ssrc = ast_random(); + rtp->seqno = ast_random() & 0xffff; + ast_set_flag(rtp, FLAG_HAS_DTMF); + + return; +} + struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr addr) { struct ast_rtp *rtp; @@ -1870,14 +1887,9 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io if (!(rtp = ast_calloc(1, sizeof(*rtp)))) return NULL; - ast_mutex_init(&rtp->bridge_lock); + ast_rtp_new_init(rtp); - rtp->them.sin_family = AF_INET; - rtp->us.sin_family = AF_INET; rtp->s = rtp_socket(); - rtp->ssrc = ast_random(); - rtp->seqno = ast_random() & 0xffff; - ast_set_flag(rtp, FLAG_HAS_DTMF); if (rtp->s < 0) { free(rtp); ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno));