Compare commits

..

1 Commits

Author SHA1 Message Date
sqozz 579defbb7c Replace linphone with pylinphone 4 years ago
  1. 56
      README.md
  2. 46
      phoneinterface.py

56
README.md

@ -1,56 +0,0 @@
# fetapi - FeTAp with a Raspberry Pi
```
,ooFeTApFeTApFeTA%=+-,.
,+FeTAp+' `o,,
,oFeTAp+ `,
,ooo' ,oFeTApFeTAp o
oo +FeTAp+' `oo, H
o o' X o l
,@=@+ o ,,-+*==+-., R o .;
,@=@+ o o' ,/ 22 11 ``, E`ooooo'
@@* @@ oo o' / 33 , ` ` , ; T
@:n T:@ oo o ; 44 , . \ L
uM:m A:K oFeTAp' ;55 , : ; A
E:Rn N:t F, | ` : ; | H
SC:h K:o e, ` 66 ` , dHHH C
A:Ll L:s r, ` 77 `. , . 0 `q/ S
ER:a P:U n, \ 88 99 00 ,' L
R:Be i:M s `<,,______,-` sZ, E
i:T E:r p, `sZ B
S:K l:T r, A
o:N H:a e, G
t:a s:c c, ,x+x+'
k:T:@:U:M:R:n; h, ,p+e+r+a+t/
`@:n:M:E:'
```
## Installation
### Installing `linphone-cli` on Raspbian
1. Install `debootstrap`
```
apt install debootstrap
```
2. Create a *Debian/sid* chroot environment
```
cd /var/tmp
mkdir debian-sid
debootstrap --arch=armel --foreign --variant=minbase sid ./debian-sid http://ftp.de.debian.org/debian
chroot debian-sid/ /debootstrap/debootstrap --second-stage
```
3. Install `linphone-cli` inside the chroot environment
```
chroot debian-sid/ apt -y install linphone-cli
```

46
phoneinterface.py

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

Loading…
Cancel
Save