diff options
author | Joshua Colp <jcolp@digium.com> | 2008-02-18 23:47:01 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2008-02-18 23:47:01 +0000 |
commit | e54da94808472d0a35b3bd51f07e2f102210b95e (patch) | |
tree | b5f0bd047d53611a89ec0394a3c4efec497c9365 /main | |
parent | 6c3a7a3e516dee84fde9fe8dce2d827a50079574 (diff) |
Add a non-invasive API for application level manipulation of T38 on a channel. This uses control frames (so they can even pass across IAX2) to negotiate T38 and provided a way of getting the current status of T38 using queryoption. This should by no means cause any issues and if it does I will take responsibility for it.
(closes issue #11873)
Reported by: dimas
Patches:
v4-t38-api.patch uploaded by dimas (license 88)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103799 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/channel.c | 27 | ||||
-rw-r--r-- | main/frame.c | 19 |
2 files changed, 35 insertions, 11 deletions
diff --git a/main/channel.c b/main/channel.c index bbfcfdd4a..197cf1e71 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4481,23 +4481,28 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha /*! \brief Sets an option on a channel */ int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int datalen, int block) { - int res; - - if (chan->tech->setoption) { - res = chan->tech->setoption(chan, option, data, datalen); - if (res < 0) - return res; - } else { + if (!chan->tech->setoption) { errno = ENOSYS; return -1; } - if (block) { - /* XXX Implement blocking -- just wait for our option frame reply, discarding - intermediate packets. XXX */ + + if (block) ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); + + return chan->tech->setoption(chan, option, data, datalen); +} + +int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, int *datalen, int block) +{ + if (!chan->tech->queryoption) { + errno = ENOSYS; return -1; } - return 0; + + if (block) + ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); + + return chan->tech->queryoption(chan, option, data, datalen); } struct tonepair_def { diff --git a/main/frame.c b/main/frame.c index ff182cc05..304bd2716 100644 --- a/main/frame.c +++ b/main/frame.c @@ -710,6 +710,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) char cn[60]; char cp[40]; char cmn[40]; + const char *message = "Unknown"; if (!name) name = noname; @@ -786,6 +787,24 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) case AST_CONTROL_UNHOLD: strcpy(subclass, "Unhold"); break; + case AST_CONTROL_T38: + if (f->datalen != sizeof(enum ast_control_t38)) { + message = "Invalid"; + } else { + enum ast_control_t38 state = *((enum ast_control_t38 *) f->data); + if (state == AST_T38_REQUEST_NEGOTIATE) + message = "Negotiation Requested"; + else if (state == AST_T38_REQUEST_TERMINATE) + message = "Negotiation Request Terminated"; + else if (state == AST_T38_NEGOTIATED) + message = "Negotiated"; + else if (state == AST_T38_TERMINATED) + message = "Terminated"; + else if (state == AST_T38_REFUSED) + message = "Refused"; + } + snprintf(subclass, sizeof(subclass), "T38/%s", message); + break; case -1: strcpy(subclass, "Stop generators"); break; |