mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-06 01:45:11 +00:00
Add support for Digium Phones.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8-digiumphones@357459 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
46
main/file.c
46
main/file.c
@@ -1177,11 +1177,18 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
|
||||
/*!
|
||||
* \brief the core of all waitstream() functions
|
||||
*/
|
||||
static int waitstream_core(struct ast_channel *c, const char *breakon,
|
||||
const char *forward, const char *reverse, int skip_ms,
|
||||
int audiofd, int cmdfd, const char *context)
|
||||
static int waitstream_core(struct ast_channel *c,
|
||||
const char *breakon,
|
||||
const char *forward,
|
||||
const char *reverse,
|
||||
int skip_ms,
|
||||
int audiofd,
|
||||
int cmdfd,
|
||||
const char *context,
|
||||
ast_waitstream_fr_cb cb)
|
||||
{
|
||||
const char *orig_chan_name = NULL;
|
||||
|
||||
int err = 0;
|
||||
|
||||
if (!breakon)
|
||||
@@ -1197,6 +1204,11 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
|
||||
if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM))
|
||||
orig_chan_name = ast_strdupa(c->name);
|
||||
|
||||
if (c->stream && cb) {
|
||||
long ms_len = ast_tellstream(c->stream) / (ast_format_rate(c->stream->fmt->format) / 1000);
|
||||
cb(c, ms_len, AST_WAITSTREAM_CB_START);
|
||||
}
|
||||
|
||||
while (c->stream) {
|
||||
int res;
|
||||
int ms;
|
||||
@@ -1258,6 +1270,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
enum ast_waitstream_fr_cb_values cb_val = 0;
|
||||
res = fr->subclass.integer;
|
||||
if (strchr(forward, res)) {
|
||||
int eoftest;
|
||||
@@ -1268,13 +1281,19 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
|
||||
} else {
|
||||
ungetc(eoftest, c->stream->f);
|
||||
}
|
||||
cb_val = AST_WAITSTREAM_CB_FASTFORWARD;
|
||||
} else if (strchr(reverse, res)) {
|
||||
ast_stream_rewind(c->stream, skip_ms);
|
||||
cb_val = AST_WAITSTREAM_CB_REWIND;
|
||||
} else if (strchr(breakon, res)) {
|
||||
ast_frfree(fr);
|
||||
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if (cb_val && cb) {
|
||||
long ms_len = ast_tellstream(c->stream) / (ast_format_rate(c->stream->fmt->format) / 1000);
|
||||
cb(c, ms_len, cb_val);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AST_FRAME_CONTROL:
|
||||
@@ -1324,21 +1343,32 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
|
||||
return (err || c->_softhangup) ? -1 : 0;
|
||||
}
|
||||
|
||||
int ast_waitstream_fr_w_cb(struct ast_channel *c,
|
||||
const char *breakon,
|
||||
const char *forward,
|
||||
const char *reverse,
|
||||
int ms,
|
||||
ast_waitstream_fr_cb cb)
|
||||
{
|
||||
return waitstream_core(c, breakon, forward, reverse, ms,
|
||||
-1 /* no audiofd */, -1 /* no cmdfd */, NULL /* no context */, cb);
|
||||
}
|
||||
|
||||
int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int ms)
|
||||
{
|
||||
return waitstream_core(c, breakon, forward, reverse, ms,
|
||||
-1 /* no audiofd */, -1 /* no cmdfd */, NULL /* no context */);
|
||||
-1 /* no audiofd */, -1 /* no cmdfd */, NULL /* no context */, NULL /* no callback */);
|
||||
}
|
||||
|
||||
int ast_waitstream(struct ast_channel *c, const char *breakon)
|
||||
{
|
||||
return waitstream_core(c, breakon, NULL, NULL, 0, -1, -1, NULL);
|
||||
return waitstream_core(c, breakon, NULL, NULL, 0, -1, -1, NULL, NULL /* no callback */);
|
||||
}
|
||||
|
||||
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int cmdfd)
|
||||
{
|
||||
return waitstream_core(c, breakon, NULL, NULL, 0,
|
||||
audiofd, cmdfd, NULL /* no context */);
|
||||
audiofd, cmdfd, NULL /* no context */, NULL /* no callback */);
|
||||
}
|
||||
|
||||
int ast_waitstream_exten(struct ast_channel *c, const char *context)
|
||||
@@ -1349,7 +1379,7 @@ int ast_waitstream_exten(struct ast_channel *c, const char *context)
|
||||
if (!context)
|
||||
context = c->context;
|
||||
return waitstream_core(c, NULL, NULL, NULL, 0,
|
||||
-1, -1, context);
|
||||
-1, -1, context, NULL /* no callback */);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user