Wav File delayed for 2-5sec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Perhaps not really related to the problem. Doing 'long time' blocking
task in the callback should be avoided, as it may stop the library
thread where the callback is invoked.

BR,
nanang


On Tue, Nov 10, 2009 at 3:52 PM, Voip Tester <voip at cashers.de> wrote:
> Hi,
>
> although I refered to the manual, I worry about the audio file to be played
> with first seconds cut.
> Sometimes only 2 sec are cut and sometimes even 5 or more are missing at the
> beginning.
> It depends on the time that it takes for "reading"/preparing the wave file.
>
> That's the way I implement it in MyCallCallback class:
>>
>> ??? def on_media_state(self):
>> ??? if self.call.info().media_state == pj.MediaState.ACTIVE:
>> ??? ??? global player_id
>> ??? ??? call_slot = self.call.info().conf_slot
>> ??? ??? #pj.Lib.instance().conf_connect(call_slot, 0)
>> ??? ??? #pj.Lib.instance().conf_connect(0, call_slot)
>> ??? ??? print "one more..."
>> ??? ??? wfile = wave.open("play.wav")
>> ??? ??? time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
>> ??? ??? print str(time) + "ms"
>> ??? ??? wfile.close()
>> ??? ??? player_id = lib.create_player("play.wav",True)
>> ??? ??? lib.conf_connect(lib.player_get_slot(player_id),
>> current_call.info().conf_slot)
>> ??? ??? print "audio wait...",time
>> ??? ??? sleep(time*3)
>> ??? ??? print "audio over now..."
>> ??? ??? lib.conf_disconnect(lib.player_get_slot(player_id),
>> current_call.info().conf_slot)
>> ??? ??? lib.player_destroy(player_id)
>> ??? ??? print "!!!destroyed lib + player"
>
> And it works without error messages, but as described above, it does not
> play the file from the beginning :-(
>
> It "sleeps" as expected after this output (log level: 4) and after some
> seconds it starts playing the audio for the caller:
>>
>> ?20:17:58.039? strm0x89515ec? VAD temporarily disabled
>> ?20:17:58.039? strm0x89515ec? Encoder stream started
>> ?20:17:58.039? strm0x89515ec? Decoder stream started
>> ?20:17:58.039? pjsua_media.c? Media updates, stream #0: PCMA (sendrecv)
>> one more...
>> 12.631625ms
>> ?20:17:58.039?? wav_player.c? File player 'play.wav' created:
>> samp.rate=8000, ch=1, bufsize=4KB, filesize=202KB
>> ?20:17:58.040?? conference.c? Port 2 (play.wav) transmitting to port 1
>> (sip:101 at 192.168.1.99)
>> audio wait... 12.631625
>
> And just to be sure there is no error in another part of the .py, that's how
> i catch the call-in:
>>
>> ??? def on_incoming_call(self, call):
>> ??????? global current_call, player_id
>> ??????? if current_call:
>> ??????????? print "Busy...",current_call
>> ??? ??? print "dont mind..."
>> ??? ??? call.answer(486, "Busy")
>> ??????????? return
>> ??????? print "Incoming call from ", call.info().remote_uri
>> ??????? current_call = call
>> ??????? call_cb = MyCallCallback(call)
>> ??????? call.set_callback(call_cb)
>> ??? call.answer(200)
>
> Looking fwd. to advice from you.
>
> Thanks a lot and have a nice day
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux