Update 'trashtalker.py'

This commit is contained in:
Maff 2019-04-29 14:07:46 +00:00
parent 032214b5a0
commit 664cf3beb2
1 changed files with 20 additions and 12 deletions

View File

@ -7,22 +7,29 @@ from signal import signal, SIGTERM
from random import shuffle from random import shuffle
## NOTE: ## NOTE:
## This library uses the PJSUA library which is officially deprecated ## This script is designed to run either on the same machine or firewalled/segregated network segment
## The reason for this is that I couldn't get this to work with equivalent ## as the telephony appliance(s) that will use it. While there should be no security risk to doing so,
## code for PJSUA2. ## you should not have the SIP endpoint exposed by this application reachable on the public internet.
## At time of publishing, the only library version of pjsua available ## This script should be configured to run automatically, and your telephony appliance should be configured
## in the repos for Debian 9 is the deprecated PJSUA (python-pjsua) ## to treat it as a no-authentication or "IP-based authentication" SIP trunk. Any number or name will
## Please also be aware that, by default, playlist length is limited ## be recognised and answered automatically by this script.
## to 64 items. I can find no reason for this limitation, and it is
## specific to the python bindings for the PJSUA library.
## If you'd like to have a playlist longer than 64 items, you will need to
## recompile python-pjsua with the appropriate adjustment to _pjsua.c line 2515
## ##
## If you can get this working using PJSUA2, a pull request would be greatly ## This script uses the PJSUA library which is officially deprecated
## appreciated. ## The reason for this is that I couldn't get this to work with equivalent code for PJSUA2.
## At time of publishing, the only library version of pjsua available in the repos for Debian 9
## is the deprecated PJSUA (python-pjsua)
## Please also be aware that, by default, playlist length is limited to 64 items. I can find no reason
## for this limitation, and it is specific to the python bindings for the PJSUA library.
## If you'd like to have a playlist longer than 64 items, you will need to recompile python-pjsua
## with the appropriate adjustment to _pjsua.c line 2515
##
## If you can get this working using PJSUA2, a pull request would be greatly appreciated.
# Configuration # Configuration
LOG_LEVEL=0 LOG_LEVEL=0
# You can have multiple copies of this script serving different playlists by simply duplicating it
# ensuring you change the sourcepath and sipport accordingly.
#TODO: make this configurable via a standard config file.
sourcepath="/opt/media/" sourcepath="/opt/media/"
sipport=5062 sipport=5062
# End configuration # End configuration
@ -78,6 +85,7 @@ class CallCb(pj.CallCallback):
loop=True, filelist=self.playlist, label="trashtalklist") loop=True, filelist=self.playlist, label="trashtalklist")
self.playlistslot=pj.Lib.instance().playlist_get_slot(self.playlist_instance) self.playlistslot=pj.Lib.instance().playlist_get_slot(self.playlist_instance)
olog(4, "event-call-state-early", "initialised new trashtalk playlist instance") olog(4, "event-call-state-early", "initialised new trashtalk playlist instance")
#answer the call once playlist is prepared
self.call.answer(SIPStates.answer) self.call.answer(SIPStates.answer)
elif self.call.info().state == pj.CallState.CONFIRMED: elif self.call.info().state == pj.CallState.CONFIRMED:
olog(3, "event-call-state-confirmed", "answered call") olog(3, "event-call-state-confirmed", "answered call")