I found a way to detect and avoid detection of dtmf using a global flag, and
a conditional, that in each dtmf event received checks if the time has
finished or not. It´s very easy when you have a event being sent (like
DTMF_START). But does exist in sipxtapi a event for end of file?

I tried to find it out, printing on the screen the names of the media events
when they were called, but, I just got (DTMF_START, DTMF_STOP, LOCAL_STOP
and REMOTE_STOP). I thought that PLAYFILE_START and PLAYFILE_STOP were
activated when the functions sipxCallAudioPlayFileStart and
sipxCallAudioPlayFileStop were aclled, respectively. As I coudn´t find a way
to get this events working on, it just works when activated by the
DTMF_START events.

Regards,
Mário Henrique Gontijo Freitas

2007/7/3, Daniel Sigurgeirsson <[EMAIL PROTECTED]>:

My solution was this:

every "reaction" to a Dtmf event, be it playing a single sound file,
playing multiple files, one after another, or whatever the action is, is
performed on a separate thread. This thread regularly checks a cancel flag
which the main thread (which is processing dtmf) will set when a dtmf event
is received. So if the action thread is playing a file which is 3 seconds
long, instead of sleeping for 3 seconds it sleeps for 100 milliseconds 30
times, and checks the cancel flag in each iteration.

This works pretty well in my case, the code is written in C# but it
shouldn't be much problem implementing same thing in C++.

Regards,
Daníel

------------------------------
Date: Tue, 3 Jul 2007 17:05:27 -0300
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [sipxtapi-dev] Using sipxCallAudioPlayFileStart
CC: [email protected]

I´m Using Cpp

But I found a way to calculate this. I got the audio file size and
calculated this value over the pcm sample rate. Then I called the sleep with
this value times 1000 (1 second = 1000 miliseconds). It works fine, because
it´s fast and gives me a reasonable value.

Anyway, I found other prbolem: can I stop o Sleep call without if
finishes? Because I made for test an app that receives a dtmf and plays some
wav. the problem is that when I play a lot of dtmf, the application
"enqueue" this calls, and plays the same sound followed one by one. I want
that when I press the dtmf, stops playing the current audio and starts to
play the new one.

Regards
Mário Henrique Gontijo Freitas

2007/7/3, Daniel Sigurgeirsson <[EMAIL PROTECTED]>:

Yes, if the file is a .wav file then the lengh can be calculated based on
information in the header.

What programming language are you using?

Regards,
Daníel

------------------------------
Date: Tue, 3 Jul 2007 13:45:20 -0300
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [sipxtapi-dev] Using sipxCallAudioPlayFileStart
CC: [email protected]


This is a bad news to me :{

Do you know if there is a way to get the size of a file? (It can be in
bytes or kbytes) I´ll try to calculate the sleep time according to the size
of the file. I´ll have to do this, because the audio files that I use have
different lengths, and then I can´t establish a default sleep time

Regards


2007/7/3, Daniel Sigurgeirsson <[EMAIL PROTECTED]>:

Hi,

sipxCallAudioPlayFileStart is asyncronous so it will return immediately,
and will not wait until the file has been played fully. Sipxtapi is supposed
to fire events when playback has finised (or is terminated), but this
doesn't work properly in the current version, I believe there is some
rewrite going on regarding events and how notifications are passed from
various libraries back to the main sipxtapi part, perhaps someone can shed a
light on the status of that?

Another thing, apparently you must also call the corresponding
sipxCallAudioStop function inbetween, otherwise sipxtapi doesn't correctly
decrement the count of files being played, and hence the call will never be
torn down properly. I also believe this will change, once the modifications
from Jaroslav will be incorporated into the main trunk (what is the status
of that BTW?)

Anyway, the solution I'm using is the same as yours, i.e. read the length
of the file in seconds, and then sleep the current thread for that amount.

Regards,
Daníel

 ------------------------------
Date: Tue, 3 Jul 2007 10:44:05 -0300
From: [EMAIL PROTECTED]
To: [email protected]
Subject: [sipxtapi-dev] Using sipxCallAudioPlayFileStart


Hello

When 1 make 2 calls of the function sipxCallAudioPlayFileStart I just can
hear the second played file. The first call doesn´t play the audio.

Do you know how can I avoid this?

I tried to use SLEEP, with the same length of the first audio, and,
although it works, this solution doesn´t help so much for my purpose.

Regards
--
Mário Henrique Gontijo Freitas
[EMAIL PROTECTED]


------------------------------
Live Earth is coming.  Learn more about the hottest summer event - only on
MSN. Check it out!
<http://liveearth.msn.com/?source=msntaglineliveearthwlm>




--

Mário Henrique Gontijo Freitas
[EMAIL PROTECTED]


------------------------------
Hotmail to go? Get your Hotmail, news, sports and much more! Check out the
New MSN Mobile <http://mobile.msn.com/>




--

Mário Henrique Gontijo Freitas
[EMAIL PROTECTED]


------------------------------
Live Earth is coming.  Learn more about the hottest summer event - only on
MSN. Check it out!<http://liveearth.msn.com?source=msntaglineliveearthwlm>




--

Mário Henrique Gontijo Freitas
[EMAIL PROTECTED]
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to