1999-12-05 02:03:40 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
1999-12-05 02:03:40 +00:00
|
|
|
*
|
2006-02-25 05:11:44 +00:00
|
|
|
* Copyright (C) 1999 - 2006, Digium, Inc.
|
1999-12-05 02:03:40 +00:00
|
|
|
*
|
2004-12-06 21:53:57 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
1999-12-05 02:03:40 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
1999-12-05 02:03:40 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Translate via the use of pseudo channels
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
2012-03-22 19:51:16 +00:00
|
|
|
* \author Mark Spencer <markster@digium.com>
|
1999-12-05 02:03:40 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-15 16:20:16 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2005-04-22 13:11:34 +00:00
|
|
|
#include <sys/time.h>
|
2007-09-29 00:19:15 +00:00
|
|
|
#include <sys/resource.h>
|
2009-03-12 17:32:13 +00:00
|
|
|
#include <math.h>
|
2005-04-22 13:11:34 +00:00
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/translate.h"
|
2006-04-14 14:08:19 +00:00
|
|
|
#include "asterisk/module.h"
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/frame.h"
|
|
|
|
#include "asterisk/sched.h"
|
|
|
|
#include "asterisk/cli.h"
|
|
|
|
#include "asterisk/term.h"
|
1999-12-05 02:03:40 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*! \todo
|
|
|
|
* TODO: sample frames for each supported input format.
|
|
|
|
* We build this on the fly, by taking an SLIN frame and using
|
|
|
|
* the existing converter to play with it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! max sample recalc */
|
|
|
|
#define MAX_RECALC 1000
|
2004-05-17 22:59:27 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*! \brief the list of translators */
|
2006-11-02 18:01:10 +00:00
|
|
|
static AST_RWLIST_HEAD_STATIC(translators, ast_translator);
|
1999-12-05 02:03:40 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
struct translator_path {
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_translator *step; /*!< Next step translator */
|
|
|
|
uint32_t table_cost; /*!< Complete table cost to destination */
|
|
|
|
uint8_t multistep; /*!< Multiple conversions required for this translation */
|
1999-12-05 02:03:40 +00:00
|
|
|
};
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \brief a matrix that, for any pair of supported formats,
|
2006-04-08 21:40:57 +00:00
|
|
|
* indicates the total cost of translation and the first step.
|
|
|
|
* The full path can be reconstricted iterating on the matrix
|
|
|
|
* until step->dstfmt == desired_format.
|
2006-04-17 16:42:03 +00:00
|
|
|
*
|
|
|
|
* Array indexes are 'src' and 'dest', in that order.
|
2006-10-25 14:55:11 +00:00
|
|
|
*
|
|
|
|
* Note: the lock in the 'translators' list is also used to protect
|
|
|
|
* this structure.
|
2006-04-08 21:40:57 +00:00
|
|
|
*/
|
2011-02-03 16:22:10 +00:00
|
|
|
static struct translator_path **__matrix;
|
1999-12-05 02:03:40 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \brief table for converting index to format id values.
|
|
|
|
*
|
|
|
|
* \note this table is protected by the table_lock.
|
2006-04-08 21:40:57 +00:00
|
|
|
*/
|
2011-02-03 16:22:10 +00:00
|
|
|
static int *__indextable;
|
|
|
|
|
|
|
|
/*! protects the __indextable for resizing */
|
|
|
|
static ast_rwlock_t tablelock;
|
|
|
|
|
|
|
|
/* index size starts at this*/
|
|
|
|
#define INIT_INDEX 32
|
|
|
|
/* index size grows by this as necessary */
|
|
|
|
#define GROW_INDEX 16
|
|
|
|
|
|
|
|
/*! the current largest index used by the __matrix and __indextable arrays*/
|
|
|
|
static int cur_max_index;
|
|
|
|
/*! the largest index that can be used in either the __indextable or __matrix before resize must occur */
|
|
|
|
static int index_size;
|
|
|
|
|
|
|
|
static void matrix_rebuild(int samples);
|
1999-12-05 02:03:40 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief converts format id to index value.
|
|
|
|
*/
|
|
|
|
static int format2index(enum ast_format_id id)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
int x;
|
|
|
|
|
|
|
|
ast_rwlock_rdlock(&tablelock);
|
|
|
|
for (x = 0; x < cur_max_index; x++) {
|
|
|
|
if (__indextable[x] == id) {
|
|
|
|
/* format already exists in index2format table */
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
return -1; /* not found */
|
|
|
|
}
|
2006-06-13 20:59:15 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief add a new format to the matrix and index table structures.
|
|
|
|
*
|
|
|
|
* \note it is perfectly safe to call this on formats already indexed.
|
|
|
|
*
|
|
|
|
* \retval 0, success
|
|
|
|
* \retval -1, matrix and index table need to be resized
|
|
|
|
*/
|
|
|
|
static int add_format2index(enum ast_format_id id)
|
|
|
|
{
|
|
|
|
if (format2index(id) != -1) {
|
|
|
|
/* format is already already indexed */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_rwlock_wrlock(&tablelock);
|
|
|
|
if (cur_max_index == (index_size)) {
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
return -1; /* hit max length */
|
|
|
|
}
|
|
|
|
__indextable[cur_max_index] = id;
|
|
|
|
cur_max_index++;
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-06-13 20:59:15 +00:00
|
|
|
|
2012-03-22 19:51:16 +00:00
|
|
|
/*!
|
2011-02-03 16:22:10 +00:00
|
|
|
* \internal
|
|
|
|
* \brief converts index value back to format id
|
|
|
|
*/
|
|
|
|
static enum ast_format_id index2format(int index)
|
|
|
|
{
|
|
|
|
enum ast_format_id format_id;
|
|
|
|
|
|
|
|
if (index >= cur_max_index) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ast_rwlock_rdlock(&tablelock);
|
|
|
|
format_id = __indextable[index];
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
|
|
|
|
return format_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief resize both the matrix and index table so they can represent
|
|
|
|
* more translators
|
|
|
|
*
|
|
|
|
* \note _NO_ locks can be held prior to calling this function
|
|
|
|
*
|
|
|
|
* \retval 0, success
|
|
|
|
* \retval -1, failure. Old matrix and index table can still be used though
|
|
|
|
*/
|
|
|
|
static int matrix_resize(int init)
|
|
|
|
{
|
|
|
|
struct translator_path **tmp_matrix = NULL;
|
|
|
|
int *tmp_table = NULL;
|
|
|
|
int old_index;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
|
|
|
ast_rwlock_wrlock(&tablelock);
|
|
|
|
|
|
|
|
old_index = index_size;
|
|
|
|
if (init) {
|
|
|
|
index_size += INIT_INDEX;
|
|
|
|
} else {
|
|
|
|
index_size += GROW_INDEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make new 2d array of translator_path structures */
|
|
|
|
if (!(tmp_matrix = ast_calloc(1, sizeof(struct translator_path *) * (index_size)))) {
|
|
|
|
goto resize_cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < index_size; x++) {
|
|
|
|
if (!(tmp_matrix[x] = ast_calloc(1, sizeof(struct translator_path) * (index_size)))) {
|
|
|
|
goto resize_cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make new index table */
|
|
|
|
if (!(tmp_table = ast_calloc(1, sizeof(int) * index_size))) {
|
|
|
|
goto resize_cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if everything went well this far, free the old and use the new */
|
|
|
|
if (!init) {
|
|
|
|
for (x = 0; x < old_index; x++) {
|
|
|
|
ast_free(__matrix[x]);
|
|
|
|
}
|
|
|
|
ast_free(__matrix);
|
|
|
|
|
|
|
|
memcpy(tmp_table, __indextable, sizeof(int) * old_index);
|
|
|
|
ast_free(__indextable);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now copy them over */
|
|
|
|
__matrix = tmp_matrix;
|
|
|
|
__indextable = tmp_table;
|
|
|
|
|
|
|
|
matrix_rebuild(0);
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
resize_cleanup:
|
|
|
|
ast_rwlock_unlock(&tablelock);
|
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
|
|
|
if (tmp_matrix) {
|
|
|
|
for (x = 0; x < index_size; x++) {
|
|
|
|
ast_free(tmp_matrix[x]);
|
|
|
|
}
|
|
|
|
ast_free(tmp_matrix);
|
|
|
|
}
|
|
|
|
ast_free(tmp_table);
|
2006-06-13 20:59:15 +00:00
|
|
|
|
1999-12-05 02:03:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief reinitialize the __matrix during matrix rebuild
|
|
|
|
*
|
|
|
|
* \note must be protected by the translators list lock
|
|
|
|
*/
|
|
|
|
static void matrix_clear(void)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; x < index_size; x++) {
|
|
|
|
memset(__matrix[x], '\0', sizeof(struct translator_path) * (index_size));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief get a matrix entry
|
|
|
|
*
|
|
|
|
* \note This function must be protected by the translators list lock
|
|
|
|
*/
|
|
|
|
static struct translator_path *matrix_get(unsigned int x, unsigned int y)
|
|
|
|
{
|
|
|
|
if (!(x >= 0 && y >= 0)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return __matrix[x] + y;
|
|
|
|
}
|
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*
|
|
|
|
* wrappers around the translator routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Allocate the descriptor, required outbuf space,
|
2010-06-03 17:09:11 +00:00
|
|
|
* and possibly desc.
|
2006-04-08 21:40:57 +00:00
|
|
|
*/
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
static void *newpvt(struct ast_translator *t, const struct ast_format *explicit_dst)
|
2006-04-08 21:40:57 +00:00
|
|
|
{
|
|
|
|
struct ast_trans_pvt *pvt;
|
|
|
|
int len;
|
|
|
|
char *ofs;
|
2006-04-14 14:08:19 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*
|
|
|
|
* compute the required size adding private descriptor,
|
2010-06-03 17:09:11 +00:00
|
|
|
* buffer, AST_FRIENDLY_OFFSET.
|
2006-04-08 21:40:57 +00:00
|
|
|
*/
|
|
|
|
len = sizeof(*pvt) + t->desc_size;
|
|
|
|
if (t->buf_size)
|
|
|
|
len += AST_FRIENDLY_OFFSET + t->buf_size;
|
|
|
|
pvt = ast_calloc(1, len);
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (!pvt) {
|
2006-04-08 21:40:57 +00:00
|
|
|
return NULL;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
pvt->t = t;
|
|
|
|
ofs = (char *)(pvt + 1); /* pointer to data space */
|
|
|
|
if (t->desc_size) { /* first comes the descriptor */
|
|
|
|
pvt->pvt = ofs;
|
|
|
|
ofs += t->desc_size;
|
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (t->buf_size) {/* finally buffer and header */
|
2008-06-26 17:06:17 +00:00
|
|
|
pvt->outbuf.c = ofs + AST_FRIENDLY_OFFSET;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
}
|
|
|
|
/* if a explicit destination format is provided, set that on the pvt so the
|
|
|
|
* translator will process it. */
|
|
|
|
if (explicit_dst) {
|
|
|
|
ast_format_copy(&pvt->explicit_dst, explicit_dst);
|
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
/* call local init routine, if present */
|
2013-01-01 17:10:42 +00:00
|
|
|
if (t->newpvt && t->newpvt(pvt)) {
|
2007-06-06 21:20:11 +00:00
|
|
|
ast_free(pvt);
|
2006-04-08 21:40:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2006-08-21 02:11:39 +00:00
|
|
|
ast_module_ref(t->module);
|
2006-04-08 21:40:57 +00:00
|
|
|
return pvt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy(struct ast_trans_pvt *pvt)
|
|
|
|
{
|
|
|
|
struct ast_translator *t = pvt->t;
|
|
|
|
|
|
|
|
if (t->destroy)
|
|
|
|
t->destroy(pvt);
|
2007-06-06 21:20:11 +00:00
|
|
|
ast_free(pvt);
|
2006-08-21 02:11:39 +00:00
|
|
|
ast_module_unref(t->module);
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
|
|
|
|
2010-06-03 17:09:11 +00:00
|
|
|
/*! \brief framein wrapper, deals with bound checks. */
|
2006-04-08 21:40:57 +00:00
|
|
|
static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int samples = pvt->samples; /* initial value */
|
2011-02-03 16:22:10 +00:00
|
|
|
|
2006-05-31 16:56:50 +00:00
|
|
|
/* Copy the last in jb timing info to the pvt */
|
Merged revisions 98943 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r98943 | russell | 2008-01-15 17:26:52 -0600 (Tue, 15 Jan 2008) | 25 lines
Commit a fix for some memory access errors pointed out by the valgrind2.txt
output on issue #11698.
The issue here is that it is possible for an instance of a translator to get
destroyed while the frame allocated as a part of the translator is still being
processed. Specifically, this is possible anywhere between a call to ast_read()
and ast_frame_free(), which is _a lot_ of places in the code. The reason this
happens is that the channel might get masqueraded during this time. During a
masquerade, existing translation paths get destroyed.
So, this patch fixes the issue in an API and ABI compatible way. (This one is
for you, paravoid!)
It changes an int in ast_frame to be used as flag bits. The 1 bit is still used
to indicate that the frame contains timing information. Also, a second flag has
been added to indicate that the frame came from a translator. When a frame with
this flag gets released and has this flag, a function is called in translate.c to
let it know that this frame is doing being processed. At this point, the flag gets
cleared. Also, if the translator was requested to be destroyed while its internal
frame still had this flag set, its destruction has been deffered until it finds out
that the frame is no longer being processed.
Admittedly, this feels like a hack. But, it does fix the issue, and I was not able
to think of a better solution ...
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98944 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-15 23:31:53 +00:00
|
|
|
ast_copy_flags(&pvt->f, f, AST_FRFLAG_HAS_TIMING_INFO);
|
2006-05-31 16:56:50 +00:00
|
|
|
pvt->f.ts = f->ts;
|
|
|
|
pvt->f.len = f->len;
|
|
|
|
pvt->f.seqno = f->seqno;
|
2006-04-08 21:40:57 +00:00
|
|
|
|
|
|
|
if (f->samples == 0) {
|
|
|
|
ast_log(LOG_WARNING, "no samples for %s\n", pvt->t->name);
|
|
|
|
}
|
|
|
|
if (pvt->t->buffer_samples) { /* do not pass empty frames to callback */
|
2010-06-03 17:09:11 +00:00
|
|
|
if (f->datalen == 0) { /* perform native PLC if available */
|
|
|
|
/* If the codec has native PLC, then do that */
|
2007-05-24 15:28:29 +00:00
|
|
|
if (!pvt->t->native_plc)
|
|
|
|
return 0;
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
|
|
|
if (pvt->samples + f->samples > pvt->t->buffer_samples) {
|
|
|
|
ast_log(LOG_WARNING, "Out of buffer space\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we require a framein routine, wouldn't know how to do
|
|
|
|
* it otherwise.
|
|
|
|
*/
|
|
|
|
ret = pvt->t->framein(pvt, f);
|
|
|
|
/* diagnostic ... */
|
|
|
|
if (pvt->samples == samples)
|
|
|
|
ast_log(LOG_WARNING, "%s did not update samples %d\n",
|
|
|
|
pvt->t->name, pvt->samples);
|
2008-03-04 23:04:29 +00:00
|
|
|
return ret;
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
|
|
|
|
2006-06-04 08:15:41 +00:00
|
|
|
/*! \brief generic frameout routine.
|
2006-04-08 21:40:57 +00:00
|
|
|
* If samples and datalen are 0, take whatever is in pvt
|
|
|
|
* and reset them, otherwise take the values in the caller and
|
|
|
|
* leave alone the pvt values.
|
|
|
|
*/
|
|
|
|
struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt,
|
|
|
|
int datalen, int samples)
|
|
|
|
{
|
|
|
|
struct ast_frame *f = &pvt->f;
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (samples) {
|
2006-04-08 21:40:57 +00:00
|
|
|
f->samples = samples;
|
2011-02-03 16:22:10 +00:00
|
|
|
} else {
|
2006-04-08 21:40:57 +00:00
|
|
|
if (pvt->samples == 0)
|
|
|
|
return NULL;
|
|
|
|
f->samples = pvt->samples;
|
|
|
|
pvt->samples = 0;
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (datalen) {
|
2006-04-08 21:40:57 +00:00
|
|
|
f->datalen = datalen;
|
2011-02-03 16:22:10 +00:00
|
|
|
} else {
|
2006-04-08 21:40:57 +00:00
|
|
|
f->datalen = pvt->datalen;
|
|
|
|
pvt->datalen = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
f->frametype = AST_FRAME_VOICE;
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_copy(&f->subclass.format, &pvt->t->dst_format);
|
2006-04-08 21:40:57 +00:00
|
|
|
f->mallocd = 0;
|
|
|
|
f->offset = AST_FRIENDLY_OFFSET;
|
|
|
|
f->src = pvt->t->name;
|
2008-06-26 17:06:17 +00:00
|
|
|
f->data.ptr = pvt->outbuf.c;
|
2008-01-14 17:39:31 +00:00
|
|
|
|
2009-10-21 03:09:04 +00:00
|
|
|
return ast_frisolate(f);
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_frame *default_frameout(struct ast_trans_pvt *pvt)
|
|
|
|
{
|
|
|
|
return ast_trans_frameout(pvt, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end of callback wrappers and helpers */
|
|
|
|
|
1999-12-05 02:03:40 +00:00
|
|
|
void ast_translator_free_path(struct ast_trans_pvt *p)
|
|
|
|
{
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_trans_pvt *pn = p;
|
|
|
|
while ( (p = pn) ) {
|
|
|
|
pn = p->next;
|
|
|
|
destroy(p);
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-04 08:15:41 +00:00
|
|
|
/*! \brief Build a chain of translators based upon the given source and dest formats */
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dst, struct ast_format *src)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_trans_pvt *head = NULL, *tail = NULL;
|
2011-02-03 16:22:10 +00:00
|
|
|
int src_index, dst_index;
|
|
|
|
struct ast_format tmp_fmt1;
|
|
|
|
struct ast_format tmp_fmt2;
|
|
|
|
|
|
|
|
src_index = format2index(src->id);
|
|
|
|
dst_index = format2index(dst->id);
|
2008-08-06 03:29:42 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (src_index == -1 || dst_index == -1) {
|
|
|
|
ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src_index == -1 ? "starting" : "ending");
|
2008-08-06 03:29:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
while (src_index != dst_index) {
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_trans_pvt *cur;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
struct ast_format *explicit_dst = NULL;
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_translator *t = matrix_get(src_index, dst_index)->step;
|
2006-04-08 21:40:57 +00:00
|
|
|
if (!t) {
|
2011-02-03 16:22:10 +00:00
|
|
|
int src_id = index2format(src_index);
|
|
|
|
int dst_id = index2format(dst_index);
|
|
|
|
ast_log(LOG_WARNING, "No translator path from %s to %s\n",
|
|
|
|
ast_getformatname(ast_format_set(&tmp_fmt1, src_id, 0)),
|
|
|
|
ast_getformatname(ast_format_set(&tmp_fmt2, dst_id, 0)));
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2000-01-05 20:03:55 +00:00
|
|
|
return NULL;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (dst_index == t->dst_fmt_index) {
|
|
|
|
explicit_dst = dst;
|
|
|
|
}
|
|
|
|
if (!(cur = newpvt(t, explicit_dst))) {
|
2011-02-03 16:22:10 +00:00
|
|
|
int src_id = index2format(src_index);
|
|
|
|
int dst_id = index2format(dst_index);
|
2009-11-04 14:05:12 +00:00
|
|
|
ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_getformatname(ast_format_set(&tmp_fmt1, src_id, 0)),
|
|
|
|
ast_getformatname(ast_format_set(&tmp_fmt2, dst_id, 0)));
|
|
|
|
if (head) {
|
|
|
|
ast_translator_free_path(head);
|
|
|
|
}
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2005-07-25 19:10:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!head) {
|
2006-04-08 21:40:57 +00:00
|
|
|
head = cur;
|
2011-02-03 16:22:10 +00:00
|
|
|
} else {
|
2006-04-08 21:40:57 +00:00
|
|
|
tail->next = cur;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
tail = cur;
|
|
|
|
cur->nextin = cur->nextout = ast_tv(0, 0);
|
2005-07-25 19:10:38 +00:00
|
|
|
/* Keep going if this isn't the final destination */
|
2011-02-03 16:22:10 +00:00
|
|
|
src_index = cur->t->dst_fmt_index;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-04-08 21:40:57 +00:00
|
|
|
return head;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*! \brief do the actual translation */
|
2001-03-22 04:20:13 +00:00
|
|
|
struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_trans_pvt *p = path;
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_frame *out;
|
2004-04-20 15:28:58 +00:00
|
|
|
struct timeval delivery;
|
2006-05-31 16:56:50 +00:00
|
|
|
int has_timing_info;
|
|
|
|
long ts;
|
|
|
|
long len;
|
|
|
|
int seqno;
|
|
|
|
|
Merged revisions 98943 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r98943 | russell | 2008-01-15 17:26:52 -0600 (Tue, 15 Jan 2008) | 25 lines
Commit a fix for some memory access errors pointed out by the valgrind2.txt
output on issue #11698.
The issue here is that it is possible for an instance of a translator to get
destroyed while the frame allocated as a part of the translator is still being
processed. Specifically, this is possible anywhere between a call to ast_read()
and ast_frame_free(), which is _a lot_ of places in the code. The reason this
happens is that the channel might get masqueraded during this time. During a
masquerade, existing translation paths get destroyed.
So, this patch fixes the issue in an API and ABI compatible way. (This one is
for you, paravoid!)
It changes an int in ast_frame to be used as flag bits. The 1 bit is still used
to indicate that the frame contains timing information. Also, a second flag has
been added to indicate that the frame came from a translator. When a frame with
this flag gets released and has this flag, a function is called in translate.c to
let it know that this frame is doing being processed. At this point, the flag gets
cleared. Also, if the translator was requested to be destroyed while its internal
frame still had this flag set, its destruction has been deffered until it finds out
that the frame is no longer being processed.
Admittedly, this feels like a hack. But, it does fix the issue, and I was not able
to think of a better solution ...
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98944 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-15 23:31:53 +00:00
|
|
|
has_timing_info = ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO);
|
2006-05-31 16:56:50 +00:00
|
|
|
ts = f->ts;
|
|
|
|
len = f->len;
|
|
|
|
seqno = f->seqno;
|
2006-04-08 21:40:57 +00:00
|
|
|
|
2005-07-15 23:00:47 +00:00
|
|
|
if (!ast_tvzero(f->delivery)) {
|
|
|
|
if (!ast_tvzero(path->nextin)) {
|
2004-04-05 20:47:44 +00:00
|
|
|
/* Make sure this is in line with what we were expecting */
|
2005-07-15 23:00:47 +00:00
|
|
|
if (!ast_tveq(path->nextin, f->delivery)) {
|
2004-04-05 20:47:44 +00:00
|
|
|
/* The time has changed between what we expected and this
|
2005-07-25 19:41:39 +00:00
|
|
|
most recent time on the new packet. If we have a
|
|
|
|
valid prediction adjust our output time appropriately */
|
|
|
|
if (!ast_tvzero(path->nextout)) {
|
|
|
|
path->nextout = ast_tvadd(path->nextout,
|
|
|
|
ast_tvsub(f->delivery, path->nextin));
|
|
|
|
}
|
2005-07-15 23:00:47 +00:00
|
|
|
path->nextin = f->delivery;
|
2004-04-05 20:47:44 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This is our first pass. Make sure the timing looks good */
|
2005-07-15 23:00:47 +00:00
|
|
|
path->nextin = f->delivery;
|
|
|
|
path->nextout = f->delivery;
|
2004-04-05 20:47:44 +00:00
|
|
|
}
|
|
|
|
/* Predict next incoming sample */
|
2011-02-03 16:22:10 +00:00
|
|
|
path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(&f->subclass.format)));
|
2004-04-05 19:45:53 +00:00
|
|
|
}
|
2005-07-15 23:00:47 +00:00
|
|
|
delivery = f->delivery;
|
2011-02-03 16:22:10 +00:00
|
|
|
for (out = f; out && p ; p = p->next) {
|
2006-04-08 21:40:57 +00:00
|
|
|
framein(p, out);
|
2011-02-03 16:22:10 +00:00
|
|
|
if (out != f) {
|
2008-01-31 23:14:57 +00:00
|
|
|
ast_frfree(out);
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
out = p->t->frameout(p);
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (consume) {
|
2001-03-22 04:20:13 +00:00
|
|
|
ast_frfree(f);
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
if (out == NULL) {
|
2006-04-08 21:40:57 +00:00
|
|
|
return NULL;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
/* we have a frame, play with times */
|
|
|
|
if (!ast_tvzero(delivery)) {
|
|
|
|
/* Regenerate prediction after a discontinuity */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (ast_tvzero(path->nextout)) {
|
2006-04-08 21:40:57 +00:00
|
|
|
path->nextout = ast_tvnow();
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
|
|
|
|
/* Use next predicted outgoing timestamp */
|
|
|
|
out->delivery = path->nextout;
|
2011-02-03 16:22:10 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/* Predict next outgoing timestamp from samples in this
|
|
|
|
frame. */
|
2011-02-03 16:22:10 +00:00
|
|
|
path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(&out->subclass.format)));
|
2006-04-08 21:40:57 +00:00
|
|
|
} else {
|
|
|
|
out->delivery = ast_tv(0, 0);
|
Merged revisions 98943 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r98943 | russell | 2008-01-15 17:26:52 -0600 (Tue, 15 Jan 2008) | 25 lines
Commit a fix for some memory access errors pointed out by the valgrind2.txt
output on issue #11698.
The issue here is that it is possible for an instance of a translator to get
destroyed while the frame allocated as a part of the translator is still being
processed. Specifically, this is possible anywhere between a call to ast_read()
and ast_frame_free(), which is _a lot_ of places in the code. The reason this
happens is that the channel might get masqueraded during this time. During a
masquerade, existing translation paths get destroyed.
So, this patch fixes the issue in an API and ABI compatible way. (This one is
for you, paravoid!)
It changes an int in ast_frame to be used as flag bits. The 1 bit is still used
to indicate that the frame contains timing information. Also, a second flag has
been added to indicate that the frame came from a translator. When a frame with
this flag gets released and has this flag, a function is called in translate.c to
let it know that this frame is doing being processed. At this point, the flag gets
cleared. Also, if the translator was requested to be destroyed while its internal
frame still had this flag set, its destruction has been deffered until it finds out
that the frame is no longer being processed.
Admittedly, this feels like a hack. But, it does fix the issue, and I was not able
to think of a better solution ...
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98944 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-15 23:31:53 +00:00
|
|
|
ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
|
2006-05-31 16:56:50 +00:00
|
|
|
if (has_timing_info) {
|
|
|
|
out->ts = ts;
|
|
|
|
out->len = len;
|
|
|
|
out->seqno = seqno;
|
|
|
|
}
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
/* Invalidate prediction if we're entering a silence period */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (out->frametype == AST_FRAME_CNG) {
|
2006-04-08 21:40:57 +00:00
|
|
|
path->nextout = ast_tv(0, 0);
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2009-10-21 16:46:22 +00:00
|
|
|
return out;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Compute the computational cost of a single translation step.
|
|
|
|
*
|
|
|
|
* \note This function is only used to decide which translation path to
|
|
|
|
* use between two translators with identical src and dst formats. Computational
|
|
|
|
* cost acts only as a tie breaker. This is done so hardware translators
|
|
|
|
* can naturally have precedence over software translators.
|
|
|
|
*/
|
|
|
|
static void generate_computational_cost(struct ast_translator *t, int seconds)
|
2004-05-17 22:59:27 +00:00
|
|
|
{
|
2008-01-10 23:33:24 +00:00
|
|
|
int num_samples = 0;
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_trans_pvt *pvt;
|
2007-09-29 00:19:15 +00:00
|
|
|
struct rusage start;
|
|
|
|
struct rusage end;
|
2004-05-17 22:59:27 +00:00
|
|
|
int cost;
|
2011-02-03 16:22:10 +00:00
|
|
|
int out_rate = ast_format_rate(&t->dst_format);
|
2005-11-14 19:00:38 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!seconds) {
|
2006-04-08 21:40:57 +00:00
|
|
|
seconds = 1;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
|
2004-05-17 22:59:27 +00:00
|
|
|
/* If they don't make samples, give them a terrible score */
|
|
|
|
if (!t->sample) {
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_debug(3, "Translator '%s' does not produce sample frames.\n", t->name);
|
2011-02-03 16:22:10 +00:00
|
|
|
t->comp_cost = 999999;
|
2004-05-17 22:59:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-10 23:33:24 +00:00
|
|
|
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
pvt = newpvt(t, NULL);
|
2004-05-17 22:59:27 +00:00
|
|
|
if (!pvt) {
|
|
|
|
ast_log(LOG_WARNING, "Translator '%s' appears to be broken and will probably fail.\n", t->name);
|
2011-02-03 16:22:10 +00:00
|
|
|
t->comp_cost = 999999;
|
2004-05-17 22:59:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-10 23:33:24 +00:00
|
|
|
|
2007-09-29 00:19:15 +00:00
|
|
|
getrusage(RUSAGE_SELF, &start);
|
2008-01-10 23:33:24 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/* Call the encoder until we've processed the required number of samples */
|
2008-01-10 23:33:24 +00:00
|
|
|
while (num_samples < seconds * out_rate) {
|
2006-04-08 21:40:57 +00:00
|
|
|
struct ast_frame *f = t->sample();
|
2004-05-17 22:59:27 +00:00
|
|
|
if (!f) {
|
|
|
|
ast_log(LOG_WARNING, "Translator '%s' failed to produce a sample frame.\n", t->name);
|
2006-04-08 21:40:57 +00:00
|
|
|
destroy(pvt);
|
2011-02-03 16:22:10 +00:00
|
|
|
t->comp_cost = 999999;
|
2004-05-17 22:59:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
framein(pvt, f);
|
2004-05-17 22:59:27 +00:00
|
|
|
ast_frfree(f);
|
2006-07-10 19:05:48 +00:00
|
|
|
while ((f = t->frameout(pvt))) {
|
2008-01-10 23:33:24 +00:00
|
|
|
num_samples += f->samples;
|
2006-04-08 21:40:57 +00:00
|
|
|
ast_frfree(f);
|
2004-05-17 22:59:27 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 23:33:24 +00:00
|
|
|
|
2007-09-29 00:19:15 +00:00
|
|
|
getrusage(RUSAGE_SELF, &end);
|
2008-01-10 23:33:24 +00:00
|
|
|
|
|
|
|
cost = ((end.ru_utime.tv_sec - start.ru_utime.tv_sec) * 1000000) + end.ru_utime.tv_usec - start.ru_utime.tv_usec;
|
|
|
|
cost += ((end.ru_stime.tv_sec - start.ru_stime.tv_sec) * 1000000) + end.ru_stime.tv_usec - start.ru_stime.tv_usec;
|
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
destroy(pvt);
|
2008-01-10 23:33:24 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
t->comp_cost = cost / seconds;
|
2008-01-10 23:33:24 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!t->comp_cost) {
|
|
|
|
t->comp_cost = 1;
|
|
|
|
}
|
2004-05-17 22:59:27 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
*
|
|
|
|
* \brief If no table cost value was pre set by the translator. An attempt is made to
|
|
|
|
* automatically generate that cost value from the cost table based on our src and
|
|
|
|
* dst formats.
|
|
|
|
*
|
|
|
|
* \note This function allows older translators built before the translation cost
|
|
|
|
* changed away from using onely computational time to continue to be registered
|
|
|
|
* correctly. It is expected that translators built after the introduction of this
|
|
|
|
* function will manually assign their own table cost value.
|
|
|
|
*
|
|
|
|
* \note This function is safe to use on any audio formats that used to be defined in the
|
|
|
|
* first 64 bits of the old bit field codec representation.
|
|
|
|
*
|
|
|
|
* \retval Table Cost value greater than 0.
|
|
|
|
* \retval 0 on error.
|
|
|
|
*/
|
|
|
|
static int generate_table_cost(struct ast_format *src, struct ast_format *dst)
|
2010-08-12 20:17:17 +00:00
|
|
|
{
|
|
|
|
int src_rate = ast_format_rate(src);
|
2011-02-03 16:22:10 +00:00
|
|
|
int src_ll = 0;
|
2010-08-12 20:17:17 +00:00
|
|
|
int dst_rate = ast_format_rate(dst);
|
2011-02-03 16:22:10 +00:00
|
|
|
int dst_ll = 0;
|
2010-08-12 20:17:17 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if ((AST_FORMAT_GET_TYPE(src->id) != AST_FORMAT_TYPE_AUDIO) || (AST_FORMAT_GET_TYPE(dst->id) != AST_FORMAT_TYPE_AUDIO)) {
|
|
|
|
/* This method of generating table cost is limited to audio.
|
|
|
|
* Translators for media other than audio must manually set their
|
|
|
|
* table cost. */
|
|
|
|
return 0;
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
src_ll = ast_format_is_slinear(src);
|
|
|
|
dst_ll = ast_format_is_slinear(dst);
|
2011-02-03 16:22:10 +00:00
|
|
|
if (src_ll) {
|
|
|
|
if (dst_ll && (src_rate == dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LL_ORIGSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate == dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LY_ORIGSAMP;
|
|
|
|
} else if (dst_ll && (src_rate < dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LL_UPSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate < dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LY_UPSAMP;
|
|
|
|
} else if (dst_ll && (src_rate > dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LL_DOWNSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate > dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LL_LY_DOWNSAMP;
|
|
|
|
} else {
|
|
|
|
return AST_TRANS_COST_LL_UNKNOWN;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (dst_ll && (src_rate == dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LL_ORIGSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate == dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LY_ORIGSAMP;
|
|
|
|
} else if (dst_ll && (src_rate < dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LL_UPSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate < dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LY_UPSAMP;
|
|
|
|
} else if (dst_ll && (src_rate > dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LL_DOWNSAMP;
|
|
|
|
} else if (!dst_ll && (src_rate > dst_rate)) {
|
|
|
|
return AST_TRANS_COST_LY_LY_DOWNSAMP;
|
|
|
|
} else {
|
|
|
|
return AST_TRANS_COST_LY_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*!
|
|
|
|
* \brief rebuild a translation matrix.
|
|
|
|
* \note This function expects the list of translators to be locked
|
2006-01-11 05:00:45 +00:00
|
|
|
*/
|
2011-02-03 16:22:10 +00:00
|
|
|
static void matrix_rebuild(int samples)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
|
|
|
struct ast_translator *t;
|
2011-02-03 16:22:10 +00:00
|
|
|
int newtablecost;
|
2006-07-10 19:05:48 +00:00
|
|
|
int x; /* source format index */
|
|
|
|
int y; /* intermediate format index */
|
|
|
|
int z; /* destination format index */
|
2005-11-14 19:00:38 +00:00
|
|
|
|
2007-06-24 18:51:41 +00:00
|
|
|
ast_debug(1, "Resetting translation matrix\n");
|
2006-02-25 05:11:44 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
matrix_clear();
|
2006-04-18 21:39:20 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/* first, compute all direct costs */
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_TRAVERSE(&translators, t, list) {
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!t->active) {
|
2006-10-31 22:19:08 +00:00
|
|
|
continue;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
x = t->src_fmt_index;
|
|
|
|
z = t->dst_fmt_index;
|
2010-08-12 20:17:17 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (samples) {
|
|
|
|
generate_computational_cost(t, samples);
|
|
|
|
}
|
2010-08-12 20:17:17 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* This new translator is the best choice if any of the below are true.
|
2010-08-12 20:17:17 +00:00
|
|
|
* 1. no translation path is set between x and z yet.
|
2011-02-03 16:22:10 +00:00
|
|
|
* 2. the new table cost is less.
|
|
|
|
* 3. the new computational cost is less. Computational cost is only used
|
|
|
|
* to break a tie between two identical translation paths.
|
2010-08-12 20:17:17 +00:00
|
|
|
*/
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!matrix_get(x, z)->step ||
|
|
|
|
(t->table_cost < matrix_get(x, z)->step->table_cost) ||
|
|
|
|
(t->comp_cost < matrix_get(x, z)->step->comp_cost)) {
|
2010-08-12 20:17:17 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
matrix_get(x, z)->step = t;
|
|
|
|
matrix_get(x, z)->table_cost = t->table_cost;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-18 21:39:20 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/*
|
|
|
|
* For each triple x, y, z of distinct formats, check if there is
|
|
|
|
* a path from x to z through y which is cheaper than what is
|
|
|
|
* currently known, and in case, update the matrix.
|
|
|
|
* Repeat until the matrix is stable.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
int changed = 0;
|
2011-02-03 16:22:10 +00:00
|
|
|
for (x = 0; x < cur_max_index; x++) { /* source format */
|
|
|
|
for (y = 0; y < cur_max_index; y++) { /* intermediate format */
|
|
|
|
if (x == y) { /* skip ourselves */
|
2006-02-25 05:11:44 +00:00
|
|
|
continue;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
for (z = 0; z < cur_max_index; z++) { /* dst format */
|
|
|
|
if ((z == x || z == y) || /* skip null conversions */
|
|
|
|
!matrix_get(x, y)->step || /* no path from x to y */
|
|
|
|
!matrix_get(y, z)->step) { /* no path from y to z */
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* calculate table cost from x->y->z */
|
|
|
|
newtablecost = matrix_get(x, y)->table_cost + matrix_get(y, z)->table_cost;
|
|
|
|
|
|
|
|
/* if no step already exists between x and z OR the new cost of using the intermediate
|
|
|
|
* step is cheaper, use this step. */
|
|
|
|
if (!matrix_get(x, z)->step || (newtablecost < matrix_get(x, z)->table_cost)) {
|
|
|
|
struct ast_format tmpx;
|
|
|
|
struct ast_format tmpy;
|
|
|
|
struct ast_format tmpz;
|
|
|
|
matrix_get(x, z)->step = matrix_get(x, y)->step;
|
|
|
|
matrix_get(x, z)->table_cost = newtablecost;
|
|
|
|
matrix_get(x, z)->multistep = 1;
|
|
|
|
changed++;
|
|
|
|
ast_debug(3, "Discovered %d cost path from %s to %s, via %s\n",
|
|
|
|
matrix_get(x, z)->table_cost,
|
|
|
|
ast_getformatname(ast_format_set(&tmpx, index2format(x), 0)),
|
|
|
|
ast_getformatname(ast_format_set(&tmpy, index2format(z), 0)),
|
|
|
|
ast_getformatname(ast_format_set(&tmpz, index2format(y), 0)));
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
2006-02-25 05:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!changed) {
|
2006-04-08 21:40:57 +00:00
|
|
|
break;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
|
2010-08-12 20:17:17 +00:00
|
|
|
const char *ast_translate_path_to_str(struct ast_trans_pvt *p, struct ast_str **str)
|
|
|
|
{
|
|
|
|
struct ast_trans_pvt *pn = p;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
char tmp[256];
|
2010-08-12 20:17:17 +00:00
|
|
|
|
|
|
|
if (!p || !p->t) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_set(str, 0, "%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), p->t->src_format.id));
|
2010-08-12 20:17:17 +00:00
|
|
|
|
|
|
|
while ( (p = pn) ) {
|
|
|
|
pn = p->next;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(str, 0, "->%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), p->t->dst_format.id));
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ast_str_buffer(*str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *complete_trans_path_choice(const char *line, const char *word, int pos, int state)
|
|
|
|
{
|
|
|
|
int which = 0;
|
|
|
|
int wordlen = strlen(word);
|
|
|
|
int i;
|
|
|
|
char *ret = NULL;
|
|
|
|
size_t len = 0;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
const struct ast_format_list *format_list = ast_format_list_get(&len);
|
2010-08-12 20:17:17 +00:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (AST_FORMAT_GET_TYPE(format_list[i].format.id) != AST_FORMAT_TYPE_AUDIO) {
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strncasecmp(word, format_list[i].name, wordlen) && ++which > state) {
|
|
|
|
ret = ast_strdup(format_list[i].name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_format_list_destroy(format_list);
|
2010-08-12 20:17:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
static void handle_cli_recalc(struct ast_cli_args *a)
|
2006-09-18 19:54:18 +00:00
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
int time = a->argv[4] ? atoi(a->argv[4]) : 1;
|
2006-09-18 19:54:18 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (time <= 0) {
|
|
|
|
ast_cli(a->fd, " Recalc must be greater than 0. Defaulting to 1.\n");
|
|
|
|
time = 1;
|
2007-10-11 19:03:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (time > MAX_RECALC) {
|
|
|
|
ast_cli(a->fd, " Maximum limit of recalc exceeded by %d, truncating value to %d\n", time - MAX_RECALC, MAX_RECALC);
|
|
|
|
time = MAX_RECALC;
|
|
|
|
}
|
|
|
|
ast_cli(a->fd, " Recalculating Codec Translation (number of sample seconds: %d)\n\n", time);
|
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
|
|
|
matrix_rebuild(time);
|
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
|
|
|
}
|
2006-09-18 19:54:18 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
static char *handle_show_translation_table(struct ast_cli_args *a)
|
|
|
|
{
|
2011-02-23 23:55:58 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int i;
|
|
|
|
int k;
|
|
|
|
int curlen = 0;
|
|
|
|
int longest = 0;
|
|
|
|
int f_len;
|
|
|
|
size_t f_size = 0;
|
|
|
|
const struct ast_format_list *f_list = ast_format_list_get(&f_size);
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
struct ast_str *out = ast_str_create(1024);
|
|
|
|
|
2011-02-23 23:55:58 +00:00
|
|
|
f_len = f_size;
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
2007-10-11 19:03:06 +00:00
|
|
|
ast_cli(a->fd, " Translation times between formats (in microseconds) for one second of data\n");
|
|
|
|
ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n");
|
2011-02-03 16:22:10 +00:00
|
|
|
|
2006-09-18 19:54:18 +00:00
|
|
|
/* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
for (i = 0; i < f_len; i++) {
|
2010-08-12 20:17:17 +00:00
|
|
|
/* translation only applies to audio right now. */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (AST_FORMAT_GET_TYPE(f_list[i].format.id) != AST_FORMAT_TYPE_AUDIO)
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
curlen = strlen(ast_getformatname(&f_list[i].format));
|
2011-02-03 16:22:10 +00:00
|
|
|
if (curlen > longest) {
|
2006-09-18 19:54:18 +00:00
|
|
|
longest = curlen;
|
2009-03-12 17:32:13 +00:00
|
|
|
}
|
2006-09-18 19:54:18 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
for (i = -1; i < f_len; i++) {
|
|
|
|
x = -1;
|
|
|
|
if ((i >= 0) && ((x = format2index(f_list[i].format.id)) == -1)) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-08-12 20:17:17 +00:00
|
|
|
/* translation only applies to audio right now. */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (i >= 0 && (AST_FORMAT_GET_TYPE(f_list[i].format.id) != AST_FORMAT_TYPE_AUDIO)) {
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2008-01-11 00:54:54 +00:00
|
|
|
/*Go ahead and move to next iteration if dealing with an unknown codec*/
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (i >= 0 && !strcmp(ast_getformatname(&f_list[i].format), "unknown")) {
|
2008-01-11 00:54:54 +00:00
|
|
|
continue;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_set(&out, 0, " ");
|
|
|
|
for (k = -1; k < f_len; k++) {
|
|
|
|
y = -1;
|
|
|
|
if ((k >= 0) && ((y = format2index(f_list[k].format.id)) == -1)) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-08-12 20:17:17 +00:00
|
|
|
/* translation only applies to audio right now. */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (k >= 0 && (AST_FORMAT_GET_TYPE(f_list[k].format.id) != AST_FORMAT_TYPE_AUDIO)) {
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2008-01-11 00:54:54 +00:00
|
|
|
/*Go ahead and move to next iteration if dealing with an unknown codec*/
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (k >= 0 && !strcmp(ast_getformatname(&f_list[k].format), "unknown")) {
|
2008-01-11 00:54:54 +00:00
|
|
|
continue;
|
2009-03-12 17:32:13 +00:00
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (k >= 0) {
|
|
|
|
curlen = strlen(ast_getformatname(&f_list[k].format));
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
if (curlen < 5) {
|
2007-08-20 22:53:48 +00:00
|
|
|
curlen = 5;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x >= 0 && y >= 0 && matrix_get(x, y)->step) {
|
2009-03-12 17:32:13 +00:00
|
|
|
/* Actual codec output */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "%*d", curlen + 1, (matrix_get(x, y)->table_cost/100));
|
|
|
|
} else if (i == -1 && k >= 0) {
|
2006-09-18 19:54:18 +00:00
|
|
|
/* Top row - use a dynamic size */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "%*s", curlen + 1, ast_getformatname(&f_list[k].format));
|
|
|
|
} else if (k == -1 && i >= 0) {
|
2006-09-18 19:54:18 +00:00
|
|
|
/* Left column - use a static size. */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "%*s", longest, ast_getformatname(&f_list[i].format));
|
2006-09-18 19:54:18 +00:00
|
|
|
} else if (x >= 0 && y >= 0) {
|
2009-03-12 17:32:13 +00:00
|
|
|
/* Codec not supported */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "%*s", curlen + 1, "-");
|
2006-09-18 19:54:18 +00:00
|
|
|
} else {
|
2009-03-12 17:32:13 +00:00
|
|
|
/* Upper left hand corner */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "%*s", longest, "");
|
2006-09-18 19:54:18 +00:00
|
|
|
}
|
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&out, 0, "\n");
|
2009-03-12 17:32:13 +00:00
|
|
|
ast_cli(a->fd, "%s", ast_str_buffer(out));
|
2006-09-18 19:54:18 +00:00
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_free(out);
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_format_list_destroy(f_list);
|
2007-10-11 19:03:06 +00:00
|
|
|
return CLI_SUCCESS;
|
2006-09-18 19:54:18 +00:00
|
|
|
}
|
2000-01-05 20:03:55 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
static char *handle_show_translation_path(struct ast_cli_args *a)
|
|
|
|
{
|
|
|
|
struct ast_format input_src_format;
|
|
|
|
size_t len = 0;
|
|
|
|
int i;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
const struct ast_format_list *format_list = ast_format_list_get(&len);
|
|
|
|
struct ast_str *str = ast_str_alloca(1024);
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_translator *step;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
char tmp[256];
|
2011-02-03 16:22:10 +00:00
|
|
|
|
|
|
|
ast_format_clear(&input_src_format);
|
|
|
|
for (i = 0; i < len; i++) {
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (AST_FORMAT_GET_TYPE(format_list[i].format.id) != AST_FORMAT_TYPE_AUDIO) {
|
2011-02-03 16:22:10 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strncasecmp(format_list[i].name, a->argv[4], strlen(format_list[i].name))) {
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_format_copy(&input_src_format, &format_list[i].format);
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!input_src_format.id) {
|
|
|
|
ast_cli(a->fd, "Source codec \"%s\" is not found.\n", a->argv[4]);
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_format_list_destroy(format_list);
|
2011-02-03 16:22:10 +00:00
|
|
|
return CLI_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
|
|
|
ast_cli(a->fd, "--- Translation paths SRC Codec \"%s\" sample rate %d ---\n", a->argv[4], ast_format_rate(&input_src_format));
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
int src;
|
|
|
|
int dst;
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if ((AST_FORMAT_GET_TYPE(format_list[i].format.id) != AST_FORMAT_TYPE_AUDIO) || (format_list[i].format.id == input_src_format.id)) {
|
2011-02-03 16:22:10 +00:00
|
|
|
continue;
|
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
dst = format2index(format_list[i].format.id);
|
2011-02-03 16:22:10 +00:00
|
|
|
src = format2index(input_src_format.id);
|
|
|
|
ast_str_reset(str);
|
|
|
|
if ((len >= cur_max_index) && (src != -1) && (dst != -1) && matrix_get(src, dst)->step) {
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&str, 0, "%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), matrix_get(src, dst)->step->src_format.id));
|
2011-02-03 16:22:10 +00:00
|
|
|
while (src != dst) {
|
|
|
|
step = matrix_get(src, dst)->step;
|
|
|
|
if (!step) {
|
|
|
|
ast_str_reset(str);
|
|
|
|
break;
|
|
|
|
}
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_str_append(&str, 0, "->%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), step->dst_format.id));
|
2011-02-03 16:22:10 +00:00
|
|
|
src = step->dst_fmt_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_strlen_zero(ast_str_buffer(str))) {
|
|
|
|
ast_str_set(&str, 0, "No Translation Path");
|
|
|
|
}
|
|
|
|
ast_cli(a->fd, "\t%-10.10s To %-10.10s: %-60.60s\n", a->argv[4], format_list[i].name, ast_str_buffer(str));
|
|
|
|
}
|
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
|
|
|
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_format_list_destroy(format_list);
|
2011-02-03 16:22:10 +00:00
|
|
|
return CLI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
|
|
|
{
|
|
|
|
static const char * const option[] = { "recalc", "paths", NULL };
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case CLI_INIT:
|
|
|
|
e->command = "core show translation";
|
|
|
|
e->usage =
|
|
|
|
"Usage: 'core show translation' can be used in two ways.\n"
|
|
|
|
" 1. 'core show translation [recalc [<recalc seconds>]]\n"
|
|
|
|
" Displays known codec translators and the cost associated\n"
|
|
|
|
" with each conversion. If the argument 'recalc' is supplied along\n"
|
|
|
|
" with optional number of seconds to test a new test will be performed\n"
|
|
|
|
" as the chart is being displayed.\n"
|
|
|
|
" 2. 'core show translation paths [codec]'\n"
|
|
|
|
" This will display all the translation paths associated with a codec\n";
|
|
|
|
return NULL;
|
|
|
|
case CLI_GENERATE:
|
|
|
|
if (a->pos == 3) {
|
|
|
|
return ast_cli_complete(a->word, option, a->n);
|
|
|
|
}
|
|
|
|
if (a->pos == 4 && !strcasecmp(a->argv[3], option[1])) {
|
|
|
|
return complete_trans_path_choice(a->line, a->word, a->pos, a->n);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a->argc > 5)
|
|
|
|
return CLI_SHOWUSAGE;
|
|
|
|
|
|
|
|
if (a->argv[3] && !strcasecmp(a->argv[3], option[1]) && a->argc == 5) { /* show paths */
|
|
|
|
return handle_show_translation_path(a);
|
|
|
|
} else if (a->argv[3] && !strcasecmp(a->argv[3], option[0])) { /* recalc and then fall through to show table */
|
|
|
|
handle_cli_recalc(a);
|
|
|
|
} else if (a->argc > 3) { /* wrong input */
|
|
|
|
return CLI_SHOWUSAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return handle_show_translation_table(a);
|
|
|
|
}
|
|
|
|
|
2006-09-18 19:54:18 +00:00
|
|
|
static struct ast_cli_entry cli_translate[] = {
|
2007-10-22 20:05:18 +00:00
|
|
|
AST_CLI_DEFINE(handle_cli_core_show_translation, "Display translation matrix")
|
2006-09-18 19:54:18 +00:00
|
|
|
};
|
2000-01-05 20:03:55 +00:00
|
|
|
|
2006-06-04 08:15:41 +00:00
|
|
|
/*! \brief register codec translator */
|
2006-08-21 02:11:39 +00:00
|
|
|
int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
2006-10-25 14:55:11 +00:00
|
|
|
struct ast_translator *u;
|
2007-07-26 15:49:18 +00:00
|
|
|
char tmp[80];
|
2006-04-08 21:40:57 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (add_format2index(t->src_format.id) || add_format2index(t->dst_format.id)) {
|
|
|
|
if (matrix_resize(0)) {
|
|
|
|
ast_log(LOG_WARNING, "Translator matrix can not represent any more translators. Out of resources.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
add_format2index(t->src_format.id);
|
|
|
|
add_format2index(t->dst_format.id);
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
if (!mod) {
|
2006-04-14 14:08:19 +00:00
|
|
|
ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n");
|
2006-04-08 21:40:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2006-08-21 02:11:39 +00:00
|
|
|
|
|
|
|
if (!t->buf_size) {
|
2006-04-08 21:40:57 +00:00
|
|
|
ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!t->table_cost && !(t->table_cost = generate_table_cost(&t->src_format, &t->dst_format))) {
|
|
|
|
ast_log(LOG_WARNING, "Table cost could not be generated for %s, "
|
|
|
|
"Please set table_cost variable on translator.\n", t->name);
|
|
|
|
return -1;
|
|
|
|
}
|
2006-08-21 02:11:39 +00:00
|
|
|
|
|
|
|
t->module = mod;
|
2011-02-03 16:22:10 +00:00
|
|
|
t->src_fmt_index = format2index(t->src_format.id);
|
|
|
|
t->dst_fmt_index = format2index(t->dst_format.id);
|
2006-10-31 22:19:08 +00:00
|
|
|
t->active = 1;
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (t->src_fmt_index == -1 || t->dst_fmt_index == -1) {
|
|
|
|
ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->src_fmt_index == -1 ? "starting" : "ending");
|
2008-08-06 03:29:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (t->src_fmt_index >= cur_max_index) {
|
|
|
|
ast_log(LOG_WARNING, "Source format %s is larger than cur_max_index\n", ast_getformatname(&t->src_format));
|
2005-07-05 14:00:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (t->dst_fmt_index >= cur_max_index) {
|
|
|
|
ast_log(LOG_WARNING, "Destination format %s is larger than cur_max_index\n", ast_getformatname(&t->dst_format));
|
1999-12-05 02:03:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
if (t->buf_size) {
|
2008-03-04 23:04:29 +00:00
|
|
|
/*
|
|
|
|
* Align buf_size properly, rounding up to the machine-specific
|
|
|
|
* alignment for pointers.
|
|
|
|
*/
|
2006-04-08 21:40:57 +00:00
|
|
|
struct _test_align { void *a, *b; } p;
|
|
|
|
int align = (char *)&p.b - (char *)&p.a;
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2006-07-10 19:05:48 +00:00
|
|
|
t->buf_size = ((t->buf_size + align - 1) / align) * align;
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (t->frameout == NULL) {
|
2006-04-08 21:40:57 +00:00
|
|
|
t->frameout = default_frameout;
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
generate_computational_cost(t, 1);
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_verb(2, "Registered translator '%s' from format %s to %s, table cost, %d, computational cost %d\n",
|
|
|
|
term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
|
|
|
|
ast_getformatname(&t->src_format), ast_getformatname(&t->dst_format), t->table_cost, t->comp_cost);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2006-10-25 14:55:11 +00:00
|
|
|
/* find any existing translators that provide this same srcfmt/dstfmt,
|
2011-02-03 16:22:10 +00:00
|
|
|
and put this one in order based on computational cost */
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
|
2011-02-03 16:22:10 +00:00
|
|
|
if ((u->src_fmt_index == t->src_fmt_index) &&
|
|
|
|
(u->dst_fmt_index == t->dst_fmt_index) &&
|
|
|
|
(u->comp_cost > t->comp_cost)) {
|
2007-11-08 05:28:47 +00:00
|
|
|
AST_RWLIST_INSERT_BEFORE_CURRENT(t, list);
|
2006-10-25 14:55:11 +00:00
|
|
|
t = NULL;
|
2010-07-16 15:20:40 +00:00
|
|
|
break;
|
2006-10-25 14:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
2006-10-25 14:55:11 +00:00
|
|
|
|
|
|
|
/* if no existing translator was found for this format combination,
|
|
|
|
add it to the beginning of the list */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (t) {
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_INSERT_HEAD(&translators, t, list);
|
2011-02-03 16:22:10 +00:00
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
matrix_rebuild(0);
|
2006-10-31 22:19:08 +00:00
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
|
1999-12-05 02:03:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-14 19:00:38 +00:00
|
|
|
/*! \brief unregister codec translator */
|
1999-12-05 02:03:40 +00:00
|
|
|
int ast_unregister_translator(struct ast_translator *t)
|
|
|
|
{
|
2004-04-21 04:26:38 +00:00
|
|
|
char tmp[80];
|
2006-01-11 05:00:45 +00:00
|
|
|
struct ast_translator *u;
|
2006-10-30 22:27:56 +00:00
|
|
|
int found = 0;
|
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
|
|
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
|
1999-12-05 02:03:40 +00:00
|
|
|
if (u == t) {
|
2007-11-08 05:28:47 +00:00
|
|
|
AST_RWLIST_REMOVE_CURRENT(list);
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_verb(2, "Unregistered translator '%s' from format %s to %s\n",
|
|
|
|
term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
|
|
|
|
ast_getformatname(&t->src_format),
|
|
|
|
ast_getformatname(&t->dst_format));
|
2006-10-30 22:27:56 +00:00
|
|
|
found = 1;
|
1999-12-05 02:03:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
2006-10-30 22:27:56 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (found) {
|
|
|
|
matrix_rebuild(0);
|
|
|
|
}
|
2006-10-30 22:27:56 +00:00
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-10-30 22:27:56 +00:00
|
|
|
|
1999-12-05 02:03:40 +00:00
|
|
|
return (u ? 0 : -1);
|
|
|
|
}
|
|
|
|
|
2006-10-31 22:19:08 +00:00
|
|
|
void ast_translator_activate(struct ast_translator *t)
|
|
|
|
{
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
t->active = 1;
|
2011-02-03 16:22:10 +00:00
|
|
|
matrix_rebuild(0);
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ast_translator_deactivate(struct ast_translator *t)
|
|
|
|
{
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_WRLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
t->active = 0;
|
2011-02-03 16:22:10 +00:00
|
|
|
matrix_rebuild(0);
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-10-31 22:19:08 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 19:00:38 +00:00
|
|
|
/*! \brief Calculate our best translator source format, given costs, and a desired destination */
|
2011-02-03 16:22:10 +00:00
|
|
|
int ast_translator_best_choice(struct ast_format_cap *dst_cap,
|
|
|
|
struct ast_format_cap *src_cap,
|
|
|
|
struct ast_format *dst_fmt_out,
|
|
|
|
struct ast_format *src_fmt_out)
|
1999-12-05 02:03:40 +00:00
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
unsigned int besttablecost = INT_MAX;
|
|
|
|
unsigned int beststeps = INT_MAX;
|
|
|
|
struct ast_format best;
|
|
|
|
struct ast_format bestdst;
|
|
|
|
struct ast_format_cap *joint_cap = ast_format_cap_joint(dst_cap, src_cap);
|
|
|
|
ast_format_clear(&best);
|
|
|
|
ast_format_clear(&bestdst);
|
|
|
|
|
|
|
|
if (joint_cap) { /* yes, pick one and return */
|
|
|
|
struct ast_format tmp_fmt;
|
|
|
|
ast_format_cap_iter_start(joint_cap);
|
|
|
|
while (!ast_format_cap_iter_next(joint_cap, &tmp_fmt)) {
|
2010-08-12 20:17:17 +00:00
|
|
|
/* We are guaranteed to find one common format. */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!best.id) {
|
|
|
|
ast_format_copy(&best, &tmp_fmt);
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* If there are multiple common formats, pick the one with the highest sample rate */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (ast_format_rate(&best) < ast_format_rate(&tmp_fmt)) {
|
|
|
|
ast_format_copy(&best, &tmp_fmt);
|
2010-08-12 20:17:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
|
2004-12-06 21:53:57 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_cap_iter_end(joint_cap);
|
|
|
|
|
2006-04-08 21:40:57 +00:00
|
|
|
/* We are done, this is a common format to both. */
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_copy(dst_fmt_out, &best);
|
|
|
|
ast_format_copy(src_fmt_out, &best);
|
|
|
|
ast_format_cap_destroy(joint_cap);
|
2006-04-08 21:40:57 +00:00
|
|
|
return 0;
|
2010-08-12 20:17:17 +00:00
|
|
|
} else { /* No, we will need to translate */
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_format cur_dst;
|
|
|
|
struct ast_format cur_src;
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
2010-08-12 20:17:17 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_cap_iter_start(dst_cap);
|
|
|
|
while (!ast_format_cap_iter_next(dst_cap, &cur_dst)) {
|
|
|
|
ast_format_cap_iter_start(src_cap);
|
|
|
|
while (!ast_format_cap_iter_next(src_cap, &cur_src)) {
|
|
|
|
int x = format2index(cur_src.id);
|
|
|
|
int y = format2index(cur_dst.id);
|
|
|
|
if (x < 0 || y < 0) {
|
|
|
|
continue;
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!matrix_get(x, y) || !(matrix_get(x, y)->step)) {
|
|
|
|
continue;
|
2010-08-12 20:17:17 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
if (((matrix_get(x, y)->table_cost < besttablecost) || (matrix_get(x, y)->multistep < beststeps))) {
|
2006-04-08 21:40:57 +00:00
|
|
|
/* better than what we have so far */
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_copy(&best, &cur_src);
|
|
|
|
ast_format_copy(&bestdst, &cur_dst);
|
|
|
|
besttablecost = matrix_get(x, y)->table_cost;
|
|
|
|
beststeps = matrix_get(x, y)->multistep;
|
2004-12-06 21:53:57 +00:00
|
|
|
}
|
2006-02-25 05:11:44 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_cap_iter_end(src_cap);
|
2004-12-06 21:53:57 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
|
|
|
|
ast_format_cap_iter_end(dst_cap);
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2011-02-03 16:22:10 +00:00
|
|
|
if (best.id) {
|
|
|
|
ast_format_copy(dst_fmt_out, &bestdst);
|
|
|
|
ast_format_copy(src_fmt_out, &best);
|
|
|
|
return 0;
|
2006-04-08 21:40:57 +00:00
|
|
|
}
|
2011-02-03 16:22:10 +00:00
|
|
|
return -1;
|
1999-12-05 02:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-17 16:42:03 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
unsigned int ast_translate_path_steps(struct ast_format *dst_format, struct ast_format *src_format)
|
2006-04-17 16:42:03 +00:00
|
|
|
{
|
2006-10-25 14:55:11 +00:00
|
|
|
unsigned int res = -1;
|
2011-02-03 16:22:10 +00:00
|
|
|
int src, dest;
|
2006-04-18 21:39:20 +00:00
|
|
|
/* convert bitwise format numbers into array indices */
|
2011-02-03 16:22:10 +00:00
|
|
|
src = format2index(src_format->id);
|
|
|
|
dest = format2index(dst_format->id);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2008-08-06 03:29:42 +00:00
|
|
|
if (src == -1 || dest == -1) {
|
|
|
|
ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src == -1 ? "starting" : "ending");
|
|
|
|
return -1;
|
|
|
|
}
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (matrix_get(src, dest)->step) {
|
|
|
|
res = matrix_get(src, dest)->multistep + 1;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2006-11-02 18:01:10 +00:00
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
|
|
|
return res;
|
2006-04-17 16:42:03 +00:00
|
|
|
}
|
2006-07-10 19:05:48 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
void ast_translate_available_formats(struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result)
|
2006-10-25 14:55:11 +00:00
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
struct ast_format tmp_fmt;
|
2012-07-13 16:49:40 +00:00
|
|
|
struct ast_format cur_dest, cur_src;
|
2011-02-03 16:22:10 +00:00
|
|
|
int src_audio = 0;
|
|
|
|
int src_video = 0;
|
|
|
|
int index;
|
|
|
|
|
2012-07-13 16:49:40 +00:00
|
|
|
ast_format_cap_iter_start(dest);
|
|
|
|
while (!ast_format_cap_iter_next(dest, &cur_dest)) {
|
|
|
|
/* We give preference to a joint format structure if possible */
|
|
|
|
if (ast_format_cap_get_compatible_format(src, &cur_dest, &tmp_fmt)) {
|
|
|
|
ast_format_cap_add(result, &tmp_fmt);
|
|
|
|
} else {
|
|
|
|
/* Otherwise we just use the destination format */
|
|
|
|
ast_format_cap_add(result, &cur_dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_format_cap_iter_end(dest);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
|
|
|
/* if we don't have a source format, we just have to try all
|
|
|
|
possible destination formats */
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!src) {
|
|
|
|
return;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_cap_iter_start(src);
|
|
|
|
while (!ast_format_cap_iter_next(src, &cur_src)) {
|
|
|
|
/* If we have a source audio format, get its format index */
|
|
|
|
if (AST_FORMAT_GET_TYPE(cur_src.id) == AST_FORMAT_TYPE_AUDIO) {
|
|
|
|
src_audio = format2index(cur_src.id);
|
|
|
|
}
|
2006-10-26 16:35:34 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* If we have a source video format, get its format index */
|
|
|
|
if (AST_FORMAT_GET_TYPE(cur_src.id) == AST_FORMAT_TYPE_VIDEO) {
|
|
|
|
src_video = format2index(cur_src.id);
|
|
|
|
}
|
2006-10-26 16:35:34 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
AST_RWLIST_RDLOCK(&translators);
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* For a given source audio format, traverse the list of
|
|
|
|
known audio formats to determine whether there exists
|
|
|
|
a translation path from the source format to the
|
|
|
|
destination format. */
|
|
|
|
for (index = 0; (src_audio >= 0) && index < cur_max_index; index++) {
|
|
|
|
ast_format_set(&tmp_fmt, index2format(index), 0);
|
2009-11-04 14:05:12 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_AUDIO) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if this is not a desired format, nothing to do */
|
|
|
|
if (!ast_format_cap_iscompatible(dest, &tmp_fmt)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if the source is supplying this format, then
|
|
|
|
we can leave it in the result */
|
|
|
|
if (ast_format_cap_iscompatible(src, &tmp_fmt)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-30 22:27:56 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if we don't have a translation path from the src
|
|
|
|
to this format, remove it from the result */
|
|
|
|
if (!matrix_get(src_audio, index)->step) {
|
|
|
|
ast_format_cap_remove_byid(result, tmp_fmt.id);
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* now check the opposite direction */
|
|
|
|
if (!matrix_get(index, src_audio)->step) {
|
|
|
|
ast_format_cap_remove_byid(result, tmp_fmt.id);
|
|
|
|
}
|
2009-11-04 14:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* For a given source video format, traverse the list of
|
|
|
|
known video formats to determine whether there exists
|
|
|
|
a translation path from the source format to the
|
|
|
|
destination format. */
|
|
|
|
for (index = 0; (src_video >= 0) && index < cur_max_index; index++) {
|
|
|
|
ast_format_set(&tmp_fmt, index2format(index), 0);
|
|
|
|
if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_VIDEO) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if this is not a desired format, nothing to do */
|
|
|
|
if (!ast_format_cap_iscompatible(dest, &tmp_fmt)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if the source is supplying this format, then
|
|
|
|
we can leave it in the result */
|
|
|
|
if (ast_format_cap_iscompatible(src, &tmp_fmt)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-30 22:27:56 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* if we don't have a translation path from the src
|
|
|
|
to this format, remove it from the result */
|
|
|
|
if (!matrix_get(src_video, index)->step) {
|
|
|
|
ast_format_cap_remove_byid(result, tmp_fmt.id);
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
/* now check the opposite direction */
|
|
|
|
if (!matrix_get(index, src_video)->step) {
|
|
|
|
ast_format_cap_remove_byid(result, tmp_fmt.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AST_RWLIST_UNLOCK(&translators);
|
|
|
|
}
|
|
|
|
ast_format_cap_iter_end(src);
|
|
|
|
}
|
2006-10-25 14:55:11 +00:00
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
int ast_translate_init(void)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
ast_rwlock_init(&tablelock);
|
|
|
|
res = matrix_resize(1);
|
|
|
|
res |= ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
|
2006-10-25 14:55:11 +00:00
|
|
|
return res;
|
|
|
|
}
|