[Asterisk-cvs] asterisk/channels chan_h323.c,1.54,1.55 chan_mgcp.c,1.52,1.53 chan_sip.c,1.398,1.399 chan_skinny.c,1.41,1.42

markster at lists.digium.com markster at lists.digium.com
Thu May 27 00:04:11 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv31689/channels

Modified Files:
	chan_h323.c chan_mgcp.c chan_sip.c chan_skinny.c 
Log Message:
Make RTP handle codecs (first pass)


Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- chan_h323.c	20 May 2004 21:56:12 -0000	1.54
+++ chan_h323.c	27 May 2004 04:18:45 -0000	1.55
@@ -1776,7 +1776,7 @@
 
 }
 
-static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
 {
 	/* XXX Deal with Video */
 	struct oh323_pvt *p;

Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- chan_mgcp.c	24 May 2004 15:07:08 -0000	1.52
+++ chan_mgcp.c	27 May 2004 04:18:46 -0000	1.53
@@ -433,7 +433,7 @@
 static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
 static int transmit_modify_request(struct mgcp_subchannel *sub);
 static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callerid);
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp);
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs);
 static int transmit_connection_del(struct mgcp_subchannel *sub);
 static int transmit_audit_endpoint(struct mgcp_endpoint *p);
 static void start_rtp(struct mgcp_subchannel *sub);
@@ -1908,13 +1908,17 @@
 	return 0;
 }
 
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp)
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs)
 {
 	struct mgcp_request resp;
 	char local[256];
 	char tmp[80];
 	int x;
+	int capability;
     struct mgcp_endpoint *p = sub->parent;
+	capability = p->capability;
+	if (codecs)
+		capability = codecs;
 	if (!strlen(sub->cxident) && rtp) {
 		/* We don't have a CXident yet, store the destination and
 		   wait a bit */
@@ -1923,7 +1927,7 @@
 	}
 	snprintf(local, sizeof(local), "p:20");
 	for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) {
-		if (p->capability & x) {
+		if (capability & x) {
 			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x));
 			strcat(local, tmp);
 		}
@@ -2298,7 +2302,7 @@
                         }
                         strncpy(sub->cxident, c, sizeof(sub->cxident) - 1);
                         if (sub->tmpdest.sin_addr.s_addr) {
-                            transmit_modify_with_sdp(sub, NULL);
+                            transmit_modify_with_sdp(sub, NULL, 0);
                         }
                     }
                     else {
@@ -3710,13 +3714,13 @@
 	return NULL;
 }
 
-static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
 {
 	/* XXX Is there such thing as video support with MGCP? XXX */
 	struct mgcp_subchannel *sub;
 	sub = chan->pvt->pvt;
 	if (sub) {
-		transmit_modify_with_sdp(sub, rtp);
+		transmit_modify_with_sdp(sub, rtp, codecs);
 		return 0;
 	}
 	return -1;

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.398
retrieving revision 1.399
diff -u -d -r1.398 -r1.399
--- chan_sip.c	26 May 2004 22:18:59 -0000	1.398
+++ chan_sip.c	27 May 2004 04:18:46 -0000	1.399
@@ -493,7 +493,7 @@
 static int transmit_request(struct sip_pvt *p, char *msg, int inc, int reliable, int newbranch);
 static int transmit_request_with_auth(struct sip_pvt *p, char *msg, int inc, int reliable, int newbranch);
 static int transmit_invite(struct sip_pvt *p, char *msg, int sendsdp, char *auth, char *authheader, char *vxml_url,char *distinctive_ring, int init);
-static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp);
+static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codec);
 static int transmit_info_with_digit(struct sip_pvt *p, char digit);
 static int transmit_message_with_text(struct sip_pvt *p, char *text);
 static int transmit_refer(struct sip_pvt *p, char *dest);
@@ -3003,7 +3003,7 @@
 }
 
 /*--- add_sdp: Add Session Description Protocol message ---*/
-static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
 {
 	int len;
 	int codec;
@@ -3022,6 +3022,7 @@
 	char a[1024] = "";
 	char a2[1024] = "";
 	int x;
+	int capability;
 	struct sockaddr_in dest;
 	struct sockaddr_in vdest = { 0, };
 	/* XXX We break with the "recommendation" and send our IP, in order that our
@@ -3031,6 +3032,10 @@
 		ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n");
 		return -1;
 	}
+	capability = p->jointcapability;
+	if (codecs) 
+		capability = codecs & p->jointcapability;
+		
 	if (!p->sessionid) {
 		p->sessionid = getpid();
 		p->sessionversion = p->sessionid;
@@ -3073,7 +3078,7 @@
 	snprintf(t, sizeof(t), "t=0 0\r\n");
 	snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
 	snprintf(m2, sizeof(m2), "m=video %d RTP/AVP", ntohs(vdest.sin_port));
-	if (p->jointcapability & p->prefcodec) {
+	if (capability & p->prefcodec) {
 		if (sip_debug_test_pvt(p))
 			ast_verbose("Answering/Requesting with root capability %d\n", p->prefcodec);
 		codec = ast_rtp_lookup_code(p->rtp, 1, p->prefcodec);
@@ -3094,7 +3099,7 @@
 	/* Start by sending our preferred codecs */
 	cur = prefs;
 	while(cur) {
-		if ((p->jointcapability & cur->codec) && !(alreadysent & cur->codec)) {
+		if ((capability & cur->codec) && !(alreadysent & cur->codec)) {
 			if (sip_debug_test_pvt(p))
 				ast_verbose("Answering with preferred capability 0x%x(%s)\n", cur->codec, ast_getformatname(cur->codec));
 			codec = ast_rtp_lookup_code(p->rtp, 1, cur->codec);
@@ -3116,7 +3121,7 @@
 	}
 	/* Now send any other common codecs, and non-codec formats: */
 	for (x = 1; x <= (videosupport ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) {
-		if ((p->jointcapability & x) && !(alreadysent & x)) {
+		if ((capability & x) && !(alreadysent & x)) {
 			if (sip_debug_test_pvt(p))
 				ast_verbose("Answering with capability 0x%x(%s)\n", x, ast_getformatname(x));
 			codec = ast_rtp_lookup_code(p->rtp, 1, x);
@@ -3161,7 +3166,7 @@
 	if ((sizeof(m) <= strlen(m) - 2) || (sizeof(m2) <= strlen(m2) - 2) || (sizeof(a) == strlen(a)) || (sizeof(a2) == strlen(a2)))
 		ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n");
 	len = strlen(v) + strlen(s) + strlen(o) + strlen(c) + strlen(t) + strlen(m) + strlen(a);
-	if ((p->vrtp) && (p->jointcapability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
+	if ((p->vrtp) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
 		len += strlen(m2) + strlen(a2);
 	snprintf(costr, sizeof(costr), "%d", len);
 	add_header(resp, "Content-Type", "application/sdp");
@@ -3173,7 +3178,7 @@
 	add_line(resp, t);
 	add_line(resp, m);
 	add_line(resp, a);
-	if ((p->vrtp) && (p->jointcapability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */
+	if ((p->vrtp) && (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */
 		add_line(resp, m2);
 		add_line(resp, a2);
 	}
@@ -3205,7 +3210,7 @@
 		return -1;
 	}
 	respprep(&resp, p, msg, req);
-	add_sdp(&resp, p, NULL, NULL);
+	add_sdp(&resp, p, NULL, NULL, 0);
 	return send_response(p, &resp, retrans, seqno);
 }
 
@@ -3272,7 +3277,7 @@
 /* transmit_reinvite_with_sdp: Transmit reinvite with SDP :-) ---*/
 /*   A re-invite is basically a new INVITE with the same CALL-ID and TAG as the
      INVITE that opened the SIP dialogue */
-static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codec)
 {
 	struct sip_request req;
 	if (p->canreinvite == REINVITE_UPDATE)
@@ -3281,7 +3286,7 @@
 		reqprep(&req, p, "INVITE", 0, 1);
 	
 	add_header(&req, "Allow", ALLOWED_METHODS);
-	add_sdp(&req, p, rtp, vrtp);
+	add_sdp(&req, p, rtp, vrtp, codec);
 	/* Use this as the basis */
 	copy_request(&p->initreq, &req);
 	parse(&p->initreq);
@@ -3428,7 +3433,7 @@
 	}
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	if (sdp) {
-		add_sdp(&req, p, NULL, NULL);
+		add_sdp(&req, p, NULL, NULL, 0);
 	} else {
 		add_header(&req, "Content-Length", "0");
 		add_blank_header(&req);
@@ -7725,7 +7730,7 @@
 	return NULL;
 }
 
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codec)
 {
 	struct sip_pvt *p;
 	p = chan->pvt->pvt;
@@ -7739,7 +7744,7 @@
 		else
 			memset(&p->vredirip, 0, sizeof(p->vredirip));
 		if (!p->gotrefer) {
-			transmit_reinvite_with_sdp(p, rtp, vrtp);
+			transmit_reinvite_with_sdp(p, rtp, vrtp, codec);
 			p->outgoing = 1;
 		}
 		return 0;

Index: chan_skinny.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- chan_skinny.c	26 May 2004 23:15:23 -0000	1.41
+++ chan_skinny.c	27 May 2004 04:18:46 -0000	1.42
@@ -948,7 +948,7 @@
 	return NULL;
 }
 
-static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp)
+static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
 {
 	struct skinny_subchannel *sub;
 	sub = chan->pvt->pvt;




More information about the svn-commits mailing list