Merged revisions 48964 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48964 | file | 2006-12-25 23:31:58 -0500 (Mon, 25 Dec 2006) | 2 lines

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: https://origsvn.digium.com/svn/asterisk/trunk@48965 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2006-12-26 04:34:07 +00:00
parent b3ab530077
commit 7f61b822c1
3 changed files with 21 additions and 6 deletions

View File

@@ -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));