[asterisk-commits] russell: branch group/vldtmf r39429 - in
/team/group/vldtmf: ./ channels/ inc...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Aug 8 18:05:49 MST 2006
Author: russell
Date: Tue Aug 8 20:05:49 2006
New Revision: 39429
URL: http://svn.digium.com/view/asterisk?rev=39429&view=rev
Log:
- Add dtmf_begin and dtmf_end callbacks to all of the channel drivers
- create ast_senddigit_begin() and ast_senddigit_end
- modify ast_senddigit() to call begin() and end() with a pause in the middle
- modify ast_dtmf_stream() to use ast_senddigit() instead of manually queueing
dtmf frames
Modified:
team/group/vldtmf/app.c
team/group/vldtmf/channel.c
team/group/vldtmf/channels/chan_agent.c
team/group/vldtmf/channels/chan_alsa.c
team/group/vldtmf/channels/chan_features.c
team/group/vldtmf/channels/chan_h323.c
team/group/vldtmf/channels/chan_iax2.c
team/group/vldtmf/channels/chan_jingle.c
team/group/vldtmf/channels/chan_local.c
team/group/vldtmf/channels/chan_mgcp.c
team/group/vldtmf/channels/chan_misdn.c
team/group/vldtmf/channels/chan_oss.c
team/group/vldtmf/channels/chan_phone.c
team/group/vldtmf/channels/chan_sip.c
team/group/vldtmf/channels/chan_skinny.c
team/group/vldtmf/channels/chan_vpb.cc
team/group/vldtmf/channels/chan_zap.c
team/group/vldtmf/include/asterisk/channel.h
team/group/vldtmf/include/asterisk/frame.h
Modified: team/group/vldtmf/app.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/app.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/app.c (original)
+++ team/group/vldtmf/app.c Tue Aug 8 20:05:49 2006
@@ -212,10 +212,6 @@
{
const char *ptr;
int res = 0;
- struct ast_frame f = {
- .frametype = AST_FRAME_DTMF,
- .src = "ast_dtmf_stream"
- };
if (!between)
between = 100;
@@ -240,11 +236,8 @@
if (*ptr == 'f' || *ptr == 'F') {
/* ignore return values if not supported by channel */
ast_indicate(chan, AST_CONTROL_FLASH);
- } else {
- f.subclass = *ptr;
- if ((res = ast_write(chan, &f)))
- break;
- }
+ } else
+ ast_senddigit(chan, *ptr);
/* pause between digits */
if ((res = ast_safe_sleep(chan, between)))
break;
Modified: team/group/vldtmf/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channel.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channel.c (original)
+++ team/group/vldtmf/channel.c Tue Aug 8 20:05:49 2006
@@ -241,7 +241,8 @@
" Indication: %s\n"
" Transfer : %s\n"
" Capabilities: %d\n"
- " Send Digit: %s\n"
+ " Digit Begin: %s\n"
+ " Digit End: %s\n"
" Send HTML : %s\n"
" Image Support: %s\n"
" Text Support: %s\n",
@@ -250,7 +251,8 @@
(cl->tech->indicate) ? "yes" : "no",
(cl->tech->transfer) ? "yes" : "no",
(cl->tech->capabilities) ? cl->tech->capabilities : -1,
- (cl->tech->send_digit) ? "yes" : "no",
+ (cl->tech->send_digit_begin) ? "yes" : "no",
+ (cl->tech->send_digit_end) ? "yes" : "no",
(cl->tech->send_html) ? "yes" : "no",
(cl->tech->send_image) ? "yes" : "no",
(cl->tech->send_text) ? "yes" : "no"
@@ -2266,12 +2268,13 @@
return res;
}
-static int do_senddigit(struct ast_channel *chan, char digit)
+int ast_senddigit_begin(struct ast_channel *chan, char digit)
{
int res = -1;
- if (chan->tech->send_digit)
- res = chan->tech->send_digit(chan, digit);
+ if (chan->tech->send_digit_begin)
+ res = chan->tech->send_digit_begin(chan, digit);
+
if (res) {
/*
* Device does not support DTMF tones, lets fake
@@ -2307,12 +2310,30 @@
ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
+
return 0;
}
+int ast_senddigit_end(struct ast_channel *chan, char digit)
+{
+ int res = -1;
+
+ if (chan->tech->send_digit_end)
+ res = chan->tech->send_digit_end(chan, digit);
+
+ if (res && chan->generator)
+ ast_playtones_stop(chan);
+
+ return 0;
+}
+
int ast_senddigit(struct ast_channel *chan, char digit)
{
- return do_senddigit(chan, digit);
+ ast_senddigit_begin(chan, digit);
+
+ ast_safe_sleep(chan, 100); /* XXX 100ms ... probably should be configurable */
+
+ return ast_senddigit_end(chan, digit);
}
int ast_prod(struct ast_channel *chan)
@@ -2380,19 +2401,16 @@
chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
- res = (chan->tech->send_digit_begin == NULL) ? 0 :
- chan->tech->send_digit_begin(chan, fr->subclass);
+ ast_clear_flag(chan, AST_FLAG_BLOCKING);
+ ast_channel_unlock(chan);
+ res = ast_senddigit_begin(chan, fr->subclass);
+ ast_channel_lock(chan);
+ CHECK_BLOCKING(chan);
break;
case AST_FRAME_DTMF_END:
- /* XXX Change this once send_digit_end callbacks are implemented */
-#if 0
- res = (chan->tech->send_digit_end == NULL) ? 0 :
- chan->tech->send_digit_end(chan);
- break;
-#endif
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = do_senddigit(chan,fr->subclass);
+ res = ast_senddigit_end(chan, fr->subclass);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
Modified: team/group/vldtmf/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_agent.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_agent.c (original)
+++ team/group/vldtmf/channels/chan_agent.c Tue Aug 8 20:05:49 2006
@@ -237,7 +237,8 @@
static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause);
static int agent_devicestate(void *data);
static void agent_logoff_maintenance(struct agent_pvt *p, char *loginchan, long logintime, const char *uniqueid, char *logcommand);
-static int agent_digit(struct ast_channel *ast, char digit);
+static int agent_digit_begin(struct ast_channel *ast, char digit);
+static int agent_digit_end(struct ast_channel *ast, char digit);
static int agent_call(struct ast_channel *ast, char *dest, int timeout);
static int agent_hangup(struct ast_channel *ast);
static int agent_answer(struct ast_channel *ast);
@@ -257,7 +258,8 @@
.capabilities = -1,
.requester = agent_request,
.devicestate = agent_devicestate,
- .send_digit = agent_digit,
+ .send_digit_begin = agent_digit_begin,
+ .send_digit_end = agent_digit_end,
.call = agent_call,
.hangup = agent_hangup,
.answer = agent_answer,
@@ -602,15 +604,22 @@
return res;
}
-static int agent_digit(struct ast_channel *ast, char digit)
+static int agent_digit_begin(struct ast_channel *ast, char digit)
{
struct agent_pvt *p = ast->tech_pvt;
int res = -1;
ast_mutex_lock(&p->lock);
- if (p->chan)
- res = p->chan->tech->send_digit(p->chan, digit);
- else
- res = 0;
+ ast_senddigit_begin(p->chan, digit);
+ ast_mutex_unlock(&p->lock);
+ return res;
+}
+
+static int agent_digit_end(struct ast_channel *ast, char digit)
+{
+ struct agent_pvt *p = ast->tech_pvt;
+ int res = -1;
+ ast_mutex_lock(&p->lock);
+ ast_senddigit_end(p->chan, digit);
ast_mutex_unlock(&p->lock);
return res;
}
Modified: team/group/vldtmf/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_alsa.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_alsa.c (original)
+++ team/group/vldtmf/channels/chan_alsa.c Tue Aug 8 20:05:49 2006
@@ -204,7 +204,7 @@
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR,
.requester = alsa_request,
- .send_digit = alsa_digit,
+ .send_digit_end = alsa_digit,
.send_text = alsa_text,
.hangup = alsa_hangup,
.answer = alsa_answer,
Modified: team/group/vldtmf/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_features.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_features.c (original)
+++ team/group/vldtmf/channels/chan_features.c Tue Aug 8 20:05:49 2006
@@ -95,7 +95,8 @@
#define SUB_THREEWAY 2 /* Three-way call */
static struct ast_channel *features_request(const char *type, int format, void *data, int *cause);
-static int features_digit(struct ast_channel *ast, char digit);
+static int features_digit_begin(struct ast_channel *ast, char digit);
+static int features_digit_end(struct ast_channel *ast, char digit);
static int features_call(struct ast_channel *ast, char *dest, int timeout);
static int features_hangup(struct ast_channel *ast);
static int features_answer(struct ast_channel *ast);
@@ -109,7 +110,8 @@
.description = tdesc,
.capabilities = -1,
.requester = features_request,
- .send_digit = features_digit,
+ .send_digit_begin = features_digit_begin,
+ .send_digit_end = features_digit_end,
.call = features_call,
.hangup = features_hangup,
.answer = features_answer,
@@ -300,7 +302,7 @@
return res;
}
-static int features_digit(struct ast_channel *ast, char digit)
+static int features_digit_begin(struct ast_channel *ast, char digit)
{
struct feature_pvt *p = ast->tech_pvt;
int res = -1;
@@ -310,7 +312,23 @@
ast_mutex_lock(&p->lock);
x = indexof(p, ast, 0);
if (!x && p->subchan)
- res = ast_senddigit(p->subchan, digit);
+ res = ast_senddigit_begin(p->subchan, digit);
+ ast_mutex_unlock(&p->lock);
+
+ return res;
+}
+
+static int features_digit_end(struct ast_channel *ast, char digit)
+{
+ struct feature_pvt *p = ast->tech_pvt;
+ int res = -1;
+ int x;
+
+ /* Queue up a frame representing the indication as a control frame */
+ ast_mutex_lock(&p->lock);
+ x = indexof(p, ast, 0);
+ if (!x && p->subchan)
+ res = ast_senddigit_end(p->subchan, digit);
ast_mutex_unlock(&p->lock);
return res;
}
Modified: team/group/vldtmf/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_h323.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_h323.c (original)
+++ team/group/vldtmf/channels/chan_h323.c Tue Aug 8 20:05:49 2006
@@ -220,7 +220,8 @@
static int h323_do_reload(void);
static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause);
-static int oh323_digit(struct ast_channel *c, char digit);
+static int oh323_digit_begin(struct ast_channel *c, char digit);
+static int oh323_digit_end(struct ast_channel *c, char digit);
static int oh323_call(struct ast_channel *c, char *dest, int timeout);
static int oh323_hangup(struct ast_channel *c);
static int oh323_answer(struct ast_channel *c);
@@ -235,7 +236,8 @@
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
.requester = oh323_request,
- .send_digit = oh323_digit,
+ .send_digit_begin = oh323_digit_begin,
+ .send_digit_end = oh323_digit_end,
.call = oh323_call,
.hangup = oh323_hangup,
.answer = oh323_answer,
@@ -370,11 +372,17 @@
ast_mutex_unlock(&iflock);
}
+static int oh323_digit_begin(struct ast_channel *chan, char digit)
+{
+ /* XXX Implement me, plz, kthx */
+ return 0;
+}
+
/**
* Send (play) the specified digit to the channel.
*
*/
-static int oh323_digit(struct ast_channel *c, char digit)
+static int oh323_digit_end(struct ast_channel *c, char digit)
{
struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
char *token;
Modified: team/group/vldtmf/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_iax2.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_iax2.c (original)
+++ team/group/vldtmf/channels/chan_iax2.c Tue Aug 8 20:05:49 2006
@@ -776,7 +776,8 @@
static int iax2_answer(struct ast_channel *c);
static int iax2_call(struct ast_channel *c, char *dest, int timeout);
static int iax2_devicestate(void *data);
-static int iax2_digit(struct ast_channel *c, char digit);
+static int iax2_digit_begin(struct ast_channel *c, char digit);
+static int iax2_digit_end(struct ast_channel *c, char digit);
static int iax2_do_register(struct iax2_registry *reg);
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan);
static int iax2_hangup(struct ast_channel *c);
@@ -809,7 +810,8 @@
.properties = AST_CHAN_TP_WANTSJITTER,
.requester = iax2_request,
.devicestate = iax2_devicestate,
- .send_digit = iax2_digit,
+ .send_digit_begin = iax2_digit_begin,
+ .send_digit_end = iax2_digit_end,
.send_text = iax2_sendtext,
.send_image = iax2_sendimage,
.send_html = iax2_sendhtml,
@@ -2395,9 +2397,14 @@
-static int iax2_digit(struct ast_channel *c, char digit)
-{
- return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
+static int iax2_digit_begin(struct ast_channel *c, char digit)
+{
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF_BEGIN, digit, 0, NULL, 0, -1);
+}
+
+static int iax2_digit_end(struct ast_channel *c, char digit)
+{
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF_END, digit, 0, NULL, 0, -1);
}
static int iax2_sendtext(struct ast_channel *c, const char *text)
Modified: team/group/vldtmf/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_jingle.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_jingle.c (original)
+++ team/group/vldtmf/channels/chan_jingle.c Tue Aug 8 20:05:49 2006
@@ -172,7 +172,8 @@
/* Forward declarations */
static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause);
-static int jingle_digit(struct ast_channel *ast, char digit);
+static int jingle_digit_begin(struct ast_channel *ast, char digit);
+static int jingle_digit_end(struct ast_channel *ast, char digit);
static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
static int jingle_hangup(struct ast_channel *ast);
static int jingle_answer(struct ast_channel *ast);
@@ -195,7 +196,8 @@
.description = tdesc,
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
.requester = jingle_request,
- .send_digit = jingle_digit,
+ .send_digit_begin = jingle_digit_begin,
+ .send_digit_end = jingle_digit_end,
.bridge = ast_rtp_bridge,
.call = jingle_call,
.hangup = jingle_hangup,
@@ -1180,7 +1182,13 @@
return res;
}
-static int jingle_digit(struct ast_channel *ast, char digit)
+static int jingle_digit_begin(struct ast_channel *chan, char digit)
+{
+ /* XXX Does jingle have a concept of the length of a dtmf digit ? */
+ return 0;
+}
+
+static int jingle_digit_end(struct ast_channel *ast, char digit)
{
struct jingle_pvt *p = ast->tech_pvt;
struct jingle *client = p->parent;
Modified: team/group/vldtmf/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_local.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_local.c (original)
+++ team/group/vldtmf/channels/chan_local.c Tue Aug 8 20:05:49 2006
@@ -67,7 +67,8 @@
#define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
static struct ast_channel *local_request(const char *type, int format, void *data, int *cause);
-static int local_digit(struct ast_channel *ast, char digit);
+static int local_digit_begin(struct ast_channel *ast, char digit);
+static int local_digit_end(struct ast_channel *ast, char digit);
static int local_call(struct ast_channel *ast, char *dest, int timeout);
static int local_hangup(struct ast_channel *ast);
static int local_answer(struct ast_channel *ast);
@@ -85,7 +86,8 @@
.description = tdesc,
.capabilities = -1,
.requester = local_request,
- .send_digit = local_digit,
+ .send_digit_begin = local_digit_begin,
+ .send_digit_end = local_digit_end,
.call = local_call,
.hangup = local_hangup,
.answer = local_answer,
@@ -325,11 +327,11 @@
return res;
}
-static int local_digit(struct ast_channel *ast, char digit)
+static int local_digit_begin(struct ast_channel *ast, char digit)
{
struct local_pvt *p = ast->tech_pvt;
int res = -1;
- struct ast_frame f = { AST_FRAME_DTMF, };
+ struct ast_frame f = { AST_FRAME_DTMF_BEGIN, };
int isoutbound;
ast_mutex_lock(&p->lock);
@@ -337,6 +339,23 @@
f.subclass = digit;
res = local_queue_frame(p, isoutbound, &f, ast);
ast_mutex_unlock(&p->lock);
+
+ return res;
+}
+
+static int local_digit_end(struct ast_channel *ast, char digit)
+{
+ struct local_pvt *p = ast->tech_pvt;
+ int res = -1;
+ struct ast_frame f = { AST_FRAME_DTMF_END, };
+ int isoutbound;
+
+ ast_mutex_lock(&p->lock);
+ isoutbound = IS_OUTBOUND(ast, p);
+ f.subclass = digit;
+ res = local_queue_frame(p, isoutbound, &f, ast);
+ ast_mutex_unlock(&p->lock);
+
return res;
}
Modified: team/group/vldtmf/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_mgcp.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_mgcp.c (original)
+++ team/group/vldtmf/channels/chan_mgcp.c Tue Aug 8 20:05:49 2006
@@ -427,7 +427,8 @@
static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame);
static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen);
static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int mgcp_senddigit(struct ast_channel *ast, char digit);
+static int mgcp_senddigit_begin(struct ast_channel *ast, char digit);
+static int mgcp_senddigit_end(struct ast_channel *ast, char digit);
static int mgcp_devicestate(void *data);
static const struct ast_channel_tech mgcp_tech = {
@@ -444,7 +445,8 @@
.write = mgcp_write,
.indicate = mgcp_indicate,
.fixup = mgcp_fixup,
- .send_digit = mgcp_senddigit,
+ .send_digit_begin = mgcp_senddigit_begin,
+ .send_digit_end = mgcp_senddigit_end,
.bridge = ast_rtp_bridge,
};
@@ -1224,7 +1226,13 @@
return 0;
}
-static int mgcp_senddigit(struct ast_channel *ast, char digit)
+static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
+{
+ /* Let asterisk play inband indications */
+ return -1;
+}
+
+static int mgcp_senddigit_end(struct ast_channel *ast, char digit)
{
struct mgcp_subchannel *sub = ast->tech_pvt;
char tmp[4];
@@ -1236,7 +1244,7 @@
ast_mutex_lock(&sub->lock);
transmit_notify_request(sub, tmp);
ast_mutex_unlock(&sub->lock);
- return -1;
+ return -1; /* Return non-zero so that Asterisk will stop the inband indications */
}
/*!
Modified: team/group/vldtmf/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_misdn.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_misdn.c (original)
+++ team/group/vldtmf/channels/chan_misdn.c Tue Aug 8 20:05:49 2006
@@ -2102,7 +2102,13 @@
return 0;
}
-static int misdn_digit(struct ast_channel *ast, char digit )
+static int misdn_digit_begin(struct ast_channel *chan, char digit)
+{
+ /* XXX Modify this callback to support Asterisk controlling the length of DTMF */
+ return 0;
+}
+
+static int misdn_digit_end(struct ast_channel *ast, char digit )
{
struct chan_list *p;
@@ -3079,7 +3085,8 @@
.description="Channel driver for mISDN Support (Bri/Pri)",
.capabilities= AST_FORMAT_ALAW ,
.requester=misdn_request,
- .send_digit=misdn_digit,
+ .send_digit_begin=misdn_digit_begin,
+ .send_digit_end=misdn_digit_end,
.call=misdn_call,
.bridge=misdn_bridge,
.hangup=misdn_hangup,
@@ -3097,7 +3104,8 @@
.description="Channel driver for mISDN Support (Bri/Pri)",
.capabilities=AST_FORMAT_ALAW ,
.requester=misdn_request,
- .send_digit=misdn_digit,
+ .send_digit_begin=misdn_digit_begin,
+ .send_digit_end=misdn_digit_end,
.call=misdn_call,
.hangup=misdn_hangup,
.answer=misdn_answer,
Modified: team/group/vldtmf/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_oss.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_oss.c (original)
+++ team/group/vldtmf/channels/chan_oss.c Tue Aug 8 20:05:49 2006
@@ -407,7 +407,8 @@
static struct ast_channel *oss_request(const char *type, int format, void *data
, int *cause);
-static int oss_digit(struct ast_channel *c, char digit);
+static int oss_digit_begin(struct ast_channel *c, char digit);
+static int oss_digit_end(struct ast_channel *c, char digit);
static int oss_text(struct ast_channel *c, const char *text);
static int oss_hangup(struct ast_channel *c);
static int oss_answer(struct ast_channel *c);
@@ -423,7 +424,8 @@
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR,
.requester = oss_request,
- .send_digit = oss_digit,
+ .send_digit_begin = oss_digit_begin,
+ .send_digit_end = oss_digit_end,
.send_text = oss_text,
.hangup = oss_hangup,
.answer = oss_answer,
@@ -757,7 +759,12 @@
/*
* some of the standard methods supported by channels.
*/
-static int oss_digit(struct ast_channel *c, char digit)
+static int oss_digit_begin(struct ast_channel *c, char digit)
+{
+ return 0;
+}
+
+static int oss_digit_end(struct ast_channel *c, char digit)
{
/* no better use for received digits than print them */
ast_verbose( " << Console Received digit %c >> \n", digit);
Modified: team/group/vldtmf/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_phone.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_phone.c (original)
+++ team/group/vldtmf/channels/chan_phone.c Tue Aug 8 20:05:49 2006
@@ -162,7 +162,8 @@
static char cid_name[AST_MAX_EXTENSION];
static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause);
-static int phone_digit(struct ast_channel *ast, char digit);
+static int phone_digit_begin(struct ast_channel *ast, char digit);
+static int phone_digit_end(struct ast_channel *ast, char digit);
static int phone_call(struct ast_channel *ast, char *dest, int timeout);
static int phone_hangup(struct ast_channel *ast);
static int phone_answer(struct ast_channel *ast);
@@ -178,7 +179,8 @@
.description = tdesc,
.capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
.requester = phone_request,
- .send_digit = phone_digit,
+ .send_digit_begin = phone_digit_begin,
+ .send_digit_end = phone_digit_end,
.call = phone_call,
.hangup = phone_hangup,
.answer = phone_answer,
@@ -193,7 +195,8 @@
.type = "Phone",
.description = tdesc,
.requester = phone_request,
- .send_digit = phone_digit,
+ .send_digit_begin = phone_digit_begin,
+ .send_digit_end = phone_digit_end,
.call = phone_call,
.hangup = phone_hangup,
.answer = phone_answer,
@@ -241,7 +244,13 @@
return 0;
}
-static int phone_digit(struct ast_channel *ast, char digit)
+static int phone_digit_begin(struct ast_channel *chan, char digit)
+{
+ /* XXX Modify this callback to let Asterisk support controlling the length of DTMF */
+ return 0;
+}
+
+static int phone_digit_end(struct ast_channel *ast, char digit)
{
struct phone_pvt *p;
int outdigit;
@@ -330,7 +339,7 @@
{
digit++;
while (*digit)
- phone_digit(ast, *digit++);
+ phone_digit_end(ast, *digit++);
}
}
Modified: team/group/vldtmf/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_sip.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_sip.c (original)
+++ team/group/vldtmf/channels/chan_sip.c Tue Aug 8 20:05:49 2006
@@ -1157,7 +1157,8 @@
static int sip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
static int sip_transfer(struct ast_channel *ast, const char *dest);
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int sip_senddigit(struct ast_channel *ast, char digit);
+static int sip_senddigit_begin(struct ast_channel *ast, char digit);
+static int sip_senddigit_end(struct ast_channel *ast, char digit);
/*--- Transmitting responses and requests */
static int sipsock_read(int *id, int fd, short events, void *ignore);
@@ -1508,7 +1509,8 @@
.indicate = sip_indicate,
.transfer = sip_transfer,
.fixup = sip_fixup,
- .send_digit = sip_senddigit,
+ .send_digit_begin = sip_senddigit_begin,
+ .send_digit_end = sip_senddigit_end,
.bridge = ast_rtp_bridge,
.send_text = sip_sendtext,
};
@@ -3430,9 +3432,29 @@
return ret;
}
+static int sip_senddigit_begin(struct ast_channel *ast, char digit)
+{
+ struct sip_pvt *p = ast->tech_pvt;
+ int res = 0;
+
+ /* XXX Implement me, plz, kthx */
+
+ ast_mutex_lock(&p->lock);
+ switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
+ case SIP_DTMF_INBAND:
+ res = -1; /* Tell Asterisk to generate inband indications */
+ break;
+ default:
+ break;
+ }
+ ast_mutex_unlock(&p->lock);
+
+ return res;
+}
+
/*! \brief Send DTMF character on SIP channel
within one call, we're able to transmit in many methods simultaneously */
-static int sip_senddigit(struct ast_channel *ast, char digit)
+static int sip_senddigit_end(struct ast_channel *ast, char digit)
{
struct sip_pvt *p = ast->tech_pvt;
int res = 0;
@@ -3447,10 +3469,11 @@
ast_rtp_senddigit(p->rtp, digit);
break;
case SIP_DTMF_INBAND:
- res = -1;
+ res = -1; /* Tell Asterisk to stop inband indications */
break;
}
ast_mutex_unlock(&p->lock);
+
return res;
}
Modified: team/group/vldtmf/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_skinny.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_skinny.c (original)
+++ team/group/vldtmf/channels/chan_skinny.c Tue Aug 8 20:05:49 2006
@@ -1006,7 +1006,8 @@
static int skinny_write(struct ast_channel *ast, struct ast_frame *frame);
static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen);
static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int skinny_senddigit(struct ast_channel *ast, char digit);
+static int skinny_senddigit_begin(struct ast_channel *ast, char digit);
+static int skinny_senddigit_end(struct ast_channel *ast, char digit);
static const struct ast_channel_tech skinny_tech = {
.type = "Skinny",
@@ -1021,7 +1022,8 @@
.write = skinny_write,
.indicate = skinny_indicate,
.fixup = skinny_fixup,
- .send_digit = skinny_senddigit,
+ .send_digit_begin = skinny_senddigit_begin,
+ .send_digit_end = skinny_senddigit_end,
/* .bridge = ast_rtp_bridge, */
};
@@ -2387,7 +2389,12 @@
return 0;
}
-static int skinny_senddigit(struct ast_channel *ast, char digit)
+static int skinny_senddigit_begin(struct ast_channel *ast, char digit)
+{
+ return -1; /* Start inband indications */
+}
+
+static int skinny_senddigit_end(struct ast_channel *ast, char digit)
{
#if 0
struct skinny_subchannel *sub = ast->tech_pvt;
@@ -2398,7 +2405,7 @@
sprintf(tmp, "%d", digit);
transmit_tone(d->session, digit);
#endif
- return -1;
+ return -1; /* Stop inband indications */
}
static char *control2str(int ind) {
Modified: team/group/vldtmf/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_vpb.cc?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_vpb.cc (original)
+++ team/group/vldtmf/channels/chan_vpb.cc Tue Aug 8 20:05:49 2006
@@ -341,9 +341,9 @@
static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context);
static void *do_chanreads(void *pvt);
-
static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause);
-static int vpb_digit(struct ast_channel *ast, char digit);
+static int vpb_digit_begin(struct ast_channel *ast, char digit);
+static int vpb_digit_end(struct ast_channel *ast, char digit);
static int vpb_call(struct ast_channel *ast, char *dest, int timeout);
static int vpb_hangup(struct ast_channel *ast);
static int vpb_answer(struct ast_channel *ast);
@@ -360,9 +360,8 @@
properties: 0,
requester: vpb_request,
devicestate: NULL,
- send_digit: vpb_digit,
- send_digit_begin: NULL,
- send_digit_end: NULL,
+ send_digit_begin: vpb_digit_begin,
+ send_digit_end: vpb_digit_end,
call: vpb_call,
hangup: vpb_hangup,
answer: vpb_answer,
@@ -389,9 +388,8 @@
properties: 0,
requester: vpb_request,
devicestate: NULL,
- send_digit: vpb_digit,
- send_digit_begin: NULL,
- send_digit_end: NULL,
+ send_digit_begin: vpb_digit_begin,
+ send_digit_end: vpb_digit_end,
call: vpb_call,
hangup: vpb_hangup,
answer: vpb_answer,
@@ -863,11 +861,11 @@
vpb_timer_stop(p->ring_timer);
vpb_timer_start(p->ring_timer);
} else
- f.frametype = -1; /* ignore ring on station port. */
+ f.frametype = AST_FRAME_NULL; /* ignore ring on station port. */
break;
case VPB_RING_OFF:
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
break;
case VPB_TIMEREXP:
@@ -876,12 +874,12 @@
p->state = VPB_STATE_PLAYBUSY;
vpb_timer_stop(p->busy_timer);
vpb_timer_start(p->busy_timer);
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
} else if (e->data == p->ringback_timer_id) {
playtone(p->handle, &Ringbacktone);
vpb_timer_stop(p->ringback_timer);
vpb_timer_start(p->ringback_timer);
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
} else if (e->data == p->ring_timer_id) {
/* We didnt get another ring in time! */
if (p->owner->_state != AST_STATE_UP) {
@@ -890,23 +888,23 @@
f.subclass = AST_CONTROL_HANGUP;
} else {
vpb_timer_stop(p->ring_timer);
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
}
} else {
- f.frametype = -1; /* Ignore. */
+ f.frametype = AST_FRAME_NULL; /* Ignore. */
}
break;
case VPB_DTMF_DOWN:
case VPB_DTMF:
if (use_ast_dtmfdet){
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
} else if (p->owner->_state == AST_STATE_UP) {
f.frametype = AST_FRAME_DTMF;
f.subclass = e->data;
} else
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
break;
case VPB_TONEDETECT:
@@ -950,11 +948,11 @@
f.subclass = AST_CONTROL_HANGUP;
} else {
p->lastgrunt = ast_tvnow();
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
}
}
else {
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
}
break;
@@ -970,7 +968,7 @@
f.subclass = AST_CONTROL_HANGUP;
#else
ast_log(LOG_NOTICE,"%s: Got call progress callback but blind dialing \n", p->dev);
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
#endif
break;
@@ -983,14 +981,14 @@
if (p->owner->_state == AST_STATE_UP)
f.subclass = AST_CONTROL_HANGUP;
else
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
}
break;
case VPB_LOOP_ONHOOK:
if (p->owner->_state == AST_STATE_UP)
f.subclass = AST_CONTROL_HANGUP;
else
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
break;
case VPB_STATION_ONHOOK:
f.subclass = AST_CONTROL_HANGUP;
@@ -1009,22 +1007,22 @@
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "%s: Dialend\n", p->dev);
} else {
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
}
break;
case VPB_PLAY_UNDERFLOW:
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
vpb_reset_play_fifo_alarm(p->handle);
break;
case VPB_RECORD_OVERFLOW:
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
vpb_reset_record_fifo_alarm(p->handle);
break;
default:
- f.frametype = -1;
+ f.frametype = AST_FRAME_NULL;
break;
}
@@ -1831,7 +1829,12 @@
return 0;
}
-static int vpb_digit(struct ast_channel *ast, char digit)
+static int vpb_digit_begin(struct ast_channel *ast, char digit)
+{
+ /* XXX Modify this callback to let Asterisk control the length of DTMF */
+ return 0;
+}
+static int vpb_digit_end(struct ast_channel *ast, char digit)
{
struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
char s[2];
Modified: team/group/vldtmf/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_zap.c?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_zap.c (original)
+++ team/group/vldtmf/channels/chan_zap.c Tue Aug 8 20:05:49 2006
@@ -693,7 +693,8 @@
} *iflist = NULL, *ifend = NULL;
static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
-static int zt_digit(struct ast_channel *ast, char digit);
+static int zt_digit_begin(struct ast_channel *ast, char digit);
+static int zt_digit_end(struct ast_channel *ast, char digit);
static int zt_sendtext(struct ast_channel *c, const char *text);
static int zt_call(struct ast_channel *ast, char *rdest, int timeout);
static int zt_hangup(struct ast_channel *ast);
@@ -711,7 +712,8 @@
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
.requester = zt_request,
- .send_digit = zt_digit,
+ .send_digit_begin = zt_digit_begin,
+ .send_digit_end = zt_digit_end,
.send_text = zt_sendtext,
.call = zt_call,
.hangup = zt_hangup,
@@ -1002,7 +1004,12 @@
return 0;
}
-static int zt_digit(struct ast_channel *ast, char digit)
+static int zt_digit_begin(struct ast_channel *ast, char digit)
+{
+ /* XXX Implement me, plz, kthx */
+ return 0;
+}
+static int zt_digit_end(struct ast_channel *ast, char digit)
{
ZT_DIAL_OPERATION zo;
struct zt_pvt *p;
Modified: team/group/vldtmf/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/include/asterisk/channel.h?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/include/asterisk/channel.h (original)
+++ team/group/vldtmf/include/asterisk/channel.h Tue Aug 8 20:05:49 2006
@@ -200,13 +200,11 @@
int (* const devicestate)(void *data); /*!< Devicestate call back */
- int (* const send_digit)(struct ast_channel *chan, char digit); /*!< Send a literal DTMF digit */
-
/*! \brief Start sending a literal DTMF digit */
int (* const send_digit_begin)(struct ast_channel *chan, char digit);
- /*! \brief Stop sending the last literal DTMF digit */
- int (* const send_digit_end)(struct ast_channel *chan);
+ /*! \brief Stop sending a literal DTMF digit */
+ int (* const send_digit_end)(struct ast_channel *chan, char digit);
/*! \brief Call a given phone number (address, etc), but don't
take longer than timeout seconds to do so. */
@@ -851,6 +849,9 @@
*/
int ast_senddigit(struct ast_channel *chan, char digit);
+int ast_senddigit_begin(struct ast_channel *chan, char digit);
+int ast_senddigit_end(struct ast_channel *chan, char digit);
+
/*! \brief Receives a text string from a channel
* Read a string of text from a channel
* \param chan channel to act upon
Modified: team/group/vldtmf/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/include/asterisk/frame.h?rev=39429&r1=39428&r2=39429&view=diff
==============================================================================
--- team/group/vldtmf/include/asterisk/frame.h (original)
+++ team/group/vldtmf/include/asterisk/frame.h Tue Aug 8 20:05:49 2006
@@ -84,7 +84,12 @@
*/
-/*! Frame types */
+/*!
+ * \brief Frame types
+ *
+ * \note It is important that the values of each frame type are never changed,
+ * because it will break backwards compatability with older versions.
+ */
enum ast_frame_type {
/*! DTMF end event, subclass is the digit */
AST_FRAME_DTMF_END = 1,
More information about the asterisk-commits
mailing list