Universal Android SIP library based on PJSIP that provides core SIP functionality for React Native, Flutter, and native Android applications.
This library extracts the core SIP business logic from the original react-native-sip2 project into a reusable Android library. It contains all the essential SIP functionality including account management, call handling, audio/video support, and event broadcasting.
The library is designed to be used by different platform wrappers:
- React Native:
react-native-sip2- Thin wrapper for React Native - Flutter:
flutter_sip2- Thin wrapper for Flutter - Native Android: Direct integration
- ✅ SIP account creation and management
- ✅ Account registration and deregistration
- ✅ Incoming and outgoing calls
- ✅ Call control (answer, hangup, hold, mute, etc.)
- ✅ Audio/video support
- ✅ DTMF support
- ✅ Call transfer and redirect
- ✅ Event broadcasting
- ✅ Background service support
- ✅ Wake lock management
- ✅ Audio routing (speaker, earpiece)
- ✅ Codec configuration
- ✅ STUN/TURN support
- ✅ Echo cancellation
- ✅ Cross-platform compatibility
sip2-android-core/
├── android/
│ └── src/main/
│ ├── java/
│ │ ├── org/pjsip/pjsua2/ # JNI wrappers for PJSIP
│ │ └── org/telon/sip2/ # Universal SIP business logic
│ │ ├── dto/ # Data Transfer Objects
│ │ ├── utils/ # Utility classes
│ │ ├── PjSipService.java # Main SIP service
│ │ ├── PjSipAccount.java # Account management
│ │ ├── PjSipCall.java # Call handling
│ │ └── ...
│ ├── jniLibs/ # Native libraries (.so files)
│ │ ├── arm64-v8a/
│ │ ├── armeabi-v7a/
│ │ ├── x86/
│ │ └── x86_64/
│ └── AndroidManifest.xml
├── integration/
│ ├── react_native/ # React Native integration files
│ │ ├── dto/ # DTO classes for React Native
│ │ ├── utils/ # Utility classes for React Native
│ │ ├── PjSipModule.java # React Native module
│ │ ├── PjSipModulePackage.java # React Native package
│ │ ├── PjSipBroadcastReceiver.java # Broadcast receiver
│ │ ├── PjActions.java # Action definitions
│ │ ├── PjSipRemoteVideoViewManager.java # Video view manager
│ │ └── PjSipPreviewVideoViewManager.java # Preview view manager
│ └── flutter/ # Flutter integration files
│ ├── dto/ # DTO classes for Flutter
│ ├── utils/ # Utility classes for Flutter
│ ├── PjActions.java # Action definitions
│ └── PjSipBroadcastReceiver.java # Broadcast receiver
├── build.gradle
├── package.json
└── README.md
Main service that handles all SIP operations:
- Library initialization
- Account management
- Call handling
- Event broadcasting
- Background processing
Manages SIP account lifecycle:
- Account creation and configuration
- Registration/deregistration
- Account state management
Handles individual call operations:
- Call state management
- Audio/video control
- Call actions (answer, hangup, hold, etc.)
Data Transfer Objects for configuration:
AccountConfigurationDTO- Account settingsCallSettingsDTO- Call parametersServiceConfigurationDTO- Service settingsSipMessageDTO- SIP message data
The library provides separate integration layers for different platforms:
PjSipModule.java- Main React Native modulePjSipModulePackage.java- React Native packagePjSipBroadcastReceiver.java- Event broadcastingPjActions.java- Action definitionsPjSipRemoteVideoViewManager.java- Video view managerPjSipPreviewVideoViewManager.java- Preview view manager- DTO classes and utilities
PjSipBroadcastReceiver.java- Event broadcastingPjActions.java- Action definitions- DTO classes and utilities
import { Sip2Core } from 'react-native-sip2';
// Initialize the library
await Sip2Core.start();
// Create account
const account = await Sip2Core.createAccount({
id: 'sip:user@domain.com',
password: 'password',
domain: 'domain.com',
port: 5060
});
// Make a call
const call = await Sip2Core.makeCall(account.id, 'sip:destination@domain.com');import 'package:flutter_sip2/flutter_sip2.dart';
// Initialize the library
await FlutterSip2.start();
// Create account
final account = await FlutterSip2.createAccount({
'id': 'sip:user@domain.com',
'password': 'password',
'domain': 'domain.com',
'port': 5060,
});
// Make a call
final call = await FlutterSip2.makeCall(account['id'], 'sip:destination@domain.com');import org.telon.sip2.PjSipService;
import org.telon.sip2.dto.AccountConfigurationDTO;
// Start the service
Intent intent = new Intent(this, PjSipService.class);
intent.setAction(PjActions.ACTION_START);
startService(intent);
// Create account
AccountConfigurationDTO config = new AccountConfigurationDTO();
config.setId("sip:user@domain.com");
config.setPassword("password");
config.setDomain("domain.com");
config.setPort(5060);
Intent createIntent = new Intent(this, PjSipService.class);
createIntent.setAction(PjActions.ACTION_ACCOUNT_CREATE);
createIntent.putExtra("config", config);
startService(createIntent);- Android SDK 33+
- Java 17+
- Gradle 7.0+
# Build the library
npm run build
# Run tests
npm run test
# Clean build
cd android && ./gradlew cleanThe build produces an Android AAR library that can be included in other projects.
libpjsua2.so- PJSIP core librarylibopenh264.so- H.264 video codec
androidx.annotation:annotation:1.5.0junit:junit:4.13.2(test)androidx.test.ext:junit:1.1.5(test)androidx.test.espresso:espresso-core:3.5.1(test)
The library requires the following Android permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />The library broadcasts the following events:
org.telon.account.started- Service startedorg.telon.account.created- Account createdorg.telon.registration.changed- Registration state changedorg.telon.call.changed- Call state changedorg.telon.call.terminated- Call terminatedorg.telon.call.received- Incoming call receivedorg.telon.call.screen.locked- Screen locked during callorg.telon.message.received- SIP message receivedorg.telon.handled- Action handled
ServiceConfigurationDTO config = new ServiceConfigurationDTO();
config.setUserAgent("My SIP Client");
config.setStunServers("stun:stun.l.google.com:19302");AccountConfigurationDTO config = new AccountConfigurationDTO();
config.setId("sip:user@domain.com");
config.setPassword("password");
config.setDomain("domain.com");
config.setPort(5060);
config.setTransport("UDP");
config.setRegTimeout(300);CallSettingsDTO settings = new CallSettingsDTO();
settings.setAudioCount(1);
settings.setVideoCount(0);
settings.setFlag(0);- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
- react-native-sip2 - React Native wrapper
- flutter_sip2 - Flutter wrapper
- pjsip-android-lib - JNI library
For issues and questions:
- Create an issue on GitHub
- Check the documentation
- Review the example applications