|
|
|
@ -18,7 +18,7 @@
|
|
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
|
*
|
|
|
|
|
* \brief Frame manipulation routines
|
|
|
|
|
* \brief Frame and codec manipulation routines
|
|
|
|
|
*
|
|
|
|
|
* \author Mark Spencer <markster@digium.com>
|
|
|
|
|
*/
|
|
|
|
@ -91,7 +91,7 @@ static struct ast_format_list {
|
|
|
|
|
{ 1, AST_FORMAT_LPC10, "lpc10", "LPC10" }, /*!< codec_lpc10.c */
|
|
|
|
|
{ 1, AST_FORMAT_G729A, "g729", "G.729A" }, /*!< Binary commercial distribution */
|
|
|
|
|
{ 1, AST_FORMAT_SPEEX, "speex", "SpeeX" }, /*!< codec_speex.c */
|
|
|
|
|
{ 1, AST_FORMAT_ILBC, "ilbc", "iLBC"}, /*!< codec_ilbc.c */
|
|
|
|
|
{ 1, AST_FORMAT_ILBC, "ilbc", "iLBC"}, /*!< codec_ilbc.c */
|
|
|
|
|
{ 0, 0, "nothing", "undefined" },
|
|
|
|
|
{ 0, 0, "nothing", "undefined" },
|
|
|
|
|
{ 0, 0, "nothing", "undefined" },
|
|
|
|
@ -198,6 +198,7 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
|
|
|
|
|
{
|
|
|
|
|
struct ast_frame *opt;
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
/* IF we have an optimization frame, send it */
|
|
|
|
|
if (s->opt) {
|
|
|
|
|
if (s->opt->offset < AST_FRIENDLY_OFFSET)
|
|
|
|
@ -480,13 +481,14 @@ int ast_fr_fdhangup(int fd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* unused functions */
|
|
|
|
|
|
|
|
|
|
void ast_swapcopy_samples(void *dst, const void *src, int samples)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
unsigned short *dst_s = dst;
|
|
|
|
|
const unsigned short *src_s = src;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<samples; i++)
|
|
|
|
|
for (i = 0; i < samples; i++)
|
|
|
|
|
dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -515,12 +517,14 @@ char* ast_getformatname(int format)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *ast_getformatname_multiple(char *buf, size_t size, int format) {
|
|
|
|
|
|
|
|
|
|
char *ast_getformatname_multiple(char *buf, size_t size, int format)
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
unsigned len;
|
|
|
|
|
char *start, *end = buf;
|
|
|
|
|
if (!size) return buf;
|
|
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
|
return buf;
|
|
|
|
|
snprintf(end, size, "0x%x (", format);
|
|
|
|
|
len = strlen(end);
|
|
|
|
|
end += len;
|
|
|
|
@ -544,13 +548,13 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format) {
|
|
|
|
|
static struct ast_codec_alias_table {
|
|
|
|
|
char *alias;
|
|
|
|
|
char *realname;
|
|
|
|
|
|
|
|
|
|
} ast_codec_alias_table[] = {
|
|
|
|
|
{"slinear","slin"},
|
|
|
|
|
{"g723.1","g723"},
|
|
|
|
|
{ "slinear", "slin"},
|
|
|
|
|
{ "g723.1", "g723"},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *ast_expand_codec_alias(const char *in) {
|
|
|
|
|
static const char *ast_expand_codec_alias(const char *in)
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
|
|
for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(ast_codec_alias_table[0]); x++) {
|
|
|
|
@ -567,8 +571,8 @@ int ast_getformatbyname(const char *name)
|
|
|
|
|
all = strcasecmp(name, "all") ? 0 : 1;
|
|
|
|
|
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
|
|
|
|
|
if(AST_FORMAT_LIST[x].visible && (all ||
|
|
|
|
|
!strcasecmp(AST_FORMAT_LIST[x].name,name) ||
|
|
|
|
|
!strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
|
|
|
|
|
!strcasecmp(AST_FORMAT_LIST[x].name,name) ||
|
|
|
|
|
!strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
|
|
|
|
|
format |= AST_FORMAT_LIST[x].bits;
|
|
|
|
|
if(!all)
|
|
|
|
|
break;
|
|
|
|
@ -578,7 +582,8 @@ int ast_getformatbyname(const char *name)
|
|
|
|
|
return format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *ast_codec2str(int codec) {
|
|
|
|
|
char *ast_codec2str(int codec)
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
char *ret = "unknown";
|
|
|
|
|
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
|
|
|
|
@ -648,13 +653,13 @@ static int show_codec_n(int fd, int argc, char *argv[])
|
|
|
|
|
if (sscanf(argv[2],"%d",&codec) != 1)
|
|
|
|
|
return RESULT_SHOWUSAGE;
|
|
|
|
|
|
|
|
|
|
for (i=0;i<32;i++)
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
|
if (codec & (1 << i)) {
|
|
|
|
|
found = 1;
|
|
|
|
|
ast_cli(fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! found)
|
|
|
|
|
if (!found)
|
|
|
|
|
ast_cli(fd, "Codec %d not found\n", codec);
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
@ -938,7 +943,7 @@ int ast_codec_pref_index(struct ast_codec_pref *pref, int index)
|
|
|
|
|
return slot ? AST_FORMAT_LIST[slot-1].bits : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief ast_codec_pref_remove: Remove codec from pref list */
|
|
|
|
|
/*! \brief Remove codec from pref list */
|
|
|
|
|
void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
|
|
|
|
|
{
|
|
|
|
|
struct ast_codec_pref oldorder;
|
|
|
|
@ -961,7 +966,7 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief ast_codec_pref_append: Append codec to list */
|
|
|
|
|
/*! \brief Append codec to list */
|
|
|
|
|
int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
|
|
|
|
|
{
|
|
|
|
|
int x, newindex = -1;
|
|
|
|
@ -988,7 +993,7 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief ast_codec_choose: Pick a codec */
|
|
|
|
|
/*! \brief Pick a codec */
|
|
|
|
|
int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
|
|
|
|
|
{
|
|
|
|
|
int x, ret = 0, slot;
|
|
|
|
@ -996,9 +1001,9 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
|
|
|
|
|
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
|
|
|
|
|
slot = pref->order[x];
|
|
|
|
|
|
|
|
|
|
if(!slot)
|
|
|
|
|
if (!slot)
|
|
|
|
|
break;
|
|
|
|
|
if ( formats & AST_FORMAT_LIST[slot-1].bits ) {
|
|
|
|
|
if (formats & AST_FORMAT_LIST[slot-1].bits) {
|
|
|
|
|
ret = AST_FORMAT_LIST[slot-1].bits;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|