diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-26 04:31:58 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-26 04:31:58 +0000 |
commit | cb366eccb630d34261b3e2d455470c30d24fa9c6 (patch) | |
tree | 0740b6f5add270b039bb3ab1f862ff5f8b5cf7e6 /main/rtp.c | |
parent | 9b1d7a3c1c3bbe9e8b2369121c644ee713507faf (diff) |
Add an API call that initializes an RTP structure. We need this because chan_sip is cheeky and uses a temporary RTP structure for codec purposes, and the API calls that are used rely on the lock. (Pointed out on asterisk-dev by Andy Wang)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@48964 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/rtp.c')
-rw-r--r-- | main/rtp.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/main/rtp.c b/main/rtp.c index 78052d88f..9b97b7ee3 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1798,6 +1798,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; @@ -1808,14 +1825,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)); |