[svn-commits] branch oej/sdpcleanup r25926 - in /team/oej/sdpcleanup: ./ channels/ include/...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue May 9 01:28:27 MST 2006


Author: oej
Date: Tue May  9 03:28:27 2006
New Revision: 25926

URL: http://svn.digium.com/view/asterisk?rev=25926&view=rev
Log:
- Cleanup process_sdp
- Preparing for fmtp: support
- Move some definitions from rtp.c to rtp.h since they are needed outside of rtp.c

Modified:
    team/oej/sdpcleanup/channels/chan_sip.c
    team/oej/sdpcleanup/include/asterisk/rtp.h
    team/oej/sdpcleanup/rtp.c

Modified: team/oej/sdpcleanup/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channels/chan_sip.c?rev=25926&r1=25925&r2=25926&view=diff
==============================================================================
--- team/oej/sdpcleanup/channels/chan_sip.c (original)
+++ team/oej/sdpcleanup/channels/chan_sip.c Tue May  9 03:28:27 2006
@@ -3027,6 +3027,7 @@
 	struct ast_variable *v = NULL;
 	int fmt;
 	int what;
+	int needvideo = 0;
 	
 	ast_mutex_unlock(&i->lock);
 	/* Don't hold a sip pvt lock while we allocate a channel */
@@ -3045,6 +3046,10 @@
 		what = i->capability;
 	else
 		what = global_capability;
+	needvideo = i->prefcodec & AST_FORMAT_VIDEO_MASK;
+	if (option_debug && needvideo) 
+		ast_log(LOG_DEBUG, "This call needs video! HOLLYWOOD next!\n");
+
 	tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | (i->jointcapability & AST_FORMAT_VIDEO_MASK);
 	fmt = ast_best_codec(tmp->nativeformats);
 
@@ -3065,7 +3070,7 @@
 		tmp->fds[0] = ast_rtp_fd(i->rtp);
 		tmp->fds[1] = ast_rtcp_fd(i->rtp);
 	}
-	if (i->vrtp) {
+	if (needvideo && i->vrtp) {
 		tmp->fds[2] = ast_rtp_fd(i->vrtp);
 		tmp->fds[3] = ast_rtcp_fd(i->vrtp);
 	}
@@ -3726,26 +3731,40 @@
 	char host[258];
 	char iabuf[INET_ADDRSTRLEN];
 	int len = -1;
-	int portno = -1;
-	int vportno = -1;
+	int portno = -1;		/*!< RTP Audio port number */
+	int vportno = -1;		/*!< RTP Video port number */
 	int peercapability, peernoncodeccapability;
 	int vpeercapability=0, vpeernoncodeccapability=0;
 	struct sockaddr_in sin;
+	struct sockaddr_in vsin;	/*!< Video socket address */
 	const char *codecs;
-	struct hostent *hp;
-	struct ast_hostent ahp;
+	struct hostent *hp;		/*!< RTP Audio host IP */
+	struct hostent *vhp = NULL;	/*!< RTP video host IP */
+	struct ast_hostent audiohp;
+	struct ast_hostent videohp;
 	int codec;
 	int destiterator = 0;
 	int iterator;
 	int sendonly = 0;
-	int x,y;
+	int x;
+	int numberofports;
 	int debug=sip_debug_test_pvt(p);
 	struct ast_channel *bridgepeer = NULL;
-
+	struct ast_rtp newaudiortp, newvideortp;
+	int newjointcapability;
+	int newpeercapability;
+	int newnoncodeccapability;
+	int numberofmediastreams = 0;
+		
 	if (!p->rtp) {
 		ast_log(LOG_ERROR, "Got SDP but have no RTP session allocated.\n");
 		return -1;
 	}
+
+	ast_rtp_pt_default(&newaudiortp);
+	if (p->vrtp)
+		ast_rtp_pt_default(&newvideortp);
+
 
 	/* Update our last rtprx when we receive an SDP, too */
 	time(&p->lastrtprx);
@@ -3756,6 +3775,7 @@
 		ast_log(LOG_NOTICE, "Content is '%s', not 'application/sdp'\n", get_header(req, "Content-Type"));
 		return -1;
 	}
