summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMatteo Brancaleoni <mbrancaleoni@espia.it>2003-02-20 06:00:14 +0000
committerMatteo Brancaleoni <mbrancaleoni@espia.it>2003-02-20 06:00:14 +0000
commit48130719cb745182878765357eed27d0a7256c98 (patch)
tree52c2c6abd07e82e95cb7b09c31804c0e9bd1f5f6 /channels
parentcf3b725fe906080f6abf3f2ff16eb565660062aa (diff)
Thu Feb 20 07:00:00 CET 2003
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f579f7366..557e83b6a 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1632,8 +1632,10 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
{
int len;
int codec;
+ int alreadysent = 0;
char costr[80];
struct sockaddr_in sin;
+ struct sip_codec_pref *cur;
char v[256];
char s[256];
char o[256];
@@ -1665,8 +1667,25 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", inet_ntoa(dest.sin_addr));
snprintf(t, sizeof(t), "t=0 0\r\n");
snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
+ /* Start by sending our preferred codecs */
+ cur = prefs;
+ while(cur) {
+ if (p->capability & cur->codec) {
+ if (sipdebug)
+ ast_verbose("Answering with preferred capability %d\n", cur->codec);
+ if ((codec = ast2rtp(cur->codec)) > -1) {
+ snprintf(costr, sizeof(costr), " %d", codec);
+ strcat(m, costr);
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast2rtpn(x));
+ strcat(a, costr);
+ }
+ }
+ alreadysent |= cur->codec;
+ cur = cur->next;
+ }
+ /* Now send anything else in no particular order */
for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) {
- if (p->capability & x) {
+ if ((p->capability & x) && !(alreadysent & x)) {
if (sipdebug)
ast_verbose("Answering with capability %d\n", x);
if ((codec = ast2rtp(x)) > -1) {