a few questions

TF
Tiago Ferreira
Fri, Aug 14, 2009 9:28 AM

Hello,

I just started using pjsip in python and I was wondering if you could answer
me a few questions.

1: I tried sending audio with a wave file but I had no success thus far. Can
anyone show me a simple audio tutorial or code sample for python?

2: I am starting to implement a small script that registers to a server,
answers calls and receives DTMF signals and acts according to what he
received. Bui I just saw the FAQ and from what I understood, using pjsip I
can't interpret the received DTMF signals, is this true?

Thank you

Tiago

Hello, I just started using pjsip in python and I was wondering if you could answer me a few questions. 1: I tried sending audio with a wave file but I had no success thus far. Can anyone show me a simple audio tutorial or code sample for python? 2: I am starting to implement a small script that registers to a server, answers calls and receives DTMF signals and acts according to what he received. Bui I just saw the FAQ and from what I understood, using pjsip I can't interpret the received DTMF signals, is this true? Thank you Tiago
SI
Saúl Ibarra
Fri, Aug 14, 2009 9:36 AM

On Fri, Aug 14, 2009 at 11:28 AM, Tiago Ferreiramaiaboy@hotmail.com wrote:

Hello,

I just started using pjsip in python and I was wondering if you could answer
me a few questions.

1: I tried sending audio with a wave file but I had no success thus far. Can
anyone show me a simple audio tutorial or code sample for python?

Try this:

player = self.core.lib.create_player("/tmp/ring.wav", True)
lib.conf_connect(lib.player_get_slot(player), 0)

2: I am starting to implement a small script that registers to a server,
answers calls and receives DTMF signals and acts according to what he
received. Bui I just saw the FAQ and from what I understood, using pjsip I
can’t interpret the received DTMF signals, is this true?

I don't think you are able to interpret DTMF tones from the Python API...

Regards,

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net

On Fri, Aug 14, 2009 at 11:28 AM, Tiago Ferreira<maiaboy@hotmail.com> wrote: > Hello, > > > > I just started using pjsip in python and I was wondering if you could answer > me a few questions. > > > > 1: I tried sending audio with a wave file but I had no success thus far. Can > anyone show me a simple audio tutorial or code sample for python? > Try this: player = self.core.lib.create_player("/tmp/ring.wav", True) lib.conf_connect(lib.player_get_slot(player), 0) > > > 2: I am starting to implement a small script that registers to a server, > answers calls and receives DTMF signals and acts according to what he > received. Bui I just saw the FAQ and from what I understood, using pjsip I > can’t interpret the received DTMF signals, is this true? > I don't think you are able to interpret DTMF tones from the Python API... Regards, -- /Saúl http://www.saghul.net | http://www.sipdoc.net
TF
Tiago Ferreira
Fri, Aug 14, 2009 12:13 PM

Hello

I tried it and got the following exception

Unhandled exception in thread started by <function _worker_thread_main at
0x9b119cc>
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2807, in
_worker_thread_main
time.sleep(0.050)
File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2754, in
_cb_on_call_state
_lib._cb_on_call_state(call_id)
File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2652, in
_cb_on_call_state
if call:
File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2760, in
_cb_on_call_media_state
_lib._cb_on_call_media_state(call_id)
File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2665, in
_cb_on_call_media_state
call._cb.on_media_state()
File "firstTry.py", line 41, in on_media_state
if self.call.info().media_state == pj.MediaState.ACTIVE:
NameError: global name 'pj' is not defined

Any ideas?

-----Mensagem original-----
De: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] Em
nome de Saúl Ibarra
Enviada: sexta-feira, 14 de Agosto de 2009 10:37
Para: pjsip list
Assunto: Re: [pjsip] a few questions

On Fri, Aug 14, 2009 at 11:28 AM, Tiago Ferreiramaiaboy@hotmail.com wrote:

Hello,

I just started using pjsip in python and I was wondering if you could

answer

me a few questions.

1: I tried sending audio with a wave file but I had no success thus far.

Can

anyone show me a simple audio tutorial or code sample for python?

Try this:

player = self.core.lib.create_player("/tmp/ring.wav", True)
lib.conf_connect(lib.player_get_slot(player), 0)

2: I am starting to implement a small script that registers to a server,
answers calls and receives DTMF signals and acts according to what he
received. Bui I just saw the FAQ and from what I understood, using pjsip I
can’t interpret the received DTMF signals, is this true?

I don't think you are able to interpret DTMF tones from the Python API...