+	/* Try to find first media stream */
 	m = get_sdp(req, "m");
 	destiterator = 0;
 	c = get_sdp_iterate(&destiterator, req, "c");
@@ -3768,21 +3788,30 @@
 		return -1;
 	}
 	/* XXX This could block for a long time, and block the main thread! XXX */
-	hp = ast_gethostbyname(host, &ahp);
+	hp = ast_gethostbyname(host, &audiohp);
 	if (!hp) {
 		ast_log(LOG_WARNING, "Unable to lookup host in c= line, '%s'\n", c);
 		return -1;
 	}
 	iterator = 0;
 	ast_set_flag(&p->flags[0], SIP_NOVIDEO);	
+
+
+	/* Find media streams in this SDP offer */
 	while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') {
-		int found = 0;
-		if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &y, &len) == 2) ||
+		int audio = FALSE;
+		numberofmediastreams++;
+
+		if (p->vrtp)
+			ast_rtp_pt_clear(&newvideortp);  /* Must be cleared in case no m=video line exists */
+		numberofports = 1;
+		if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) ||
 		    (sscanf(m, "audio %d RTP/AVP %n", &x, &len) == 1)) {
-			found = 1;
+			audio = TRUE;
+			/* Found audio stream in this media definition */
 			portno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
-			ast_rtp_pt_clear(p->rtp);
+			ast_rtp_pt_clear(&newaudiortp);
 			for (codecs = m + len; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
 				if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
 					ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
@@ -3790,14 +3819,11 @@
 				}
 				if (debug)
 					ast_verbose("Found RTP audio format %d\n", codec);
-				ast_rtp_set_m_type(p->rtp, codec);
+				ast_rtp_set_m_type(&newaudiortp, codec);
 			}
-		}
-		if (p->vrtp)
-			ast_rtp_pt_clear(p->vrtp);  /* Must be cleared in case no m=video line exists */
-
-		if (p->vrtp && (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) {
-			found = 1;
+		} else if ((sscanf(m, "video %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) ||
+		    (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) {
+			/* If it is not audio - is it video ? */
 			ast_clear_flag(&p->flags[0], SIP_NOVIDEO);	
 			vportno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
@@ -3807,110 +3833,139 @@
 					return -1;
 				}
 				if (debug)
-					ast_verbose("Found RTP video format %d\n", codec);
-				ast_rtp_set_m_type(p->vrtp, codec);
-			}
-		}
-		if (!found )
-			ast_log(LOG_WARNING, "Unknown SDP media type in offer: %s\n", m);
-	}
-	if (portno == -1 && vportno == -1) {
-		/* No acceptable offer found in SDP */
-		return -2;
-	}
-	/* Check for Media-description-level-address for audio */
-	if (pedanticsipchecking) {
-		c = get_sdp_iterate(&destiterator, req, "c");
-		if (!ast_strlen_zero(c)) {
-			if (sscanf(c, "IN IP4 %256s", host) != 1) {
-				ast_log(LOG_WARNING, "Invalid secondary host in c= line, '%s'\n", c);
-			} else {
-				/* XXX This could block for a long time, and block the main thread! XXX */
-				hp = ast_gethostbyname(host, &ahp);
-				if (!hp) {
-					ast_log(LOG_WARNING, "Unable to lookup host in secondary c= line, '%s'\n", c);
+						ast_verbose("Found RTP video format %d\n", codec);
+					ast_rtp_set_m_type(&newvideortp, codec);
+				}
+			} else 
+				ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
+			if (numberofports > 1)
+				ast_log(LOG_WARNING, "SDP offered %d ports for media, not supported by Asterisk. Will try anyway...\n", numberofports);
+		
+
+			/* Check for Media-description-level-address for audio */
+			if (pedanticsipchecking) {
+				c = get_sdp_iterate(&destiterator, req, "c");
+				if (!ast_strlen_zero(c)) {
+					if (sscanf(c, "IN IP4 %256s", host) != 1) {
+						ast_log(LOG_WARNING, "Invalid secondary host in c= line, '%s'\n", c);
+				} else {
+					/* XXX This could block for a long time, and block the main thread! XXX */
+					if (!audio && !(hp = ast_gethostbyname(host, &audiohp)))
+						ast_log(LOG_WARNING, "Unable to lookup RTP Audio host in secondary c= line, '%s'\n", c);
+					else if (!(vhp = ast_gethostbyname(host, &videohp)))
+						ast_log(LOG_WARNING, "Unable to lookup RTP video host in secondary c= line, '%s'\n", c);
 				}
 			}
-		}
-	}
+
+		}
+	}
+	if (portno == -1 && vportno == -1)
+		/* No acceptable offer found in SDP  - we have no ports */
+		/* Do not change RTP or VRTP if this is a re-invite */
+		return -2;
+
+	if (numberofmediastreams > 2)
+		/* We have too many media streams, fail this offer */
+		return -3;
+
 	/* RTP addresses and ports for audio and video */
 	sin.sin_family = AF_INET;
