[Freeswitch-users] freetdm api - ftdm_channel_read()

Moises Silva moises.silva at gmail.com
Sun Jul 31 01:43:14 MSD 2011


Hi Juraj,

see your questions answered below ...

On Wed, Jul 27, 2011 at 1:21 PM, Juraj Fabo <juraj.fabo at gmail.com> wrote:
> According to return value of sangoma_get_rx_queue_sz() the default rx
> queue size is 10.

That is correct. And you can change that in the FreeTDM wanpipe.conf
configuration to set a different default or by using
FTDM_COMMAND_SET_RX/TX_QUEUE_SIZE

> How can an application do this reading of a channel by the means of
> the freetdm api in more nice way?
> I did not find a better way yet, than to read it in the loop.
> Any way to explicitly read the number of available frames?

I just committed new code to allow access to the internal iostats
structure (which contains the size of the queue and number of elements
on it). See src/include/freetdm.h ftdm_channel_iostats_t, bear in mind
you must enable the feature using FTDM_COMMAND_SWITCH_IOSTATS, then
you can retrieve the stats with FTDM_COMMAND_GET_IOSTATS. I added an
example of usage in mod_freetdm/mod_freetdm.c

Do "git pull" to get it.

> Actually, why the ftdm_channel_read() does not read them ALL at once
> and sets the number of read bytes via *datalen output parameter?
> (assuming provided *data buffer is large enough)
> In my tests, always 160 bytes were returned in one particular read.

Did you verify this by providing bigger buffer and datalen?

The reason is that you typically want to handle voice as soon as is
available, otherwise you add delay in your audio path, therefore you
never leave your voice to accumulate in the driver's buffer's.
FreeSWITCH and all other users of the FreeTDM API work this way.

In the future you might want consider asking this questions in the
freeswitch-dev mailing list to have better chances of a prompt
response (as long as the question involves C development with
FreeSWITCH/FreeTDM internal APIs).

Moises Silva
Senior Software Engineer, Software Development Manager
Sangoma Technologies Inc. | 100 Renfrew Drive, Suite 100, Markham ON
L3R 9R6 Canada
t. 1 905 474 1990 x128 | e. moy at sangoma.com



More information about the FreeSWITCH-users mailing list