Regards,

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hello I tried it and got the following exception Unhandled exception in thread started by <function _worker_thread_main at 0x9b119cc> Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2807, in _worker_thread_main time.sleep(0.050) File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2754, in _cb_on_call_state _lib._cb_on_call_state(call_id) File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2652, in _cb_on_call_state if call: File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2760, in _cb_on_call_media_state _lib._cb_on_call_media_state(call_id) File "/usr/local/lib/python2.6/dist-packages/pjsua.py", line 2665, in _cb_on_call_media_state call._cb.on_media_state() File "firstTry.py", line 41, in on_media_state if self.call.info().media_state == pj.MediaState.ACTIVE: NameError: global name 'pj' is not defined Any ideas? -----Mensagem original----- De: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] Em nome de Saúl Ibarra Enviada: sexta-feira, 14 de Agosto de 2009 10:37 Para: pjsip list Assunto: Re: [pjsip] a few questions On Fri, Aug 14, 2009 at 11:28 AM, Tiago Ferreira<maiaboy@hotmail.com> wrote: > Hello, > > > > I just started using pjsip in python and I was wondering if you could answer > me a few questions. > > > > 1: I tried sending audio with a wave file but I had no success thus far. Can > anyone show me a simple audio tutorial or code sample for python? > Try this: player = self.core.lib.create_player("/tmp/ring.wav", True) lib.conf_connect(lib.player_get_slot(player), 0) > > > 2: I am starting to implement a small script that registers to a server, > answers calls and receives DTMF signals and acts according to what he > received. Bui I just saw the FAQ and from what I understood, using pjsip I > can’t interpret the received DTMF signals, is this true? > I don't think you are able to interpret DTMF tones from the Python API... Regards, -- /Saúl http://www.saghul.net | http://www.sipdoc.net _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
SI
Saúl Ibarra
Fri, Aug 14, 2009 12:17 PM

Did you forget to do import pjsua as pj? Or have you imported it with
another name? It seems like the callback setting is failing...

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net

Did you forget to do import pjsua as pj? Or have you imported it with another name? It seems like the callback setting is failing... -- /Saúl http://www.saghul.net | http://www.sipdoc.net
TF
Tiago Ferreira
Fri, Aug 14, 2009 12:39 PM

I simply use import pjsua, do i need to use import pjsua as pj?

I simply use import pjsua, do i need to use import pjsua as pj?
SI
Saúl Ibarra
Fri, Aug 14, 2009 12:53 PM

On Fri, Aug 14, 2009 at 2:39 PM, Tiago Ferreiramaiaboy@hotmail.com wrote:

I simply use import pjsua, do i need to use import pjsua as pj?

Yes, if you later do pj.Something else yo should do pjsua.Something

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net

On Fri, Aug 14, 2009 at 2:39 PM, Tiago Ferreira<maiaboy@hotmail.com> wrote: > I simply use import pjsua, do i need to use import pjsua as pj? > Yes, if you later do pj.Something else yo should do pjsua.Something -- /Saúl http://www.saghul.net | http://www.sipdoc.net
TF
Tiago Ferreira
Fri, Aug 14, 2009 1:00 PM

I changed the import but the audio still isn't transmitted. It registers
correctly, then it makes the call, the call is accepted in the other end but
the audio isn't transmitted.

This is the class that I'm creating for this purpose:

class SimplePhone:
def init(self):
self.acc = None
self.acc_cb = None
self.current_call = None
self.server = None
self.lib = pj.Lib()
self.lib.init(log_cfg = pj.LogConfig(level=0, callback=log_cb))
self.lib.create_transport(pj.TransportType.UDP,
pj.TransportConfig(5080))
self.lib.start()

def register(self, server, extension_name, password):
    self.server = server
    self.acc = self.lib.create_account(pj.AccountConfig(server,

extension_name, password))
self.acc_cb = LockUntilRegistrationAccountCallback(self.acc)
self.acc.set_callback(self.acc_cb)
self.acc_cb.wait()

def unregister(self):
    self.acc.delete()
    self.acc = None
    self.acc_cb = None

def call(self,  phone_number):
    lck = self.lib.auto_lock()
    self.current_call = self.acc.make_call('sip:' + phone_number + '@' +

self.server, intInfoCallCallback())
del lck

def hangup(self):
    self.current_call.hangup()
    
def dial_dtmf(self, digits):
    self.current_call.dial_dtmf(digits)

def send_audio(self):
player = self.lib.create_player("/tmp/ring.wav", True)
self.lib.conf_connect(self.lib.player_get_slot(player), 0)

-----Mensagem original-----
De: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] Em
nome de Saúl Ibarra
Enviada: sexta-feira, 14 de Agosto de 2009 13:53
Para: pjsip list
Assunto: Re: [pjsip] a few questions

On Fri, Aug 14, 2009 at 2:39 PM, Tiago Ferreiramaiaboy@hotmail.com wrote:

