Browse Source

Fix status parsing

The get_status method now parses the output from linphone more
dynamically. This allows to fetch status information while in different
states of a call (ringing, call established, etc).
master
sqozz 2 years ago
parent
commit
b4b1ba31dc
  1. 10
      pylinphone.py

10
pylinphone.py

@ -109,12 +109,10 @@ class LinphoneCommunicationSocket():
answer = self.send_command("call-status {call_id}".format(call_id=call_id))
if answer["status"]:
data = answer["data"]
status = {
"state": data[0].split(":", 1)[1].strip(),
"from": data[1].split(":", 1)[1].strip(),
"direction": data[2].split(":", 1)[1].strip(),
"duration": int(data[3].split(":", 1)[1].strip())
}
status = {}
for line in data:
key, value = line.split(":", 1)
status[key.strip().lower()] = value.strip()
return status
else:
raise RuntimeError(answer["error"])

Loading…
Cancel
Save