[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r300759 - in /team/dvossel/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 5 23:21:11 UTC 2011
Author: dvossel
Date: Wed Jan 5 17:21:06 2011
New Revision: 300759
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300759
Log:
updates data.c, dsp.c, cli.c, dial.c for ast_format conversion
Modified:
team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
team/dvossel/fixtheworld_phase1_step3/main/channel.c
team/dvossel/fixtheworld_phase1_step3/main/cli.c
team/dvossel/fixtheworld_phase1_step3/main/data.c
team/dvossel/fixtheworld_phase1_step3/main/dial.c
team/dvossel/fixtheworld_phase1_step3/main/dsp.c
team/dvossel/fixtheworld_phase1_step3/main/features.c
team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Wed Jan 5 17:21:06 2011
@@ -54,6 +54,19 @@
void ast_cap_add(struct ast_cap *cap, struct ast_format *format);
/*!
+ * \brief Add all formats Asterisk knows about for a specific type to
+ * the capabilities structure. Formats with attributes are set, but their
+ * attributes are initilized to 0's. An attribute structure of 0's should
+ * indicate to the format attribute interface that the format has full
+ * capabilities.
+ *
+ * \note A copy of the input format is made and that copy is
+ * what is placed in the ast_cap structure. The actual
+ * input format ptr is not stored.
+ */
+void ast_cap_add_all_by_type(struct ast_cap *cap, enum ast_format_type type);
+
+/*!
* \brief Append the formats in src to dst
*/
void ast_cap_append(struct ast_cap *src, struct ast_cap *dst);
Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Wed Jan 5 17:21:06 2011
@@ -1084,6 +1084,11 @@
#endif
if (!tmp) {
/* Channel structure allocation failure. */
+ return NULL;
+ }
+ if (!(tmp->nativeformats = ast_cap_alloc())) {
+ ao2_ref(tmp, -1);
+ /* format capabilities structure allocation failure */
return NULL;
}
Modified: team/dvossel/fixtheworld_phase1_step3/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/cli.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/cli.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/cli.c Wed Jan 5 17:21:06 2011
@@ -1387,7 +1387,7 @@
struct timeval now;
struct ast_str *out = ast_str_thread_get(&ast_str_thread_global_buf, 16);
char cdrtime[256];
- char nf[256], wf[256], rf[256];
+ char nf[256];
struct ast_str *write_transpath = ast_str_alloca(256);
struct ast_str *read_transpath = ast_str_alloca(256);
long elapsed_seconds=0;
@@ -1469,9 +1469,9 @@
S_OR(c->dialed.number.str, "(N/A)"),
c->language,
ast_state2str(c->_state), c->_state, c->rings,
- ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
- ast_getformatname_multiple(wf, sizeof(wf), c->writeformat),
- ast_getformatname_multiple(rf, sizeof(rf), c->readformat),
+ ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
+ ast_getformatname(&c->writeformat),
+ ast_getformatname(&c->readformat),
c->writetrans ? "Yes" : "No",
ast_translate_path_to_str(c->writetrans, &write_transpath),
c->readtrans ? "Yes" : "No",
Modified: team/dvossel/fixtheworld_phase1_step3/main/data.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/data.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/data.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/data.c Wed Jan 5 17:21:06 2011
@@ -3142,7 +3142,7 @@
}
fmlist = ast_get_format_list(&fmlist_size);
for (x = 0; x < fmlist_size; x++) {
- if (ast_cap_iscompatible(cap, ast_set_format(&tmp_fmt, fmlist[x].id, 0))) {
+ if (ast_cap_iscompatible(cap, ast_format_set(&tmp_fmt, fmlist[x].id, 0))) {
codec = ast_data_add_node(codecs, "codec");
if (!codec) {
return -1;
Modified: team/dvossel/fixtheworld_phase1_step3/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/dial.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/dial.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/dial.c Wed Jan 5 17:21:06 2011
@@ -248,13 +248,26 @@
{
char numsubst[AST_MAX_EXTENSION];
int res = 1;
+ struct ast_cap *cap_all_audio = NULL;
+ struct ast_cap *cap_request;
/* Copy device string over */
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
+ if (chan) {
+ cap_request = chan->nativeformats;
+ } else {
+ cap_all_audio = ast_cap_alloc();
+ ast_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
+ cap_request = cap_all_audio;
+ }
+
/* If we fail to create our owner channel bail out */
- if (!(channel->owner = ast_request(channel->tech, chan ? chan->nativeformats : AST_FORMAT_AUDIO_MASK, chan, numsubst, &channel->cause)))
- return -1;
+ if (!(channel->owner = ast_request(channel->tech, cap_request, chan, numsubst, &channel->cause))) {
+ cap_all_audio = ast_cap_destroy(cap_all_audio);
+ return -1;
+ }
+ cap_all_audio = ast_cap_destroy(cap_all_audio);
channel->owner->appl = "AppDial2";
channel->owner->data = "(Outgoing Line)";
Modified: team/dvossel/fixtheworld_phase1_step3/main/dsp.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/dsp.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/dsp.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/dsp.c Wed Jan 5 17:21:06 2011
@@ -1106,7 +1106,7 @@
ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n");
return 0;
}
- if (inf->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (inf->subclass.format.id != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n");
return 0;
}
@@ -1280,7 +1280,7 @@
ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n");
return 0;
}
- if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (f->subclass.format.id != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n");
return 0;
}
@@ -1298,7 +1298,7 @@
ast_log(LOG_WARNING, "Can't calculate noise on a non-voice frame\n");
return 0;
}
- if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (f->subclass.format.id != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n");
return 0;
}
@@ -1329,7 +1329,7 @@
odata = af->data.ptr;
len = af->datalen;
/* Make sure we have short data */
- switch (af->subclass.codec) {
+ switch (af->subclass.format.id) {
case AST_FORMAT_SLINEAR:
shortdata = af->data.ptr;
len = af->datalen / 2;
@@ -1350,7 +1350,7 @@
default:
/*Display warning only once. Otherwise you would get hundreds of warnings every second */
if (dsp->display_inband_dtmf_warning)
- ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass.codec));
+ ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(&af->subclass.format));
dsp->display_inband_dtmf_warning = 0;
return af;
}
@@ -1479,7 +1479,7 @@
memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start));
}
- switch (af->subclass.codec) {
+ switch (af->subclass.format.id) {
case AST_FORMAT_SLINEAR:
break;
case AST_FORMAT_ULAW:
@@ -1491,6 +1491,8 @@
for (x = 0; x < len; x++) {
odata[x] = AST_LIN2A((unsigned short) shortdata[x]);
}
+ /* fall through */
+ default:
break;
}
Modified: team/dvossel/fixtheworld_phase1_step3/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/features.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/features.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/features.c Wed Jan 5 17:21:06 2011
@@ -573,7 +573,7 @@
}
}
-static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, struct ast_channel *transferee, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, int igncallerstate, const char *language);
+static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, struct ast_channel *transferee, const char *type, struct ast_cap *cap, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, int igncallerstate, const char *language);
/*!
* \brief bridge the call
@@ -1144,17 +1144,20 @@
static struct ast_channel *create_test_channel(const struct ast_channel_tech *fake_tech)
{
struct ast_channel *test_channel1;
+ struct ast_format tmp_fmt;
if (!(test_channel1 = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
NULL, NULL, 0, 0, "TestChannel1"))) {
return NULL;
}
/* normally this is done in the channel driver */
- test_channel1->nativeformats = AST_FORMAT_GSM;
- test_channel1->writeformat = AST_FORMAT_GSM;
- test_channel1->rawwriteformat = AST_FORMAT_GSM;
- test_channel1->readformat = AST_FORMAT_GSM;
- test_channel1->rawreadformat = AST_FORMAT_GSM;
+ ast_cap_add(test_channel1->nativeformats, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
+
+ ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
+ ast_format_set(&test_channel1->rawwriteformat, AST_FORMAT_GSM, 0);
+ ast_format_set(&test_channel1->readformat, AST_FORMAT_GSM, 0);
+ ast_format_set(&test_channel1->rawreadformat, AST_FORMAT_GSM, 0);
+
test_channel1->tech = fake_tech;
return test_channel1;
@@ -1904,7 +1907,7 @@
}
newchan = feature_request_and_dial(transferer, transferee, "Local",
- ast_best_codec(transferer->nativeformats),
+ transferer->nativeformats,
xferto, atxfernoanswertimeout, &outstate,
transferer->caller.id.number.valid ? transferer->caller.id.number.str : NULL,
transferer->caller.id.name.valid ? transferer->caller.id.name.str : NULL,
@@ -2113,7 +2116,7 @@
ast_log(LOG_NOTICE, "We're trying to call %s/%s\n", transferer_tech, transferer_name);
newchan = feature_request_and_dial(transferee, NULL, transferer_tech,
- ast_best_codec(transferee->nativeformats),
+ transferee->nativeformats,
transferer_name, atxfernoanswertimeout, &outstate,
transferee->caller.id.number.valid ? transferee->caller.id.number.str : NULL,
transferee->caller.id.name.valid ? transferee->caller.id.name.str : NULL,
@@ -2125,7 +2128,7 @@
ast_indicate(transferee, AST_CONTROL_HOLD);
newchan = feature_request_and_dial(transferer, transferee, "Local",
- ast_best_codec(transferer->nativeformats),
+ transferer->nativeformats,
xferto, atxfernoanswertimeout, &outstate,
transferer->caller.id.number.valid ? transferer->caller.id.number.str : NULL,
transferer->caller.id.name.valid ? transferer->caller.id.name.str : NULL,
@@ -2141,7 +2144,7 @@
ast_safe_sleep(transferee, atxferloopdelay);
ast_debug(1, "Trying to callback...\n");
newchan = feature_request_and_dial(transferee, NULL, transferer_tech,
- ast_best_codec(transferee->nativeformats),
+ transferee->nativeformats,
transferer_name, atxfernoanswertimeout, &outstate,
transferee->caller.id.number.valid ? transferee->caller.id.number.str : NULL,
transferee->caller.id.name.valid ? transferee->caller.id.name.str : NULL,
@@ -2754,7 +2757,7 @@
* \todo XXX Check - this is very similar to the code in channel.c
* \return always a channel
*/
-static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, struct ast_channel *transferee, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, int igncallerstate, const char *language)
+static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, struct ast_channel *transferee, const char *type, struct ast_cap *cap, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, int igncallerstate, const char *language)
{
int state = 0;
int cause = 0;
@@ -2766,8 +2769,16 @@
struct timeval started;
int x, len = 0;
char *disconnect_code = NULL, *dialed_code = NULL;
-
- if (!(chan = ast_request(type, format, caller, data, &cause))) {
+ struct ast_cap *tmp_cap;
+ struct ast_format best_audio_fmt;
+
+ tmp_cap = ast_cap_alloc();
+ if (!tmp_cap) {
+ return NULL;
+ }
+ ast_cap_add(tmp_cap, ast_best_codec(cap, &best_audio_fmt));
+
+ if (!(chan = ast_request(type, tmp_cap, caller, data, &cause))) {
ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
switch(cause) {
case AST_CAUSE_BUSY:
@@ -2833,8 +2844,8 @@
if (chan && (chan == active_channel)){
if (!ast_strlen_zero(chan->call_forward)) {
- if (!(chan = ast_call_forward(caller, chan, NULL, format, NULL, outstate))) {
- return NULL;
+ if (!(chan = ast_call_forward(caller, chan, NULL, tmp_cap, NULL, outstate))) {
+ goto done;
}
continue;
}
@@ -2935,7 +2946,7 @@
} else {
res = -1;
}
-
+ tmp_cap = ast_cap_destroy(tmp_cap);
if (outstate)
*outstate = state;
Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=300759&r1=300758&r2=300759
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Wed Jan 5 17:21:06 2011
@@ -31,6 +31,7 @@
#include "asterisk/version.h"
#include "asterisk/format.h"
#include "asterisk/format_cap.h"
+#include "asterisk/frame.h"
#include "asterisk/astobj2.h"
#include "asterisk/utils.h"
@@ -100,6 +101,20 @@
ast_format_copy(format, fnew);
ao2_link(cap->formats, fnew);
ao2_ref(fnew, -1);
+}
+
+void ast_cap_add_all_by_type(struct ast_cap *cap, enum ast_format_type type)
+{
+ int x;
+ size_t f_len = 0;
+ struct ast_format tmp_fmt;
+ const struct ast_format_list *f_list = ast_get_format_list(&f_len);
+
+ for (x = 0; x < f_len; x++) {
+ if (AST_FORMAT_GET_TYPE(f_list[x].id) == type) {
+ ast_cap_add(cap, ast_format_set(&tmp_fmt, f_list[x].id, 0));
+ }
+ }
}
void ast_cap_append(struct ast_cap *src, struct ast_cap *dst)
More information about the asterisk-commits
mailing list