--- ./channels/chan_sip.c.sav 2010-10-16 17:06:28.000000000 +0100 +++ ./channels/chan_sip.c 2010-10-16 17:06:39.000000000 +0100 @@ -10161,6 +10161,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38) { int alreadysent = 0; + int doing_directmedia = FALSE; struct sockaddr_in sin; struct sockaddr_in vsin; @@ -10222,6 +10223,11 @@ } if (add_audio) { + /* Remote IP address specified, and redircodecs has been set. + This sets the initial state for the type of SDP redirect to be done. + */ + doing_directmedia = (p->redirip.sin_addr.s_addr && p->redircodecs) ? TRUE : FALSE; + /* Check if we need video in this call */ if ((p->jointcapability & AST_FORMAT_VIDEO_MASK) && !p->novideo) { if (p->vrtp) { @@ -10252,12 +10258,25 @@ snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr)); if (add_audio) { + if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_ONEDIR) { + hold = "a=recvonly\r\n"; + doing_directmedia = FALSE; + } else if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_INACTIVE) { + hold = "a=inactive\r\n"; + doing_directmedia = FALSE; + } else { + hold = "a=sendrecv\r\n"; + } capability = p->jointcapability; /* XXX note, Video and Text are negated - 'true' means 'no' */ ast_debug(1, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability), p->novideo ? "True" : "False", p->notext ? "True" : "False"); ast_debug(1, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec)); + if( doing_directmedia ) { + capability &= p->redircodecs; + ast_debug(1, "** Our NATIVE-BRIDGE filtered capability: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability)); + } /* Check if we need audio */ if (capability & AST_FORMAT_AUDIO_MASK) @@ -10304,13 +10323,6 @@ ast_str_append(&m_audio, 0, "m=audio %d RTP/AVP", ntohs(dest.sin_port)); - if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_ONEDIR) - hold = "a=recvonly\r\n"; - else if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_INACTIVE) - hold = "a=inactive\r\n"; - else - hold = "a=sendrecv\r\n"; - /* Now, start adding audio codecs. These are added in this order: - First what was requested by the calling channel - Then preferences in order from sip.conf device config for this peer/user