Posted: Tue May 19, 2009 4:50 am Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
Dmitry, Russell,
thanks for your help! I fixed the problem with not using "offset" but
can anyone tell me when offset is beeing used?
Another question: Is there a documentation outside the sources where I
can get some more information about channels and frames?
Regards, Holger
Dmitry Andrianov wrote:
Quote:
2 Holger Wirtz:
I believe you should not use calloc/free to manipulate frames.
Also, I have no idea why you are trying to manipulate "offset" frame field. This is probably the thing which makes your code crash.
2 Atis Lezdins:
one frame (20ms) is not enough to produce any beep. You will need many frames for the beep to be heard.
In any case, apps/app_morsecode.c should be good start.
Regards,
Dmitry Andrianov
-----Original Message-----
From: asterisk-dev-bounces@lists.digium.com [mailto:asterisk-dev-bounces@lists.digium.com] On Behalf Of Atis Lezdins
Sent: Monday, May 18, 2009 3:17 PM
To: Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] How to create a slinear silent frame?
On Mon, May 18, 2009 at 12:36 PM, Holger Wirtz <wirtz@dfn.de> wrote:
> Hi,
>
> I tried to create an empty frame (with data set to 0000000...) but I get
> crashes when I try to send this frames with ast_write() to a channel.
>
> I created the frame like this:
>
> --- cut here ---
> struct ast_frame* frame_create_silent_voice(int offset,int samples)
> {
> struct ast_frame* f=NULL;
> short *data=NULL;
> int i=0;
>
> if((f=calloc(1,sizeof(struct ast_frame)))==NULL)
> {
> ast_log(LOG_ERROR,"Unable to allocate memory for slinear
> frame\n");
> return(NULL);
> }
>
> f->frametype=AST_FRAME_VOICE;
> f->subclass=AST_FORMAT_SLINEAR;
> f->mallocd=AST_MALLOCD_HDR|AST_MALLOCD_DATA;
> f->samples=samples;
> f->datalen=samples*sizeof(short);
> f->offset=offset;
> f->src=NULL;
> f->data=NULL;
>
> if((data=(short *)calloc(1,sizeof(short)*samples)+offset)==NULL)
> {
> ast_log(LOG_ERROR,"Unable to create array for frame
> data\n");
> if(f!=NULL)
> {
> free(f);
> f=NULL;
> }
> }
> else
> {
> f->data=data;
> }
>
> return(f);
> }
> --- cut here ---
>
> What am I doing wrong, can anyone help?
>
While on topic, i'm also interested how to create a beep frame. There
are some frequency generations in indications.c, but i guess i'll need
just a frame :)
Posted: Tue May 19, 2009 12:00 pm Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
Holger Wirtz wrote:
Quote:
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.
Quote:
Another question: Is there a documentation outside the sources where I
can get some more information about channels and frames?
Nope.
--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kpfleming@digium.com
Check us out at www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Tue May 19, 2009 12:47 pm Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
Hi Kevin,
Kevin P. Fleming wrote:
Quote:
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?
Quote:
> 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...
Posted: Tue May 19, 2009 1:21 pm Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
Holger Wirtz wrote:
Quote:
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?
It's always best to supply at least AST_FRIENDLY_OFFSET bytes of space
anyway, in case the consumer of your frames is not who you expect it to
be :-) It is also possible that a translator could modify the data in
place on an existing frame (although I don't think any of our existing
translators do that, it's within the rules as best I can remember), so
you can't even be sure that if a translation path is in place that it
will be creating new frames from yours.
--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kpfleming@digium.com
Check us out at www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Tue May 19, 2009 1:36 pm Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
19 maj 2009 kl. 16.12 skrev Kevin P. Fleming:
Quote:
Holger Wirtz wrote:
> 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?
It's always best to supply at least AST_FRIENDLY_OFFSET bytes of space
anyway, in case the consumer of your frames is not who you expect it
to
be :-) It is also possible that a translator could modify the data in
place on an existing frame (although I don't think any of our existing
translators do that, it's within the rules as best I can remember), so
you can't even be sure that if a translation path is in place that it
will be creating new frames from yours.
This needs to be added to doxygen... Hint, hint ;-)
/O
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
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@lists.digium.com [mailto:asterisk-dev-bounces@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:
Quote:
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?
Quote:
> 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...
Posted: Tue May 19, 2009 2:16 pm Post subject: [asterisk-dev] How to create a slinear silent frame? SOLVED
On May 19, 2009, at 9:26 AM, Olle E. Johansson wrote:
Quote:
19 maj 2009 kl. 16.12 skrev Kevin P. Fleming:
> Holger Wirtz wrote:
>
>> 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?
>
> It's always best to supply at least AST_FRIENDLY_OFFSET bytes of
> space
> anyway, in case the consumer of your frames is not who you expect it
> to
> be :-) It is also possible that a translator could modify the data in
> place on an existing frame (although I don't think any of our
> existing
> translators do that, it's within the rules as best I can remember),
> so
> you can't even be sure that if a translation path is in place that it
> will be creating new frames from yours.
This needs to be added to doxygen... Hint, hint ;-)
Feel free to add it! ... hint, hint ;-)
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
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).
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
Quote:
-----Original Message-----
From: asterisk-dev-bounces@lists.digium.com [mailto:asterisk-dev-bounces@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...
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum