MCPcopy Index your code
hub / github.com/VoiSmart/pjsip-android

github.com/VoiSmart/pjsip-android @2.16.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.16.0 ↗ · + Follow
7,550 symbols 12,957 edges 340 files 2,285 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PJSIP Android

NOTICE! This project is experimental, so don't use it in production! No support is provided and only bug fixes and pull requests can be accepted.

Documentation

API reference for the sipservice package is published to GitHub Pages and built automatically by Dokka on every tagged release:

  • Latest: https://voismart.github.io/pjsip-android/latest/
  • Versioned index: https://voismart.github.io/pjsip-android/

What you need to work with this library:

  • An android device with Android API 24
  • A PBX (E.g. VoiSmart Orchestra or FreeSWITCH, which is open). I'm not going to enter in the detail of how to properly configure your PBX, because that's a different topic and there are excellent tutorials out there.

Architecture

Architecture

This project wraps the standard PJSUA2 bindings in a background service and completely hides SIP from the rest of the application, to be able to have VoIP capabilities at a high level of abstraction. You can talk to the service using static methods and you will receive broadcast intents as a response. To talk to the service, refer to SipServiceCommand static methods. To receive events from the service, extend BroadcastEventReceiver. To see which events are emitted by the service, refer to BroadcastEventEmitter. All the commands that you will send to the service will get executed in the background and without blocking your main thread. Once the service has done the requested job or operation, it will notify you with a broadcast intent. So, you don't risk blocking your UI thread in any way.

Native PJSIP library for Android is compiled using PJSIP Android Builder

State of the art

What is tested and working

  • Single account
  • Make a single call
  • In-Call operations
  • mute
  • unmute
  • hold
  • un-hold
  • blind transfer
  • Attended call transfer
  • send DTMF (RFC 2833)
  • Accept an incoming call
  • Answer with video an incoming call
  • Decline an incoming call
  • Get/Set codec priorities
  • Hang up all active calls
  • Hold all active calls
  • Hold/Decline sip call when incoming/outgoing gsm call
  • Video support
  • switch camera
  • mute/unmute video
  • video preview
  • Use of a fixed SIP Call-ID Header. Refer to this for more details
  • Get Call Statistics on call disconnected. Refer to this for more details
  • Sip Credential encryption on device. Refer to Android Jetpack Security library for more details
  • Call Reconnection: useful after a network disconnection, it will try to reconnect the call with new ip/port
  • TLS and SRTP support
  • with server certificate verification option (enabled via SipServiceCommand#setVerifySipServerCert but to make it work, it is necessary to add a ca-bundle.crt file in the sip./sipservice/src/main/assets/ directory; without that the verification will not be enabled)
  • Silent Calls

What is missing (contributions are welcome)

  • Multiple calls support
  • be able to handle other calls coming in while you have an active call
  • Conference calls
  • Complete multiple accounts support
  • Respond to a call and play a sound file
  • Support for In-Call RTCP signaling to get call statistics
  • Other things which I'm not aware at the moment...

Used Libraries versions

  • PJSIP: 2.16
  • OpenSSL: 3.5.5
  • OpenH264: 2.6.0
  • Opus: 1.6.1
  • bcg729: 1.1.1

Logging

This library ships with a default logger which logs with the default Android Log class and a default DEBUG loglevel. You can customize such behaviour by either:

  1. Setting a specific loglevel (see Logger#setLogLevel)
  2. Setting your own LoggerDelegate. E.g.:

    ```java class SipServiceLogger extends Logger.LoggerDelegate { @Override public void error(String tag, String message) { Timber.tag(tag).e(message); }

    @Override
    public void error(String tag, String message, Throwable exception) {
        Timber.tag(tag).e(exception, message);
    }
    
    @Override
    public void debug(String tag, String message) {
        Timber.tag(tag).d(message);
    }
    
    @Override
    public void info(String tag, String message) {
        Timber.tag(tag).i(message);
    }
    

    } ```

Timber can be configured as you wish, to log everything or just in debug mode, or log to anywhere.

SIP Logging

To allow see PjSip logs you need to set SipServiceUtils.ENABLE_SIP_LOGGING to true which will log all pjsip logs while in debug mode.

Recompile native libraries

Refer to PJSIP Android Builder

Extension points exported contracts — how you extend this code

SipServiceConstants (Interface)
(no doc) [4 implementers]
sipservice/src/main/java/net/gotev/sipservice/SipServiceConstants.java
LoggerDelegate (Interface)
(no doc) [2 implementers]
sipservice/src/main/java/net/gotev/sipservice/Logger.java
pjsua2Constants (Interface)
(no doc) [1 implementers]
sipservice/src/main/java/org/pjsip/pjsua2/pjsua2Constants.java

Core symbols most depended-on inside this repo

error
called by 68
sipservice/src/main/java/net/gotev/sipservice/Logger.java
debug
called by 56
sipservice/src/main/java/net/gotev/sipservice/Logger.java
getCPtr
called by 46
sipservice/src/main/java/org/pjsip/pjsua2/ContainerNode.java
getAction
called by 44
sipservice/src/main/java/net/gotev/sipservice/BroadcastEventEmitter.java
getValue
called by 35
sipservice/src/main/java/net/gotev/sipservice/ObfuscationHelper.java
add
called by 27
sipservice/src/main/java/org/pjsip/pjsua2/IntVector.java
checkAccount
called by 27
sipservice/src/main/java/net/gotev/sipservice/SipServiceCommand.java
getIdUri
called by 25
sipservice/src/main/java/net/gotev/sipservice/SipAccountData.java

Shape

Method 7,203
Class 339
Enum 5
Interface 3

Languages

Java100%

Modules by API surface

sipservice/src/main/java/org/pjsip/pjsua2/pjsua2JNI.java3,078 symbols
sipservice/src/main/java/org/pjsip/pjsua2/Endpoint.java75 symbols
sipservice/src/main/java/org/pjsip/pjsua2/Call.java73 symbols
sipservice/src/main/java/org/pjsip/pjsua2/AccountNatConfig.java70 symbols
sipservice/src/main/java/net/gotev/sipservice/SipService.java64 symbols
sipservice/src/main/java/org/pjsip/pjsua2/MediaConfig.java60 symbols
sipservice/src/main/java/org/pjsip/pjsua2/TlsConfig.java58 symbols
sipservice/src/main/java/net/gotev/sipservice/SipAccountData.java49 symbols
sipservice/src/main/java/org/pjsip/pjsua2/CallInfo.java48 symbols
sipservice/src/main/java/org/pjsip/pjsua2/AudDevManager.java45 symbols
sipservice/src/main/java/org/pjsip/pjsua2/StreamInfo.java44 symbols
sipservice/src/main/java/net/gotev/sipservice/SipCall.java42 symbols

For agents

$ claude mcp add pjsip-android \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact