[asterisk-commits] file: trunk r201902 - in /trunk: channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 19 10:41:28 CDT 2009


Author: file
Date: Fri Jun 19 10:41:24 2009
New Revision: 201902

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201902
Log:
Add support for allowing an RTP engine to decide on whether it is possible for specific formats to be transcoded for an RTP instance.

Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/rtp_engine.h
    trunk/main/rtp_engine.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=201902&r1=201901&r2=201902
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jun 19 10:41:24 2009
@@ -5338,7 +5338,7 @@
 		return res;
 	}
 	p->callingpres = ast->cid.cid_pres;
-	p->jointcapability = ast_translate_available_formats(p->capability, p->prefcodec);
+	p->jointcapability = ast_rtp_instance_available_formats(p->rtp, p->capability, p->prefcodec);
 	p->jointnoncodeccapability = p->noncodeccapability;
 
 	/* If there are no audio formats left to offer, punt */

Modified: trunk/include/asterisk/rtp_engine.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/include/asterisk/rtp_engine.h?view=diff&rev=201902&r1=201901&r2=201902
==============================================================================
--- trunk/include/asterisk/rtp_engine.h (original)
+++ trunk/include/asterisk/rtp_engine.h Fri Jun 19 10:41:24 2009
@@ -353,6 +353,8 @@
 	int (*activate)(struct ast_rtp_instance *instance);
 	/*! Callback to request that the RTP engine send a STUN BIND request */
 	void (*stun_request)(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username);
+	/*! Callback to get the transcodeable formats supported */
+	int (*available_formats)(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
 	/*! Linked list information */
 	AST_RWLIST_ENTRY(ast_rtp_engine) entry;
 };
@@ -1497,6 +1499,26 @@
  */
 int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer);
 
+/*! \brief Request the formats that can be transcoded
+ *
+ * \param instance The RTP instance
+ * \param to_endpoint Formats being sent/received towards the endpoint
+ * \param to_asterisk Formats being sent/received towards Asterisk
+ *
+ * \retval supported formats
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_rtp_instance_available_formats(instance, AST_FORMAT_ULAW, AST_FORMAT_SLINEAR);
+ * \endcode
+ *
+ * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
+ *
+ * \since 1.6.3
+ */
+int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
+
 /*!
  * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
  *

Modified: trunk/main/rtp_engine.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/rtp_engine.c?view=diff&rev=201902&r1=201901&r2=201902
==============================================================================
--- trunk/main/rtp_engine.c (original)
+++ trunk/main/rtp_engine.c Fri Jun 19 10:41:24 2009
@@ -37,6 +37,7 @@
 #include "asterisk/options.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/pbx.h"
+#include "asterisk/translate.h"
 
 /*! Structure that represents an RTP session (instance) */
 struct ast_rtp_instance {
@@ -1572,6 +1573,17 @@
 	return res;
 }
 
+int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
+{
+	int formats;
+
+	if (instance->engine->available_formats && (formats = instance->engine->available_formats(instance, to_endpoint, to_asterisk))) {
+		return formats;
+	}
+
+	return ast_translate_available_formats(to_endpoint, to_asterisk);
+}
+
 int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
 {
 	return instance->engine->activate ? instance->engine->activate(instance) : 0;




More information about the asterisk-commits mailing list