[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r308571 - in /team/dvossel/fixthew...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 22 15:00:52 CST 2011
Author: dvossel
Date: Tue Feb 22 15:00:47 2011
New Revision: 308571
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=308571
Log:
addresses reviewboard comments
Modified:
team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c
team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c
team/dvossel/fixtheworld_phase2/codecs/codec_resample.c
team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
team/dvossel/fixtheworld_phase2/include/asterisk/_private.h
team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h
team/dvossel/fixtheworld_phase2/include/asterisk/format.h
team/dvossel/fixtheworld_phase2/include/asterisk/format_cap.h
team/dvossel/fixtheworld_phase2/include/asterisk/rtp_engine.h
team/dvossel/fixtheworld_phase2/main/audiohook.c
team/dvossel/fixtheworld_phase2/main/format.c
team/dvossel/fixtheworld_phase2/main/format_cap.c
team/dvossel/fixtheworld_phase2/main/frame.c
team/dvossel/fixtheworld_phase2/main/rtp_engine.c
Modified: team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c (original)
+++ team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c Tue Feb 22 15:00:47 2011
@@ -245,7 +245,7 @@
}
if (!stop && bridge) {
ast_bridge_handle_trip(bridge, NULL, winner, -1);
- ao2_unlock(winner->bridge);
+ ao2_unlock(bridge);
}
ao2_lock(multiplexed_thread);
}
Modified: team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c (original)
+++ team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c Tue Feb 22 15:00:47 2011
@@ -86,7 +86,7 @@
struct softmix_bridge_data {
struct ast_timer *timer;
- int internal_rate;
+ unsigned int internal_rate;
};
/*! \brief Function called when a bridge is created */
@@ -94,7 +94,7 @@
{
struct softmix_bridge_data *bridge_data;
- if (!(bridge_data = ast_calloc(1, sizeof(struct softmix_bridge_data)))) {
+ if (!(bridge_data = ast_calloc(1, sizeof(*bridge_data)))) {
return -1;
}
if (!(bridge_data->timer = ast_timer_open())) {
@@ -230,10 +230,23 @@
/*! \brief Function which acts as the mixing thread */
static int softmix_bridge_thread(struct ast_bridge *bridge)
{
+ struct {
+ /*! Each index represents a sample rate used above the internal rate. */
+ unsigned int sample_rates[8];
+ /*! Each index represents the number of channels using the same index in the sample_rates array. */
+ unsigned int num_channels[8];
+ /*! the number of channels above the internal sample rate */
+ unsigned int num_above_internal_rate;
+ /*! the number of channels at the internal sample rate */
+ unsigned int num_at_internal_rate;
+ /*! the absolute highest sample rate supported by any channel in the bridge */
+ unsigned int highest_supported_rate;
+ } stats;
struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
struct ast_timer *timer = bridge_data->timer;
int timingfd = ast_timer_fd(timer);
int update_all_rates = 0; /* set this when the internal sample rate has changed */
+ int i;
ast_timer_set_rate(timer, (1000 / SOFTMIX_INTERVAL));
@@ -243,10 +256,8 @@
int timeout = -1;
/* these variables help determine if a rate change is required */
- int highest_supported_rate = 8000;
- int num_above_internal_rate = 0;
- int num_below_internal_rate = 0;
- int num_at_internal_rate = 0;
+ memset(&stats, 0, sizeof(stats));
+ stats.highest_supported_rate = 8000;
/* Go through pulling audio from each factory that has it available */
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
@@ -278,15 +289,24 @@
/* Gather stats about channel sample rates. */
channel_native_rate = MAX(ast_format_rate(&bridge_channel->chan->rawwriteformat),
ast_format_rate(&bridge_channel->chan->rawreadformat));
- if (channel_native_rate > highest_supported_rate) {
- highest_supported_rate = channel_native_rate;
+
+ if (channel_native_rate > stats.highest_supported_rate) {
+ stats.highest_supported_rate = channel_native_rate;
}
if (channel_native_rate > bridge_data->internal_rate) {
- num_above_internal_rate++;
+ for (i = 0; i < ARRAY_LEN(stats.sample_rates); i++) {
+ if (stats.sample_rates[i] == channel_native_rate) {
+ stats.num_channels[i]++;
+ break;
+ } else if (!stats.sample_rates[i]) {
+ stats.sample_rates[i] = channel_native_rate;
+ stats.num_channels[i]++;
+ break;
+ }
+ }
+ stats.num_above_internal_rate++;
} else if (channel_native_rate == bridge_data->internal_rate) {
- num_at_internal_rate++;
- } else if (channel_native_rate < bridge_data->internal_rate) {
- num_below_internal_rate++;
+ stats.num_at_internal_rate++;
}
ast_mutex_unlock(&sc->lock);
@@ -318,14 +338,40 @@
* 1. two or more channels support a higher sample rate
* 2. no channels support the current sample rate or a higher rate
*/
- if ((num_above_internal_rate >= 2) ||
- (!num_at_internal_rate && !num_above_internal_rate)) {
+ if (stats.num_above_internal_rate >= 2) {
+ /* the highest rate is just used as a starting point */
+ unsigned int best_rate = stats.highest_supported_rate;
+ int best_index = -1;
+
+ /* 1. pick the best sample rate two or more channels support
+ * 2. if two or more channels do not support the same rate, pick the
+ * lowest sample rate that is still above the internal rate. */
+ for (i = 0; ((i < ARRAY_LEN(stats.num_channels)) && stats.num_channels[i]); i++) {
+ if ((stats.num_channels[i] >= 2 && (best_index == -1)) ||
+ ((best_index != -1) &&
+ (stats.num_channels[i] >= 2) &&
+ (stats.sample_rates[best_index] < stats.sample_rates[i]))) {
+
+ best_rate = stats.sample_rates[i];
+ best_index = i;
+ } else if (best_index == -1) {
+ best_rate = MIN(best_rate, stats.sample_rates[i]);
+ }
+ }
+
+ ast_log(LOG_NOTICE, " UPDATED FROM %d to %d\n", bridge_data->internal_rate, best_rate);
+ bridge_data->internal_rate = best_rate;
update_all_rates = 1;
- ast_log(LOG_NOTICE, " UPDATED FROM %d to %d\n", bridge_data->internal_rate, highest_supported_rate);
- bridge_data->internal_rate = highest_supported_rate;
+ } else if (!stats.num_at_internal_rate && !stats.num_above_internal_rate) {
+ update_all_rates = 1;
+ /* in this case, the highest supported rate is actually lower than the internal rate */
+ bridge_data->internal_rate = stats.highest_supported_rate;
+ ast_log(LOG_NOTICE, " UPDATED FROM %d to %d\n", bridge_data->internal_rate, stats.highest_supported_rate);
+ update_all_rates = 1;
} else {
update_all_rates = 0;
}
+
ao2_unlock(bridge);
/* Wait for the timing source to tell us to wake up and get things done */
Modified: team/dvossel/fixtheworld_phase2/codecs/codec_resample.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/codec_resample.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/codec_resample.c (original)
+++ team/dvossel/fixtheworld_phase2/codecs/codec_resample.c Tue Feb 22 15:00:47 2011
@@ -40,9 +40,9 @@
#define OUTBUF_SIZE 8096
-struct ast_translator *translators;
-int trans_size;
-int id_list[] = {
+static struct ast_translator *translators;
+static int trans_size;
+static int id_list[] = {
AST_FORMAT_SLINEAR,
AST_FORMAT_SLINEAR12,
AST_FORMAT_SLINEAR16,
@@ -54,16 +54,12 @@
AST_FORMAT_SLINEAR192,
};
-struct resamp_pvt {
- SpeexResamplerState *resampler;
-};
-
static int resamp_new(struct ast_trans_pvt *pvt)
{
- struct resamp_pvt *resamp_pvt = pvt->pvt;
+ SpeexResamplerState *resamp_pvt = pvt->pvt;
int err;
- if (!(resamp_pvt->resampler = speex_resampler_init(1, ast_format_rate(&pvt->t->src_format), ast_format_rate(&pvt->t->dst_format), 5, &err))) {
+ if (!(resamp_pvt = speex_resampler_init(1, ast_format_rate(&pvt->t->src_format), ast_format_rate(&pvt->t->dst_format), 5, &err))) {
return -1;
}
@@ -72,18 +68,17 @@
static void resamp_destroy(struct ast_trans_pvt *pvt)
{
- struct resamp_pvt *resamp_pvt = pvt->pvt;
- speex_resampler_destroy(resamp_pvt->resampler);
-
+ SpeexResamplerState *resamp_pvt = pvt->pvt;
+ speex_resampler_destroy(resamp_pvt);
}
static int resamp_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
- struct resamp_pvt *resamp_pvt = pvt->pvt;
+ SpeexResamplerState *resamp_pvt = pvt->pvt;
unsigned int out_samples = (OUTBUF_SIZE / sizeof(int16_t)) - pvt->samples;
unsigned int in_samples = f->samples;
- speex_resampler_process_int(resamp_pvt->resampler,
+ speex_resampler_process_int(resamp_pvt,
0,
f->data.ptr,
&in_samples,
@@ -127,7 +122,7 @@
translators[idx].newpvt = resamp_new;
translators[idx].destroy = resamp_destroy;
translators[idx].framein = resamp_framein;
- translators[idx].desc_size = sizeof(struct resamp_pvt);
+ translators[idx].desc_size = sizeof(SpeexResamplerState *);
translators[idx].buffer_samples = (OUTBUF_SIZE / sizeof(int16_t));
translators[idx].buf_size = OUTBUF_SIZE;
ast_format_set(&translators[idx].src_format, id_list[x], 0);
Modified: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c (original)
+++ team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c Tue Feb 22 15:00:47 2011
@@ -36,11 +36,11 @@
* \note The only attribute that affects compatibility here is the sample rate.
*/
struct silk_attr {
- int samplerate;
- int maxbitrate;
- int dtx;
- int fec;
- int packetloss_percentage;
+ unsigned int samplerate;
+ unsigned int maxbitrate;
+ unsigned int dtx;
+ unsigned int fec;
+ unsigned int packetloss_percentage;
};
static enum ast_format_cmp_res silk_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2)
@@ -57,27 +57,22 @@
static int silk_get_val(const struct ast_format_attr *fattr, int key, void *result)
{
const struct silk_attr *attr = (struct silk_attr *) fattr;
+ int *val = result;
switch (key) {
- int *val;
case SILK_ATTR_KEY_SAMP_RATE:
- val = result;
*val = attr->samplerate;
break;
case SILK_ATTR_KEY_MAX_BITRATE:
- val = result;
*val = attr->maxbitrate;
break;
case SILK_ATTR_KEY_DTX:
- val = result;
*val = attr->dtx;
break;
case SILK_ATTR_KEY_FEC:
- val = result;
*val = attr->fec;
break;
case SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE:
- val = result;
*val = attr->packetloss_percentage;
break;
default:
@@ -201,7 +196,7 @@
static int load_module(void)
{
if (ast_format_attr_reg_interface(&silk_interface)) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/_private.h?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/_private.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/_private.h Tue Feb 22 15:00:47 2011
@@ -90,4 +90,16 @@
*/
int ast_plc_reload(void);
+/*!
+ * \brief Init the ast_format attribute interface register container.
+ */
+int ast_format_attr_init(void);
+
+/*!
+ * \brief Init the Asterisk global format list after all format attribute modules have been loaded
+ */
+int ast_format_list_init(void);
+
+/*! \brief initializes the rtp engine arrays */
+int ast_rtp_engine_init(void);
#endif /* _ASTERISK__PRIVATE_H */
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h Tue Feb 22 15:00:47 2011
@@ -66,14 +66,11 @@
};
enum ast_audiohook_init_flags {
- /* Audiohook manipulate callback is capable of handling slinear at any sample rate.
+ /*! Audiohook manipulate callback is capable of handling slinear at any sample rate.
* Without enabling this flag on initialization the manipulation callback is guaranteed
* 8khz audio only. */
AST_AUDIOHOOK_MANIPULATE_ALL_RATES = (1 << 0),
};
-
-#define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*!< Tolerance in milliseconds for audiohooks synchronization */
-#define AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE 100 /*!< When small queue is enabled, this is the maximum amount of audio that can remain queued at a time. */
struct ast_audiohook;
@@ -116,7 +113,7 @@
struct ast_trans_pvt *trans_pvt; /*!< Translation path for reading frames */
ast_audiohook_manipulate_callback manipulate_callback; /*!< Manipulation callback */
struct ast_audiohook_options options; /*!< Applicable options */
- int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/
+ unsigned int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/
AST_LIST_ENTRY(ast_audiohook) list; /*!< Linked list information */
};
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/format.h?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format.h Tue Feb 22 15:00:47 2011
@@ -156,7 +156,7 @@
struct ast_format_list {
struct ast_format format; /*!< The unique format. */
char name[64]; /*!< short name */
- int samplespersecond; /*!< Number of samples per second (8000/16000) */
+ unsigned int samplespersecond; /*!< Number of samples per second (8000/16000) */
char desc[128]; /*!< Description */
int fr_len; /*!< Single frame length in bytes */
int min_ms; /*!< Min value */
@@ -423,56 +423,12 @@
int ast_format_attr_unreg_interface(const struct ast_format_attr_interface *interface);
/*!
- * \brief Init the ast_format attribute interface register container.
- */
-int ast_format_attr_init(void);
-
-/*!
- * \brief Init the Asterisk global format list after all format attribute modules have been loaded
- */
-int ast_format_list_init(void);
-
-/*!
* \brief Determine if a format is 16bit signed linear of any sample rate.
*/
-static force_inline int ast_format_is_slinear(const struct ast_format *format)
-{
- if (format->id == AST_FORMAT_SLINEAR ||
- format->id == AST_FORMAT_SLINEAR12 ||
- format->id == AST_FORMAT_SLINEAR16 ||
- format->id == AST_FORMAT_SLINEAR24 ||
- format->id == AST_FORMAT_SLINEAR32 ||
- format->id == AST_FORMAT_SLINEAR44 ||
- format->id == AST_FORMAT_SLINEAR48 ||
- format->id == AST_FORMAT_SLINEAR96 ||
- format->id == AST_FORMAT_SLINEAR192) {
- return 1;
- }
- return 0;
-}
+int ast_format_is_slinear(const struct ast_format *format);
/*!
* \brief Get the best slinear format id for a given sample rate
*/
-static force_inline enum ast_format_id ast_format_slin_by_rate(int rate) {
- if (rate >= 192000) {
- return AST_FORMAT_SLINEAR192;
- } else if (rate >= 96000) {
- return AST_FORMAT_SLINEAR96;
- } else if (rate >= 48000) {
- return AST_FORMAT_SLINEAR48;
- } else if (rate >= 44100) {
- return AST_FORMAT_SLINEAR44;
- } else if (rate >= 32000) {
- return AST_FORMAT_SLINEAR32;
- } else if (rate >= 24000) {
- return AST_FORMAT_SLINEAR24;
- } else if (rate >= 16000) {
- return AST_FORMAT_SLINEAR16;
- } else if (rate >= 12000) {
- return AST_FORMAT_SLINEAR12;
- }
- return AST_FORMAT_SLINEAR;
-}
-
+enum ast_format_id ast_format_slin_by_rate(unsigned int rate);
#endif /* _AST_FORMAT_H */
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/format_cap.h?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format_cap.h Tue Feb 22 15:00:47 2011
@@ -158,8 +158,8 @@
* \brief Find if input ast_format is within the capabilities of the ast_format_cap object
* then return the compatible format from the capabilities structure in the result.
*
- * retval 1 format is compatible with formats held in ast_format_cap object.
- * retval 0 format is not compatible with any formats in ast_format_cap object.
+ * \retval 1 format is compatible with formats held in ast_format_cap object.
+ * \retval 0 format is not compatible with any formats in ast_format_cap object.
*/
int ast_format_cap_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format, struct ast_format *result);
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/rtp_engine.h?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/rtp_engine.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/rtp_engine.h Tue Feb 22 15:00:47 2011
@@ -1820,8 +1820,6 @@
* attribute interface is unloaded, this function must be called to notify the rtp_engine. */
int ast_rtp_engine_unload_format(const struct ast_format *format);
-/*! \brief initializes the rtp engine arrays */
-int ast_rtp_engine_init(void);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/dvossel/fixtheworld_phase2/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/audiohook.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/audiohook.c (original)
+++ team/dvossel/fixtheworld_phase2/main/audiohook.c Tue Feb 22 15:00:47 2011
@@ -37,6 +37,9 @@
#include "asterisk/slinfactory.h"
#include "asterisk/frame.h"
#include "asterisk/translate.h"
+
+#define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*!< Tolerance in milliseconds for audiohooks synchronization */
+#define AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE 100 /*!< When small queue is enabled, this is the maximum amount of audio that can remain queued at a time. */
struct ast_audiohook_translate {
struct ast_trans_pvt *trans_pvt;
Modified: team/dvossel/fixtheworld_phase2/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Tue Feb 22 15:00:47 2011
@@ -554,6 +554,44 @@
return 0;
}
+int ast_format_is_slinear(const struct ast_format *format)
+{
+ if (format->id == AST_FORMAT_SLINEAR ||
+ format->id == AST_FORMAT_SLINEAR12 ||
+ format->id == AST_FORMAT_SLINEAR16 ||
+ format->id == AST_FORMAT_SLINEAR24 ||
+ format->id == AST_FORMAT_SLINEAR32 ||
+ format->id == AST_FORMAT_SLINEAR44 ||
+ format->id == AST_FORMAT_SLINEAR48 ||
+ format->id == AST_FORMAT_SLINEAR96 ||
+ format->id == AST_FORMAT_SLINEAR192) {
+ return 1;
+ }
+ return 0;
+}
+
+enum ast_format_id ast_format_slin_by_rate(unsigned int rate)
+{
+ if (rate >= 192000) {
+ return AST_FORMAT_SLINEAR192;
+ } else if (rate >= 96000) {
+ return AST_FORMAT_SLINEAR96;
+ } else if (rate >= 48000) {
+ return AST_FORMAT_SLINEAR48;
+ } else if (rate >= 44100) {
+ return AST_FORMAT_SLINEAR44;
+ } else if (rate >= 32000) {
+ return AST_FORMAT_SLINEAR32;
+ } else if (rate >= 24000) {
+ return AST_FORMAT_SLINEAR24;
+ } else if (rate >= 16000) {
+ return AST_FORMAT_SLINEAR16;
+ } else if (rate >= 12000) {
+ return AST_FORMAT_SLINEAR12;
+ }
+ return AST_FORMAT_SLINEAR;
+}
+
const char* ast_getformatname(const struct ast_format *format)
{
int x;
@@ -606,8 +644,8 @@
}
static struct ast_codec_alias_table {
- char *alias;
- char *realname;
+ const char *alias;
+ const char *realname;
} ast_codec_alias_table[] = {
{ "slinear", "slin"},
{ "slinear16", "slin16"},
@@ -732,13 +770,15 @@
return NULL;
}
- if ((a->argc < 3) || (a->argc > 4))
+ if ((a->argc < 3) || (a->argc > 4)) {
return CLI_SHOWUSAGE;
+ }
f_list = ast_format_list_get(&f_len);
- if (!ast_opt_dont_warn)
+ if (!ast_opt_dont_warn) {
ast_cli(a->fd, "Disclaimer: this command is for informational purposes only.\n"
"\tIt does not indicate anything about your configuration.\n");
+ }
ast_cli(a->fd, "%8s %5s %8s %s\n","ID","TYPE","NAME","DESCRIPTION");
ast_cli(a->fd, "-----------------------------------------------------------------------------------\n");
@@ -805,8 +845,9 @@
return NULL;
}
- if (a->argc != 4)
+ if (a->argc != 4) {
return CLI_SHOWUSAGE;
+ }
if (sscanf(a->argv[3], "%30d", &type_punned_codec) != 1) {
return CLI_SHOWUSAGE;
@@ -822,8 +863,9 @@
}
}
- if (!found)
+ if (!found) {
ast_cli(a->fd, "Codec %d not found\n", format_id);
+ }
f_list = ast_format_list_destroy(f_list);
return CLI_SUCCESS;
@@ -1098,6 +1140,38 @@
return 0;
}
+static int conf_process_format_name(const char *name, enum ast_format_id *id)
+{
+ if (!strcasecmp(name, "silk")) {
+ *id = AST_FORMAT_SILK;
+ } else {
+ *id = 0;
+ return -1;
+ }
+ return 0;
+}
+
+static int conf_process_sample_rate(const char *rate, unsigned int *result)
+{
+ if (!strcasecmp(rate, "8000")) {
+ *result = 8000;
+ } else if (!strcasecmp(rate, "12000")) {
+ *result = 12000;
+ } else if (!strcasecmp(rate, "16000")) {
+ *result = 16000;
+ } else if (!strcasecmp(rate, "24000")) {
+ *result = 24000;
+ } else if (!strcasecmp(rate, "32000")) {
+ *result = 32000;
+ } else if (!strcasecmp(rate, "48000")) {
+ *result = 48000;
+ } else {
+ *result = 0;
+ return -1;
+ }
+
+ return 0;
+}
static int load_format_config(void)
{
struct ast_flags config_flags = { 0, };
@@ -1115,8 +1189,9 @@
int usedtx;
} settings;
- if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
+ }
/* remove all custom formats from the AO2 Container. Note, this has no affect on the
* global format list until the list is rebuild. That is why this is okay to do while
@@ -1134,31 +1209,13 @@
ast_copy_string(entry.name, cat, sizeof(entry.name));
var = ast_variable_browse(cfg, cat);
for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
- if (!strcasecmp(var->name, "type")) {
- if (!strcasecmp(var->value, "silk")) {
- settings.id = AST_FORMAT_SILK;
- } else {
- ast_log(LOG_WARNING, "Can not make custom format type for '%s' at line %d of %s\n",
+ if (!strcasecmp(var->name, "type") && conf_process_format_name(var->value, &settings.id)) {
+ ast_log(LOG_WARNING, "Can not make custom format type for '%s' at line %d of %s\n",
+ var->value, var->lineno, FORMAT_CONFIG);
+ continue;
+ } else if (!strcasecmp(var->name, "samprate") && conf_process_sample_rate(var->value, &entry.samplespersecond)) {
+ ast_log(LOG_WARNING, "Sample rate '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
- continue;
- }
- } else if (!strcasecmp(var->name, "samprate")) {
- if (!strcasecmp(var->value, "8000")) {
- entry.samplespersecond = 8000;
- } else if (!strcasecmp(var->value, "12000")) {
- entry.samplespersecond = 12000;
- } else if (!strcasecmp(var->value, "16000")) {
- entry.samplespersecond = 16000;
- } else if (!strcasecmp(var->value, "24000")) {
- entry.samplespersecond = 24000;
- } else if (!strcasecmp(var->value, "32000")) {
- entry.samplespersecond = 32000;
- } else if (!strcasecmp(var->value, "48000")) {
- entry.samplespersecond = 48000;
- } else {
- ast_log(LOG_WARNING, "Sample rate '%s' at line %d of %s is not supported.\n",
- var->value, var->lineno, FORMAT_CONFIG);
- }
} else if (!strcasecmp(var->name, "maxbitrate")) {
if (sscanf(var->value, "%30u", &settings.maxbitrate) != 1) {
ast_log(LOG_WARNING, "maxbitrate '%s' at line %d of %s is not supported.\n",
Modified: team/dvossel/fixtheworld_phase2/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format_cap.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format_cap.c Tue Feb 22 15:00:47 2011
@@ -295,8 +295,8 @@
f = ao2_find(tmp_cap->formats, (struct ast_format *) format, OBJ_POINTER | tmp_cap->nolock);
if (f) {
+ ast_format_copy(result, f);
ao2_ref(f, -1);
- ast_format_copy(result, f);
return 1;
}
ast_format_clear(result);
Modified: team/dvossel/fixtheworld_phase2/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/frame.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/frame.c (original)
+++ team/dvossel/fixtheworld_phase2/main/frame.c Tue Feb 22 15:00:47 2011
@@ -1075,11 +1075,13 @@
short *fdata = f->data.ptr;
short adjust_value = abs(adjustment);
- if ((f->frametype != AST_FRAME_VOICE) || !(ast_format_is_slinear(&f->subclass.format)))
+ if ((f->frametype != AST_FRAME_VOICE) || !(ast_format_is_slinear(&f->subclass.format))) {
return -1;
-
- if (!adjustment)
+ }
+
+ if (!adjustment) {
return 0;
+ }
for (count = 0; count < f->samples; count++) {
if (adjustment > 0) {
Modified: team/dvossel/fixtheworld_phase2/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/rtp_engine.c?view=diff&rev=308571&r1=308570&r2=308571
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/rtp_engine.c (original)
+++ team/dvossel/fixtheworld_phase2/main/rtp_engine.c Tue Feb 22 15:00:47 2011
@@ -39,6 +39,7 @@
#include "asterisk/pbx.h"
#include "asterisk/translate.h"
#include "asterisk/netsock2.h"
+#include "asterisk/_private.h"
struct ast_srtp_res *res_srtp = NULL;
struct ast_srtp_policy_res *res_srtp_policy = NULL;
More information about the asterisk-commits
mailing list