[asterisk-commits] rtp engine.h: No sense allowing payload types larger than RF... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 3 08:46:21 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: rtp_engine.h: No sense allowing payload types larger than RFC allows.
......................................................................


rtp_engine.h: No sense allowing payload types larger than RFC allows.

* Tweaked add_static_payload() to not use magic numbers.

Change-Id: I1719ff0f6d3ce537a91572501eae5bcd912a420b
---
M include/asterisk/rtp_engine.h
M main/rtp_engine.c
2 files changed, 15 insertions(+), 14 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index d99852d..d6a9be5 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -78,14 +78,13 @@
 #include "asterisk/stasis.h"
 #include "asterisk/vector.h"
 
-/* Maximum number of payloads supported */
-#if defined(LOW_MEMORY)
+/*! Maximum number of payload types RTP can support. */
 #define AST_RTP_MAX_PT 128
-#else
-#define AST_RTP_MAX_PT 196
-#endif
 
-/* Maximum number of generations */
+/*! First dynamic RTP payload type */
+#define AST_RTP_PT_FIRST_DYNAMIC 96
+
+/*! Maximum number of generations */
 #define AST_RED_MAX_GENERATION 5
 
 /*!
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 069b2fc..6e647d3 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1740,22 +1740,24 @@
 static void add_static_payload(int map, struct ast_format *format, int rtp_code)
 {
 	int x;
+
+	ast_assert(map < ARRAY_LEN(static_RTP_PT));
+
 	ast_rwlock_wrlock(&static_RTP_PT_lock);
 	if (map < 0) {
 		/* find next available dynamic payload slot */
-		for (x = 96; x < 127; x++) {
+		for (x = AST_RTP_PT_FIRST_DYNAMIC; x < AST_RTP_MAX_PT; ++x) {
 			if (!static_RTP_PT[x].asterisk_format && !static_RTP_PT[x].rtp_code) {
 				map = x;
 				break;
 			}
 		}
-	}
-
-	if (map < 0) {
-		ast_log(LOG_WARNING, "No Dynamic RTP mapping available for format %s\n",
-			ast_format_get_name(format));
-		ast_rwlock_unlock(&static_RTP_PT_lock);
-		return;
+		if (map < 0) {
+			ast_log(LOG_WARNING, "No Dynamic RTP mapping available for format %s\n",
+				ast_format_get_name(format));
+			ast_rwlock_unlock(&static_RTP_PT_lock);
+			return;
+		}
 	}
 
 	if (format) {

-- 
To view, visit https://gerrit.asterisk.org/1012
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1719ff0f6d3ce537a91572501eae5bcd912a420b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list