I simply use import pjsua, do i need to use import pjsua as pj?

Yes, if you later do pj.Something else yo should do pjsua.Something

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

I changed the import but the audio still isn't transmitted. It registers correctly, then it makes the call, the call is accepted in the other end but the audio isn't transmitted. This is the class that I'm creating for this purpose: class SimplePhone: def __init__(self): self.acc = None self.acc_cb = None self.current_call = None self.server = None self.lib = pj.Lib() self.lib.init(log_cfg = pj.LogConfig(level=0, callback=log_cb)) self.lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(5080)) self.lib.start() def register(self, server, extension_name, password): self.server = server self.acc = self.lib.create_account(pj.AccountConfig(server, extension_name, password)) self.acc_cb = LockUntilRegistrationAccountCallback(self.acc) self.acc.set_callback(self.acc_cb) self.acc_cb.wait() def unregister(self): self.acc.delete() self.acc = None self.acc_cb = None def call(self, phone_number): lck = self.lib.auto_lock() self.current_call = self.acc.make_call('sip:' + phone_number + '@' + self.server, intInfoCallCallback()) del lck def hangup(self): self.current_call.hangup() def dial_dtmf(self, digits): self.current_call.dial_dtmf(digits) def send_audio(self): player = self.lib.create_player("/tmp/ring.wav", True) self.lib.conf_connect(self.lib.player_get_slot(player), 0) -----Mensagem original----- De: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] Em nome de Saúl Ibarra Enviada: sexta-feira, 14 de Agosto de 2009 13:53 Para: pjsip list Assunto: Re: [pjsip] a few questions On Fri, Aug 14, 2009 at 2:39 PM, Tiago Ferreira<maiaboy@hotmail.com> wrote: > I simply use import pjsua, do i need to use import pjsua as pj? > Yes, if you later do pj.Something else yo should do pjsua.Something -- /Saúl http://www.saghul.net | http://www.sipdoc.net _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
O
oneneno@gmx.net
Fri, Aug 14, 2009 1:37 PM

I have used
status = pjsua_set_snd_dev(8, 8); // no sound
or
status = pjsua_set_snd_dev(6, 8);

to set Bluetooth device but it doesn't work. sound goes only through speaker.

Device 0, M - Input (capture=2, playback=0)
Device 1, A (capture=1, playback=0)
Device 2, M - Output (capture=0, playback=2)
Device 3, A (capture=0, playback=1)
Device 4, B (capture=0, playback=2)
Device 5, Wave mapper (capture=2, playback=2)
Device 6, Audio Input (capture=1, playback=0)
Device 7, Audio Output (capture=0, playback=1)
Device 8, Bluetooth Advanced Audio Output (capture=0, playback=2)

???

--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

I have used status = pjsua_set_snd_dev(8, 8); // no sound or status = pjsua_set_snd_dev(6, 8); to set Bluetooth device but it doesn't work. sound goes only through speaker. Device 0, M - Input (capture=2, playback=0) Device 1, A (capture=1, playback=0) Device 2, M - Output (capture=0, playback=2) Device 3, A (capture=0, playback=1) Device 4, B (capture=0, playback=2) Device 5, Wave mapper (capture=2, playback=2) Device 6, Audio Input (capture=1, playback=0) Device 7, Audio Output (capture=0, playback=1) Device 8, Bluetooth Advanced Audio Output (capture=0, playback=2) ??? -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
SI
Saúl Ibarra
Sun, Aug 16, 2009 9:28 PM

Are you getting any log on this? Rise log level to 9 and see if
something interesting is shown...

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net

Are you getting any log on this? Rise log level to 9 and see if something interesting is shown... -- /Saúl http://www.saghul.net | http://www.sipdoc.net
TF
Tiago Ferreira
Tue, Aug 18, 2009 6:11 PM

I can't seem to find anything useful in the log

From: saghul@gmail.com
Date: Sun, 16 Aug 2009 23:28:15 +0200
To: pjsip@lists.pjsip.org
Subject: Re: [pjsip] a few questions

Are you getting any log on this? Rise log level to 9 and see if
something interesting is shown...

--
/Saúl
http://www.saghul.net | http://www.sipdoc.net


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

I can't seem to find anything useful in the log > From: saghul@gmail.com > Date: Sun, 16 Aug 2009 23:28:15 +0200 > To: pjsip@lists.pjsip.org > Subject: Re: [pjsip] a few questions > > Are you getting any log on this? Rise log level to 9 and see if > something interesting is shown... > > > -- > /Saúl > http://www.saghul.net | http://www.sipdoc.net > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org _________________________________________________________________ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/