diff options
author | Joshua Colp <jcolp@digium.com> | 2009-04-09 16:19:35 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2009-04-09 16:19:35 +0000 |
commit | abcc0b93976fe5d93143aacd46841aed40f1ff45 (patch) | |
tree | b3515cca315d0a436265cc7f4e6f74b58b471da4 /channels | |
parent | 8f28bfc63e4d64f36fd57ae6a4ef5483bb6e4cd2 (diff) |
Add support for allowing the channel driver to handle transcoding.
This was accomplished using a set of options and the setoption channel callback.
The core calls into the channel driver using these options and the channel driver
either returns success or failure.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187360 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index c3f62d8cd..c255f5edc 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2272,6 +2272,7 @@ 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_begin(struct ast_channel *ast, char digit); static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration); +static int sip_setoption(struct ast_channel *chan, int option, void *data, int datalen); static int sip_queryoption(struct ast_channel *chan, int option, void *data, int *datalen); static const char *sip_get_callid(struct ast_channel *chan); @@ -2680,6 +2681,7 @@ static const struct ast_channel_tech sip_tech = { .early_bridge = ast_rtp_instance_early_bridge, .send_text = sip_sendtext, /* called with chan locked */ .func_channel_read = acf_channel_read, + .setoption = sip_setoption, .queryoption = sip_queryoption, .get_pvt_uniqueid = sip_get_callid, }; @@ -3924,6 +3926,26 @@ static int send_request(struct sip_pvt *p, struct sip_request *req, enum xmittyp return res; } +/*! \brief Set an option on a SIP dialog */ +static int sip_setoption(struct ast_channel *chan, int option, void *data, int datalen) +{ + int res = -1; + struct sip_pvt *p = chan->tech_pvt; + + if (option == AST_OPTION_FORMAT_READ) { + int format = *(int *)data; + res = ast_rtp_instance_set_read_format(p->rtp, format); + } else if (option == AST_OPTION_FORMAT_WRITE) { + int format = *(int *)data; + res = ast_rtp_instance_set_write_format(p->rtp, format); + } else if (option == AST_OPTION_MAKE_COMPATIBLE) { + struct ast_channel *peer = data; + res = ast_rtp_instance_make_compatible(chan, p->rtp, peer); + } + + return res; +} + /*! \brief Query an option on a SIP dialog */ static int sip_queryoption(struct ast_channel *chan, int option, void *data, int *datalen) { |