[asterisk-dev] How to create a slinear silent frame? SOLVED

Holger Wirtz wirtz at dfn.de
Wed May 20 00:38:46 CDT 2009


Dmitry, Kevin,

Dmitry Andrianov wrote:
> So the final code should look like this: (given that 'samples' variable contains the number of samples you need0
> 
> 
> 	uint8_t buffer[AST_FRIENDLY_OFFSET + samples * sizeof(uint16_t)];
> 
> 	bzero(buffer, sizeof(buffer));
> 
> 	struct ast_frame frame = {
> 		.frametype = AST_FRAME_VOICE,
> 		.subclass = AST_FORMAT_SLINEAR,
> 		.samples = samples,
> 		.src = __FUNCTION__,
> 	};
> 
> 	AST_FRAME_SET_BUFFER(&frame, buffer, AST_FRIENDLY_OFFSET, samples * sizeof(int16_t));
> 
> 	return ast_frdup(&frame);
> 
> 
> However, you may be doing completely wrong thing at all. It all depends on why you need these silent frames at all. If you just need to mute something in the channel driver for example, it may be better to modify existing frame than producing new ones. If you creating some application and just need to generate silence for some period, you should better use generator instead as Russell pointed out. Again - we do not know ehat you are doing...

I didn't wrote what I am doing because I wanted not to blow up my mail
with details so noone wants to read it :-)

<advertising for my project>
I am writing a kind of conference bridge which simulates real radio
frequencies based on extensions. Therefore I need to mix up the voice
streams of the mebers based on their positions in slinear. The silent
frame is the base for mixing for all members on a "frequency" (only when
there is more than one member and a meber is speaking).

I also need to generate frames with noise, which will be mixed in after
 ast_dsp recognizes someone doesn't talking anymore (= squelch emulation).

The source code is completly rewritten but based on app_conference and
can be obtained at  https://sourceforge.net/projects/appfgcom/. The
client is located at https://sourceforge.net/projects/fgcom/ based on
iaxclient.

app_fgcom and fgcom are used for setting up voice communication for the
open source flightsimulation FlightGear (http://www.flightgear.org).
</advertising for my project>

Currently it works for my tests - thanks for your help! I have some
problems with crashes due to using ast_frfree() too much :-) But for my
questions on this topic I will open a new thread.

Again: thanks for your help!

Holger

> 
> 
> 
> -----Original Message-----
> From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Holger Wirtz
> Sent: Tuesday, May 19, 2009 5:38 PM
> To: Asterisk Developers Mailing List
> Subject: Re: [asterisk-dev] How to create a slinear silent frame? SOLVED
> 
> Hi Kevin,
> 
> Kevin P. Fleming wrote:
>> Holger Wirtz wrote:
>>
>>> thanks for your help! I fixed the problem with not using "offset" but
>>> can anyone tell me when offset is beeing used?
>> 'offset' represents the number of bytes of space available 'in front' of
>> the data buffer that the frame points to. This is used by channel
>> drivers that send frames over network connections so they can place
>> network packet headers (RTP, for example) in front of the data without
>> having to copy it into another buffer first. Most Asterisk modules that
>> produce frames allocate the number of bytes needed for the data *plus*
>> AST_FRIENDLY_OFFSET, then store the actual data in the first byte of the
>> buffer *after* AST_FRIENDLY_OFFSET and set 'offset' to that value.
> 
> thnaks a lot! I an offset necessary if I create slinear packets and
> convert them to the channel drivers codec (let's say speex)? becuase the
> data for the frame has to be calculated from scratch the translator will
> be doing everything right with the offset?
> 
>>> Another question: Is there a documentation outside the sources where I
>>> can get some more information about channels and frames?
>> Nope.
>>
> 
> Ok... learning by doing, reading the source and asking the dev-lists...
> 
> Thanks again, Holger

-- 
#####  #### ##  ##   Holger Wirtz         Phone : (+49 30) 884299-40
##  ## ##   ### ##   DFN-Verein           Fax   : (+49 30) 884299-70
##  ## #### ######   Alexanderplatz 1     E-Mail: wirtz at dfn.de
##  ## ##   ## ###   10178 Berlin
#####  ##   ##  ##   GERMANY              WWW   : http://www.dfn.de
GPG-Fingerprint: ABFA 1F51 DD8D 503C 85DC  0C51 E961 79E2 6685 9BCF



More information about the asterisk-dev mailing list