[SIP Beyond VoIP] Trying to playback audio on live session.

Adrian Georgescu ag at ag-projects.com
Mon Jun 10 11:39:30 CEST 2019


See this example

https://github.com/AGProjects/sylkserver/blob/master/sylk/applications/playback/__init__.py <https://github.com/AGProjects/sylkserver/blob/master/sylk/applications/playback/__init__.py>


> On 10 Jun 2019, at 01:53, Voipmanvn <voipmanvn at gmail.com> wrote:
> 
> Hi Adrian,
> 
> I was tried so many code to check and no-luck, seem i am get stuff on that and could not get any result with playing audio and more further action.
> 
> I hope you can give me some more document, or idea to check more.
> 
> I custom sip-session script to pickup the call. Add some code in _NH_SIPSessionDidStart
> 
> in IncomingCallInitializer(object):
> 
> Just to play audio on that session. code somethinglike
> 
> def _NH_SIPSessionDidStart(self, notification):
> 
>         notification_center = NotificationCenter()
>         session = notification.sender
>         audio_stream = notification.data.streams[0]
>         notification_center.remove_observer(self, sender=session)
>         IncomingCallInitializer.sessions -= 1
> 
>         ui = UI()
>         ui.status = 'Connected'
>         reactor.callLater(2, setattr, ui, 'status', None)
> 
>         identity = str(session.remote_identity.uri)
>         if session.remote_identity.display_name:
>             identity = '"%s" <%s>' % (session.remote_identity.display_name, identity)
>         send_notice("SIP session with '%s' established" % identity)
>         for stream in notification.data.streams:
>             if stream.type == 'audio':
>                 send_notice('Audio stream using "%s" codec at %sHz' % (stream.codec, stream.sample_rate))
>                 if stream.ice_active:
>                     send_notice('Audio RTP endpoints %s:%d (ICE type %s) <-> %s:%d (ICE type %s)' % (stream.local_rtp_address, stream.local_rtp_port, stream.local_rtp_candidate_type, stream.remote_rtp_address, stream.remote_rtp_port, stream.remote_rtp_candidate_type))
>                 else:
>                     send_notice('Audio RTP endpoints %s:%d <-> %s:%d' % (stream.local_rtp_address, stream.local_rtp_port, stream.remote_rtp_address, stream.remote_rtp_port))
>                 if stream.encryption.active:
> 
>                     send_notice('RTP audio stream is encrypted using %s (%s)\n' % (stream.encryption.type, stream.encryption.cipher))
>         if session.remote_user_agent is not None:
>             send_notice('Remote SIP User Agent is "%s"' % session.remote_user_agent)
> 
>         send_notice('start to play audio to cehck %s' % dir(session))
>         filename = '/usr/share/sipsimple/resources/sounds/pet0.wav'
>         player = WavePlayer(audio_stream.mixer, ResourcePath(filename).normalized)
>         notification_center.add_observer(self, sender=player)
>         audio_stream.bridge.add(player)
>         player.play().wait()
>         player.stop()
>         audio_stream.bridge.remove(player)
>         notification_center.remove_observer(self, sender=player)
>         session.end()
>         session = None
>         send_notice('start to play audio to cehck done')
> 
> The call is answered and nothing to play, no log to show error and i see that something death on that call, i could not exit the call as well.
> 
> Can you help me please.
> 
> 
> 
>> 
>> Yes, but there is no pre-made script to do such task, you must program this yourself.
>> 
>> You may look for inspiration at SylkServer that uses the same SDK and has an application that plays back files.
>> 
>> Adrian
>> 
>>> On 7 Jun 2019, at 05:49, Voipmanvn <voipmanvn at gmail.com <mailto:voipmanvn at gmail.com>> wrote:
>>> 
>>> Dear,
>>> 
>>> Thanks Adrian,
>>> 
>>> I am wonder if sipsimple can answer the call and play wav file. I have tried some case but no luck.
>>> 
>>> Do you have some code to suggest to work with this.
>>> 
>>> Thank you in advance.
>>> 
>>> Thanh
>>> 
>>> 
>>>> On Jun 6, 2019, at 17:49, sipbeyondvoip-request at lists.ag-projects.com <mailto:sipbeyondvoip-request at lists.ag-projects.com> wrote:
>>>> 
>>>> Send SIPBeyondVoIP mailing list submissions to
>>>> 	sipbeyondvoip at lists.ag-projects.com <mailto:sipbeyondvoip at lists.ag-projects.com>
>>>> 
>>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>> 	https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>>>> or, via email, send a message with subject or body 'help' to
>>>> 	sipbeyondvoip-request at lists.ag-projects.com
>>>> 
>>>> You can reach the person managing the list at
>>>> 	sipbeyondvoip-owner at lists.ag-projects.com
>>>> 
>>>> When replying, please edit your Subject line so it is more specific
>>>> than "Re: Contents of SIPBeyondVoIP digest..."
>>>> 
>>>> 
>>>> Today's Topics:
>>>> 
>>>> 1. Re: python-sipsimple sip-register	auto	unregistered
>>>>    (Adrian Georgescu)
>>>> 
>>>> 
>>>> ----------------------------------------------------------------------
>>>> 
>>>> Message: 1
>>>> Date: Thu, 6 Jun 2019 07:48:57 -0300
>>>> From: Adrian Georgescu <ag at ag-projects.com>
>>>> To: SIP Beyond VoIP <sipbeyondvoip at lists.ag-projects.com>
>>>> Subject: Re: [SIP Beyond VoIP] python-sipsimple sip-register	auto
>>>> 	unregistered
>>>> Message-ID: <33072C4F-3F7A-450D-85C8-B063631F52CE at ag-projects.com>
>>>> Content-Type: text/plain; charset="us-ascii"
>>>> 
>>>> I am not sure I understand your question. What do you try to achieve? Please give an example.
>>>> 
>>>> Adrian
>>>> 
>>>>> On 6 Jun 2019, at 04:57, Voipmanvn <voipmanvn at gmail.com> wrote:
>>>>> 
>>>>> Thank you  Adrian Georgescu
>>>>> I have tried and it works well.
>>>>> Farther I have tried to make funny callback in sip-audio-session.
>>>>> I set some option to pickup the call.
>>>>> 	options.auto_answer_interval = 0
>>>>>  	options.disable_sound = True
>>>>> And make test, it works too. I am wonder if you can help me some thing about callback for that answer?
>>>>> parser.add_option('--auto-answer', action='callback', callback=parse_handle_call_option, callback_args=('auto_answer_interval',), help='Interval after which to answer an incoming session (disabled by default). If the option is specified but the interval is not, it defaults to 0 (accept the session as soon as it starts ringing).', metavar='[INTERVAL]')
>>>>>  parser.add_option('--auto-hangup', action='callback', callback=parse_handle_call_option, callback_args=('auto_hangup_interval',), help='Interval after which to hang up an established session (disabled by default). If the option is specified but the interval is not, it defaults to 0 (hangup the session as soon as it connects).', metavar='[INTERVAL]')
>>>>> 
>>>>> 
>>>>> 
>>>>> Thank you in advance
>>>>> Cheer.
>>>>> ==============================
>>>>> -r 0
>>>>> 
>>>>> will keep the client registered until you press control D
>>>>> 
>>>>>> On 5 Jun 2019, at 12:18, Voipmanvn <voipmanvn at gmail.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>> wrote:
>>>>>> 
>>>>>> Hello,
>>>>>> 
>>>>>> I was tried to run sip-register with -h option. And seem that I have to press Ctr+D to unregistered. But I did not, and the script auto unregistered.
>>>>>> 
>>>>>> That is content from command line.
>>>>>> 
>>>>>> sip-register -h
>>>>>> Usage: sip-register [options]
>>>>>> 
>>>>>> This script registers the contact address of the given SIP account to the SIP
>>>>>> registrar and refresh it while the program is running. When Ctrl+D is pressed
>>>>>> it will unregister.
>>>>>> 
>>>>>> Options:
>>>>>> -h, --help            show this help message and exit
>>>>>> -a NAME, --account=NAME
>>>>>>                      The name of the account to use. If not supplied, the
>>>>>>                      default account will be used.
>>>>>> -c CONFIG_DIRECTORY, --config-directory=CONFIG_DIRECTORY
>>>>>>                      The configuration directory to use. This overrides the
>>>>>>                      default location.
>>>>>> -s, --trace-sip       Dump the raw contents of incoming and outgoing SIP
>>>>>>                      messages (disabled by default).
>>>>>> -j, --trace-pjsip     Print PJSIP logging output (disabled by default).
>>>>>> -n, --trace-notifications
>>>>>>                      Print all notifications (disabled by default).
>>>>>> -r MAX_REGISTERS, --max-registers=MAX_REGISTERS
>>>>>>                      Max number of REGISTERs sent (default 1, set to 0 for
>>>>>>                      infinite).
>>>>>> -b, --batch           Run the program in batch mode: reading input from the
>>>>>>                      console is disabled. This is particularly useful when
>>>>>>                      running this script in a non-interactive environment.
>>>>>> 
>>>>>> 
>>>>>> Please help.
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On Jun 5, 2019, at 17:00, sipbeyondvoip-request at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <mailto:sipbeyondvoip-request at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>> wrote:
>>>>>>> 
>>>>>>> Send SIPBeyondVoIP mailing list submissions to
>>>>>>> 	sipbeyondvoip at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <mailto:sipbeyondvoip at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>
>>>>>>> 
>>>>>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>>>>> 	https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> or, via email, send a message with subject or body 'help' to
>>>>>>> 	sipbeyondvoip-request at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> 
>>>>>>> You can reach the person managing the list at
>>>>>>> 	sipbeyondvoip-owner at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> 
>>>>>>> When replying, please edit your Subject line so it is more specific
>>>>>>> than "Re: Contents of SIPBeyondVoIP digest..."
>>>>>>> 
>>>>>>> 
>>>>>>> Today's Topics:
>>>>>>> 
>>>>>>> 1. python-sipsimple sip-register auto unregistered (Voipmanvn)
>>>>>>> 
>>>>>>> 
>>>>>>> ----------------------------------------------------------------------
>>>>>>> 
>>>>>>> Message: 1
>>>>>>> Date: Wed, 5 Jun 2019 11:03:32 +0700
>>>>>>> From: Voipmanvn <voipmanvn at gmail.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>
>>>>>>> To: sipbeyondvoip at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> Subject: [SIP Beyond VoIP] python-sipsimple sip-register auto
>>>>>>> 	unregistered
>>>>>>> Message-ID: <2B46476C-C55B-4BC7-8104-F9171138D330 at gmail.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>
>>>>>>> Content-Type: text/plain; charset="us-ascii"
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> I am very new in this lib and trying to make some test. I hope i can get some idea, information from our team. thank you in advance.
>>>>>>> 
>>>>>>> I add some account with:
>>>>>>> 
>>>>>>> sip-settings -a add 1002 at x.x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <mailto:1002 at x.x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>> xxxxxx
>>>>>>> sip-settings -a default 1002 at x.x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <mailto:1002 at x.x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>
>>>>>>> 
>>>>>>> Then, i run sip-register
>>>>>>> 
>>>>>>> and it return me something like
>>>>>>> 
>>>>>>> 
>>>>>>> root at sipsimple <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>:~# sip-register
>>>>>>> Using account 1002 at x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <mailto:1002 at x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>.x
>>>>>>> 2019-06-05 03:48:57 Registered contact "sip:92745381 at x.x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>:34532" for sip:1002 at x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip> <sip:1002 at x.x.x <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>>.x at x.x.x.x:5060;transport=udp (expires in 3600 seconds).
>>>>>>> 2019-06-05 03:48:58 Registration ended.
>>>>>>> 
>>>>>>> then, i see log registered and unregistered in  my asterisk box.
>>>>>>> 
>>>>>>> this is some information about lib:
>>>>>>> 
>>>>>>> python-sipsimple is already the newest version (3.4.2bionic).
>>>>>>> sipclients is already the newest version (3.4.0bionic).
>>>>>>> 
>>>>>>> Please help.
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> Thanh Truong
>>>>>>> TDVSS- https://www.tdvss.com <https://www.tdvss.com/>
>>>>>>> 71/76 Str 6, Ward 15, GV, HCM, VN
>>>>>>> tel: + 84984480646
>>>>>>> skype: voipmanvn
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> -------------- next part --------------
>>>>>>> An HTML attachment was scrubbed...
>>>>>>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/84521fc0/attachment-0001.html <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/84521fc0/attachment-0001.html>>
>>>>>>> 
>>>>>>> ------------------------------
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> SIPBeyondVoIP mailing list
>>>>>>> SIPBeyondVoIP at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>>> 
>>>>>>> 
>>>>>>> End of SIPBeyondVoIP Digest, Vol 107, Issue 1
>>>>>>> *********************************************
>>>>>> 
>>>>>> _______________________________________________
>>>>>> SIPBeyondVoIP mailing list
>>>>>> SIPBeyondVoIP at lists.ag-projects.com <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>> 
>>>>> -------------- next part --------------
>>>>> An HTML attachment was scrubbed...
>>>>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/6e17e62b/attachment.html <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/6e17e62b/attachment.html>>
>>>>> -------------- next part --------------
>>>>> A non-text attachment was scrubbed...
>>>>> Name: signature.asc
>>>>> Type: application/pgp-signature
>>>>> Size: 235 bytes
>>>>> Desc: Message signed with OpenPGP
>>>>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/6e17e62b/attachment.sig <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190605/6e17e62b/attachment.sig>>
>>>>> 
>>>>> Previous message: [SIP Beyond VoIP] python-sipsimple sip-register auto	unregistered <https://lists.ag-projects.com/pipermail/sipbeyondvoip/2019-June/003364.html>
>>>>> Messages sorted by: [ date ] <https://lists.ag-projects.com/pipermail/sipbeyondvoip/2019-June/date.html#3365> [ thread ] <https://lists.ag-projects.com/pipermail/sipbeyondvoip/2019-June/thread.html#3365> [ subject ] <https://lists.ag-projects.com/pipermail/sipbeyondvoip/2019-June/subject.html#3365> [ author ] <https://lists.ag-projects.com/pipermail/sipbeyondvoip/2019-June/author.html#3365>
>>>>> More information about the SIPBeyondVoIP mailing list <https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip>
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> SIPBeyondVoIP mailing list
>>>>> SIPBeyondVoIP at lists.ag-projects.com
>>>>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>>>> 
>>>> -------------- next part --------------
>>>> An HTML attachment was scrubbed...
>>>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190606/ee073121/attachment.html>
>>>> -------------- next part --------------
>>>> A non-text attachment was scrubbed...
>>>> Name: signature.asc
>>>> Type: application/pgp-signature
>>>> Size: 235 bytes
>>>> Desc: Message signed with OpenPGP
>>>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190606/ee073121/attachment.sig>
>>>> 
>>>> ------------------------------
>>>> 
>>>> _______________________________________________
>>>> SIPBeyondVoIP mailing list
>>>> SIPBeyondVoIP at lists.ag-projects.com
>>>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>>>> 
>>>> 
>>>> End of SIPBeyondVoIP Digest, Vol 107, Issue 4
>>>> *********************************************
>>> 
>>> _______________________________________________
>>> SIPBeyondVoIP mailing list
>>> SIPBeyondVoIP at lists.ag-projects.com <mailto:SIPBeyondVoIP at lists.ag-projects.com>
>>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>>> 
>> 
>> -------------- next part --------------
>> A non-text attachment was scrubbed...
>> Name: signature.asc
>> Type: application/pgp-signature
>> Size: 235 bytes
>> Desc: Message signed with OpenPGP
>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190607/e1f819aa/attachment-0001.sig <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190607/e1f819aa/attachment-0001.sig>>
>> 
>> ------------------------------
>> 
>> Message: 2
>> Date: Sat, 8 Jun 2019 09:36:56 +0700
>> From: Voipmanvn <voipmanvn at gmail.com <mailto:voipmanvn at gmail.com>>
>> To: sipbeyondvoip at lists.ag-projects.com <mailto:sipbeyondvoip at lists.ag-projects.com>
>> Subject: Re: [SIP Beyond VoIP] SIPBeyondVoIP Digest, Vol 107, Issue 4
>> Message-ID: <7AE342BD-8C1A-43A7-BB0C-F2475B58844B at gmail.com <mailto:7AE342BD-8C1A-43A7-BB0C-F2475B58844B at gmail.com>>
>> Content-Type: text/plain; charset="us-ascii"
>> 
>> Thank you for your idea.
>> 
>> I will try with that.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190608/04e0ad6c/attachment-0001.html <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190608/04e0ad6c/attachment-0001.html>>
>> 
>> ------------------------------
>> 
>> _______________________________________________
>> SIPBeyondVoIP mailing list
>> SIPBeyondVoIP at lists.ag-projects.com <mailto:SIPBeyondVoIP at lists.ag-projects.com>
>> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>> 
>> 
>> End of SIPBeyondVoIP Digest, Vol 107, Issue 6
>> *********************************************
> 
> _______________________________________________
> SIPBeyondVoIP mailing list
> SIPBeyondVoIP at lists.ag-projects.com
> https://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190610/067f14ef/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190610/067f14ef/attachment-0001.sig>


More information about the SIPBeyondVoIP mailing list