diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-09 17:00:36 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-09 17:00:36 +0000 |
commit | dc3df96d393aa3f7407e3b360a775ba9b443b0f8 (patch) | |
tree | 3f957e77dfbcddd3d48b00dd429957153fe1357e | |
parent | 0bafff13ec38acb8135dcbf0e2d7bddc8a691fad (diff) |
Issue #6576 - SIP_CODEC not used for early media (reported by gpapadop73)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@12477 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0e14b6ea7..4563b68b6 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2483,12 +2483,34 @@ static int sip_hangup(struct ast_channel *ast) return 0; } +/*! \brief Try setting codec suggested by the SIP_CODEC channel variable */ +static void try_suggested_sip_codec(struct sip_pvt *p) +{ + int fmt; + char *codec; + + codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC"); + if (!codec) + return; + + fmt = ast_getformatbyname(codec); + if (fmt) { + ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec); + if (p->jointcapability & fmt) { + p->jointcapability &= fmt; + p->capability &= fmt; + } else + ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n"); + } else + ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because of unrecognized/not configured codec (check allow/disallow in sip.conf): %s\n",codec); + return; +} + /*! \brief sip_answer: Answer SIP call , send 200 OK on Invite * Part of PBX interface */ static int sip_answer(struct ast_channel *ast) { - int res = 0,fmt; - char *codec; + int res = 0; struct sip_pvt *p = ast->tech_pvt; ast_mutex_lock(&p->lock); @@ -2496,19 +2518,7 @@ static int sip_answer(struct ast_channel *ast) #ifdef OSP_SUPPORT time(&p->ospstart); #endif - - codec=pbx_builtin_getvar_helper(p->owner,"SIP_CODEC"); - if (codec) { - fmt=ast_getformatbyname(codec); - if (fmt) { - ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec); - if (p->jointcapability & fmt) { - p->jointcapability &= fmt; - p->capability &= fmt; - } else - ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n"); - } else ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because of unrecognized/not configured codec (check allow/disallow in sip.conf): %s\n",codec); - } + try_suggested_sip_codec(p); ast_setstate(ast, AST_STATE_UP); if (option_debug) @@ -4514,6 +4524,7 @@ static int transmit_response_with_sdp(struct sip_pvt *p, char *msg, struct sip_r respprep(&resp, p, msg, req); if (p->rtp) { ast_rtp_offered_from_local(p->rtp, 0); + try_suggested_sip_codec(p); add_sdp(&resp, p); } else { ast_log(LOG_ERROR, "Can't add SDP to response, since we have no RTP session allocated. Call-ID %s\n", p->callid); |