[asterisk-dev] downsampling slinear16 to ulaw (or alaw or g729)

Kevin P. Fleming kpfleming at digium.com
Tue Aug 31 16:42:34 CDT 2010


On 08/31/2010 01:17 PM, Paul Albrecht wrote:

> The only time I got a different result was once after I recompiled
> asterisk. Now every time I have run the program I get the same result. I
> think the frame is set up correctly. You can check the code fragment I
> use to initialize the input frame I sent in a previous post. Lastly, I
> always use the same input frame for translation which is not consumed on
> the call to the translator.

static struct ast_frame f;
static unsigned char data[AST_FRIENDLY_OFFSET + 640];

f.data.ptr = (void *)(data + AST_FRIENDLY_OFFSET);

f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_SLINEAR16;
f.samples = 320;
f.offset = AST_FRIENDLY_OFFSET;
f.datalen = 640;

========

If these 'static' variables are at module scope (outside of any
function), then this is OK for the first time you call the translator,
as the ast_frame and the data array will be initialized to zeroes. If
these variables are in a function, then they may not be initialized to
any predictable value at all.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kfleming at digium.com
Check us out at www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list