Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.845 diff -u -r1.845 chan_sip.c --- channels/chan_sip.c 8 Sep 2005 15:34:38 -0000 1.845 +++ channels/chan_sip.c 9 Sep 2005 07:58:21 -0000 @@ -2660,8 +2660,10 @@ if (relaxdtmf) ast_dsp_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF); } - tmp->fds[0] = ast_rtp_fd(i->rtp); - tmp->fds[1] = ast_rtcp_fd(i->rtp); + if (i->rtp) { + tmp->fds[0] = ast_rtp_fd(i->rtp); + tmp->fds[1] = ast_rtcp_fd(i->rtp); + } if (i->vrtp) { tmp->fds[2] = ast_rtp_fd(i->vrtp); tmp->fds[3] = ast_rtcp_fd(i->vrtp); @@ -2830,6 +2832,12 @@ /* Retrieve audio/etc from channel. Assumes p->lock is already held. */ struct ast_frame *f; static struct ast_frame null_frame = { AST_FRAME_NULL, }; + + if (!p->rtp) { + /* We have no RTP allocated for this channel */ + return &null_frame; + } + switch(ast->fdno) { case 0: f = ast_rtp_read(p->rtp); /* RTP Audio */ @@ -2940,8 +2948,8 @@ p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); if (videosupport) p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); - if (!p->rtp) { - ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno)); + if (!p->rtp || (videosupport && !p->vrtp)) { + ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n", videosupport ? "and video" : "", strerror(errno)); ast_mutex_destroy(&p->lock); if (p->chanvars) { ast_variables_destroy(p->chanvars); @@ -3261,6 +3269,11 @@ int debug=sip_debug_test_pvt(p); struct ast_channel *bridgepeer = NULL; + if (!p->rtp) { + ast_log(LOG_ERROR, "Got SDP but have no RTP session allocated.\n"); + return -1; + } + /* Update our last rtprx when we receive an SDP, too */ time(&p->lastrtprx); time(&p->lastrtptx); @@ -4294,8 +4307,11 @@ return -1; } respprep(&resp, p, msg, req); - ast_rtp_offered_from_local(p->rtp, 0); - add_sdp(&resp, p); + if (p->rtp) { + ast_rtp_offered_from_local(p->rtp, 0); + add_sdp(&resp, p); + ast_log(LOG_ERROR, "Can't add SDP to response, since we have no RTP session allocated. Call-ID %s\n", p->callid); + } return send_response(p, &resp, retrans, seqno); } @@ -4614,7 +4630,7 @@ } } } - if (sdp) { + if (sdp && p->rtp) { ast_rtp_offered_from_local(p->rtp, 1); add_sdp(&req, p); } else {