[asterisk-commits] branch oej/sdpcleanup r32280 - /team/oej/sdpcleanup/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 5 06:22:53 MST 2006


Author: oej
Date: Mon Jun  5 08:22:53 2006
New Revision: 32280

URL: http://svn.digium.com/view/asterisk?rev=32280&view=rev
Log:
Whoaa. Video calls are working

Modified:
    team/oej/sdpcleanup/channels/chan_sip.c

Modified: team/oej/sdpcleanup/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channels/chan_sip.c?rev=32280&r1=32279&r2=32280&view=diff
==============================================================================
--- team/oej/sdpcleanup/channels/chan_sip.c (original)
+++ team/oej/sdpcleanup/channels/chan_sip.c Mon Jun  5 08:22:53 2006
@@ -5022,6 +5022,7 @@
 	return 0;
 }
 
+/*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
 static void add_codec_to_sdp(const struct sip_pvt *p, int codec, int sample_rate,
 			     char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
 			     int debug)
@@ -5042,6 +5043,7 @@
 		ast_build_string(a_buf, a_size, "a=fmtp:%d annexb=no\r\n", rtp_code);
 }
 
+/*! \brief Add RFC 2833 DTMF offer to SDP */
 static void add_noncodec_to_sdp(const struct sip_pvt *p, int format, int sample_rate,
 				char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
 				int debug)
@@ -5066,7 +5068,6 @@
 static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
 {
 	int len = 0;
-	int pref_codec;
 	int alreadysent = 0;
 	struct sockaddr_in sin;
 	struct sockaddr_in vsin;
@@ -5096,7 +5097,6 @@
 	struct sockaddr_in vdest = { 0, };
 	int debug;
 	int needvideo = FALSE;
-	int videocapability = 0;
 	
 	debug = sip_debug_test_pvt(p);
 
@@ -5157,15 +5157,26 @@
 		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 & p->prefcodec) & AST_FORMAT_VIDEO_MASK;
+		if (p->prefcodec) {
+			int videocapability = (capability & p->prefcodec) & AST_FORMAT_VIDEO_MASK; /* Outbound call */
 		
-		/*! \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));
+			/*! \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 */
+			if (!videocapability) {
+				needvideo = FALSE;
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "** No compatible video codecs... Disabling video.\n");
+			} 
+
+			/* Replace video capabilities with the new videocapability */
+			capability = (capability & AST_FORMAT_AUDIO_MASK) | videocapability;
+			if (option_debug > 2) {
+				char codecbuf[BUFSIZ];
+				if (videocapability)
+					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) 
@@ -5195,11 +5206,15 @@
 				 &m_audio_next, &m_audio_left,
 				 &a_audio_next, &a_audio_left,
 				 debug);
-		alreadysent |= p->prefcodec;
-	}
+		alreadysent |= p->prefcodec & AST_FORMAT_AUDIO_MASK;
+	}
+
+	ast_log(LOG_DEBUG, "****** ONE ************************\n");
 
 	/* Start by sending our preferred audio codecs */
 	for (x = 0; x < 32; x++) {
+		int pref_codec;
+
 		if (!(pref_codec = ast_codec_pref_index(&p->prefs, x)))
 			break; 
 
@@ -5215,11 +5230,14 @@
 				 debug);
 		alreadysent |= pref_codec;
 	}
+	ast_log(LOG_DEBUG, "****** TWO ************************\n");
 
 	/* 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;
+
+		ast_log(LOG_DEBUG, "--- Checking codec ... %d\n", x);
 
 		if (alreadysent & x)	/* Already added to SDP */
 			continue;
@@ -5229,12 +5247,17 @@
 					 &m_audio_next, &m_audio_left,
 					 &a_audio_next, &a_audio_left,
 					 debug);
-		else
+		else {
 			add_codec_to_sdp(p, x, 90000,
 					 &m_video_next, &m_video_left,
 					 &a_video_next, &a_video_left,
 					 debug);
-	}
+			if (option_debug > 2)
+				ast_log(LOG_DEBUG, "Adding video codec to SDP... %d\n", x);
+		}
+	}
+
+	ast_log(LOG_DEBUG, "****** THREE ************************\n");
 
 	/* Now add DTMF RFC2833 telephony-event as a codec */
 	for (x = 1; x <= AST_RTP_MAX; x <<= 1) {



More information about the asterisk-commits mailing list