Ivan, owner of a smart intercom, complained: the app transmitted sound with a delay of about 900 ms. Conversations turned into chaos. We migrated him to WebRTC — RTT dropped to 200 ms, reducing latency by 78%. Our 5+ years of proven experience shows that choosing the right stack solves 80% of echo and latency issues.
Intercoms, baby monitors, walkie-talkies — common denominator: the phone hears the device and simultaneously speaks into it. Unlike a regular VoIP call between two phones, here one side is an embedded Linux microcomputer (ESP32, Raspberry Pi, NXP i.MX) that does not support SIP or WebRTC without additional software. This fundamentally changes the choice of architecture. For intelligible speech, RTT must not exceed 300–400 ms, otherwise dialogue becomes impossible. We have helped 30+ clients solve this problem.
How to Ensure Minimal Latency
Round-trip time (RTT) for intelligible speech should be no more than 300–400 ms. HLS and RTMP are not suitable. SIP is possible but has protocol overhead. WebRTC was designed specifically for this scenario. WebRTC establishes connections 3 times faster than SIP due to ICE + STUN. A typical WebRTC project starts at $2,000, saving up to 40% on infrastructure compared to SIP servers.
IoT device side: libwebrtc on Linux or specialized solutions: aiortc (Python), Pion (Go), GStreamer with webrtcbin plugin. Pion is minimal and easy to deploy on Raspberry Pi. GStreamer webrtcbin — if the device already uses GStreamer.
Mobile app side:
iOS: GoogleWebRTC (pod 'WebRTC-SDK') or native WebRTCFramework. Create RTCPeerConnection with audio track:
let audioConstraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil) let audioSource = factory.audioSource(with: audioConstraints) let audioTrack = factory.audioTrack(with: audioSource, trackId: "audio0") peerConnection.add(audioTrack, streamIds: ["stream0"]) Configure RTCAudioSession with .voiceChat category — automatically enables echo suppression and noise suppression (AEC/NS) built into WebRTC.
Android: io.getstream:stream-webrtc-android or org.webrtc:google-webrtc. AudioManager.MODE_IN_COMMUNICATION is mandatory for correct audio routing (earpiece/speakerphone).
Flutter: flutter_webrtc. Configure mediaConstraints for audio:
final Map<String, dynamic> mediaConstraints = { 'audio': { 'echoCancellation': true, 'noiseSuppression': true, 'autoGainControl': true, } }; Echo Cancellation: The Main Pain of Two-Way Audio
Without AEC (Acoustic Echo Cancellation): the phone's microphone picks up sound from the speaker (or vice versa — the device hears itself) — the user hears echo with 200 ms delay. Unusable.
WebRTC includes built-in AEC3 (third generation). It works automatically when the audio session category is set correctly. Problems arise when:
- The IoT device does not support an echo reference path — then AEC on the device side is ineffective. Solution: offload AEC to the server side (media server with processing enabled).
- Bluetooth headset + WebRTC — on Android
AudioManagerinCOMMUNICATIONmode switches BT profile to HFP (narrowband 8 kHz). For wideband audio, A2DP is needed, but it does not support recording. Compromise: either low quality with BT, or AirPods/wired headphones.
Why WebRTC is Better than SIP for IoT
| Parameter | WebRTC | SIP |
|---|---|---|
| Connection setup time | <500 ms | 1–3 s |
| Server requirements | STUN/TURN | SIP server (Asterisk) |
| Echo cancellation | Built-in AEC3 | Depends on implementation |
| NAT Traversal | ICE (automatic) | Requires configuration |
WebRTC does not require server registration and establishes connections faster. SIP is indispensable when integrating with existing telephony (e.g., Grandstream IP intercoms). According to RFC 7874, WebRTC with Opus codec provides speech quality comparable to PSTN.
SIP as an Alternative
If the IoT device supports SIP (many IP intercoms: Grandstream, Panasonic, Commax), use a SIP client on mobile.
iOS: PJSIP (C library) with Swift wrapper or Linphone SDK. Android: MjSip or PJSIP via JNI, or the ready-made Linphone SDK for Android. Flutter: sip_ua (Dart SIP, works over WebSocket transport).
SIP on mobile requires registration on an Asterisk/FreeSWITCH server. Call from intercom → SIP INVITE → server → push notification to phone (via CallKit on iOS, ConnectionService/IncomingCallNotification on Android). Without push, the notification does not arrive when the app is closed.
CallKit (iOS): incoming call appears as a regular phone call — full-screen interface with the intercom name. CXProvider, CXCallUpdate — standard integration. Requires voip Background Mode in Info.plist + APNs VoIP certificate.
Android ConnectionService: analogous to CallKit. TelecomManager.addNewIncomingCall() — shows system incoming call interface. Works from Android 6+.
Environmental Noise and Aggressive Noise Suppression
Outside wind, construction nearby — the IoT device sends a noisy stream. Additional noise suppression: RTCRtpSender with RTCDefaultVideoEncoderFactory — audio only. WebRTC RNNoise is integrated into native WebRTC and enabled via AudioProcessing::Config::NoiseSuppression.
For heavy server-side processing: Janus with janus_audiobridge plugin applies noise suppression before mixing.
Step-by-Step WebRTC Setup on IoT Device
- Install Pion library on the device (Go):
go get github.com/pion/webrtc/v3. - Configure ICE using a public STUN server (e.g.,
stun:stun.l.google.com:19302). - Create an audio track with Opus 48000 Hz parameters.
- On the mobile app side, create
RTCPeerConnectionand add an audio track. - Exchange SDP offer and answer via a signaling server (WebSocket or MQTT).
- Test the connection: use Coturn for testing the TURN server.
Testing
The main challenge: simulating NAT traversal in a test environment. Use Coturn in Docker for local TURN testing. Test on symmetric NAT (corporate network with strict rules) — mandatory. Without a TURN server, approximately 15–20% of connections will not establish.
Timeline: two-way WebRTC audio with IoT device (Linux/Pion) + iOS or Android client — 5–7 business days. With SIP integration and CallKit — 8–12 days.
What's Included
- Documentation for WebRTC/SIP integration into your app.
- Source code repositories (iOS/Android/Flutter + IoT).
- Deployment instructions for the device.
- Support for 2 weeks after delivery.
With over 5 years of proven expertise in IoT audio communication, we guarantee reliable, low-latency connections. We have completed 30+ projects with two-way audio, from intercoms to industrial talkback devices. Infrastructure savings up to 40% compared to SIP servers. Get a consultation on your project — contact us.







