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).
This commit is contained in:
sqozz 2021-02-25 10:35:02 +01:00
parent 7e28f36dc3
commit b4b1ba31dc
1 changed files with 4 additions and 6 deletions

View File

@ -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"])