summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/asterisk/rtp_engine.h18
-rw-r--r--main/rtp_engine.c14
-rw-r--r--res/res_rtp_asterisk.c5
3 files changed, 35 insertions, 2 deletions
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index c1b21b6ed..9820e51bc 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -1216,6 +1216,24 @@ void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_fo
* \since 1.8
*/
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code);
+/*!
+ * \brief Search for a payload code in the ast_rtp_codecs structure
+ *
+ * \param codecs Codecs structure to look in
+ * \param code The format to look for
+ *
+ * \retval Numerical payload or -1 if unable to find payload in codecs
+ *
+ * Example usage:
+ *
+ * \code
+ * int payload = ast_rtp_codecs_payload_code(&codecs, 0);
+ * \endcode
+ *
+ * This looks for the numerical payload for ULAW in the codecs structure.
+ *
+ */
+int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int code);
/*!
* \brief Retrieve mime subtype information on a payload
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 4861387e3..90e1abb45 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -762,7 +762,21 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_form
return res;
}
+int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int code)
+{
+ struct ast_rtp_payload_type *type;
+ int res = -1;
+
+ /* Search the payload type in the codecs passed */
+ if ((type = ao2_find(codecs->payloads, &code, OBJ_NOLOCK | OBJ_KEY)))
+ {
+ res = type->payload;
+ ao2_ref(type, -1);
+ return res;
+ }
+ return res;
+}
const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options)
{
int i;
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 0bcd16511..9f3b8b83d 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2790,8 +2790,9 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, unsigned int
}
/* If the payload coming in is not one of the negotiated ones then send it to the core, this will cause formats to change and the bridge to break */
- if ((ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance1), 0, NULL, bridged_payload) == -1) &&
- !ast_rtp_codecs_get_payload_format(ast_rtp_instance_get_codecs(instance1), bridged_payload)) {
+ if (ast_rtp_codecs_find_payload_code(ast_rtp_instance_get_codecs(instance1),bridged_payload) == -1)
+ {
+ ast_debug(1, "Unsupported payload type received \n");
return -1;
}