Add call status functionality
This commit is contained in:
parent
9e5c0a69ee
commit
15c57bf4cc
2 changed files with 17 additions and 0 deletions
|
@ -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):
|
||||
|
|
|
@ -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…
Reference in a new issue