+	vsin.sin_family = AF_INET;
 	memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
+	if (vhp)
+		memcpy(&vsin.sin_addr, vhp->h_addr, sizeof(vsin.sin_addr));
+		
 
 	/* Setup audio port number */
 	sin.sin_port = htons(portno);
+	/* Setup video port number */
+	vsin.sin_port = htons(vportno);
+
 	if (p->rtp && sin.sin_port) {
 		ast_rtp_set_peer(p->rtp, &sin);
-		if (debug) {
+		if (debug)
 			ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
-		}
-	}
-	/* Check for Media-description-level-address for video */
-	if (pedanticsipchecking) {
-		c = get_sdp_iterate(&destiterator, req, "c");
-		if (!ast_strlen_zero(c)) {
-			if (sscanf(c, "IN IP4 %256s", host) != 1) {
-				ast_log(LOG_WARNING, "Invalid secondary host in c= line, '%s'\n", c);
-			} else {
-				/* XXX This could block for a long time, and block the main thread! XXX */
-				hp = ast_gethostbyname(host, &ahp);
-				if (!hp) {
-					ast_log(LOG_WARNING, "Unable to lookup host in secondary c= line, '%s'\n", c);
-				}
-			}
-		}
-	}
+	}
+
 	/* Setup video port number */
-	sin.sin_port = htons(vportno);
-	if (p->vrtp && sin.sin_port) {
-		ast_rtp_set_peer(p->vrtp, &sin);
-		if (debug) {
-			ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
-		}
+	if (p->vrtp && vsin.sin_port) {
+		ast_rtp_set_peer(p->vrtp, &vsin);
+		if (debug) 
+			ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), vsin.sin_addr), ntohs(vsin.sin_port));
 	}
 
 	/* Next, scan through each "a=rtpmap:" line, noting each
 	 * specified RTP payload type (with corresponding MIME subtype):
 	 */
+	/* XXX This needs to be done per media stream, since it's media stream specific */
 	iterator = 0;
 	while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
 		char* mimeSubtype = ast_strdupa(a); /* ensures we have enough space */
 		if (!strcasecmp(a, "sendonly")) {
-			sendonly=1;
+			sendonly = 1;
 			continue;
-		}
-		if (!strcasecmp(a, "sendrecv")) {
-		  	sendonly=0;
-		}
-		if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2) continue;
+		}  else if (!strcasecmp(a, "sendrecv")) {
+			sendonly = 0;
+			continue;
+		} else if (!strcasecmp(a, "inactive")) {
+			/* Inactive media streams: Not supported */
+			if (debug)
+				ast_verbose("Got unsupported a:inactive in SDP offer \n");
+			continue;
+		} else if (!strncasecmp(a, "fmtp:", (size_t) 5)) {
+			/* Format parameters:  Not supported */
+			/* Note: This is used for codec parameters, like bitrate for
+				G722 and video formats for H263 and H264 
+				See RFC2327 for an example */
+			if (debug)
+				ast_verbose("Got unsupported a:fmtp in SDP offer \n");
+			continue;
+		} else if (!strncasecmp(a, "maxprate:", (size_t) 9)) {
+			/* Video stuff:  Not supported */
+			if (debug)
+				ast_verbose("Got unsupported a:maxprate in SDP offer \n");
+			continue;
+		} else if (!strncasecmp(a, "crypto:", (size_t) 7)) {
+			/* SRTP stuff, not yet supported */
+			if (debug)
+				ast_verbose("Got unsupported a:crypto in SDP offer \n");
+			continue;
+		} else if (!strncasecmp(a, "ptime:", (size_t) 6)) {
+			if (debug)
+				ast_verbose("Got unsupported a:ptime in SDP offer \n");
+			continue;
+		} else if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2) 
+			continue;
+		/* We have a rtpmap to handle */
 		if (debug)
