Skip to content

callstats-io/AppRTCMobile_android

Repository files navigation

AppRTC Android demo

AppRTC demo application with Callstats.io android library integration

Getting Started

These instructions will help you run the apprtc android demo application with callstats integration. See notes on how you will get callstats library related credentials to run the application.

Without the callstats credentials the application will not run.

Prerequisites

  • Minimum SDK version 21
  • Library dependency
    • WebRTC native
    • Callstats.io android
    • Autobanh websocket
    • JSON WebToken
    • Spongy castle
    • EventBus

Provide credentials

Build and run the android application

  • In the apprtc demo application give some room name ( for example csio-test-1234 ), and dial
  • Open browser, and try to join the same room from here - https://appr.tc/
  • Watch your android logcat for sample events
  • Or Check your Callstats.io dashboard for given WebRTC sessions

Events implemented in demo

  • Look into CSIOEvents.java class for sample events integration in the demo application. Please note that not all the events mentioned in https://docs.callstats.io/restapi/ is implemented. Check the library document for further reference.
  • Sample events covered in demo app :
    • Febric setup event
      • Fabric setup - Should call before create and answer or offer
      • Fabric hold, and resume
    • ICE events
      • ICE connection, gathering, signaling change
    • Media Events
      • Mutes/unmutes
      • Video play/pause
    • Special Event - application log
      • Application specific log. Can be anything that you find should be important for your application
      • Example - Toggle between front/rear camera, when user connected/disconnected/join/leave apprtc room, etc.

Integration process

  1. Get Callstats.io WebRTC analytic library for android from https://github.com/callstats-io/callstats-android. It also includes the documentation on how we can integrate the library with any WebRTC application along with an integration with callstats own demo application.

  2. Include it in your gradle dependency. The apprtc demo is using 0.1.1 version.

    implementation "io.callstats:callstats:<version>"
    

    $ Example

  3. Include Google WebRTC prebuild library from JCenter. https://webrtc.org/native-code/android/. The apprtc demo is using 1.0.25003 version

    implementation 'org.webrtc:google-webrtc:<version>'
    

    $ Example

  4. [ Optional ] Include EventBus. We are using 3.1.1 version

    implementation 'org.greenrobot:eventbus:<version>'
    

    $ Example

  5. Create Callstats object

    callstats = new Callstats(
        context,
        appID, // Application ID from Callstats
        localID, // current user ID
        deviceID, // unique device ID
        jwt, // jwt from server for authentication
        alias, // user alias
        clientVersion, // user version
        callstatsConfig) // Callstats config parameter 
    

    $ Example

  6. Start callstats session with a unique identifier. For appRTC session monitoring demo we are using appRTC room number as unique identifier

    callstats.startSession(room)
    

    $ Example

  7. Initiate fabric setup event. After fabric setup is complete, we will be able to send data

    // peerConnection - of type WebRTC peer connection
    // peerId - of type string - application specifc identifier for this peer connection
    callstats.addNewFabric(peerConnection, peerId)
    

    $ Example

  8. Try to send some data to AppRTC session data. For example -

    • WebRTC ICE Connection state change

      callstats.reportEvent(peerId, new OnIceConnectionChange(newState))
      

      $ Example

    • WebRTC ICE gathering state change

      callstats.reportEvent(peerId, new OnIceGatheringChange(newState))
      

      $ Example

    • WebRTC Signaling state change

      callstats.reportEvent(peerId, new OnSignalingChange(newState))
      

      $ Example

    • On Add new stream

      callstats.reportEvent(peerId, OnAddStream.INSTANCE);
      

      $ Example

    • On audio mute, and unmute

      callstats.reportEvent(peerId, new OnAudio(isMuted, deviceId))
      

      $ Example

    • On video play, and pause

      callstats.reportEvent(peerId, new OnVideo(isPaused, deviceId))
      

      $ Example

    • On fabric hold

      callstats.reportEvent(peerId, OnHold.INSTANCE);
      

      $ Example

    • On fabric resume

      callstats.reportEvent(peerId, OnResume.INSTANCE);
      

      $ Example

    • To send custom message

      // message - of type string
      // level - of type io.callstats.LoggingLevel
      // loggingType - of type io.callstats.LoggingType
      callstats.log(message, level, loggingType);
      
      

      $ Example

  9. When a AppRTC peer connection session ends, stop the session monitoring

    callstats.stopSession()
    

    $ Example

Releases

No releases published

Packages

No packages published

Languages