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 -0300From: [EMAIL PROTECTED]: [EMAIL PROTECTED]:
Re: [sipxtapi-dev] Using sipxCallAudioPlayFileStartCC: [EMAIL PROTECTED] Using
CppBut 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. RegardsMá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 -0300From: [EMAIL PROTECTED]: [EMAIL PROTECTED]:
Re: [sipxtapi-dev] Using sipxCallAudioPlayFileStartCC:
[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 -0300From: [EMAIL PROTECTED]: [EMAIL PROTECTED]:
[sipxtapi-dev] Using sipxCallAudioPlayFileStart
HelloWhen 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! -- Mário Henrique Gontijo [EMAIL PROTECTED]
Hotmail to go? Get your Hotmail, news, sports and much more! Check out the New
MSN Mobile-- Mário Henrique Gontijo [EMAIL PROTECTED]
_________________________________________________________________
Play free games, earn tickets, get cool prizes! Join Live Search Club.
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/