-			ast_verbose("Found description format %s\n", mimeSubtype);
+			ast_verbose("Found description format %s for ID %d\n", mimeSubtype, codec);
+
 		/* Note: should really look at the 'freq' and '#chans' params too */
-		ast_rtp_set_rtpmap_type(p->rtp, codec, "audio", mimeSubtype);
+		ast_rtp_set_rtpmap_type(&newaudiortp, codec, "audio", mimeSubtype);
 		if (p->vrtp)
-			ast_rtp_set_rtpmap_type(p->vrtp, codec, "video", mimeSubtype);
-	}
-
-	/* Now gather all of the codecs that were asked for: */
-	ast_rtp_get_current_formats(p->rtp,
-				&peercapability, &peernoncodeccapability);
+			ast_rtp_set_rtpmap_type(&newvideortp, codec, "video", mimeSubtype);
+	}
+
+	/* Now gather all of the codecs that we are asked for: */
+	ast_rtp_get_current_formats(&newaudiortp, &peercapability, &peernoncodeccapability);
 	if (p->vrtp)
-		ast_rtp_get_current_formats(p->vrtp,
-				&vpeercapability, &vpeernoncodeccapability);
-	p->jointcapability = p->capability & (peercapability | vpeercapability);
-	p->peercapability = (peercapability | vpeercapability);
-	p->noncodeccapability = noncodeccapability & peernoncodeccapability;
-	
+		ast_rtp_get_current_formats(&newvideortp, &vpeercapability, &vpeernoncodeccapability);
+
+	newjointcapability = p->capability & (peercapability | vpeercapability);
+	newpeercapability = (peercapability | vpeercapability);
+	newnoncodeccapability = noncodeccapability & peernoncodeccapability;
+		
+	/* THIS SHOULD MOVE TO AFTER ERROR CHECKING */
 	if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO) {
 		ast_clear_flag(&p->flags[0], SIP_DTMF);
-		if (p->noncodeccapability & AST_RTP_DTMF) {
+		if (newnoncodeccapability & AST_RTP_DTMF) {
 			/* XXX Would it be reasonable to drop the DSP at this point? XXX */
 			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.... */
 		const unsigned slen=512;
@@ -3918,34 +3973,60 @@
 
 		ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n",
 			ast_getformatname_multiple(s1, slen, p->capability),
-			ast_getformatname_multiple(s2, slen, peercapability),
+			ast_getformatname_multiple(s2, slen, newpeercapability),
 			ast_getformatname_multiple(s3, slen, vpeercapability),
-			ast_getformatname_multiple(s4, slen, p->jointcapability));
+			ast_getformatname_multiple(s4, slen, newjointcapability));
 
 		ast_verbose("Non-codec capabilities: us - %s, peer - %s, combined - %s\n",
 			ast_rtp_lookup_mime_multiple(s1, slen, noncodeccapability, 0),
 			ast_rtp_lookup_mime_multiple(s2, slen, peernoncodeccapability, 0),
-			ast_rtp_lookup_mime_multiple(s3, slen, p->noncodeccapability, 0));
-	}
-	if (!p->jointcapability) {
+			ast_rtp_lookup_mime_multiple(s3, slen, newnoncodeccapability, 0));
+	}
+	if (!newjointcapability) {
 		ast_log(LOG_NOTICE, "No compatible codecs!\n");
+		/* Do NOT Change current setting */
 		return -1;
 	}
 
 	if (!p->owner) 	/* There's no open channel owning us */
 		return 0;
