[svn-commits] branch oej/codecnegotiation r17779 - in
/team/oej/codecnegotiation: apps/ cha...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Thu Apr 6 01:43:24 MST 2006
Author: oej
Date: Thu Apr 6 03:43:17 2006
New Revision: 17779
URL: http://svn.digium.com/view/asterisk?rev=17779&view=rev
Log:
Update from mithraen (Denis Smirnov)
Modified:
team/oej/codecnegotiation/apps/app_chanisavail.c
team/oej/codecnegotiation/apps/app_dial.c
team/oej/codecnegotiation/apps/app_echo.c
team/oej/codecnegotiation/apps/app_queue.c
team/oej/codecnegotiation/channels/chan_agent.c
team/oej/codecnegotiation/channels/chan_h323.c
team/oej/codecnegotiation/channels/chan_sip.c
team/oej/codecnegotiation/include/asterisk/channel.h
Modified: team/oej/codecnegotiation/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/apps/app_chanisavail.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/apps/app_chanisavail.c (original)
+++ team/oej/codecnegotiation/apps/app_chanisavail.c Thu Apr 6 03:43:17 2006
@@ -124,7 +124,7 @@
snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
status = inuse = ast_device_state(trychan);
}
- if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) {
+ if ((inuse <= 1) && (tempchan = ast_request_inherit(chan, tech, number, &status))) {
pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
/* Store the originally used channel too */
snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
Modified: team/oej/codecnegotiation/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/apps/app_dial.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/apps/app_dial.c (original)
+++ team/oej/codecnegotiation/apps/app_dial.c Thu Apr 6 03:43:17 2006
@@ -470,7 +470,7 @@
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
/* Setup parameters */
- o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
+ o->chan = ast_request_inherit(in, tech, stuff, &cause);
if (!o->chan)
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
} else {
@@ -1015,7 +1015,7 @@
ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
}
/* Request the peer */
- tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause);
+ tmp->chan = ast_request_inherit(chan, tech, numsubst, &cause);
if (!tmp->chan) {
/* If we can't, just go on to the next call */
ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
@@ -1046,7 +1046,7 @@
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
ast_hangup(tmp->chan);
/* Setup parameters */
- tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
+ tmp->chan = ast_request_inherit(chan, tech, stuff, &cause);
if (!tmp->chan)
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
} else {
Modified: team/oej/codecnegotiation/apps/app_echo.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/apps/app_echo.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/apps/app_echo.c (original)
+++ team/oej/codecnegotiation/apps/app_echo.c Thu Apr 6 03:43:17 2006
@@ -61,10 +61,8 @@
struct localuser *u;
LOCAL_USER_ADD(u);
-
- format = ast_channel_best_codec(chan);
- ast_set_write_format(chan, format);
- ast_set_read_format(chan, format);
+
+ ast_set_best_format(chan);
while (ast_waitfor(chan, -1) > -1) {
struct ast_frame *f = ast_read(chan);
Modified: team/oej/codecnegotiation/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/apps/app_queue.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/apps/app_queue.c (original)
+++ team/oej/codecnegotiation/apps/app_queue.c Thu Apr 6 03:43:17 2006
@@ -1414,7 +1414,7 @@
location = "";
/* Request the peer */
- tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status);
+ tmp->chan = ast_request_inherit(qe->chan, tech, location, &status);
if (!tmp->chan) { /* If we can't, just go on to the next call */
#if 0
ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
@@ -1711,7 +1711,7 @@
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
/* Setup parameters */
- o->chan = ast_request(tech, in->nativeformats, stuff, &status);
+ o->chan = ast_request_inherit(in, tech, stuff, &status);
if (status != o->oldstatus)
update_dial_status(qe->parent, o->member, status);
if (!o->chan) {
Modified: team/oej/codecnegotiation/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/channels/chan_agent.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/channels/chan_agent.c (original)
+++ team/oej/codecnegotiation/channels/chan_agent.c Thu Apr 6 03:43:17 2006
@@ -214,13 +214,11 @@
ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast_get_read_format(ast), ast->writeformat);\
- ast_set_read_format(ast, ast_get_read_format(ast)); \
- ast_set_write_format(ast, ast->writeformat); \
+ ast_channel_formats_reset(ast); \
} \
if (ast_get_read_format(p->chan) != ast->rawreadformat) \
ast_set_read_format(p->chan, ast->rawreadformat); \
- if (p->chan->writeformat != ast->rawwriteformat) \
+ if (ast_get_write(format(p->chan) != ast->rawwriteformat) \
ast_set_write_format(p->chan, ast->rawwriteformat); \
} \
} while(0)
Modified: team/oej/codecnegotiation/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/channels/chan_h323.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/channels/chan_h323.c (original)
+++ team/oej/codecnegotiation/channels/chan_h323.c Thu Apr 6 03:43:17 2006
@@ -234,8 +234,7 @@
if (h323debug)
ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name);
c->nativeformats = pvt->nativeformats;
- ast_set_read_format(c, ast_get_read_format(c));
- ast_set_write_format(c, ast_get_write_format(c));
+ ast_channel_formats_reset(c);
}
if (pvt->needhangup) {
if (h323debug)
@@ -569,8 +568,7 @@
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass;
pvt->nativeformats = f->subclass;
- ast_set_read_format(pvt->owner, ast_get_read_format(pvt->owner));
- ast_set_write_format(pvt->owner, ast_get_write_format(pvt->owner));
+ ast_channel_formats_reset(pvt->owner);
ast_mutex_unlock(&pvt->owner->lock);
}
/* Do in-band DTMF detection */
@@ -1202,8 +1200,7 @@
pvt->nativeformats = rtptype.code;
if (pvt->owner && !ast_mutex_trylock(&pvt->owner->lock)) {
pvt->owner->nativeformats = pvt->nativeformats;
- ast_set_read_format(pvt->owner, ast_get_read_format(pvt->owner));
- ast_set_write_format(pvt->owner, ast_get_write_format(pvt->owner));
+ ast_channel_reset_formats(pvt->owner);
if (pvt->options.progress_audio)
ast_queue_control(pvt->owner, AST_CONTROL_PROGRESS);
ast_mutex_unlock(&pvt->owner->lock);
Modified: team/oej/codecnegotiation/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/channels/chan_sip.c?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/channels/chan_sip.c (original)
+++ team/oej/codecnegotiation/channels/chan_sip.c Thu Apr 6 03:43:17 2006
@@ -3152,8 +3152,7 @@
if (option_debug)
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
- ast_set_read_format(p->owner, ast_get_read_format(p->owner));
- ast_set_write_format(p->owner, p->owner->writeformat);
+ ast_channel_formats_reset(p->owner);
}
if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
@@ -3825,8 +3824,7 @@
ast_getformatname_multiple(s1, slen, p->jointcapability),
ast_getformatname_multiple(s2, slen, p->owner->nativeformats));
p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, 1) | (p->capability & vpeercapability);
- ast_set_read_format(p->owner, ast_get_read_format(p->owner));
- ast_set_write_format(p->owner, p->owner->writeformat);
+ ast_channel_formats_reset(p->owner);
}
if ((bridgepeer=ast_bridged_channel(p->owner))) {
/* We have a bridge */
Modified: team/oej/codecnegotiation/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/include/asterisk/channel.h?rev=17779&r1=17778&r2=17779&view=diff
==============================================================================
--- team/oej/codecnegotiation/include/asterisk/channel.h (original)
+++ team/oej/codecnegotiation/include/asterisk/channel.h Thu Apr 6 03:43:17 2006
@@ -591,6 +591,18 @@
*/
struct ast_channel *ast_request(const char *type, int format, void *data, int *status);
+
+/*! \brief call ast_request with format/type of parent channel
+ */
+static inline struct ast_channel *ast_request_inherit(struct ast_channel *chan, const char *type, void *data, int *status)
+{
+ if( type == NULL ) {
+ ast_request(chan->tech->type, chan->nativeformats, data, status);
+ } else {
+ ast_request(type, chan->nativeformats, data, status);
+ }
+}
+
/*!
* \brief Request a channel of a given type, with data as optional information used
* by the low level module and attempt to place a call on it
@@ -1000,13 +1012,34 @@
/* Choose the best codec... Uhhh... Yah. */
extern int ast_best_codec(int fmts);
-/*! Pick the best codec from channel nativeformats */
-/*!
+/*!
+ * \brief Pick the best codec from channel nativeformats
* \param channel channel, from that nativeformats used
*/
static inline int ast_channel_best_codec(struct ast_channel *channel)
{
return ast_best_codec(channel->nativeformats);
+}
+
+static inline void ast_channel_formats_reset(struct ast_channel *channel)
+{
+ int r, w;
+ r = ast_get_read_format(channel);
+ w = ast_get_read_format(channel);
+ ast_log(LOG_DEBUG, "Resetting read to %d and write to %d on channel %s\n", r, w, channel->name);
+ ast_set_read_format(channel, r);
+ ast_set_write_format(channel, w);
+}
+
+/*!
+ * \brief Set best format, identical to read/write
+ * \param channel channel, from that nativeformats used and formats set
+ */
+static inline void ast_set_best_format(struct ast_channel *channel)
+{
+ int format = ast_channel_best_codec(channel);
+ ast_set_read_format(channel, format);
+ ast_set_write_format(channel, format);
}
/*! Checks the value of an option */
More information about the svn-commits
mailing list