]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
rtp_engine.h: No sense allowing payload types larger than RFC allows. 03/1003/1
authorRichard Mudgett <rmudgett@digium.com>
Tue, 28 Jul 2015 00:10:11 +0000 (19:10 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 31 Jul 2015 01:34:23 +0000 (20:34 -0500)
* Tweaked add_static_payload() to not use magic numbers.

Change-Id: I1719ff0f6d3ce537a91572501eae5bcd912a420b

include/asterisk/rtp_engine.h
main/rtp_engine.c

index 376fac8dc7d54620fde406a495ed5ff320ae2800..80183ede7f796ffec10672dd0e32dcc02feb6f88 100644 (file)
@@ -78,14 +78,13 @@ extern "C" {
 #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
 
 /*!
index f139dc4545617c4f6316ad2a85103a362f115644..296d84f2c496ea3ee84128bcb47147162e18f019 100644 (file)
@@ -1740,22 +1740,24 @@ static void set_next_mime_type(struct ast_format *format, int rtp_code, const ch
 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) {