[asterisk-commits] file: branch file/rtp_engine r140653 - in /team/file/rtp_engine: channels/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 2 13:36:39 CDT 2008
Author: file
Date: Tue Sep 2 13:36:39 2008
New Revision: 140653
URL: http://svn.digium.com/view/asterisk?view=rev&rev=140653
Log:
Add some finer grain control over DTMF.
Modified:
team/file/rtp_engine/channels/chan_sip.c
team/file/rtp_engine/include/asterisk/rtp_engine.h
team/file/rtp_engine/main/rtp_engine.c
Modified: team/file/rtp_engine/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/channels/chan_sip.c?view=diff&rev=140653&r1=140652&r2=140653
==============================================================================
--- team/file/rtp_engine/channels/chan_sip.c (original)
+++ team/file/rtp_engine/channels/chan_sip.c Tue Sep 2 13:36:39 2008
@@ -5259,7 +5259,11 @@
sip_pvt_lock(p);
switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
case SIP_DTMF_INBAND:
- res = -1; /* Tell Asterisk to generate inband indications */
+ if (p->rtp && p->rtp->dtmf_mode == AST_RTP_DTMF_MODE_INBAND) {
+ ast_rtp_instance_dtmf_begin(p->rtp, digit);
+ } else {
+ res = -1; /* Tell Asterisk to generate inband indications */
+ }
break;
case SIP_DTMF_RFC2833:
if (p->rtp)
@@ -5291,7 +5295,11 @@
ast_rtp_instance_dtmf_end(p->rtp, digit);
break;
case SIP_DTMF_INBAND:
- res = -1; /* Tell Asterisk to stop inband indications */
+ if (p->rtp && p->rtp->dtmf_mode == AST_RTP_DTMF_MODE_INBAND) {
+ ast_rtp_instance_dtmf_end(p->rtp, digit);
+ } else {
+ res = -1; /* Tell Asterisk to stop inband indications */
+ }
break;
}
sip_pvt_unlock(p);
@@ -5536,10 +5544,16 @@
if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) {
- i->vad = ast_dsp_new();
- ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
- if (global_relaxdtmf)
- ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
+ if (!i->rtp || ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_INBAND)) {
+ i->vad = ast_dsp_new();
+ ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
+ if (global_relaxdtmf)
+ ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
+ }
+ } else if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) {
+ if (i->rtp) {
+ ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_RFC2833);
+ }
}
/* Set file descriptors for audio, video, realtime text and UDPTL as needed */
Modified: team/file/rtp_engine/include/asterisk/rtp_engine.h
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/include/asterisk/rtp_engine.h?view=diff&rev=140653&r1=140652&r2=140653
==============================================================================
--- team/file/rtp_engine/include/asterisk/rtp_engine.h (original)
+++ team/file/rtp_engine/include/asterisk/rtp_engine.h Tue Sep 2 13:36:39 2008
@@ -91,6 +91,16 @@
enum ast_rtp_options {
/*! Remote side is using non-standard G.726 */
AST_RTP_OPT_G726_NONSTANDARD = (1 << 0),
+};
+
+/*! RTP DTMF Modes */
+enum ast_rtp_dtmf_mode {
+ /*! No DTMF is being carried over the RTP stream */
+ AST_RTP_DTMF_MODE_NONE = 0,
+ /*! DTMF is being carried out of band using RFC2833 */
+ AST_RTP_DTMF_MODE_RFC2833,
+ /*! DTMF is being carried inband over the RTP stream */
+ AST_RTP_DTMF_MODE_INBAND,
};
/*! Result codes when RTP glue is queried for information */
@@ -310,6 +320,8 @@
void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
/*! Callback for setting the remote address that RTP is to be sent to */
void (*remote_address_set)(struct ast_rtp_instance *instance, struct sockaddr_in *sin);
+ /*! Callback for changing DTMF mode */
+ int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
/*! Callback for retrieving statistics */
int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
/*! Callback for setting QoS values */
@@ -358,6 +370,8 @@
int holdtimeout;
/*! Send RTP comfort noice packets for keepalive */
int keepalive;
+ /*! DTMF mode in use */
+ enum ast_rtp_dtmf_mode dtmf_mode;
};
/*! Structure that represents the glue that binds an RTP instance to a channel */
@@ -865,6 +879,24 @@
*/
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit);
+/*! \brief Set the DTMF mode that should be used
+ *
+ * \param instance the RTP instance to set DTMF mode on
+ * \param dtmf_mode The DTMF mode that is in use
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833);
+ * \endcode
+ *
+ * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
+ */
+int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
+
/*! \brief Indicate a new source of audio has dropped in
*
* \param instance Instance that the new media source is feeding into
Modified: team/file/rtp_engine/main/rtp_engine.c
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/main/rtp_engine.c?view=diff&rev=140653&r1=140652&r2=140653
==============================================================================
--- team/file/rtp_engine/main/rtp_engine.c (original)
+++ team/file/rtp_engine/main/rtp_engine.c Tue Sep 2 13:36:39 2008
@@ -643,6 +643,17 @@
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
{
return instance->engine->dtmf_end ? instance->engine->dtmf_end(instance, digit) : -1;
+}
+
+int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
+{
+ if (!instance->engine->dtmf_mode_set || instance->engine->dtmf_mode_set(instance, dtmf_mode)) {
+ return -1;
+ }
+
+ instance->dtmf_mode = dtmf_mode;
+
+ return 0;
}
void ast_rtp_instance_new_source(struct ast_rtp_instance *instance)
More information about the asterisk-commits
mailing list