[svn-commits] branch oej/sdpcleanup r32276 - in /team/oej/sdpcleanup: ./ channels/ configs/...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jun 5 04:35:22 MST 2006


Author: oej
Date: Mon Jun  5 06:35:22 2006
New Revision: 32276

URL: http://svn.digium.com/view/asterisk?rev=32276&view=rev
Log:
Try to base the outbound video offer on the inbound one.

Added:
    team/oej/sdpcleanup/contrib/utils/zones2indications.c
      - copied unchanged from r32255, trunk/contrib/utils/zones2indications.c
Modified:
    team/oej/sdpcleanup/   (props changed)
    team/oej/sdpcleanup/channel.c
    team/oej/sdpcleanup/channels/chan_sip.c
    team/oej/sdpcleanup/configs/indications.conf.sample
    team/oej/sdpcleanup/include/asterisk/rtp.h
    team/oej/sdpcleanup/rtp.c

Propchange: team/oej/sdpcleanup/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/sdpcleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun  5 06:35:22 2006
@@ -1,1 +1,1 @@
-/trunk:1-32251
+/trunk:1-32275

Modified: team/oej/sdpcleanup/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channel.c?rev=32276&r1=32275&r2=32276&view=diff
==============================================================================
--- team/oej/sdpcleanup/channel.c (original)
+++ team/oej/sdpcleanup/channel.c Mon Jun  5 06:35:22 2006
@@ -2614,6 +2614,7 @@
 	int fmt;
 	int res;
 	int foo;
+	int videoformat = format & AST_FORMAT_VIDEO_MASK;
 
 	if (!cause)
 		cause = &foo;
@@ -2628,8 +2629,8 @@
 		if (strcasecmp(type, chan->tech->type))
 			continue;
 
-		capabilities = chan->tech->capabilities | (format & AST_FORMAT_VIDEO_MASK);
-		fmt = format;
+		capabilities = chan->tech->capabilities;
+		fmt = format & AST_FORMAT_AUDIO_MASK;
 		res = ast_translator_best_choice(&fmt, &capabilities);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format);
@@ -2640,7 +2641,7 @@
 		if (!chan->tech->requester)
 			return NULL;
 		
