batondocs← SiteSign in
Integrations/Pion

Pion

Pass the credential pair into webrtc.Configuration when you build the peer connection.

main.go
config := webrtc.Configuration{
  ICEServers: []webrtc.ICEServer{{
    URLs: []string{
      "stun:relay.usebaton.io:3478",
      "turn:relay.usebaton.io:3478?transport=udp",
      "turn:relay.usebaton.io:3478?transport=tcp",
      "turns:relay.usebaton.io:443?transport=tcp",
    },
    Username:       "1718200000:project_ab12",
    Credential:     "<ephemeral-credential>",
    CredentialType: webrtc.ICECredentialTypePassword,
  }},
}
pc, err := webrtc.NewPeerConnection(config)

Fetch the URLs and credential pair from your server (which called the credentials API); don't hardcode them.