[asterisk-commits] kmoore: branch group/media_formats-reviewed-trunk r418464 - /team/group/media...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 13 11:36:50 CDT 2014


Author: kmoore
Date: Sun Jul 13 11:36:42 2014
New Revision: 418464

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418464
Log:
media formats: Prevent crash on unset format

This prevents a crash on getting the codec rate for unset formats. This
can be validly unset if the RTP instance has never receieved an audio
RTP frame which can occur in off-nominal situations.

Review: https://reviewboard.asterisk.org/r/3761/

Modified:
    team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c

Modified: team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c?view=diff&rev=418464&r1=418463&r2=418464
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c Sun Jul 13 11:36:42 2014
@@ -2190,6 +2190,10 @@
 	rtp->dtlstimerid = -1;
 #endif
 
+	rtp->f.subclass.format = ao2_bump(ast_format_none);
+	rtp->lastrxformat = ao2_bump(ast_format_none);
+	rtp->lasttxformat = ao2_bump(ast_format_none);
+
 	return 0;
 }
 
@@ -3056,14 +3060,9 @@
 	if (ast_format_cmp(rtp->lasttxformat, format) == AST_FORMAT_CMP_NOT_EQUAL) {
 		/* Oh dear, if the format changed we will have to set up a new smoother */
 		if (option_debug > 0) {
-			if (rtp->lasttxformat) {
-				ast_debug(1, "Ooh, format changed from %s to %s\n",
-					ast_format_get_name(rtp->lasttxformat),
-					ast_format_get_name(frame->subclass.format));
-			} else {
-				ast_debug(1, "Ooh, format is being set to %s\n",
-					ast_format_get_name(frame->subclass.format));
-			}
+			ast_debug(1, "Ooh, format changed from %s to %s\n",
+				ast_format_get_name(rtp->lasttxformat),
+				ast_format_get_name(frame->subclass.format));
 		}
 		ao2_replace(rtp->lasttxformat, format);
 		if (rtp->smoother) {
@@ -3412,10 +3411,10 @@
 		}
 	} else if ((rtp->resp == resp) && !power) {
 		f = create_dtmf_frame(instance, AST_FRAME_DTMF_END, ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_DTMF_COMPENSATE));
-		f->samples = rtp->dtmfsamples * (rtp->lastrxformat ? (rtp_get_rate(rtp->lastrxformat) / 1000) : 8);
+		f->samples = rtp->dtmfsamples * (rtp_get_rate(rtp->lastrxformat) / 1000);
 		rtp->resp = 0;
 	} else if (rtp->resp == resp) {
-		rtp->dtmfsamples += 20 * (rtp->lastrxformat ? (rtp_get_rate(rtp->lastrxformat) / 1000) : 8);
+		rtp->dtmfsamples += 20 * (rtp_get_rate(rtp->lastrxformat) / 1000);
 	}
 
 	rtp->dtmf_timeout = 0;
@@ -3432,7 +3431,7 @@
 	   guaranteed to have it every 20ms or anything */
 	if (rtpdebug) {
 		ast_debug(0, "- RTP 3389 Comfort noise event: Format %s (len = %d)\n",
-			rtp->lastrxformat ? ast_format_get_name(rtp->lastrxformat) : "unknown", len);
+			ast_format_get_name(rtp->lastrxformat), len);
 	}
 
 	if (ast_test_flag(rtp, FLAG_3389_WARNING)) {




More information about the asterisk-commits mailing list