Browse Source

Add call status functionality

master
sqozz 4 years ago
parent
commit
15c57bf4cc
  1. 1
      README.md
  2. 16
      pylinphone.py

1
README.md

@ -11,6 +11,7 @@ Currently implemented Features: @@ -11,6 +11,7 @@ Currently implemented Features:
* pause the call (`call-pause`)
* resume the call (`call-resume`)
* play dtmf tones (`dtmf`)
* get call status (`call-status`)
Features supported by the unix socket (linphone deamon):

16
pylinphone.py

@ -93,6 +93,22 @@ class LinphoneCommunicationSocket(): @@ -93,6 +93,22 @@ class LinphoneCommunicationSocket():
else:
raise RuntimeError(answer["error"])
def call_status(self, call_id):
self.socket.send("call-status {call_id}".format(call_id=call_id).encode("ascii"))
answer = self._await_answer()
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())
}
return status
else:
raise RuntimeError(answer["error"])
def call_resume(self, call_id):
self.socket.send("call-resume {call_id}".format(call_id=call_id).encode("ascii"))
answer = self._await_answer()

Loading…
Cancel
Save