+
+	/* Ok, we're going with this offer */
+	if (debug && option_debug)
+		ast_log(LOG_DEBUG, "Ok, we're accepting this SDP offer! \n");
+
+	p->jointcapability = newjointcapability;
+	p->peercapability = newpeercapability;
+	p->noncodeccapability = newnoncodeccapability;
+		
+	/* We are now ready to change p->rtp and p->vrtp with the offered codecs, since
+		they are acceptable */
+	{
+		int i;
+		/* Copy payload types from source to destination */
+		for (i=0; i < MAX_RTP_PT; ++i) {
+			p->rtp->current_RTP_PT[i].isAstFormat = newaudiortp.current_RTP_PT[i].isAstFormat;
+			p->rtp->current_RTP_PT[i].code = newaudiortp.current_RTP_PT[i].code; 
+			if (p->vrtp) {
+				p->vrtp->current_RTP_PT[i].isAstFormat = newvideortp.current_RTP_PT[i].isAstFormat;
+				p->vrtp->current_RTP_PT[i].code = newvideortp.current_RTP_PT[i].code; 
+			}
+		}
+	}
 
 	if (!(p->owner->nativeformats & p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
 		const unsigned slen=512;
 		char s1[slen], s2[slen];
-		ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n", 
+		if (debug)
+			ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n", 
 				ast_getformatname_multiple(s1, slen, p->jointcapability),
 				ast_getformatname_multiple(s2, slen, p->owner->nativeformats));
 		p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, 1) | (p->capability & vpeercapability);
 		ast_set_read_format(p->owner, p->owner->readformat);
 		ast_set_write_format(p->owner, p->owner->writeformat);
 	}
