How to force audio codecs to PCMA or G.711, I want...
# ask-ai
s
How to force audio codecs to PCMA or G.711, I want to dial to landlines (using SIP trunk) via web browser interface but it seems the audio is not getting reached to landline.
t
Thanks for reaching out, Abhi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I understand you want to force PCMA / G.711 from the browser so calls reach PSTN via your SIP trunk. Short answer: you cannot force the browser-side WebRTC client to use PCMA/G.711. Browsers use Opus for WebRTC media and do not expose a reliable way to make the client send G.711. LiveKit bridges WebRTC (Opus) to SIP and will use G.711 on the SIP/PSTN leg as needed — transcoding between Opus and G.711 is handled by the SIP bridge. What to check since audio isn’t reaching the landline: • Confirm your SIP trunk settings (codec support, phone number, auth, IPs/ports) with your provider. • Verify LiveKit’s SIP trunk config matches the provider (UDP/TCP/TLS, SRTP/RTP, allowed codecs). • Check firewall/NAT for RTP: ensure UDP RTP ports used by LiveKit and the trunk are open and not blocked. • Inspect call setup and SDP exchange logs to confirm LiveKit offered/negotiated G.711 to the SIP side and whether any codecs were rejected. • Test with a known-working SIP provider (e.g., Twilio/Telnyx) or a SIP softphone to isolate whether the trunk or LiveKit bridge is the issue. If you’d like, tell me: • which SIP provider and transport (UDP/TCP/TLS) you’re using, • an example call SID / timestamps or logs (SDP from browser and SIP INVITE/200 OK), and I’ll walk through the specific checks and point out what to look for in the SDP and trunk configuration. Sources: Agents telephony integration | LiveKit Documentation | SIP Telephony and Encryption | Why WebRTC beats WebSockets for realtime voice AI | LiveKit | Firewall Tips, with interactive elements
s
I am currently using Twilio with UDP enabled.
t
Thanks — that helps. Since you’re using Twilio with UDP, here are targeted troubleshooting steps and what I need to dig deeper. Steps to check now: • Confirm Twilio’s SIP trunk is configured to accept G.711 (PCMA/PCMU) and that your Twilio trunk uses UDP transport. • On your LiveKit SIP config, ensure transport and ports match Twilio (UDP) and SRTP/RTP settings if applicable. • Check firewall/NAT: allow outbound/inbound UDP RTP ports used by LiveKitTwilio (verify the port range Twilio expects). • Capture the SDP from the browser (offer) and the SIP INVITE/200 OK between LiveKit and Twilio. Look for: ◦ Browser SDP: Opus listed (expected). ◦ SIP SDP: presence of PCMA/PCMU in the m=audio payloads and successful codec negotiation. • If Twilio rejects codecs, Twilio’s SIP logs will show the reason — inspect Twilio call logs for SIP response codes or codec negotiation failures. If you can share (paste) any of the following, I’ll analyze them: • Browser offer SDP (the local offer when publishing audio), and • SIP INVITE SDP and 200 OK SDP from the LiveKit→Twilio exchange, or • Twilio SIP trunk logs showing the SIP responses/error codes. If you prefer, tell me which ports/ranges your firewall allows and I’ll point out what to open. , with interactive elements
s
These are IP access control list at Twilio 0.0.0.0 / 1 0.0.0.0-127.255.255.255 127.0.0.1 / 1 0.0.0.0-127.255.255.255 128.0.0.0 / 1 28.0.0.0-255.255.255.255
t
Thanks — I see your Twilio IP ACL entries. To continue troubleshooting why audio isn’t reaching the PSTN, please confirm a few more details and then paste relevant logs/SDPs if possible. Quick checks I need from you • Which RTP port range is configured on your Twilio trunk (and on your LiveKit SIP settings)? • What UDP ports and port range are open on your firewall/NAT for media (RTP/RTCP)? • Are you using SRTP or plain RTP to Twilio? • Can you paste the browser offer SDP and the SIP INVITE/200 OK SDPs from the LiveKit↔️Twilio exchange (redact any secrets)? What I’ll look for once you share • Whether Twilio and LiveKit negotiated PCMA/PCMU in the SIP SDP. • Any mismatched transport/port ranges or SRTP vs RTP failures. • SIP response codes or explicit codec-rejection lines in the logs. If you prefer, tell me the RTP port range you have open and I’ll say whether it matches Twilio’s expected ports and what to change next. , with interactive elements
s
What's best way to use the Web interface for participant and SIP participant to have conversation in room without this issue.
t
Thanks — I’ll outline the best, practical way to run a WebRTC participant and a SIP (Twilio) participant in the same LiveKit room so audio reliably reaches the landline. Summary of the approach • Keep the browser as a normal WebRTC participant (browser will send Opus). LiveKit will bridge and transcode to G.711 (PCMA/PCMU) for the SIP/PSTN leg — you don’t need to force G.711 in the browser. • Ensure the SIP bridge between LiveKit and Twilio is configured for UDP and G.711 and that media ports/transport match. Best-practice checklist • SIP trunk settings (Twilio) ◦ Enable UDP transport and confirm Twilio is set to accept G.711 (PCMA/PCMU). ◦ Verify Twilio SIP trunk IP ACL entries are correct for your LiveKit egress IPs. ◦ Confirm the RTP port range Twilio expects for media. • LiveKit SIP bridge configuration ◦ Use UDP transport if Twilio is using UDP. ◦ Ensure LiveKit is configured to offer/accept G.711 to Twilio (this is handled by the bridge). ◦ If using SRTP, make sure both sides agree; mismatched SRTP/RTP causes silence. • Firewall / NAT ◦ Open outbound/inbound UDP ports for RTP/RTCP used by LiveKit↔️Twilio. Confirm the port range matches Twilio’s and LiveKit’s configured range. ◦ Allow SIP signaling ports (UDP/TCP/TLS) used between LiveKit and Twilio. ◦ If NAT, ensure proper symmetric RTP handling or use a media relay with public IP. • SDP & logs to verify ◦ Browser SDP: should show Opus (expected). ◦ SIP INVITE/200 OK SDP between LiveKit and Twilio: should list PCMA/PCMU in audio m= lines and agree on payload types. ◦ Twilio logs: check for SIP response codes or codec negotiation errors. • Room flow / UX notes ◦ Create two participants in the LiveKit room: the browser user and a SIP participant created by the SIP bridge for the PSTN call. The SIP participant appears in the room like any other participant. ◦ Ensure the browser participant is publishing audio and subscribed by the SIP participant (LiveKit handles routing but check subscription policy if you use restricted subscriptions). Troubleshooting steps if audio still fails 1. Capture and compare SDPs (browser offer vs. SIP INVITE/200 OK). Look for absence of PCMA/PCMU or port mismatches. 2. Check Twilio SIP logs for rejected codecs or unreachable media. 3. Temporarily test with a SIP softphone or a known-good Twilio trunk config to isolate whether the issue is the trunk or LiveKit bridge. 4. Verify UDP RTP ports are not blocked by your firewall/NAT. If you want, I can: • Walk through analyzing your browser offer SDP and the LiveKit→Twilio SIP INVITE/200 OK (redact secrets). • Recommend exact port ranges to open if you tell me what your firewall currently allows. Which would you like to do next? , with interactive elements