From 712f56abcc8050beaa3e80835b818cc7a28bf4fb Mon Sep 17 00:00:00 2001 From: sqozz Date: Tue, 1 Sep 2020 10:36:48 +0200 Subject: [PATCH] Implement outgoing calls --- README.md | 1 + pylinphone.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index d08cd65..73ad457 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Currently implemented Features: * register a new account (`register`) * check status for an registered account (`register-status` and `register-info`) * event-queue polling and onEvent functions (`pop-event`) +* create an outgoing call (`call`) * answer an incoming call (`accept`) * terminate a running call (`terminate`) diff --git a/pylinphone.py b/pylinphone.py index 5a79858..3ce1016 100644 --- a/pylinphone.py +++ b/pylinphone.py @@ -69,6 +69,14 @@ class LinphoneCommunicationSocket(): else: raise RuntimeError(answer["error"]) + def call(self, sip_address): + self.socket.send("call {sip_address}".format(sip_address=sip_address).encode("ascii")) + answer = self._await_answer() + if answer["status"]: + return answer["data"][0].split(":", 1)[1].strip() + else: + raise RuntimeError(answer["error"]) + def process_event(self): self.socket.send("pop-event".encode("ascii")) answer = self._await_answer() @@ -150,3 +158,15 @@ class LinphoneCommunicationSocket(): print("dummy onLinphoneCallStreamsRunning") pass + def onLinphoneCallOutgoingInit(self, event): + print("dummy onLinphoneCallOutgoingInit") + pass + + def onLinphoneCallOutgoingProgress(self, event): + print("dummy onLinphoneCallOutgoingProgress") + pass + + def onLinphoneCallOutgoingRinging(self, event): + print("dummy onLinphoneCallOutgoingRinging") + pass +