-	if ((bridgepeer=ast_bridged_channel(p->owner))) {
+
+	if ((bridgepeer = ast_bridged_channel(p->owner))) {
 		/* We have a bridge */
 		/* Turn on/off music on hold if we are holding/unholding */
 		if (sin.sin_addr.s_addr && !sendonly) {
@@ -3959,12 +4040,15 @@
 			ast_moh_start(bridgepeer, NULL);
 			if (sendonly)
 				ast_rtp_stop(p->rtp);
+			/* RTCP needs to go ahead, even if we're on hold!!! */
+
 			/* Activate a re-invite */
 			ast_queue_frame(p->owner, &ast_null_frame);
 		}
 	}
 
 	/* Manager Hold and Unhold events must be generated, if necessary */
+	/* XXX Support for sendonly/recvonly needs to be fixed !!! */
 	if (sin.sin_addr.s_addr && !sendonly) {
 		append_history(p, "Unhold", "%s", req->data);
 
@@ -3993,6 +4077,7 @@
 
 	return 0;
 }
+
 
 /*! \brief Add header to SIP message */
 static int add_header(struct sip_request *req, const char *var, const char *value)
@@ -4723,7 +4808,7 @@
 	if ((p->vrtp) &&
 	    (!ast_test_flag(&p->flags[0], SIP_NOVIDEO)) &&
 	    (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
-		snprintf(b, sizeof(b), "b=CT:%d\r\n", p->maxcallbitrate);	
+		snprintf(b, sizeof(b), "b=CT:%d\r\n", p->maxcallbitrate);
 	snprintf(t, sizeof(t), "t=0 0\r\n");
 
 	ast_build_string(&m_audio_next, &m_audio_left, "m=audio %d RTP/AVP", ntohs(dest.sin_port));
@@ -9850,6 +9935,7 @@
 static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
 {
 	int outgoing = ast_test_flag(&p->flags[0], SIP_OUTGOING);
+	int res = 0;
 	
 	if (option_debug > 3) {
 		int reinvite = (p->owner && p->owner->_state == AST_STATE_UP);
@@ -9885,7 +9971,7 @@
 				ast_setstate(p->owner, AST_STATE_RINGING);
 		}
 		if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
-			process_sdp(p, req);
+			res = process_sdp(p, req);
 			if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
 				/* Queue a progress frame only if we have SDP in 180 */
 				ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
@@ -9897,7 +9983,7 @@
 			sip_cancel_destroy(p);
 		/* Ignore 183 Session progress without SDP */
 		if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
-			process_sdp(p, req);
+			res = process_sdp(p, req);
 			if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
 				/* Queue a progress frame */
 				ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
@@ -9909,7 +9995,9 @@
 			sip_cancel_destroy(p);
 		p->authtries = 0;
 		if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) 
-			process_sdp(p, req);
+			if (res = process_sdp(p, req) && !ast_test_flag(req, SIP_PKT_IGNORE))
+				/* This 200 OK's SDP is not acceptable, so we need to ack, then hangup */
+				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 
 		/* Parse contact header for continued conversation */
 		/* When we get 200 OK, we know which device (and IP) to contact for this call */
@@ -12370,6 +12458,9 @@
 		*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;	/* Can't find codec to connect to host */
 		return NULL;
 	}
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
+
 	if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE))) {
 		ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", (char *)data);
 		*cause = AST_CAUSE_SWITCH_CONGESTION;

Modified: team/oej/sdpcleanup/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/asterisk/rtp.h?rev=25926&r1=25925&r2=25926&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/asterisk/rtp.h (original)
+++ team/oej/sdpcleanup/include/asterisk/rtp.h Tue May  9 03:28:27 2006
@@ -40,13 +40,15 @@
 
 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
 /*! DTMF (RFC2833) */
-#define AST_RTP_DTMF            (1 << 0)
+#define AST_RTP_DTMF            	(1 << 0)
 /*! 'Comfort Noise' (RFC3389) */
-#define AST_RTP_CN              (1 << 1)
+#define AST_RTP_CN              	(1 << 1)
 /*! DTMF (Cisco Proprietary) */
-#define AST_RTP_CISCO_DTMF      (1 << 2)
+#define AST_RTP_CISCO_DTMF      	(1 << 2)
 /*! Maximum RTP-specific code */
-#define AST_RTP_MAX             AST_RTP_CISCO_DTMF
+#define AST_RTP_MAX             	AST_RTP_CISCO_DTMF
+
+#define MAX_RTP_PT			256
 
 struct ast_rtp_protocol {
 	/*! Get RTP struct, or NULL if unwilling to transfer */
@@ -60,15 +62,61 @@
 	AST_LIST_ENTRY(ast_rtp_protocol) list;
 };
 
+typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
+
+/*! \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 */
+};
+
+#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 [...]"
  *
  */
-struct ast_rtp;
-
-typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
+struct ast_rtp {
+	int s;				/*!< File descriptor */
+	char resp;			/*!< Frame subclass */
+	struct ast_frame f;		/*!< The media frame */
+	unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];	/*!< The RTP raw data */
+	unsigned int ssrc;		/*!< Synchronization source, RFC 3550, page 10. */
+	unsigned int lastts;
+	unsigned int lastdigitts;
+	unsigned int lastrxts;
+	unsigned int lastividtimestamp;
+	unsigned int lastovidtimestamp;
+	unsigned int lasteventseqn;
+	unsigned int lasteventendseqn;
+	int lasttxformat;
+	int lastrxformat;
+	int dtmfcount;
+	unsigned int dtmfduration;
+	int nat;
+	unsigned int flags;
+	struct sockaddr_in us;		/*!< Socket representation of the local endpoint. */
+	struct sockaddr_in them;	/*!< Socket representation of the remote endpoint. */
+	struct timeval rxcore;
+	struct timeval txcore;
+	struct timeval dtmfmute;
+	struct ast_smoother *smoother;
+	int *ioid;
+	unsigned short seqno;		/*!< Sequence number, RFC 3550, page 13. */
+	unsigned short rxseqno;
+	struct sched_context *sched;
+	struct io_context *io;
+	void *data;
+	ast_rtp_callback callback;
+	struct rtpPayloadType current_RTP_PT[MAX_RTP_PT];
+	int rtp_lookup_code_cache_isAstFormat; /*!< a cache for the result of rtp_lookup_code(): */
+	int rtp_lookup_code_cache_code;
+	int rtp_lookup_code_cache_result;
+	struct ast_rtcp *rtcp;
+};
+
 
 /*!
  * \brief Initializate a RTP session.

Modified: team/oej/sdpcleanup/rtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/rtp.c?rev=25926&r1=25925&r2=25926&view=diff
==============================================================================
--- team/oej/sdpcleanup/rtp.c (original)
+++ team/oej/sdpcleanup/rtp.c Tue May  9 03:28:27 2006
@@ -73,58 +73,10 @@
 static int nochecksums = 0;
 #endif
 
-/*! \brief The value of each payload format mapping: */
-struct rtpPayloadType {
-	int isAstFormat; 	/*!< whether the following code is an AST_FORMAT */
-	int code;
-};
-
-#define MAX_RTP_PT			256
-
 #define FLAG_3389_WARNING		(1 << 0)
 #define FLAG_NAT_ACTIVE			(3 << 1)
 #define FLAG_NAT_INACTIVE		(0 << 1)
 #define FLAG_NAT_INACTIVE_NOWARN	(1 << 1)
