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

Dmitry Andrianov dimas at dataart.com
Tue May 19 09:53:25 CDT 2009


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...



-----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

_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev



More information about the asterisk-dev mailing list