[asterisk-commits] oej: trunk r89698 - in /trunk: ./ channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 27 13:24:18 CST 2007


Author: oej
Date: Tue Nov 27 13:24:17 2007
New Revision: 89698

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89698
Log:
The following patch with updates for trunk. Works much better in trunk.
Also by accident fixed a bad typo by a previous committer, which actually made video calls
not work fully...

Merged revisions 89630 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89630 | oej | 2007-11-27 16:23:17 +0100 (Tis, 27 Nov 2007) | 12 lines

If we get a codec offer using a well-known payload type, but using it for another
codec that we don't know, Asterisk did not remove that codec from the list.

With this patch, we remove the codec from audio and video rtp objects and
deny it ever existed. Thanks to lasse for testing.

(closes issue #11376)
Reported by: lasse
Patches: 
      bug11376.txt uploaded by oej (license 306)
Tested by: lasse

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/include/asterisk/rtp.h
    trunk/main/rtp.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=89698&r1=89697&r2=89698
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Nov 27 13:24:17 2007
@@ -5918,25 +5918,39 @@
 			continue;
 		} else if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) == 2) {
 			/* We have a rtpmap to handle */
-			if (debug)
-				ast_verbose("Found description format %s for ID %d\n", mimeSubtype, codec);
-			found_rtpmap_codecs[last_rtpmap_codec] = codec;
-			last_rtpmap_codec++;
 
 			/* Note: should really look at the 'freq' and '#chans' params too */
 			/* Note: This should all be done in the context of the m= above */
 			if (!strncasecmp(mimeSubtype, "H26", 3) || !strncasecmp(mimeSubtype, "MP4", 3)) {         /* Video */
-				/* Not going to do anything here for the moment, but we will soon */
-				ast_rtp_set_rtpmap_type(newtextrtp, codec, "video", mimeSubtype, 1);
+				if(ast_rtp_set_rtpmap_type(newvideortp, codec, "video", mimeSubtype, 0) != -1) {
+					if (debug)
+						ast_verbose("Found video description format %s for ID %d\n", mimeSubtype, codec);
+					found_rtpmap_codecs[last_rtpmap_codec] = codec;
+					last_rtpmap_codec++;
+				} else {
+					ast_rtp_unset_m_type(newvideortp, codec);
+					if (debug) 
+						ast_verbose("Found unknown media description format %s for ID %d\n", mimeSubtype, codec);
+				}
 			} else if (!strncasecmp(mimeSubtype, "T140",4)) { /* Text */
 				if (p->trtp) {
 					/* ast_verbose("Adding t140 mimeSubtype to textrtp struct\n"); */
 					ast_rtp_set_rtpmap_type(newtextrtp, codec, "text", mimeSubtype, 0);
 				}
 			} else {                                          /* Must be audio?? */
-				ast_rtp_set_rtpmap_type(newaudiortp, codec, "audio", mimeSubtype,
-						ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0);
+				if(ast_rtp_set_rtpmap_type(newaudiortp, codec, "audio", mimeSubtype,
+						ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0) != -1) {
+					if (debug)
+						ast_verbose("Found audio description format %s for ID %d\n", mimeSubtype, codec);
+					found_rtpmap_codecs[last_rtpmap_codec] = codec;
+					last_rtpmap_codec++;
+				} else {
+					ast_rtp_unset_m_type(newaudiortp, codec);
+					if (debug) 
+						ast_verbose("Found unknown media description format %s for ID %d\n", mimeSubtype, codec);
+				}
 			}
+
 		}
 	}
 	

Modified: trunk/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/rtp.h?view=diff&rev=89698&r1=89697&r2=89698
==============================================================================
--- trunk/include/asterisk/rtp.h (original)
+++ trunk/include/asterisk/rtp.h Tue Nov 27 13:24:17 2007
@@ -178,8 +178,14 @@
 /*! \brief Copy payload types between RTP structures */
 void ast_rtp_pt_copy(struct ast_rtp *dest, struct ast_rtp *src);
 
+/*! \brief Activate payload type */
 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
-void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
+
+/*! \brief clear payload type */
+void ast_rtp_unset_m_type(struct ast_rtp* rtp, int pt);
+
+/*! \brief Initiate payload type to a known MIME media type for a codec */
+int ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
 			     char *mimeType, char *mimeSubtype,
 			     enum ast_rtp_options options);
 

Modified: trunk/main/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/main/rtp.c?view=diff&rev=89698&r1=89697&r2=89698
==============================================================================
--- trunk/main/rtp.c (original)
+++ trunk/main/rtp.c Tue Nov 27 13:24:17 2007
@@ -1939,23 +1939,36 @@
 	rtp_bridge_unlock(rtp);
 } 
 
+/*! \brief remove setting from payload type list if the rtpmap header indicates
+    an unknown media type */
+void ast_rtp_unset_m_type(struct ast_rtp* rtp, int pt) 
+{
+	rtp_bridge_lock(rtp);
+	rtp->current_RTP_PT[pt].isAstFormat = 0;
+	rtp->current_RTP_PT[pt].code = 0;
+	rtp_bridge_unlock(rtp);
+}
+
 /*! \brief Make a note of a RTP payload type (with MIME type) that was seen in
  * an SDP "a=rtpmap:" line.
+ * \return 0 if the MIME type was found and set, -1 if it wasn't found
  */
-void ast_rtp_set_rtpmap_type(struct ast_rtp *rtp, int pt,
+int ast_rtp_set_rtpmap_type(struct ast_rtp *rtp, int pt,
 			     char *mimeType, char *mimeSubtype,
 			     enum ast_rtp_options options)
 {
 	unsigned int i;
+	int found = 0;
 
 	if (pt < 0 || pt > MAX_RTP_PT) 
-		return; /* bogus payload type */
+		return -1; /* bogus payload type */
 	
 	rtp_bridge_lock(rtp);
 
 	for (i = 0; i < sizeof(mimeTypes)/sizeof(mimeTypes[0]); ++i) {
 		if (strcasecmp(mimeSubtype, mimeTypes[i].subtype) == 0 &&
 		    strcasecmp(mimeType, mimeTypes[i].type) == 0) {
+			found = 1;
 			rtp->current_RTP_PT[pt] = mimeTypes[i].payloadType;
 			if ((mimeTypes[i].payloadType.code == AST_FORMAT_G726) &&
 			    mimeTypes[i].payloadType.isAstFormat &&
@@ -1967,7 +1980,7 @@
 
 	rtp_bridge_unlock(rtp);
 
-	return;
+	return (found ? 0 : -1);
 } 
 
 /*! \brief Return the union of all of the codecs that were set by rtp_set...() calls 




More information about the asterisk-commits mailing list