I started learning zig a few months ago and decided to create my own live media server. I tried first implementing WebRTC in zig.
WebRTC is a collection of protocols that provides peer to peer real time communication.
Since the underlying protocols may be used elsewhere, so I divided the whole multimedia pipeline into several repos.
- GitHub - zigouat/media: Media types description and function utilities · GitHub [This repo defines media types used by all other libraries, this include definition of packets/frames and codec parsing]
- GitHub - zigouat/media-protocols: Media protocols implementation in zig · GitHub [ this is the biggest repo and includes implementation of SDP/RTP/RTCP/SRTP/STUN/ICE all needed by webrtc]
- GitHub - zigouat/media-formats: Media formats implementation in zig · GitHub [This implements muxers and demuxer for packaging media, the only implementation for now is mp4]
- GitHub - zigouat/webrtc: Webrtc implementation in zig · GitHub [This is the webrtc repo]
The only protocols that are not implemented in zig are SCTP (not supported yet) and DTLS (I’m using mbedtls for now)
The implementation uses blocking code style (polling events in while loop) instead of the callbacks as defined in the WebRTC API Spec.
I 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.
Any feeedback or suggestion is welcome.
Now that I’m done here, it’s time to go back and read some RFCs.
Supported Zig versions
0.16.0
AI / LLM usage disclosure
AI/LLM is not used for the code. It’s only used to generate some tests.