aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-08-22 19:29:29 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-08-22 19:29:29 +0000
commit304aac9d8f68a374d9cd5d2b2204f8c26f10a948 (patch)
treee481d99c54cefe083c7ee461127c426a76ca3f23 /frame.c
parent19577acdfe461381b3de979cb5b0d0e39ed18ec4 (diff)
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: http://svn.digium.com/svn/asterisk/trunk@6353 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/frame.c b/frame.c
index c6abc0024..5089a968a 100755
--- a/frame.c
+++ b/frame.c
@@ -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;
+}