Skip to main content

baresdk

Python bindings for a thread-safe SIP/RTP library. Built on baresip + libre.

pip install baresdk

Features

Category
Transport UDP · TCP · TLS · WS · WSS
Crypto SRTP-SDES · DTLS-SRTP
NAT ICE · STUN · TURN
Calls Invite · Answer · Hangup · Hold/Resume · DTMF · Blind/Attended transfer
Messaging SIP MESSAGE · Presence · BLF · MWI
Audio AEC · NS · AGC · gain · mute · device hot-switch · PCM tap · WAV recording
Stats RTCP/MOS · jitter · bandwidth · SIP trace · pcap
Multi-account ✓ — unlimited accounts per stack
Thread-safe ✓ — call any API from any thread

Requirements

Linux — two runtime libraries required:

sudo apt install libssl3 libpulse0                    # Ubuntu/Debian
sudo dnf install openssl-libs pulseaudio-libs         # Fedora/RHEL
sudo pacman -S openssl libpulse                       # Arch

import baresdk prints the exact install command if either is missing.
libwebrtc-audio-processing-1 is optional — enables AEC_WEBRTC full-duplex mode; the SDK works without it.

Windows — only the Visual C++ Redistributable 2015–2022 required. OpenSSL, zlib, and opus are statically embedded.

Quick start

import baresdk as sdk

# Receive calls
sdk.configure(log_level=1)
acc = sdk.create_account("alice@pbx.example.com", "secret")
acc.register()

@sdk.on("incoming_call")
def _(ev):
    ev.call.answer()

@sdk.on("ended")
def _(ev):
    sdk.stop()

sdk.run()
# Make a call
sdk.configure(log_level=1)
acc = sdk.create_account("alice@pbx.example.com", "secret")
acc.register()

@sdk.on("registered")
def _(ev):
    sdk.call("bob@pbx.example.com")

@sdk.on("ended")
def _(ev):
    sdk.stop()

sdk.run()

WSS + DTLS-SRTP + ICE:

sdk.configure(verify_server=True)
acc = sdk.create_account("alice@pbx.example.com", "secret",
    transport="wss", server_url="wss://pbx.example.com/ws",
    media_enc="dtls_srtp", ice_enabled=True,
    stun_server="stun:stun.l.google.com:19302")

Audio

sdk.set_aec(True)
sdk.set_ns(True)
sdk.set_agc(True)
sdk.set_mic_gain(6.0)       # dB, range −20 to +20
sdk.set_speaker_gain(-3.0)
sdk.set_jitter_buffer(20, 200)
AEC mode Quality Requires
Suppressor (default, mode=1) Half-duplex nothing
WebRTC (mode=2) Full-duplex libwebrtc-audio-processing-1
# WebRTC full-duplex AEC — configure before first account (desktop only, opt-in build)
sdk.configure(aec_mode=2)   # 2 = WEBRTC; requires cmake -DBARESDK_WITH_WEBRTC_AEC=ON

sdk.create_account parameters

Parameter Type Example
transport str "udp" "tcp" "tls" "ws" "wss"
media_enc str "none" "sdes" "dtls_srtp"
ice_enabled bool
stun_server str "stun:stun.l.google.com:19302"
turn_server str "turn:turn.example.com:3478"
server_url str WebSocket URL — overrides host/port
audio_codecs list[str] ["opus", "ulaw", "alaw"]
extra_headers dict Added to every REGISTER/INVITE

sdk.configure() accepts global options (applies before first account):

Key Example
log_level 0–3
stats_interval_ms 5000
verify_server False to skip TLS verification
transport "wss"

Events — @sdk.on(name) names

Name When Sub-names (also available)
reg_state Registration changed registering · registered · unregistered · reg_failed
incoming_call INVITE received —
call_state Call changed calling · ringing · established · held · ended · cancelled · call_failed
dtmf Digit received —
media_stats Periodic RTCP/MOS report —
transfer_request REFER received —
message SIP MESSAGE received —
presence_state Buddy presence changed —
mwi Voicemail notification —
quality_alert MOS/loss/jitter/RTT threshold crossed —
sip_trace Raw SIP message (enable with trace_sip=True) —
* Every event (wildcard) —
@sdk.on("registered")
def _(ev):
    print("registered!")

@sdk.on("incoming_call")
def _(ev):
    print(f"call from {ev.from_uri}")
    ev.call.answer()

@sdk.on("media_stats")
def _(ev):
    print(f"MOS={ev.mos_lq:.2f}  RTT={ev.rtt_ms:.0f}ms  loss={ev.loss_pct:.1f}%")

Metadata

Release files for baresdk 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for baresdk 2.1.0
File Interpreter ABI Platform
baresdk-2.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
baresdk-2.1.0-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details

Total release size: 4.6 MB

Release files / baresdk-2.1.0-py3-none-win_amd64.whl

Download URL baresdk-2.1.0-py3-none-win_amd64.whl
Size 2.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
b6ded3a09bc4d2131ea1e0779e49125d6b65c45dafb6240ab8704f5263a191d3
BLAKE2b-256 checksum
How to use checksums
972a4dbeca05c4be93349e2ff12b2db9f09fdd9b01a58916237dc94073b2b3c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / baresdk-2.1.0-py3-none-manylinux_2_34_x86_64.whl

Download URL baresdk-2.1.0-py3-none-manylinux_2_34_x86_64.whl
Size 2.0 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
fc03ba2d6ae13d3bb67eca4416c6122671a840ac8d6f58433435215f0b9ae3b7
BLAKE2b-256 checksum
How to use checksums
560e9d031b01ff1de0b7c48b52d13d1c8dba6d6a24d51a0e2a63a05c1e826836
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.31.0

1 release file

1.3.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page