From 6cf17342c0d2e741f904182f89f952ef98eafa40 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Thu, 11 Jan 2024 09:37:29 -0600 Subject: [PATCH] [CHANGE] Updated example in README.md --- README.md | 38 +++++++++++++++++++++++--------------- docs/Examples.rst | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c4a06d2..8d81ab3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # pyVoIP -PyVoIP is a pure python VoIP/SIP/RTP library. Currently, it supports PCMA, PCMU, and telephone-event. +PyVoIP is a pure python VoIP/SIP/RTP library. Currently, it supports PCMA, PCMU, and telephone-event. -This library does not depend on a sound library, i.e. you can use any sound library that can handle linear sound data i.e. pyaudio or even wave. Keep in mind PCMU/PCMA only supports 8000Hz, 1 channel, 8 bit audio. +This library does not depend on a sound library, i.e. you can use any sound library that can handle linear sound data such as pyaudio or even wave. Keep in mind PCMU/PCMA only supports 8000Hz, 1 channel, 8 bit audio. ## Getting Started Simply run `pip install pyVoIP`, or if installing from source: @@ -18,20 +18,28 @@ Don't forget to check out [the documentation](https://pyvoip.readthedocs.io/)! This basic code will simple make a phone that will automatically answer then hang up. ```python -from pyVoIP.VoIP import VoIPPhone, InvalidStateError - -def answer(call): # This will be your callback function for when you receive a phone call. - try: - call.answer() - call.hangup() - except InvalidStateError: - pass - +from pyVoIP.credentials import CredentialsManager +from pyVoIP.VoIP.call import VoIPCall +from pyVoIP.VoIP.error import InvalidStateError +from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter + +class Call(VoIPCall): + + def ringing(self, invite_request): + try: + self.answer() + self.hangup() + except InvalidStateError: + pass + if __name__ == "__main__": - phone=VoIPPhone(, , , , callCallback=answer, myIP=, sipPort=, rtpPortLow=, rtpPortHigh=) - phone.start() - input('Press enter to disable the phone') - phone.stop() + cm = CredentialsManager() + cm.add(, ) + params = VoIPPhoneParamter(, , , cm, bind_ip=, call_class=Call) + phone = VoIPPhone(params) + phone.start() + input('Press enter to disable the phone') + phone.stop() ``` ### Sponsors diff --git a/docs/Examples.rst b/docs/Examples.rst index b63acf5..e4d42cc 100644 --- a/docs/Examples.rst +++ b/docs/Examples.rst @@ -31,7 +31,7 @@ The following will create a phone that answers and automatically hangs up: if __name__ == "__main__": cm = CredentialsManager() cm.add(, ) - params = VoIPPhoneParamter(, , , cm, bind_ip=, call_class=Call) + params = VoIPPhoneParamter(, , , cm, bind_ip=, call_class=Call) phone = VoIPPhone(params) phone.start() input('Press enter to disable the phone')