support new format for musiconhold.conf (issue #4908)

support non-SLINEAR moh streams (issue #4908)
add external app to feed TCP stream into Asterisk for moh (issue #4908)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6353 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-08-22 19:29:29 +00:00
parent 69f9c479e7
commit ff971379f4
7 changed files with 341 additions and 69 deletions

33
frame.c
View File

@@ -1168,7 +1168,6 @@ static int speex_samples(unsigned char *data, int len)
return cnt;
}
int ast_codec_get_samples(struct ast_frame *f)
{
int samples=0;
@@ -1210,3 +1209,35 @@ int ast_codec_get_samples(struct ast_frame *f)
return samples;
}
int ast_codec_get_len(int format, int samples)
{
int len = 0;
/* XXX Still need speex, g723, and lpc10 XXX */
switch(format) {
case AST_FORMAT_ILBC:
len = (samples / 240) * 50;
break;
case AST_FORMAT_GSM:
len = (samples / 160) * 33;
break;
case AST_FORMAT_G729A:
len = samples / 8;
break;
case AST_FORMAT_SLINEAR:
len = samples * 2;
break;
case AST_FORMAT_ULAW:
case AST_FORMAT_ALAW:
len = samples;
break;
case AST_FORMAT_ADPCM:
case AST_FORMAT_G726:
len = samples / 2;
break;
default:
ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format));
}
return len;
}