Skip to content
DashhhhhhhhPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

Repository files navigation

uSIP - Modern Python SIP Client Library

Python 3.8+ License: MIT Code style: black

A modern, professional Python SIP client library with voice support, modular architecture, and comprehensive CLI interface. Perfect for building VoIP applications, softphones, and telecommunications tools.

✨ Features

πŸš€ Core Features

  • Full SIP Protocol Support - RFC 3261 compliant implementation
  • Voice Communication - RTP-based audio streaming with device management
  • Authentication - SIP digest authentication support
  • Registration Management - Automatic re-registration with keep-alive
  • Call Management - Multiple concurrent calls with state tracking
  • Modular Architecture - Clean separation of concerns

πŸ› οΈ Developer Experience

  • Rich CLI Interface - Beautiful command-line interface with colored output
  • Comprehensive Logging - Structured logging with multiple output formats
  • Type Safety - Full type hints and mypy compliance
  • Professional APIs - Clean, intuitive programming interfaces
  • Extensive Documentation - Complete guides and examples
  • Cross-Platform - Works on Windows, macOS, and Linux

πŸ“ž Telecommunications

  • SIP Providers - Works with Asterisk, FreeSWITCH, voip.ms, Twilio SIP
  • Audio Devices - Enumeration and runtime switching
  • Session Management - Proper SIP session handling
  • Error Recovery - Robust error handling and recovery
  • Network Resilience - NAT traversal and network change handling

πŸš€ Quick Start

Installation

# Install from PyPI (when published)
pip install usip

# Or install from source
git clone https://github.com/yourusername/uSIP.git
cd uSIP
pip install -e .

Configuration

Create a .env file with your SIP credentials:

SIP_DOMAIN=your-sip-provider.com
SIP_USERNAME=your-username
SIP_PASSWORD=your-password
SIP_PORT=5060

CLI Usage

# Test your configuration
usip-cli test

# Register with SIP server
usip-cli register

# Make a call
usip-cli call +1234567890

# Show status
usip-cli status

Library Usage

from sip_client import SIPClient, SIPAccount

# Create account
account = SIPAccount(
    username="your-username",
    password="your-password", 
    domain="your-sip-provider.com"
)

# Initialize client
client = SIPClient(account)
client.start()

# Register
if client.register():
    print("Registration successful!")
    
    # Make a call
    call_id = client.make_call("sip:+1234567890@provider.com")
    if call_id:
        print(f"Call initiated: {call_id}")
        
        # Hang up after some time
        input("Press Enter to hang up...")
        client.hangup(call_id)

# Clean up
client.stop()

πŸ“š Documentation

API Reference

SIPClient

Main client class for SIP operations:

class SIPClient:
    def __init__(self, account: SIPAccount)
    def start() -> bool
    def stop()
    def register() -> bool
    def make_call(target_uri: str) -> Optional[str]
    def hangup(call_id: str) -> bool
    def get_calls() -> List[CallInfo]

SIPAccount

Account configuration:

@dataclass
class SIPAccount:
    username: str
    password: str
    domain: str
    port: int = 5060
    display_name: Optional[str] = None

Call States

class CallState(Enum):
    IDLE = auto()
    CALLING = auto()
    RINGING = auto()
    CONNECTED = auto()
    DISCONNECTED = auto()
    FAILED = auto()

CLI Commands

Command Description Example
test Test SIP configuration usip-cli test
register Register with SIP server usip-cli register
call <number> Make a call usip-cli call +1234567890
status Show client status usip-cli status

Configuration

Environment variables:

Variable Description Required Default
SIP_DOMAIN SIP server domain Yes -
SIP_USERNAME SIP username Yes -
SIP_PASSWORD SIP password Yes -
SIP_PORT SIP server port No 5060

πŸ—οΈ Architecture

Modular Design

uSIP/
β”œβ”€β”€ src/sip_client/           # Main library
β”‚   β”œβ”€β”€ models/              # Data models
β”‚   β”‚   β”œβ”€β”€ account.py       # SIP account configuration
β”‚   β”‚   β”œβ”€β”€ call.py          # Call information
β”‚   β”‚   └── enums.py         # State enumerations
β”‚   β”œβ”€β”€ audio/               # Audio management
β”‚   β”‚   β”œβ”€β”€ manager.py       # Audio streaming
β”‚   β”‚   └── devices.py       # Device enumeration
β”‚   β”œβ”€β”€ sip/                 # SIP protocol
β”‚   β”‚   β”œβ”€β”€ protocol.py      # Core SIP implementation
β”‚   β”‚   └── messages.py      # Message parsing
β”‚   β”œβ”€β”€ utils/               # Utilities
β”‚   β”‚   └── helpers.py       # Helper functions
β”‚   └── client.py            # Main client class
β”œβ”€β”€ usip_cli.py              # CLI interface
└── pyproject.toml           # Project configuration

Components

  • Client Layer - High-level SIP client API
  • Protocol Layer - SIP message handling and networking
  • Audio Layer - RTP streaming and device management
  • Model Layer - Data structures and state management
  • CLI Layer - Command-line interface

πŸ§ͺ Testing

Supported Providers

Tested with:

  • βœ… voip.ms - Full compatibility
  • βœ… Asterisk - Complete support
  • βœ… FreeSWITCH - Full functionality
  • βœ… Twilio SIP - Voice calling
  • πŸ”„ Other RFC 3261 compliant servers

Test Results

$ usip-cli test
Testing SIP client configuration...
βœ“ Configuration loaded successfully
βœ“ SIP client initialized successfully  
βœ“ Registration successful
SIP client is ready for calls!

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone repository
git clone https://github.com/yourusername/uSIP.git
cd uSIP

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

# Run type checking
mypy src/

# Format code
black src/
isort src/

πŸ“‹ Requirements

  • Python 3.8+
  • click - CLI framework
  • rich - Terminal formatting
  • cryptography - Authentication

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Acknowledgments

  • Built for the Python telecommunications community
  • Inspired by modern VoIP standards and practices
  • Designed for both beginners and professionals

πŸ“ž Support


uSIP - Modern Python SIP Client Library for Professional VoIP Applications

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages