This file provides guidance to Qwen Code when working with code in this repository.
This is the Telnyx Android WebRTC SDK - a real-time communication library for Android that enables voice calling functionality through WebRTC technology. The project consists of:
- telnyx_rtc: Main SDK module containing WebRTC implementation
- telnyx_common: Common shared code and utilities that wraps the main SDK
- samples/: Sample applications demonstrating SDK usage:
compose_app: Jetpack Compose implementationxml_app: Traditional XML views implementationconnection_service_app: Connection service integration example (Deprecated)
- Please reference the Kotlin Style Guide for general Kotlin coding conventions.
- Please make sure new code adheres to the rules mentioned at /telnyx_rtc/config/detekt.yml
- Don't change the verto message json structure without confirming first.
- When making changes to the SDK, ensure that you update the sample applications (xml_app and compose_app) accordingly to demonstrate the new functionality.
- Use the
telnyx_commonmodule to share code between the SDK and sample applications, such as utility functions, models, and constants. - Follow the established architecture patterns for WebRTC, including peer connection management, ICE candidate handling, and call state management.
- Ensure that all new features and bug fixes are accompanied by appropriate unit tests in the
telnyx_rtcmodule. - Use the provided build scripts (
build.gradle) to manage dependencies, build configurations, and testing tasks. - If asked to make a pull request, ensure you use the format described at .github/PULL_REQUEST_TEMPLATE.md, including a clear description of the changes, any relevant issue numbers, and testing instructions.
# Build the entire project
./gradlew build
# Assemble all variants without running tests
./gradlew assemble
# Clean build artifacts
./gradlew clean# Run all unit tests
./gradlew test
# Run specific test variants
./gradlew testDebugUnitTest
./gradlew testReleaseUnitTest# Run Detekt static analysis
./gradlew detekt
# Run lint checks
./gradlew lint# Generate Dokka documentation
./gradlew dokkaHtml- TelnyxClient: Primary SDK entry point for authentication, connection management, and call orchestration
- Call: Individual call management with state handling, audio controls, and call operations
- TxSocket: WebSocket connection handling using Ktor for real-time communication
- Peer: WebRTC peer connection wrapper managing media streams and ICE candidates
- Verto Protocol: JSON-RPC messaging layer for call signaling (send/receive packages)
- Observer Pattern: SocketObserver for WebSocket events, PeerConnectionObserver for WebRTC events
- State Management: Call states managed through sealed classes and StateFlow/LiveData
- Coroutines: Async operations using Kotlin coroutines throughout socket and media handling
- Dependency Injection: Hilt setup for sample apps
- TelnyxClient.connect() establishes socket connection
- credentialLogin() or tokenLogin() authenticates with Telnyx platform
- CLIENT_READY socket event indicates successful authentication
- Calls can then be initiated or received
- Outbound: newInvite() → SDP offer → ICE candidates → ANSWER received
- Inbound: INVITE received → acceptCall() → SDP answer → ICE exchange
- State Management: CallState enum tracks call progression (NEW → CONNECTING → ACTIVE → DONE)
- Firebase Cloud Messaging integration for incoming call notifications
- Push metadata handling for call recovery from background state
- Foreground service management for active calls
Sample apps require local.properties file with test credentials:
TEST_SIP_USERNAME=your_username
TEST_SIP_PASSWORD=your_password
TEST_SIP_CALLER_NAME=your_name
TEST_SIP_CALLER_NUMBER=your_number
TEST_SIP_DEST_NUMBER=destination_number
- INTERNET
- RECORD_AUDIO
- ACCESS_NETWORK_STATE
- POST_NOTIFICATIONS (Android 14+)
- FOREGROUND_SERVICE and FOREGROUND_SERVICE_PHONE_CALL (for call notifications)
- WebRTC: Custom Telnyx WebRTC library (com.telnyx.webrtc.lib:library:1.0.1)
- Networking: Ktor for WebSocket, Retrofit for HTTP, OkHttp
- Serialization: Gson for JSON processing
- Async: Kotlin Coroutines
- DI: Hilt (in sample apps)
- Logging: Timber
- Push: Firebase Cloud Messaging
- Testing: JUnit 4/5, Kotest, MockK, Robolectric
- Minimum SDK: 23, Target SDK: 34, Compile SDK: 35
- Java 11 compatibility required
- ProGuard rules must include:
-keep class com.telnyx.webrtc.** { *; } - Network state monitoring for connection recovery
- Audio device management (speaker, earpiece, Bluetooth) built-in
- Multi-call support with UUID-based call identification