-		if (!(c = chan->tech->requester(type, capabilities, data, cause)))
+		if (!(c = chan->tech->requester(type, capabilities | videoformat, data, cause)))
 			return NULL;
 
 		if (c->_state == AST_STATE_DOWN) {

Modified: team/oej/sdpcleanup/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channels/chan_sip.c?rev=32276&r1=32275&r2=32276&view=diff
==============================================================================
--- team/oej/sdpcleanup/channels/chan_sip.c (original)
+++ team/oej/sdpcleanup/channels/chan_sip.c Mon Jun  5 06:35:22 2006
@@ -4311,7 +4311,44 @@
 	newpeercapability = (peercapability | vpeercapability);
 	newnoncodeccapability = noncodeccapability & peernoncodeccapability;
 		
-	/* THIS SHOULD MOVE TO AFTER ERROR CHECKING */
+		
+	if (debug) {
+		/* shame on whoever coded this.... */
+		char s1[BUFSIZ], s2[BUFSIZ], s3[BUFSIZ], s4[BUFSIZ];
+
+		ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n",
+			ast_getformatname_multiple(s1, BUFSIZ, p->capability),
+			ast_getformatname_multiple(s2, BUFSIZ, newpeercapability),
+			ast_getformatname_multiple(s3, BUFSIZ, vpeercapability),
+			ast_getformatname_multiple(s4, BUFSIZ, newjointcapability));
+
+		ast_verbose("Non-codec capabilities (dtmf): us - %s, peer - %s, combined - %s\n",
+			ast_rtp_lookup_mime_multiple(s1, BUFSIZ, noncodeccapability, 0),
+			ast_rtp_lookup_mime_multiple(s2, BUFSIZ, peernoncodeccapability, 0),
+			ast_rtp_lookup_mime_multiple(s3, BUFSIZ, newnoncodeccapability, 0));
+	}
+	if (!newjointcapability) {
+		ast_log(LOG_NOTICE, "No compatible codecs, not accepting this offer!\n");
+		/* Do NOT Change current setting */
+		return -1;
+	}
+
+	/* We are now ready to change the sip session and p->rtp and p->vrtp with the offered codecs, since
+		they are acceptable */
+	p->jointcapability = newjointcapability;	/* Our joint codec profile for this call */
+	p->peercapability = newpeercapability;		/* The other sides capability in latest offer */
+	p->noncodeccapability = newnoncodeccapability;	/* DTMF capabilities */
+
+	{
+		int i;
+		/* Copy payload types from source to destination */
+		for (i=0; i < MAX_RTP_PT; ++i) {
+			p->rtp->current_RTP_PT[i]= newaudiortp.current_RTP_PT[i];
+			if (p->vrtp) 
+				p->vrtp->current_RTP_PT[i]= newvideortp.current_RTP_PT[i];
+		}
+	}
+
 	if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO) {
 		ast_clear_flag(&p->flags[0], SIP_DTMF);
 		if (newnoncodeccapability & AST_RTP_DTMF) {
@@ -4319,43 +4356,6 @@
 			ast_set_flag(&p->flags[0], SIP_DTMF_RFC2833);
 		} else {
 			ast_set_flag(&p->flags[0], SIP_DTMF_INBAND);
-		}
-	}
-		
-	if (debug) {
-		/* shame on whoever coded this.... */
-		char s1[BUFSIZ], s2[BUFSIZ], s3[BUFSIZ], s4[BUFSIZ];
-
-		ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n",
-			ast_getformatname_multiple(s1, BUFSIZ, p->capability),
-			ast_getformatname_multiple(s2, BUFSIZ, newpeercapability),
-			ast_getformatname_multiple(s3, BUFSIZ, vpeercapability),
-			ast_getformatname_multiple(s4, BUFSIZ, newjointcapability));
-
-		ast_verbose("Non-codec capabilities (dtmf): us - %s, peer - %s, combined - %s\n",
-			ast_rtp_lookup_mime_multiple(s1, BUFSIZ, noncodeccapability, 0),
-			ast_rtp_lookup_mime_multiple(s2, BUFSIZ, peernoncodeccapability, 0),
-			ast_rtp_lookup_mime_multiple(s3, BUFSIZ, newnoncodeccapability, 0));
-	}
-	if (!newjointcapability) {
-		ast_log(LOG_NOTICE, "No compatible codecs, not accepting this offer!\n");
-		/* Do NOT Change current setting */
-		return -1;
-	}
-
-	/* We are now ready to change the sip session and p->rtp and p->vrtp with the offered codecs, since
-		they are acceptable */
-	p->jointcapability = newjointcapability;	/* Our joint codec profile for this call */
-	p->peercapability = newpeercapability;		/* The other sides capability in latest offer */
-	p->noncodeccapability = newnoncodeccapability;	/* DTMF capabilities */
-
-	{
-		int i;
-		/* Copy payload types from source to destination */
-		for (i=0; i < MAX_RTP_PT; ++i) {
-			p->rtp->current_RTP_PT[i]= newaudiortp.current_RTP_PT[i];
-			if (p->vrtp) 
-				p->vrtp->current_RTP_PT[i]= newvideortp.current_RTP_PT[i];
 		}
 	}
 
@@ -5096,6 +5096,7 @@
 	struct sockaddr_in vdest = { 0, };
 	int debug;
 	int needvideo = FALSE;
+	int videocapability = 0;
 	
 	debug = sip_debug_test_pvt(p);
 
@@ -5137,7 +5138,7 @@
 			if (option_debug > 1)
 				ast_log(LOG_DEBUG, "This call needs video offers! \n");
 		} else if (option_debug > 1)
-			ast_log(LOG_DEBUG, "This call needs video offers, but there's no video suupport enabled ! \n");
+			ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled ! \n");
 	}
 		
 
@@ -5155,6 +5156,17 @@
 			snprintf(b, sizeof(b), "b=CT:%d\r\n", p->maxcallbitrate);
 		if (debug) 
 			ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(vsin.sin_port));	
