aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-11-01 14:58:00 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-11-01 14:58:00 +0000
commitf23d8b9e2a22f54dd591607e53c62bbe395e0041 (patch)
tree0ef9f290276a8fe8ab20c98f13483c07a9bfc3f5
parentedcdc2b86e7c25ef5e3fa8f0fc1ff492cb0a814f (diff)
Only offer codecs both sides support for directmedia
When using directmedia, Asterisk needs to limit the codecs offered to just the ones that both sides recognize, otherwise they may end up sending audio that the other side doesn't understand. (closes issue #17403) Reported by: one47 Patches: sip_codecs_simplified4 uploaded by one47 (license 23) Tested by: one47, falves11 Review: https://reviewboard.asterisk.org/r/967/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@293493 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c81ff7538..d47938cac 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10442,6 +10442,7 @@ static void get_crypto_attrib(struct sip_srtp *srtp, const char **a_crypto)
static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
{
format_t alreadysent = 0;
+ int doing_directmedia = FALSE;
struct ast_sockaddr addr = { {0,} };
struct ast_sockaddr vaddr = { {0,} };
@@ -10506,6 +10507,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
}
if (add_audio) {
+ doing_directmedia = (!ast_sockaddr_isnull(&p->redirip) && p->redircodecs) ? TRUE : FALSE;
/* Check if we need video in this call */
if ((p->jointcapability & AST_FORMAT_VIDEO_MASK) && !p->novideo) {
if (p->vrtp) {
@@ -10545,6 +10547,16 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
ast_sockaddr_stringify_addr(&dest));
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' */
@@ -10552,6 +10564,11 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
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 capablity: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability));
+ }
+
/* Check if we need audio */
if (capability & AST_FORMAT_AUDIO_MASK)
needaudio = TRUE;
@@ -10597,13 +10614,6 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
ast_str_append(&m_audio, 0, "m=audio %d RTP/%s", ast_sockaddr_port(&dest),
a_crypto ? "SAVP" : "AVP");
- 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