WebRTC Integration for Calls in Mobile App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
WebRTC Integration for Calls in Mobile App
Complex
from 1 week to 3 months
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

WebRTC Integration for Calls in Mobile Application

WebRTC — open standard for P2P real-time communication. Google maintains native SDK for Android and iOS, there are Flutter wrappers. Choosing WebRTC over Twilio/Vonage means more infrastructure control and lower operational costs on scale but requires independent signaling implementation, ICE management and TURN/STUN server deployment.

How WebRTC Call Works

Connection setup — multi-step process via ICE (Interactive Connectivity Establishment):

  1. Caller creates PeerConnection, generates offer (SDP — Session Description Protocol)
  2. offer transmitted to peer via signaling channel (WebSocket)
  3. Peer creates PeerConnection, applies offer, generates answer
  4. answer returns via signaling channel
  5. Both clients exchange ICE candidates — potential network paths
  6. ICE agent selects best path and establishes P2P connection

ICE candidates three types: host (local IP), srflx (via STUN — public IP), relay (via TURN). Direct P2P (host/srflx) works in 70–80% cases. In corporate networks behind symmetric NAT need relay via TURN.

Native Android Implementation

Google maintains WebRTC Android SDK — io.getstream:stream-webrtc-android or directly from webrtc.org.

// Initialization
PeerConnectionFactory.initialize(
    PeerConnectionFactory.InitializationOptions.builder(context)
        .createInitializationOptions()
)

val factory = PeerConnectionFactory.builder()
    .setAudioDeviceModule(JavaAudioDeviceModule.builder(context).createAudioDeviceModule())
    .createPeerConnectionFactory()

// ICE configuration
val config = PeerConnection.RTCConfiguration(
    listOf(
        PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer(),
        PeerConnection.IceServer.builder("turn:your-turn.example.com:3478")
            .setUsername("user").setPassword("pass").createIceServer()
    )
)

val peerConnection = factory.createPeerConnection(config, peerConnectionObserver)

// Audio track
val audioSource = factory.createAudioSource(MediaConstraints())
val audioTrack = factory.createAudioTrack("audio0", audioSource)
val localStream = factory.createLocalMediaStream("stream0")
localStream.addTrack(audioTrack)
peerConnection?.addStream(localStream)

Video added similarly via VideoCapturerCamera2Capturer for native camera.

iOS: RTCPeerConnection

On iOS use same Google WebRTC SDK via CocoaPods (pod 'GoogleWebRTC') or Swift Package (google/webrtc).

let config = RTCConfiguration()
config.iceServers = [
    RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"]),
    RTCIceServer(urlStrings: ["turn:your-turn.example.com:3478"],
                 username: "user", credential: "pass")
]
config.sdpSemantics = .unifiedPlan

let constraints = RTCMediaConstraints(
    mandatoryConstraints: nil,
    optionalConstraints: ["DtlsSrtpKeyAgreement": "true"]
)

let peerConnection = factory.peerConnection(
    with: config, constraints: constraints, delegate: self
)

CallKit integration mandatory for iOS — without it call doesn't get audio session priority. Details in VoIP calls article.

TURN Server: Why It's Not Optional

Without TURN server WebRTC fails behind corporate firewalls and symmetric NAT. This ~20–30% real users. Deploy coturn:

# /etc/turnserver.conf
listening-port=3478
listening-ip=0.0.0.0
relay-ip=YOUR_PUBLIC_IP
external-ip=YOUR_PUBLIC_IP
realm=your-domain.com
user=webrtc:strongpassword
lt-cred-mech

Public STUN from Google (stun.l.google.com) free but doesn't provide TURN. Need own or paid service (Twilio Network Traversal Service, Xirsys).

Signaling Protocol

WebRTC doesn't define signaling — developer responsibility. Minimum: WebSocket channel for SDP offer/answer and ICE candidates transmission.

// Send offer via WebSocket
fun createOffer() {
    val constraints = MediaConstraints().apply {
        mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"))
    }
    peerConnection?.createOffer(object : SdpObserver {
        override fun onCreateSuccess(sdp: SessionDescription) {
            peerConnection?.setLocalDescription(this, sdp)
            signalingChannel.send(json { "type" to "offer"; "sdp" to sdp.description })
        }
        // ...
    }, constraints)
}

Session state: new → connecting → connected → disconnected → failed. Handle failed — try restartIce() or connection re-establishment. Without handler user sees hung call with no feedback.

Audio Quality

WebRTC includes Opus codec, echo cancellation (AEC), noise suppression (NS) and automatic gain control (AGC) by default. For real-time quality monitoring — WebRTC stats API:

peerConnection?.getStats { report ->
    val inboundAudio = report.statsMap.values
        .filterIsInstance<RTCInboundRtpStreamStats>()
        .firstOrNull { it.kind == "audio" }
    val packetsLost = inboundAudio?.packetsLost ?: 0
    val jitter = inboundAudio?.jitter ?: 0.0
}

Jitter > 30 ms and loss > 5% — threshold for noticeable audio quality degradation.

Flutter

flutter_webrtc package wraps native WebRTC SDK. API similar to native but with extra layer. Production experience: package stable but updates lag behind native SDK — for critical vulnerabilities in WebRTC sometimes wait weeks for package update.

What's Included

Deploy TURN/STUN infrastructure, implement signaling server (WebSocket), integrate WebRTC SDK on mobile platforms, connect CallKit (iOS) / ConnectionService (Android), setup connection quality monitoring.

Timeline: 3–6 weeks for audio/video calls with infrastructure and system call API integration.