{"slug": "webrtc-implementation-in-zig", "title": "WebRTC implementation in zig", "summary": "A developer has released version 0.2.0 of a WebRTC implementation written in Zig, adding IPv6 and STUN/TURN support, RTP mid header extension, RTCP generic nack and RTX, and switching from polling to callbacks. The project, which includes a media server and supports H264, VP8, and Opus codecs, is available on GitHub and targets Zig 0.16.0.", "body_md": "I started learning zig a few months ago and decided to create my own live media server. I tried first implementing WebRTC in zig.\n\nWebRTC is a collection of protocols that provides peer to peer real time communication.\n\nSince the underlying protocols may be used elsewhere, so I divided the whole multimedia pipeline into several repos.\n\nThe only protocols that are not implemented in zig are SCTP (not supported yet) and DTLS (I’m using mbedtls for now)\n\nThe implementation uses blocking code style (polling events in while loop) instead of the callbacks as defined in the WebRTC API Spec.\n\nI included an example app where I stream an mp4 file to a browser that can be found in the repo. And the only supported codec is H264.\n\nAny feeedback or suggestion is welcome.\n\nNow that I’m done here, it’s time to go back and read some RFCs.\n\nSupported Zig versions\n\n0.16.0\n\nAI / LLM usage disclosure\n\nAI/LLM is not used for the code. It’s only used to generate some tests.\n\n13 Likes\n\n[g41797](https://ziggit.dev/u/g41797)\n2\nYour [agent code](https://github.com/zigouat/media-protocols/blob/1a9c71defbcd0bb024fe78c3929b7bb5ac7e1337/src/ice/agent.zig) helped me to solve several Io issues\n\n**Kudos**\n\n1 Like\n\nVersion 0.1.0 is out\n\nThe first version of the WebRTC library is now available.\n\nThis implementation tries to follow the WebRTC spec. However callbacks is a poor choice for the `std.Io`\n\nin Zig. For this, instead of using callbacks, we use event polling using `std.Io.Queue`\n\n.\n\nThe included features in this version are:\n\nOffer/answer and SDP generation and parsing\n\nThe base for all negotiation, this is the part used for negotiating what kind of medias, codecs, extension headers and other parameters to use for both peers. This also the trickiest part to get right. Currently we support negotiating codecs and media types.\n\nMedia types\n\nThe supported video codecs are : VP8 and H264\n\nThe supported audio codecs are: Opus\n\nICE\n\nThis is the protocol used for establishing a connection between two peers (even behind NAT). Currently we only support IPv4 and local candidates. Support for IPv6, STUN and TURN will follow in the next releases.\n\nDTLS\n\nDTLS used for establishing a secure channel between the peers and used also for encrypting data from data channels (not supported yet). Media data are not encrypted by DTLS.\n\nWe use `mbedtls`\n\nfor this (A Zig implementation is in the roadmap too).\n\nSRTP\n\nDTLS used for exchanging secrets and SRTP is used for encrypting media data. The supported ciphers for now are:\n\nAES_128_CM_SHA1_80\n\nAES_128_CM_SHA1_32\n\nRTCP Feedback\n\nThis are used for exchanging information about the quality of the streams between peers. The supported feedback are: Sender report and PLI (which is used to tell the sender to send a new keyframe for video streams).\n\nFor usage check the examples in the repo.\n\n4 Likes\n\nContinuing on my Zig’s learning journey, version 0.2.0 of WebRTC is out. The notable changes in this release are:\n\n- Add support for IPv6 and STUN/TURN candidates. More options for peers to connect together.\n- Add RTP mid header extension for identifying which rtp packets belongs to which stream.\n- Add support for RTCP generic nack and RTX. Generic nacks are a type of a feedback where the receiver signals to the sender which packets are lost and request retransmission either using the main stream used for sending or via RTX.\n- Switch from polling using\n`std.Io.Queue`\n\nto using callbacks via handler (define only which callbacks you’re interested in). As it turns out callbacks are more efficient in this case because the Io.Queue listener may be started in another thread/fiber which forces a wakeup per rtp packet.\n- Add a media engine to limit/register only codecs supported by the user.\n- Add more configuration options to the PeerConnection to control the above features.\n\nBtw, this is not the case with zio in the default mode. If you push to a queue and another task was waiting for it, the task will be resumed on the same thread where you pushed from, so no wakeup at all.", "url": "https://wpnews.pro/news/webrtc-implementation-in-zig", "canonical_source": "https://ziggit.dev/t/webrtc-implementation-in-zig/16267#post_5", "published_at": "2026-08-25 14:44:40+00:00", "updated_at": "2026-08-25 15:14:56.776440+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Zig", "WebRTC", "mbedtls", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/webrtc-implementation-in-zig", "markdown": "https://wpnews.pro/news/webrtc-implementation-in-zig.md", "text": "https://wpnews.pro/news/webrtc-implementation-in-zig.txt", "jsonld": "https://wpnews.pro/news/webrtc-implementation-in-zig.jsonld"}}