summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2009-04-09 16:19:35 +0000
committerJoshua Colp <jcolp@digium.com>2009-04-09 16:19:35 +0000
commitabcc0b93976fe5d93143aacd46841aed40f1ff45 (patch)
treeb3515cca315d0a436265cc7f4e6f74b58b471da4 /main/channel.c
parent8f28bfc63e4d64f36fd57ae6a4ef5483bb6e4cd2 (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 'main/channel.c')
-rw-r--r--main/channel.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/main/channel.c b/main/channel.c
index acf3f557b..f3444eac1 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3769,7 +3769,7 @@ done:
static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format,
struct ast_trans_pvt **trans, const int direction)
{
- int native;
+ int native, native_fmt = ast_best_codec(fmt);
int res;
char from[200], to[200];
@@ -3780,7 +3780,19 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
if (!fmt || !native) /* No audio requested */
return 0; /* Let's try a call without any sounds (video, text) */
-
+
+ /* See if the underlying channel driver is capable of performing transcoding for us */
+ if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) {
+ ast_debug(1, "Channel driver natively set channel %s to %s format %s (%d)\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(native_fmt), native_fmt);
+ chan->nativeformats = *rawformat = *format = native_fmt;
+ if (*trans) {
+ ast_translator_free_path(*trans);
+ }
+ *trans = NULL;
+ return 0;
+ }
+
/* Find a translation path from the native format to one of the desired formats */
if (!direction)
/* reading */
@@ -4202,6 +4214,12 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
int src;
int dst;
+ /* See if the channel driver can natively make these two channels compatible */
+ if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
+ !ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) {
+ return 0;
+ }
+
if (from->readformat == to->writeformat && from->writeformat == to->readformat) {
/* Already compatible! Moving on ... */
return 0;