Skip to content

Commit 9097a0a

Browse files
committed
PySIP v2.0 - Complete async rewrite
BREAKING CHANGES: - Complete rewrite with new API - Requires Python 3.10+ - New module structure Architecture: - Pure asyncio with DatagramProtocol for RTP (zero threads) - Structured concurrency with async context managers - Type-safe with __slots__ throughout New Features: - SIPClient as main entry point - Call class with media operations - Numpy-based G.711 codecs (PCMU/PCMA) - Adaptive jitter buffer - EdgeTTS integration - DTMF detection/generation (RFC 2833) - Answering Machine Detection - Call recording Protocol Support: - RFC 3261 SIP parser/builder - RFC 4566 SDP parser/builder - RFC 3550 RTP packet handling - Proper OPTIONS handling - ACK for all final responses Removed: - Legacy v1 code - Thread-based RTP handler - Old test files - Example scripts Performance: - 100+ concurrent calls on standard hardware - uvloop support for 2-3x improvement
1 parent efb7b6f commit 9097a0a

92 files changed

Lines changed: 12168 additions & 5782 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PySIP/__init__.py

Lines changed: 163 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,163 @@
1-
# PySIP is an open-source Python library designed for making VoIP
2-
# calls using the SIP (Session Initiation Protocol) and
3-
# SDP (Session Description Protocol) protocols.
4-
# It provides asynchronous capabilities, allowing you to create
5-
# VoIP applications that efficiently handle real-time communications.
6-
#
7-
# Key Features:
8-
# - Initiate VoIP calls using the SIP protocol.
9-
# - Utilize SDP for session negotiation and description.
10-
# - Asynchronous design for efficient and non-blocking communications.
11-
#
12-
# Please note that while PySIP provides asynchronous capabilities,
13-
# it may not be fully asynchronous in its current version. However,
14-
# I am actively working to enhance its asynchronous functionality
15-
# and improve overall performance.
16-
#
17-
# For more information and usage examples, visit the
18-
# PySIP GitHub repository: https://github.com/moha-abdi/pysip
19-
import logging
20-
from .utils.logger import logger, console_handler, file_handler
21-
22-
__version__ = "1.8.0"
23-
__license__ = "MIT License"
24-
__copyright__ = "Copyright (C) 2023-present Moha"
25-
26-
27-
console_handler.setLevel(logging.INFO)
28-
file_handler.setLevel(logging.DEBUG)
1+
"""
2+
PySIP - High-Performance Async SIP Client
3+
4+
A modern, asyncio-based SIP/VoIP library for Python.
5+
6+
Example:
7+
from PySIP import SIPClient
8+
9+
async with SIPClient(
10+
username="alice",
11+
password="secret",
12+
server="sip.example.com",
13+
) as client:
14+
await client.register()
15+
16+
call = client.make_call("sip:bob@example.com")
17+
await call.start()
18+
await call.say("Hello!")
19+
await call.hangup()
20+
"""
21+
22+
__version__ = "2.0.0"
23+
__author__ = "PySIP Contributors"
24+
__license__ = "MIT"
25+
26+
# Core client
27+
from .client import SIPClient, create_client
28+
from .call import Call
29+
30+
# Types and enums
31+
from .types import (
32+
CallState,
33+
CallDirection,
34+
DialogState,
35+
HangupCause,
36+
TransportType,
37+
SIPMethod,
38+
SIPStatusCode,
39+
CodecType,
40+
DTMFMode,
41+
AMDResultType,
42+
# Config classes
43+
ClientConfig,
44+
MediaConfig,
45+
RTPConfig,
46+
)
47+
48+
# Exceptions
49+
from .exceptions import (
50+
PySIPError,
51+
TransportError,
52+
ProtocolError,
53+
AuthenticationError,
54+
RegistrationError,
55+
CallError,
56+
CallRejectedError,
57+
CallFailedError,
58+
CallTimeoutError,
59+
CallStateError,
60+
MediaError,
61+
CodecError,
62+
TTSError,
63+
AMDError,
64+
DTMFError,
65+
RecordingError,
66+
)
67+
68+
# Features
69+
from .features import (
70+
TTSEngine,
71+
EdgeTTSEngine,
72+
AMDDetector,
73+
AMDResult,
74+
DTMFDetector,
75+
DTMFGenerator,
76+
CallRecorder,
77+
)
78+
79+
# Media
80+
from .media import (
81+
AudioStream,
82+
JitterBuffer,
83+
PCMUCodec,
84+
PCMACodec,
85+
)
86+
87+
# Protocol (advanced usage)
88+
from .protocol import (
89+
SIPMessage,
90+
SIPRequest,
91+
SIPResponse,
92+
SDPMessage,
93+
RTPPacket,
94+
)
95+
96+
__all__ = [
97+
# Version info
98+
"__version__",
99+
"__author__",
100+
"__license__",
101+
102+
# Core
103+
"SIPClient",
104+
"create_client",
105+
"Call",
106+
107+
# Enums
108+
"CallState",
109+
"CallDirection",
110+
"DialogState",
111+
"HangupCause",
112+
"TransportType",
113+
"SIPMethod",
114+
"SIPStatusCode",
115+
"CodecType",
116+
"DTMFMode",
117+
"AMDResultType",
118+
119+
# Config
120+
"ClientConfig",
121+
"MediaConfig",
122+
"RTPConfig",
123+
124+
# Exceptions
125+
"PySIPError",
126+
"TransportError",
127+
"ProtocolError",
128+
"AuthenticationError",
129+
"RegistrationError",
130+
"CallError",
131+
"CallRejectedError",
132+
"CallFailedError",
133+
"CallTimeoutError",
134+
"CallStateError",
135+
"MediaError",
136+
"CodecError",
137+
"TTSError",
138+
"AMDError",
139+
"DTMFError",
140+
"RecordingError",
141+
142+
# Features
143+
"TTSEngine",
144+
"EdgeTTSEngine",
145+
"AMDDetector",
146+
"AMDResult",
147+
"DTMFDetector",
148+
"DTMFGenerator",
149+
"CallRecorder",
150+
151+
# Media
152+
"AudioStream",
153+
"JitterBuffer",
154+
"PCMUCodec",
155+
"PCMACodec",
156+
157+
# Protocol
158+
"SIPMessage",
159+
"SIPRequest",
160+
"SIPResponse",
161+
"SDPMessage",
162+
"RTPPacket",
163+
]

PySIP/_internal/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Internal utilities - not part of public API
3+
"""
4+
5+
from .buffers import BufferPool
6+
from .metrics import MetricsCollector
7+
8+
__all__ = [
9+
"BufferPool",
10+
"MetricsCollector",
11+
]
12+
13+

0 commit comments

Comments
 (0)