Skip to main content

PyVoIP is a pure python VoIP/SIP/RTP library.

Project description

pyVoIP

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.

Getting Started

Simply run pip install pyVoIP, or if installing from source:

git clone https://github.com/tayler6000/pyVoIP.git
cd pyVoIP
pip install .

Don't forget to check out the documentation!

Basic Example

This basic code will simple make a phone that will automatically answer then hang up.

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


if __name__ == "__main__":
    phone = VoIPPhone(
        <SIP Server IP>,
        <SIP Server Port>,
        <SIP Server Username>,
        <SIP Server Password>,
        callCallback=answer,
        myIP=<Your computer's local IP>,
        sipPort=<Port to use for SIP (int, default 5060)>,
        rtpPortLow=<low end of the RTP Port Range>,
        rtpPortHigh=<high end of the RTP Port Range>,
    )
    phone.start()
    input("Press enter to disable the phone")
    phone.stop()

Using an outbound SIP proxy

If your provider requires a separate outbound proxy, keep server pointed at the SIP domain / registrar and pass the proxy host separately.

phone = VoIPPhone(
    "sip.example.com",
    5060,
    "alice",
    "secret",
    myIP="192.0.2.10",
    proxy="pbx.example.net",
    proxyPort=5060,
    auth_username="alice-auth-id",  # Optional: used for Proxy-Authorization
    callCallback=answer,
)

proxy may be a hostname, host:port, or a SIP URI such as sip:pbx.example.net:5060.

Sponsors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfcvoip-2.7.4.tar.gz (65.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rfcvoip-2.7.4-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file rfcvoip-2.7.4.tar.gz.

File metadata

  • Download URL: rfcvoip-2.7.4.tar.gz
  • Upload date:
  • Size: 65.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for rfcvoip-2.7.4.tar.gz
Algorithm Hash digest
SHA256 620c66bb9b45b3f74bb5fbb8e32e1d57850b13eb4dd52cec79b30684eefaf136
MD5 143bd8f76e23c8a971445b1fa888dfee
BLAKE2b-256 b78e6dd468614a375d2f038c9b0512ed906503fcabbccfaf01556aacf1029900

See more details on using hashes here.

File details

Details for the file rfcvoip-2.7.4-py3-none-any.whl.

File metadata

  • Download URL: rfcvoip-2.7.4-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for rfcvoip-2.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 42bf5b27f24ec18a8aef68ff60c902085be1a5365d53a89ed790d3ecaa8c5941
MD5 7ca47c4e1b16a7ba526a85d18abf5d1b
BLAKE2b-256 ac4273eac0311702338f613bff44ffda333cc3e8dd8147f4161e8b7c10eb0918

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page