← Back to Docs

WebRTC SFU Signaling

Mana includes a high-performance Selective Forwarding Unit (SFU) designed for multi-party video conferencing. It handles media routing, simulcast, and congestion control out of the box.

1. Signaling vs. Media

While the Mana core handles the Signaling (SDP/ICE exchange via WebSockets), the SFU sits inside the rtc.Manager to route the actual audio/video tracks between peers. This approach ensures low latency and high scalability.

2. The RTC Hook

You can listen for RTC lifecycle events using app.OnCallStart(). This is useful for:

3. Performance

By enabling EnableRTC, Mana automatically optimizes the thread pool for high-concurrency UDP traffic, which is critical for real-time media delivery.

main.go
package main

import (
    "log"
    "fmt"
    "github.com/Aswanidev-vs/mana"
    "github.com/Aswanidev-vs/mana/core"
)

func main() {
    // 1. Initialize with RTC Enabled
    cfg := mana.DefaultConfig()
    cfg.EnableRTC = true
    
    app := mana.New(cfg)
    
    // 2. SFU handles media routing automatically.
    // The OnCallStart hook triggers when a peer offers a session.
    app.OnCallStart(func(e core.CallEvent) {
        fmt.Printf("WebRTC Signaling Hub: Call initiated in Room %s", e.RoomID)
        // Handlers for SDP/ICE exchange are internal to RTCManager.
    })

    // 3. Start the engine
    log.Fatal(app.Start())
}