-
-/*! \brief RTP session description */
-struct ast_rtp {
-	int s;
-	char resp;
-	struct ast_frame f;
-	unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
-	unsigned int ssrc;		/*!< Synchronization source, RFC 3550, page 10. */
-	unsigned int lastts;
-	unsigned int lastdigitts;
-	unsigned int lastrxts;
-	unsigned int lastividtimestamp;
-	unsigned int lastovidtimestamp;
-	unsigned int lasteventseqn;
-	unsigned int lasteventendseqn;
-	int lasttxformat;
-	int lastrxformat;
-	int dtmfcount;
-	unsigned int dtmfduration;
-	int nat;
-	unsigned int flags;
-	struct sockaddr_in us;		/*!< Socket representation of the local endpoint. */
-	struct sockaddr_in them;	/*!< Socket representation of the remote endpoint. */
-	struct timeval rxcore;
-	struct timeval txcore;
-	struct timeval dtmfmute;
-	struct ast_smoother *smoother;
-	int *ioid;
-	unsigned short seqno;		/*!< Sequence number, RFC 3550, page 13. */
-	unsigned short rxseqno;
-	struct sched_context *sched;
-	struct io_context *io;
-	void *data;
-	ast_rtp_callback callback;
-	struct rtpPayloadType current_RTP_PT[MAX_RTP_PT];
-	int rtp_lookup_code_cache_isAstFormat; /*!< a cache for the result of rtp_lookup_code(): */
-	int rtp_lookup_code_cache_code;
-	int rtp_lookup_code_cache_result;
-	struct ast_rtcp *rtcp;
-};
 
 /*!
  * \brief Structure defining an RTCP session.
@@ -787,7 +739,7 @@
 	return 1;
 }
 
-/*! \brief  Make a note of a RTP paymoad type that was seen in a SDP "m=" line.
+/*! \brief  Make a note of a RTP payload type that was seen in a SDP "m=" line.
  * By default, use the well-known value for this type (although it may 
  * still be set to a different value by a subsequent "a=rtpmap:" line)
  */
@@ -796,9 +748,8 @@
 	if (pt < 0 || pt > MAX_RTP_PT) 
 		return; /* bogus payload type */
 
-	if (static_RTP_PT[pt].code != 0) {
+	if (static_RTP_PT[pt].code != 0) 
 		rtp->current_RTP_PT[pt] = static_RTP_PT[pt];
-	}
 } 
 
 /*! \brief Make a note of a RTP payload type (with MIME type) that was seen in
@@ -1378,7 +1329,7 @@
 	
 	/* Make sure we have enough space for RTP header */
 	if ((_f->frametype != AST_FRAME_VOICE) && (_f->frametype != AST_FRAME_VIDEO)) {
-		ast_log(LOG_WARNING, "RTP can only send voice\n");
+		ast_log(LOG_WARNING, "RTP can only send voice and video\n");
 		return -1;
 	}
 



More information about the svn-commits mailing list