[Freeswitch-dev] Questions about read_frame and write_frame events

Alex To tonhudung at gmail.com
Mon Nov 9 01:54:35 PST 2009


Thank you very much Mathieu

 

So if TFLAG_IO is not set, read_frame will return immediately and *frame is
NULL ? Is it a normal behavior if the call is terminated when a NULL frame
is returned ? 

 

Coz when I return a NULL frame, the call is terminated. So now my
understanding is that if my endpoint buffer is empty, I need to return a
silence frame to the other end, right?

 

Thank again Mathieu for your quick reply, that helps a lot J.

 

Regards

 

Alex To

 

From: freeswitch-dev-bounces at lists.freeswitch.org
[mailto:freeswitch-dev-bounces at lists.freeswitch.org] On Behalf Of Mathieu
Rene
Sent: Monday, November 09, 2009 2:54 AM
To: freeswitch-dev at lists.freeswitch.org
Subject: Re: [Freeswitch-dev] Questions about read_frame and write_frame
events

 

Hi,

 

See answers inline.

 

Mathieu Rene

Avant-Garde Solutions Inc

Office: + 1 (514) 664-1044 x100

Cell: +1 (514) 664-1044 x200

mrene at avgs.ca

 

 

 

 

On 8-Nov-09, at 4:21 AM, Alex To wrote:





Hi,

 

I am getting stuck on read_frame and write_frame in my custom endpoint.
Would someone shed some lights on how it works?

 

My questions about read_frame, write_frame after reading mod_iax,
mod_portaudio and mod_skyiax are:

 

1.       Is it correct that I need to check a flag (for e.g TFLAG_HUP)  of
the private object at the beginning of the event to determine whether I
should continue reading audio or just return. The flag TFLAG_HUP is set when
a hangup or kill channel event is detected.

Thats what TFLAG_IO is for, clear the flag the read_frame functions should
return immediately.

If you catch TFLAG_BREAK, on the other side, you should clear it and return
a comfort noise frame ( cng )



2.       Read_frame is called on an interval (how frequently is the interval
? how do I determine that?) to read audio from my endpoint.

It depends on the codec you are using, if you are using 20 packetization
time, it'll be called every 20ms.



3.       What is TFLAG_IO normally used for ?

See point 1



4.       What is the label "cng" is all about ? May I know what "cng" stands
for and how it is used?

CNG stands for Comfort Noise Generation, whenever read_frame jumps there, it
returns a frame of silence. It it first initialized on private_t since its
pointless to re-allocate empty frames.



5.       What if read_frame is called while my end point is not ready to
send any audio yet?

That's why you set TFLAG_IO whenever you are ready. Also note that it wont
be called until you either pre_answer (go in early media) or answer the
channel.

When a call is made, switch_ivr_originate() doesn't return until your
endpoint is ready to exchange audio.

6.       What is the tech_pvt->cng_frame is used for? I notice that the
*frame is set to tech_pvt->cng_frame if the label "cng" is reached.

See point 4.



 

Thank you very much for even reading my questions. I tried to look for
documents that explains clearly the above questions but so far no luck.
Until now I still don't have a clear understanding about these 2 events yet.

 

Best Regards

 

Alex To

_______________________________________________
FreeSWITCH-dev mailing list
FreeSWITCH-dev at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20091109/128e3f45/attachment-0001.html 


More information about the FreeSWITCH-dev mailing list