+		/* For video, we can't negotiate video offers. Let's compare the incoming call with what we got. */
+		videocapability = (capability & AST_FORMAT_AUDIO_MASK) & p->prefcodec;
+		
+		/*! \todo XXX We need to select one codec, not many, since there's no transcoding */
+		/* Now, merge this video capability into capability while removing unsupported codecs */
+		capability = (capability & AST_FORMAT_AUDIO_MASK) | videocapability;
+		if (option_debug > 2) {
+			char codecbuf[BUFSIZ];
+			ast_log(LOG_DEBUG, "** Our video codec selection is: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), videocapability));
+			ast_log(LOG_DEBUG, "** Capability now set to : %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability));
+		}
 	}
 	if (debug) 
 		ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(sin.sin_port));	
@@ -5177,22 +5189,16 @@
 	else
 		hold = "a=sendrecv\r\n";
 
-	/* Prefer the codec we were requested to use, first, no matter what */
+	/* Prefer the audio codec we were requested to use, first, no matter what */
 	if (capability & p->prefcodec) {
-		if (p->prefcodec <= AST_FORMAT_MAX_AUDIO)
-			add_codec_to_sdp(p, p->prefcodec, 8000,
-					 &m_audio_next, &m_audio_left,
-					 &a_audio_next, &a_audio_left,
-					 debug);
-		else if (needvideo)
-			add_codec_to_sdp(p, p->prefcodec, 90000,
-					 &m_video_next, &m_video_left,
-					 &a_video_next, &a_video_left,
-					 debug);
+		add_codec_to_sdp(p, p->prefcodec & AST_FORMAT_AUDIO_MASK, 8000,
+				 &m_audio_next, &m_audio_left,
+				 &a_audio_next, &a_audio_left,
+				 debug);
 		alreadysent |= p->prefcodec;
 	}
 
-	/* Start by sending our preferred codecs */
+	/* Start by sending our preferred audio codecs */
 	for (x = 0; x < 32; x++) {
 		if (!(pref_codec = ast_codec_pref_index(&p->prefs, x)))
 			break; 
@@ -5203,20 +5209,14 @@
 		if (alreadysent & pref_codec)
 			continue;
 
-		if (pref_codec <= AST_FORMAT_MAX_AUDIO)
-			add_codec_to_sdp(p, pref_codec, 8000,
-					 &m_audio_next, &m_audio_left,
-					 &a_audio_next, &a_audio_left,
-					 debug);
-		else if (needvideo)
-			add_codec_to_sdp(p, pref_codec, 90000,
-					 &m_video_next, &m_video_left,
-					 &a_video_next, &a_video_left,
-					 debug);
+		add_codec_to_sdp(p, pref_codec, 8000,
+				 &m_audio_next, &m_audio_left,
+				 &a_audio_next, &a_audio_left,
+				 debug);
 		alreadysent |= pref_codec;
 	}
 
-	/* Now send any other common codecs, and non-codec formats: */
+	/* Now send any other common audio and video codecs, and non-codec formats: */
 	for (x = 1; x <= (needvideo ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) {
 		if (!(capability & x))	/* Codec not requested */
 			continue;
@@ -5236,6 +5236,7 @@
 					 debug);
 	}
 
+	/* Now add DTMF RFC2833 telephony-event as a codec */
 	for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
 		if (!(p->noncodeccapability & x))
 			continue;
@@ -13680,7 +13681,7 @@
 #if 0
 	printf("Setting up to call extension '%s' at '%s'\n", ext ? ext : "<none>", host);
 #endif
-	p->prefcodec = format;				/* Format for this call */
+	p->prefcodec = oldformat;				/* Format for this call */
 	ast_mutex_lock(&p->lock);
 	tmpc = sip_new(p, AST_STATE_DOWN, host);	/* Place the call */
 	ast_mutex_unlock(&p->lock);

Modified: team/oej/sdpcleanup/configs/indications.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/configs/indications.conf.sample?rev=32276&r1=32275&r2=32276&view=diff
==============================================================================
--- team/oej/sdpcleanup/configs/indications.conf.sample (original)
+++ team/oej/sdpcleanup/configs/indications.conf.sample Mon Jun  5 06:35:22 2006
@@ -333,6 +333,33 @@
 info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0
 stutter = 350+375+400
 
