https://github.com/jrocharodrigues/sipamos/blob/master/sipamos.py
I tried this code but when I lift the call, I cannot hear any audio and I
am stuck up with this from last 4 days. Can someone pls help me with this ?
Is there something wrong with the code. If so, what it is ? Your help will
be very highly appreciated
Thanks,
Kaushik
This is the logic of the goal I am trying to achieve. It should
call, when confirmed, should play an audio wav file and hangup after
that
I am able to call, but when the call is lift, I cannot hear the audio.
if self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print 'Current call is', current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player('message.wav',loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created:
samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to
port 1 (sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Have not tried python but something like this works perfectly fine in C.
static pjsua_player_id player_id;
int call_playback_file(pjsua_call_id call_id, char* path, int no_loop)
{
pj_status_t status =PJ_SUCCESS;
if (call_id != PJSUA_INVALID_ID) {
pj_str_t path_as_pjstr = pj_str(path);
pjsua_player_id player_id;
status = pjsua_player_create(&path_as_pjstr, no_loop, &player_id);
if (status == PJ_SUCCESS) {
status = pjsua_conf_connect( pjsua_player_get_conf_port(player_id),
pjsua_call_get_conf_port(call_id));
if (status != PJ_SUCCESS) {
PJ_LOG(1,(THIS_FILE,"Error: Failed to connect file player to bridge with error %d", status));
}
} else {
PJ_LOG(1,(THIS_FILE,"Failed to create WAV player));
}
} else {
PU_LOG(1,(THIS_FILE,"No active call found"));
}
return status;
}
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
You might need to put the conf_connect calls in the onMediaState() callback. See if that works.
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 10:57
A: pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] PJSIP call, play music and hangup in python
This is the logic of the goal I am trying to achieve. It should call, when confirmed, should play an audio wav file and hangup after that
I am able to call, but when the call is lift, I cannot hear the audio.
if self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print 'Current call is', current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player('message.wav',loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created: samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to port 1 ( sip:***********@*****.*****.com sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Hey,
I just figured out the problem is because of ALSA ( I am using Ubuntu 14.04
). It is because of ALSA that I am not able to get the audio. Can someone
help me how to go about the whole ALSA thing to get the audio
Thanks,
Kaushik
On Tue, May 31, 2016 at 2:46 PM, Gianni Massi g.massi@infosolution.it
wrote:
You might need to put the conf_connect calls in the onMediaState()
callback. See if that works.
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org] *Per conto di *Kaushik
Turlapaty
Inviato: martedì 31 maggio 2016 10:57
A: pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] PJSIP call, play music and hangup in python
This is the logic of the goal I am trying to achieve. It should call, when confirmed, should play an audio wav file and hangup after that*
I am able to call, but when the call is lift, I cannot hear the audio. *
if* self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print *'Current call is'*, current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player(*'message.wav'*,loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created: samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to port 1 (sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Hi Kaushik,
If I understand the problem you have correctly, (please next time post logs/console ouputs leading to your diagnosis of the problem, they can be useful even if you’re 100% sure about the nature of the problem) you should be able to follow the instructions from step 3 in this link to solve your problem.
http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2013-December/016918.html
Hope this is useful,
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 13:48
A: pjsip list pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] R: PJSIP call, play music and hangup in python
Hey,
I just figured out the problem is because of ALSA ( I am using Ubuntu 14.04 ). It is because of ALSA that I am not able to get the audio. Can someone help me how to go about the whole ALSA thing to get the audio
Thanks,
Kaushik
On Tue, May 31, 2016 at 2:46 PM, Gianni Massi <g.massi@infosolution.it mailto:g.massi@infosolution.it > wrote:
You might need to put the conf_connect calls in the onMediaState() callback. See if that works.
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org mailto:pjsip-bounces@lists.pjsip.org ] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 10:57
A: pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] PJSIP call, play music and hangup in python
This is the logic of the goal I am trying to achieve. It should call, when confirmed, should play an audio wav file and hangup after that
I am able to call, but when the call is lift, I cannot hear the audio.
if self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print 'Current call is', current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player('message.wav',loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created: samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to port 1 (sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Hey,
This is the log
14:54:30.981 os_core_unix.c !pjlib 2.2.1-svn for POSIX initialized
14:54:30.983 sip_endpoint.c .Creating endpoint instance...
14:54:30.984 pjlib .select() I/O Queue created (0xca1850)
14:54:30.984 sip_endpoint.c .Module "mod-msg-print" registered
14:54:30.984 sip_transport. .Transport manager created.
14:54:30.984 pjsua_core.c .PJSUA state changed: NULL --> CREATED
14:54:30.985 sip_endpoint.c .Module "mod-pjsua-log" registered
14:54:30.985 sip_endpoint.c .Module "mod-tsx-layer" registered
14:54:30.985 sip_endpoint.c .Module "mod-stateful-util" registered
14:54:30.985 sip_endpoint.c .Module "mod-ua" registered
14:54:30.985 sip_endpoint.c .Module "mod-100rel" registered
14:54:30.985 sip_endpoint.c .Module "mod-pjsua" registered
14:54:30.985 sip_endpoint.c .Module "mod-invite" registered
14:54:31.030 alsa_dev.c ..ALSA driver found 17 devices
14:54:31.030 alsa_dev.c ..ALSA initialized
14:54:31.030 pjlib ..select() I/O Queue created (0xcb5968)
14:54:31.035 pjsua_vid.c ..Initializing video subsystem..
14:54:31.155 v4l2_dev.c ...Video4Linux2 has 1 devices
14:54:31.155 colorbar_dev.c ...Colorbar video src initialized with 1
device(s):
14:54:31.155 colorbar_dev.c ... 0: Colorbar generator
On Tue, May 31, 2016 at 6:13 PM, Gianni Massi g.massi@infosolution.it
wrote:
Hi Kaushik,
If I understand the problem you have correctly, (please next time post
logs/console ouputs leading to your diagnosis of the problem, they can be
useful even if you’re 100% sure about the nature of the problem) you should
be able to follow the instructions from step 3 in this link to solve your
problem.
http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2013-December/016918.html
Hope this is useful,
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org] *Per conto di *Kaushik
Turlapaty
Inviato: martedì 31 maggio 2016 13:48
A: pjsip list pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] R: PJSIP call, play music and hangup in python
Hey,
I just figured out the problem is because of ALSA ( I am using Ubuntu
14.04 ). It is because of ALSA that I am not able to get the audio. Can
someone help me how to go about the whole ALSA thing to get the audio
Thanks,
Kaushik
On Tue, May 31, 2016 at 2:46 PM, Gianni Massi g.massi@infosolution.it
wrote:
You might need to put the conf_connect calls in the onMediaState()
callback. See if that works.
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org] *Per conto di *Kaushik
Turlapaty
Inviato: martedì 31 maggio 2016 10:57
A: pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] PJSIP call, play music and hangup in python
This is the logic of the goal I am trying to achieve. It should call, when confirmed, should play an audio wav file and hangup after that*
I am able to call, but when the call is lift, I cannot hear the audio. *
if* self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print *'Current call is'*, current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player(*'message.wav'*,loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created: samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to port 1 (sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Everything looks in order for me, you don’t have the common problem I expected, with portaudio being used instead of alsa, so no need to follow the link I gave you. Have you tried my previous suggestion about conf_connect?
Gianni
Da: pjsip [ mailto:pjsip-bounces@lists.pjsip.org mailto:pjsip-bounces@lists.pjsip.org] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 15:10
A: pjsip list pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] R: R: PJSIP call, play music and hangup in python
Hey,
This is the log
14:54:30.981 os_core_unix.c !pjlib 2.2.1-svn for POSIX initialized
14:54:30.983 sip_endpoint.c .Creating endpoint instance...
14:54:30.984 pjlib .select() I/O Queue created (0xca1850)
14:54:30.984 sip_endpoint.c .Module "mod-msg-print" registered
14:54:30.984 sip_transport. .Transport manager created.
14:54:30.984 pjsua_core.c .PJSUA state changed: NULL --> CREATED
14:54:30.985 sip_endpoint.c .Module "mod-pjsua-log" registered
14:54:30.985 sip_endpoint.c .Module "mod-tsx-layer" registered
14:54:30.985 sip_endpoint.c .Module "mod-stateful-util" registered
14:54:30.985 sip_endpoint.c .Module "mod-ua" registered
14:54:30.985 sip_endpoint.c .Module "mod-100rel" registered
14:54:30.985 sip_endpoint.c .Module "mod-pjsua" registered
14:54:30.985 sip_endpoint.c .Module "mod-invite" registered
14:54:31.030 alsa_dev.c ..ALSA driver found 17 devices
14:54:31.030 alsa_dev.c ..ALSA initialized
14:54:31.030 pjlib ..select() I/O Queue created (0xcb5968)
14:54:31.035 pjsua_vid.c ..Initializing video subsystem..
14:54:31.155 v4l2_dev.c ...Video4Linux2 has 1 devices
14:54:31.155 colorbar_dev.c ...Colorbar video src initialized with 1 device(s):
14:54:31.155 colorbar_dev.c ... 0: Colorbar generator
On Tue, May 31, 2016 at 6:13 PM, Gianni Massi <g.massi@infosolution.it mailto:g.massi@infosolution.it > wrote:
Hi Kaushik,
If I understand the problem you have correctly, (please next time post logs/console ouputs leading to your diagnosis of the problem, they can be useful even if you’re 100% sure about the nature of the problem) you should be able to follow the instructions from step 3 in this link to solve your problem.
http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2013-December/016918.html
Hope this is useful,
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org mailto:pjsip-bounces@lists.pjsip.org ] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 13:48
A: pjsip list <pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org >
Oggetto: Re: [pjsip] R: PJSIP call, play music and hangup in python
Hey,
I just figured out the problem is because of ALSA ( I am using Ubuntu 14.04 ). It is because of ALSA that I am not able to get the audio. Can someone help me how to go about the whole ALSA thing to get the audio
Thanks,
Kaushik
On Tue, May 31, 2016 at 2:46 PM, Gianni Massi <g.massi@infosolution.it mailto:g.massi@infosolution.it > wrote:
You might need to put the conf_connect calls in the onMediaState() callback. See if that works.
Gianni
Da: pjsip [mailto:pjsip-bounces@lists.pjsip.org mailto:pjsip-bounces@lists.pjsip.org ] Per conto di Kaushik Turlapaty
Inviato: martedì 31 maggio 2016 10:57
A: pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org
Oggetto: Re: [pjsip] PJSIP call, play music and hangup in python
This is the logic of the goal I am trying to achieve. It should call, when confirmed, should play an audio wav file and hangup after that
I am able to call, but when the call is lift, I cannot hear the audio.
if self.call.info().state == pjsua.CallState.DISCONNECTED:
current_call = None
print 'Current call is', current_call
in_call = False
elif self.call.info().state == pjsua.CallState.CONFIRMED:
#Call is Answred
print "Call Answred"
wfile = wave.open("message.wav")
time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time) + "ms"
wfile.close()
call_slot = self.call.info().conf_slot
self.wav_player_id=pjsua.Lib.instance().create_player('message.wav',loop=False)
self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
sleep(time)
pjsua.Lib.instance().player_destroy(self.wav_player_id)
self.call.hangup()
in_call = False
This is some part of the log when I run the program
17:03:26.375 pjsua_aud.c .....Creating file player: test.wav..
17:03:26.375 wav_player.c ......File player 'test.wav' created: samp.rate=16000, ch=1, bufsize=4KB, filesize=166KB
17:03:26.375 pjsua_aud.c ......Player created, id=0, slot=2
17:03:26.375 pjsua_aud.c .....Conf connect: 2 --> 1
17:03:26.375 pjsua_aud.c ......Set sound device: capture=-99, playback=-99
17:03:26.376 pjsua_aud.c .......No changes in capture and playback devices
17:03:26.376 conference.c ......Port 2 (test.wav) transmitting to port 1 (sip:*@..com)
17:03:28.141 pjsua_aud.c .....Destroying player 0..
17:03:28.141 pjsua_call.c .....Call 0 hanging up: code=603..
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org mailto:pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org