diff --git a/README.md b/README.md index d2c385c..c33b077 100644 --- a/README.md +++ b/README.md @@ -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): diff --git a/pylinphone.py b/pylinphone.py index c463a96..45d883d 100644 --- a/pylinphone.py +++ b/pylinphone.py @@ -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()