[asterisk-commits] file: branch group/pimp_my_sip r388472 - in /team/group/pimp_my_sip: channels...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 10 17:57:05 CDT 2013
Author: file
Date: Fri May 10 17:56:55 2013
New Revision: 388472
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388472
Log:
Add inband DTMF detection for inbound media.
Review: https://reviewboard.asterisk.org/r/2527/
Modified:
team/group/pimp_my_sip/channels/chan_gulp.c
team/group/pimp_my_sip/include/asterisk/res_sip_session.h
team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
team/group/pimp_my_sip/res/res_sip_session.c
Modified: team/group/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=388472&r1=388471&r2=388472
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Fri May 10 17:56:55 2013
@@ -53,6 +53,7 @@
#include "asterisk/musiconhold.h"
#include "asterisk/causes.h"
#include "asterisk/taskprocessor.h"
+#include "asterisk/dsp.h"
#include "asterisk/res_sip.h"
#include "asterisk/res_sip_session.h"
@@ -610,6 +611,7 @@
static struct ast_frame *gulp_read(struct ast_channel *ast)
{
struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+ struct ast_sip_session *session = pvt->session;
struct ast_frame *f;
struct ast_sip_session_media *media = NULL;
int rtcp = 0;
@@ -636,14 +638,27 @@
return &ast_null_frame;
}
- f = ast_rtp_instance_read(media->rtp, rtcp);
-
- if (f && f->frametype == AST_FRAME_VOICE) {
- if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
- ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
- ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
- ast_set_read_format(ast, ast_channel_readformat(ast));
- ast_set_write_format(ast, ast_channel_writeformat(ast));
+ if (!(f = ast_rtp_instance_read(media->rtp, rtcp))) {
+ return f;
+ }
+
+ if (f->frametype != AST_FRAME_VOICE) {
+ return f;
+ }
+
+ if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
+ ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
+ ast_set_read_format(ast, ast_channel_readformat(ast));
+ ast_set_write_format(ast, ast_channel_writeformat(ast));
+ }
+
+ if (session->dsp) {
+ f = ast_dsp_process(ast, session->dsp, f);
+
+ if (f && (f->frametype == AST_FRAME_DTMF)) {
+ ast_debug(3, "* Detected inband DTMF '%c' on '%s'\n", f->subclass.integer,
+ ast_channel_name(ast));
}
}
Modified: team/group/pimp_my_sip/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip_session.h?view=diff&rev=388472&r1=388471&r2=388472
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip_session.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip_session.h Fri May 10 17:56:55 2013
@@ -43,6 +43,7 @@
struct pjmedia_sdp_media;
struct pjmedia_sdp_session;
struct ast_rtp_instance;
+struct ast_dsp;
struct ast_sip_session_sdp_handler;
@@ -107,6 +108,8 @@
struct ast_format_cap *req_caps;
/* Codecs overriden by dialplan on an outgoing request */
struct ast_codec_pref override_prefs;
+ /* Optional DSP, used only for inband DTMF detection if configured */
+ struct ast_dsp *dsp;
};
typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata);
Modified: team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_sdp_rtp.c?view=diff&rev=388472&r1=388471&r2=388472
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_sdp_rtp.c (original)
+++ team/group/pimp_my_sip/res/res_sip_sdp_rtp.c Fri May 10 17:56:55 2013
@@ -117,6 +117,10 @@
ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session_media->rtp),
session_media->rtp, &session->endpoint->prefs);
+
+ if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND) {
+ ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
+ }
if (!session->endpoint->ice_support && (ice = ast_rtp_instance_get_ice(session_media->rtp))) {
ice->stop(session_media->rtp);
Modified: team/group/pimp_my_sip/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.c?view=diff&rev=388472&r1=388471&r2=388472
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Fri May 10 17:56:55 2013
@@ -41,6 +41,7 @@
#include "asterisk/taskprocessor.h"
#include "asterisk/causes.h"
#include "asterisk/sdp_srtp.h"
+#include "asterisk/dsp.h"
#define SDP_HANDLER_BUCKETS 11
@@ -928,6 +929,10 @@
ast_party_id_free(&session->id);
ao2_cleanup(session->endpoint);
ast_format_cap_destroy(session->req_caps);
+
+ if (session->dsp) {
+ ast_dsp_free(session->dsp);
+ }
}
static int add_supplements(struct ast_sip_session *session)
@@ -991,6 +996,14 @@
session->endpoint = endpoint;
session->inv_session = inv_session;
session->req_caps = ast_format_cap_alloc_nolock();
+
+ if (endpoint->dtmf == AST_SIP_DTMF_INBAND) {
+ if (!(session->dsp = ast_dsp_new())) {
+ return NULL;
+ }
+
+ ast_dsp_set_features(session->dsp, DSP_FEATURE_DIGIT_DETECT);
+ }
if (add_supplements(session)) {
return NULL;
More information about the asterisk-commits
mailing list