@ -104,30 +104,28 @@ struct ast_smoother {
/*! \brief Definition of supported media formats (codecs) */
static struct ast_format_list AST_FORMAT_LIST [ ] = {
{ 1 , AST_FORMAT_G723_1 , " g723 " , " G.723.1 " , 20 , 30 , 300 , 30 , 30 } , /*!< G723.1 */
{ 1 , AST_FORMAT_GSM , " gsm " , " GSM " , 33 , 20 , 300 , 20 , 20 } , /*!< codec_gsm.c */
{ 1 , AST_FORMAT_ULAW , " ulaw " , " G.711 u-law " , 80 , 10 , 150 , 10 , 20 } , /*!< codec_ulaw.c */
{ 1 , AST_FORMAT_ALAW , " alaw " , " G.711 A-law " , 80 , 10 , 150 , 10 , 20 } , /*!< codec_alaw.c */
{ 1 , AST_FORMAT_G726 , " g726 " , " G.726 RFC3551 " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_g726.c */
{ 1 , AST_FORMAT_ADPCM , " adpcm " , " ADPCM " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_adpcm.c */
{ 1 , AST_FORMAT_SLINEAR , " slin " , " 16 bit Signed Linear PCM " , 160 , 10 , 70 , 10 , 20 , AST_SMOOTHER_FLAG_BE } , /*!< Signed linear */
{ 1 , AST_FORMAT_LPC10 , " lpc10 " , " LPC10 " , 7 , 20 , 20 , 20 , 20 } , /*!< codec_lpc10.c */
{ 1 , AST_FORMAT_G729A , " g729 " , " G.729A " , 10 , 10 , 230 , 10 , 20 , AST_SMOOTHER_FLAG_G729 } , /*!< Binary commercial distribution */
{ 1 , AST_FORMAT_SPEEX , " speex " , " SpeeX " , 10 , 10 , 60 , 10 , 20 } , /*!< codec_speex.c */
{ 1 , AST_FORMAT_ILBC , " ilbc " , " iLBC " , 50 , 30 , 30 , 30 , 30 } , /*!< codec_ilbc.c */ /* inc=30ms - workaround */
{ 1 , AST_FORMAT_G726_AAL2 , " g726aal2 " , " G.726 AAL2 " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_g726.c */
{ 1 , AST_FORMAT_G722 , " g722 " , " G722 " , 80 , 10 , 150 , 10 , 20 } , /*!< G722 Passthrough */
{ 0 , AST_FORMAT_MAX_AUDIO , " maxaudio " , " Maximum audio format " } ,
{ 1 , AST_FORMAT_JPEG , " jpeg " , " JPEG image " } , /*!< See format_jpeg.c */
{ 1 , AST_FORMAT_PNG , " png " , " PNG image " } , /*!< PNG Image format */
{ 1 , AST_FORMAT_H261 , " h261 " , " H.261 Video " } , /*!< H.261 Video Passthrough */
{ 1 , AST_FORMAT_H263 , " h263 " , " H.263 Video " } , /*!< H.263 Passthrough support, see format_h263.c */
{ 1 , AST_FORMAT_H263_PLUS , " h263p " , " H.263+ Video " } , /*!< H.263plus passthrough support See format_h263.c */
{ 1 , AST_FORMAT_H264 , " h264 " , " H.264 Video " } , /*!< Passthrough support, see format_h263.c */
{ 1 , AST_FORMAT_MP4_VIDEO , " mpeg4 " , " MPEG4 Video " } , /*!< Passthrough support for MPEG4 */
{ 0 , AST_FORMAT_MAX_VIDEO , " maxvideo " , " Maximum video format " } ,
{ 1 , AST_FORMAT_T140 , " t140 " , " Passthrough T.140 Realtime Text " } , /*!< Passthrough support for T.140 Realtime Text */
{ 0 , AST_FORMAT_MAX_TEXT , " maxtext " , " Maximum text format " } ,
{ AST_FORMAT_G723_1 , " g723 " , 8000 , " G.723.1 " , 20 , 30 , 300 , 30 , 30 } , /*!< G723.1 */
{ AST_FORMAT_GSM , " gsm " , 8000 , " GSM " , 33 , 20 , 300 , 20 , 20 } , /*!< codec_gsm.c */
{ AST_FORMAT_ULAW , " ulaw " , 8000 , " G.711 u-law " , 80 , 10 , 150 , 10 , 20 } , /*!< codec_ulaw.c */
{ AST_FORMAT_ALAW , " alaw " , 8000 , " G.711 A-law " , 80 , 10 , 150 , 10 , 20 } , /*!< codec_alaw.c */
{ AST_FORMAT_G726 , " g726 " , 8000 , " G.726 RFC3551 " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_g726.c */
{ AST_FORMAT_ADPCM , " adpcm " , 8000 , " ADPCM " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_adpcm.c */
{ AST_FORMAT_SLINEAR , " slin " , 8000 , " 16 bit Signed Linear PCM " , 160 , 10 , 70 , 10 , 20 , AST_SMOOTHER_FLAG_BE } , /*!< Signed linear */
{ AST_FORMAT_LPC10 , " lpc10 " , 8000 , " LPC10 " , 7 , 20 , 20 , 20 , 20 } , /*!< codec_lpc10.c */
{ AST_FORMAT_G729A , " g729 " , 8000 , " G.729A " , 10 , 10 , 230 , 10 , 20 , AST_SMOOTHER_FLAG_G729 } , /*!< Binary commercial distribution */
{ AST_FORMAT_SPEEX , " speex " , 8000 , " SpeeX " , 10 , 10 , 60 , 10 , 20 } , /*!< codec_speex.c */
{ AST_FORMAT_ILBC , " ilbc " , 8000 , " iLBC " , 50 , 30 , 30 , 30 , 30 } , /*!< codec_ilbc.c */ /* inc=30ms - workaround */
{ AST_FORMAT_G726_AAL2 , " g726aal2 " , 8000 , " G.726 AAL2 " , 40 , 10 , 300 , 10 , 20 } , /*!< codec_g726.c */
{ AST_FORMAT_G722 , " g722 " , 16000 , " G722 " , 80 , 10 , 150 , 10 , 20 } , /*!< codec_g722.c */
{ AST_FORMAT_SLINEAR16 , " slin16 " , 16000 , " 16 bit Signed Linear PCM (16kHz) " , 320 , 10 , 70 , 10 , 20 } , /*!< Signed linear (16kHz) */
{ AST_FORMAT_JPEG , " jpeg " , 0 , " JPEG image " } , /*!< See format_jpeg.c */
{ AST_FORMAT_PNG , " png " , 0 , " PNG image " } , /*!< PNG Image format */
{ AST_FORMAT_H261 , " h261 " , 0 , " H.261 Video " } , /*!< H.261 Video Passthrough */
{ AST_FORMAT_H263 , " h263 " , 0 , " H.263 Video " } , /*!< H.263 Passthrough support, see format_h263.c */
{ AST_FORMAT_H263_PLUS , " h263p " , 0 , " H.263+ Video " } , /*!< H.263plus passthrough support See format_h263.c */
{ AST_FORMAT_H264 , " h264 " , 0 , " H.264 Video " } , /*!< Passthrough support, see format_h263.c */
{ AST_FORMAT_MP4_VIDEO , " mpeg4 " , 0 , " MPEG4 Video " } , /*!< Passthrough support for MPEG4 */
{ AST_FORMAT_T140 , " t140 " , 0 , " Passthrough T.140 Realtime Text " } , /*!< Passthrough support for T.140 Realtime Text */
} ;
struct ast_frame ast_null_frame = { AST_FRAME_NULL , } ;
@ -525,7 +523,7 @@ char* ast_getformatname(int format)
int x ;
char * ret = " unknown " ;
for ( x = 0 ; x < sizeof ( AST_FORMAT_LIST ) / sizeof ( AST_FORMAT_LIST [ 0 ] ) ; x + + ) {
if ( AST_FORMAT_LIST [ x ] . visible & & AST_FORMAT_LIST [ x ] . bits = = format ) {
if ( AST_FORMAT_LIST [ x ] . bits = = format ) {
ret = AST_FORMAT_LIST [ x ] . name ;
break ;
}
@ -547,7 +545,7 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format)
size - = len ;
start = end ;
for ( x = 0 ; x < sizeof ( AST_FORMAT_LIST ) / sizeof ( AST_FORMAT_LIST [ 0 ] ) ; x + + ) {
if ( AST_FORMAT_LIST [ x ] . visible & & ( AST_FORMAT_LIST [ x ] . bits & format ) ) {
if ( AST_FORMAT_LIST [ x ] . bits & format ) {
snprintf ( end , size , " %s| " , AST_FORMAT_LIST [ x ] . name ) ;
len = strlen ( end ) ;
end + = len ;
@ -566,6 +564,7 @@ static struct ast_codec_alias_table {
char * realname ;
} ast_codec_alias_table [ ] = {
{ " slinear " , " slin " } ,
{ " slinear16 " , " slin16 " } ,
{ " g723.1 " , " g723 " } ,
} ;
@ -586,9 +585,9 @@ int ast_getformatbyname(const char *name)
all = strcasecmp ( name , " all " ) ? 0 : 1 ;
for ( x = 0 ; x < sizeof ( AST_FORMAT_LIST ) / sizeof ( AST_FORMAT_LIST [ 0 ] ) ; x + + ) {
if ( AST_FORMAT_LIST[ x ] . visible & & ( all | |
if ( all | |
! strcasecmp ( AST_FORMAT_LIST [ x ] . name , name ) | |
! strcasecmp ( AST_FORMAT_LIST [ x ] . name , ast_expand_codec_alias ( name ) ) ) ) {
! strcasecmp ( AST_FORMAT_LIST [ x ] . name , ast_expand_codec_alias ( name ) ) ) {
format | = AST_FORMAT_LIST [ x ] . bits ;
if ( ! all )
break ;
@ -603,7 +602,7 @@ char *ast_codec2str(int codec)
int x ;
char * ret = " unknown " ;
for ( x = 0 ; x < sizeof ( AST_FORMAT_LIST ) / sizeof ( AST_FORMAT_LIST [ 0 ] ) ; x + + ) {
if ( AST_FORMAT_LIST [ x ] . visible & & AST_FORMAT_LIST [ x ] . bits = = codec ) {
if ( AST_FORMAT_LIST [ x ] . bits = = codec ) {
ret = AST_FORMAT_LIST [ x ] . desc ;
break ;
}
@ -1357,7 +1356,7 @@ int ast_codec_get_samples(struct ast_frame *f)
samples = speex_samples ( f - > data , f - > datalen ) ;
break ;
case AST_FORMAT_G723_1 :
samples = g723_samples ( f - > data , f - > datalen ) ;
samples = g723_samples ( f - > data , f - > datalen ) ;
break ;
case AST_FORMAT_ILBC :
samples = 240 * ( f - > datalen / 50 ) ;
@ -1369,10 +1368,11 @@ int ast_codec_get_samples(struct ast_frame *f)
samples = f - > datalen * 8 ;
break ;
case AST_FORMAT_SLINEAR :
case AST_FORMAT_SLINEAR16 :
samples = f - > datalen / 2 ;
break ;
case AST_FORMAT_LPC10 :
/* assumes that the RTP packet contains one LPC10 frame */
/* assumes that the RTP packet contains one LPC10 frame */
samples = 22 * 8 ;
samples + = ( ( ( char * ) ( f - > data ) ) [ 7 ] & 0x1 ) * 8 ;
break ;
@ -1411,10 +1411,12 @@ int ast_codec_get_len(int format, int samples)
len = samples / 8 ;
break ;
case AST_FORMAT_SLINEAR :
case AST_FORMAT_SLINEAR16 :
len = samples * 2 ;
break ;
case AST_FORMAT_ULAW :
case AST_FORMAT_ALAW :
case AST_FORMAT_G722 :
len = samples ;
break ;
case AST_FORMAT_ADPCM :