Merge pull request 'Replace linphone with pylinphone' (#1) from sqozz/fetapi:pylinphone into pylinphone

Reviewed-on: https://git.blinkenbunt.org/LUG-Saar/fetapi/pulls/1
This commit is contained in:
klonfish 2020-12-28 00:23:39 +01:00
commit c882bcd59f
1 changed files with 16 additions and 30 deletions

View File

@ -2,6 +2,7 @@ import linphone
import time
import threading
import subprocess
from pylinphone import LinphoneCommunicationSocket
class PhoneProxyConfiguration(object):
@ -56,30 +57,14 @@ class PhoneInterface(object):
self.__event_cbs = []
self.__config = config
self.__core = linphone.Core.new(cbs, None, config.linphone_config)
self.__core = LinphoneCommunicationSocket("/tmp/lpdaemon")
# Create and add all proxy configs
for p in config.proxies:
ainfo = self.__core.create_auth_info(p.username, p.username,
p.password, None, p.realm,
None)
self.__core.add_auth_info(ainfo)
pconf = self.__core.create_proxy_config()
pconf.edit()
if self.__core.version < '3.9.0':
pconf.identity = p.identity
else:
pconf.identity_address = pconf.normalize_sip_uri(p.identity)
pconf.publish_enabled = False
pconf.realm = p.realm
pconf.register_enabled = True
pconf.server_addr = p.proxy
self.__core.add_proxy_config(pconf)
pconf.done()
if p.name == config.default_proxy:
self.__core.default_proxy_config = pconf
aid = self.__core.register(p.username, p.proxy_address, p.password, p.username) # sip:XXXX@hg.eventphone.de, hg.eventphone.de, MySecretPassword, XXXX
self.__audioproc = None
aplay = subprocess.Popen(['aplay', '-qD%s' % config.sound_device],
@ -89,16 +74,17 @@ class PhoneInterface(object):
stdout=aplay.stdin)
# Set default parameters overriding the ones from the given config file
self.__core.set_user_agent('FeTAp 615', '0.1')
self.__core.stun_server = config.stun_server
self.__core.ringback = ''
self.__core.max_calls = 1
self.__core.inc_timeout = config.incoming_timeout
self.__core.set_call_error_tone(linphone.Reason.Busy, '')
self.__core.disable_chat(linphone.Reason.None)
self.__core.echo_cancellation_enabled = False
self.__core.video_capture_enabled = False
self.__core.video_display_enabled = False
# TODO: figure out how to set at least some of these settings through the unix socket
#self.__core.set_user_agent('FeTAp 615', '0.1')
#self.__core.stun_server = config.stun_server
#self.__core.ringback = ''
#self.__core.max_calls = 1
#self.__core.inc_timeout = config.incoming_timeout
#self.__core.set_call_error_tone(linphone.Reason.Busy, '')
#self.__core.disable_chat(linphone.Reason.None)
#self.__core.echo_cancellation_enabled = False
#self.__core.video_capture_enabled = False
#self.__core.video_display_enabled = False
def __global_state_changed(self, core, state, msg):
print 'Global state changed:', state, msg
@ -149,8 +135,8 @@ class PhoneInterface(object):
def __pollthread(self):
while self.__running:
self.__core.iterate()
time.sleep(0.02) # Value from example code
self.__core.process_event()
time.sleep(0.2) # Value for good measure
def start(self):
self.__running = True