From 4eaa651a8a67981c9bc62b709b31b23b77ad122b Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Mon, 6 Apr 2009 16:15:30 +0000 Subject: [PATCH] Add support for changing the outbound codec on a SIP call using a dialplan variable. This adds a dialplan variable (SIP_CODEC_OUTBOUND) which controls the codec offered for an outgoing SIP call. This is much like the SIP_CODEC dialplan variable and has the same restrictions. The codec set must be one that is configured for the call. (closes issue #13243) Reported by: samdell3 Patches: 13243.diff uploaded by file (license 11) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@186624 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- CHANGES | 3 +++ channels/chan_sip.c | 12 ++++++++++-- doc/tex/channelvariables.tex | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index a9205024fa..9397ae1047 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,9 @@ SIP Changes ----------- * Added preferred_codec_only option in sip.conf. This feature limits the joint codecs sent in response to an INVITE to the single most preferred codec. + * Added SIP_CODEC_OUTBOUND dialplan variable which can be used to set the codec + to be used for the outgoing call. It must be one of the codecs configured + for the device. Applications ------------ diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 10883c5f32..17b7c8cbba 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -5836,7 +5836,12 @@ static void try_suggested_sip_codec(struct sip_pvt *p) int fmt; const char *codec; - codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC"); + if (p->outgoing_call) { + codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC_OUTBOUND"); + } else if (!(codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC_INBOUND"))) { + codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC"); + } + if (!codec) return; @@ -9838,6 +9843,7 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, int t38version, int old if (p->do_history) append_history(p, "ReInv", "Re-invite sent"); + try_suggested_sip_codec(p); if (t38version) add_sdp(&req, p, oldsdp, FALSE, TRUE); else @@ -10199,8 +10205,10 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init) ast_udptl_offered_from_local(p->udptl, 1); ast_debug(1, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : ""); add_sdp(&req, p, FALSE, FALSE, TRUE); - } else if (p->rtp) + } else if (p->rtp) { + try_suggested_sip_codec(p); add_sdp(&req, p, FALSE, TRUE, FALSE); + } } else { if (!p->notify_headers) { add_header_contentLength(&req, 0); diff --git a/doc/tex/channelvariables.tex b/doc/tex/channelvariables.tex index 4c3195246d..4c7b4d5ff7 100644 --- a/doc/tex/channelvariables.tex +++ b/doc/tex/channelvariables.tex @@ -925,7 +925,9 @@ ${SIPDOMAIN} * SIP destination domain of an inbound call (if appropriate ${SIPFROMDOMAIN} Set SIP domain on outbound calls ${SIPUSERAGENT} * SIP user agent (deprecated) ${SIPURI} * SIP uri -${SIP_CODEC} Set the SIP codec for a call +${SIP_CODEC} Set the SIP codec for an inbound call +${SIP_CODEC_INBOUND} Set the SIP codec for an inbound call +${SIP_CODEC_OUTBOUND} Set the SIP codec for an outbound call ${SIP_URI_OPTIONS} * additional options to add to the URI for an outgoing call ${RTPAUDIOQOS} RTCP QoS report for the audio of this call ${RTPVIDEOQOS} RTCP QoS report for the video of this call