+[il]
+description = Israel
+ringcadence = 1000,3000
+dial = 414
+busy = 414/500,0/500
+ring = 414/1000,0/3000
+congestion = 414/250,0/250
+callwaiting = 414/100,0/100,414/100,0/100,414/600,0/3000
+dialrecall = !414/100,!0/100,!414/100,!0/100,!414/100,!0/100,414
+record = 1400/500,0/15000
+info = 1000/330,1400/330,1800/330,0/1000
+stutter = !414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,414
+
+
+[in]
+description = India
+ringcadence = 400,200,400,2000
+dial = 400*25
+busy = 400/750,0/750
+ring = 400*25/400,0/200,400*25/400,0/2000
+congestion = 400/250,0/250
+callwaiting = 400/200,0/100,400/200,0/7500
+dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440
+record = 1400/500,0/15000
+info = !950/330,!1400/330,!1800/330,0/1000
+stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440
+
 [it]
 description = Italy
 ; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf
@@ -362,6 +389,19 @@
 info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0
 ; STUTTER - not specified
 stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425
+
+[jp]
+description = Japan
+ringcadence = 1000,2000
+dial = 400
+busy = 400/500,0/500
+ring = 400+15/1000,0/2000
+congestion = 400/500,0/500
+callwaiting = 400+16/500,0/8000
+dialrecall = !400/200,!0/200,!400/200,!0/200,!400/200,!0/200,400
+record = 1400/500,0/15000
+info = !950/330,!1400/330,!1800/330,0
+stutter = !400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,400
 
 [mx]
 description = Mexico

Modified: team/oej/sdpcleanup/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/asterisk/rtp.h?rev=32276&r1=32275&r2=32276&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/asterisk/rtp.h (original)
+++ team/oej/sdpcleanup/include/asterisk/rtp.h Mon Jun  5 06:35:22 2006
@@ -62,22 +62,25 @@
 	AST_LIST_ENTRY(ast_rtp_protocol) list;
 };
 
+
+#define FLAG_3389_WARNING		(1 << 0)
+
 typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
 
+
+/*!
+ * \brief Structure representing a RTP session.
+ *
+ * RTP session is defined on page 9 of RFC 3550: "An association among a set of participants communicating with RTP.  A participant may be involved in multiple RTP sessions at the same time [...]"
+ *
+ */
 /*! \brief The value of each payload format mapping: */
 struct rtpPayloadType {
 	int isAstFormat; 	/*!< whether the following code is an AST_FORMAT */
-	int code;		/*!< Payload code for this type in this RTP stream */
+	int code;
 };
 
-#define FLAG_3389_WARNING		(1 << 0)
-
-/*!
- * \brief Structure representing a RTP session.
- *
- * RTP session is defined on page 9 of RFC 3550: "An association among a set of participants communicating with RTP.  A participant may be involved in multiple RTP sessions at the same time [...]"
- *
- */
+/*! \brief RTP session description */
 struct ast_rtp {
 	int s;
 	char resp;
@@ -92,7 +95,6 @@
 	unsigned int lastividtimestamp;
 	unsigned int lastovidtimestamp;
 	unsigned int lasteventseqn;
-	unsigned int lasteventendseqn;
 	int lastrxseqno;                /*!< Last received sequence number */
 	unsigned short seedrxseqno;     /*!< What sequence number did they start with?*/
 	unsigned int seedrxts;          /*!< What RTP timestamp did they start with? */
@@ -103,6 +105,7 @@
 	unsigned int cycles;            /*!< Shifted count of sequence number cycles */
 	double rxjitter;                /*!< Interarrival jitter at the moment */
 	double rxtransit;               /*!< Relative transit time for previous packet */
+	unsigned int lasteventendseqn;
 	int lasttxformat;
 	int lastrxformat;
 	int dtmfcount;

Modified: team/oej/sdpcleanup/rtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/rtp.c?rev=32276&r1=32275&r2=32276&view=diff
==============================================================================
--- team/oej/sdpcleanup/rtp.c (original)
+++ team/oej/sdpcleanup/rtp.c Mon Jun  5 06:35:22 2006
@@ -96,8 +96,6 @@
 static int ast_rtcp_write_sr(void *data);
 static int ast_rtcp_write_rr(void *data);
 static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp);
-
-#define MAX_RTP_PT			256
 
 #define FLAG_3389_WARNING		(1 << 0)
 #define FLAG_NAT_ACTIVE			(3 << 1)



More information about the svn-commits mailing list