Source File
dtlsrole.go
Belonging Package
github.com/pion/webrtc/v4
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage webrtcimport ()// DTLSRole indicates the role of the DTLS transport.type DTLSRole byteconst (// DTLSRoleUnknown is the enum's zero-value.DTLSRoleUnknown DTLSRole = iota// DTLSRoleAuto defines the DTLS role is determined based on// the resolved ICE role: the ICE controlled role acts as the DTLS// client and the ICE controlling role acts as the DTLS server.DTLSRoleAuto// DTLSRoleClient defines the DTLS client role.DTLSRoleClient// DTLSRoleServer defines the DTLS server role.DTLSRoleServer)const (// https://tools.ietf.org/html/rfc5763/*The answerer MUST use either asetup attribute value of setup:active or setup:passive. Note thatif the answerer uses setup:passive, then the DTLS handshake willnot begin until the answerer is received, which adds additionallatency. setup:active allows the answer and the DTLS handshake tooccur in parallel. Thus, setup:active is RECOMMENDED.*/defaultDtlsRoleAnswer = DTLSRoleClient/*The endpoint that is the offerer MUST use the setup attributevalue of setup:actpass and be prepared to receive a client_hellobefore it receives the answer.*/defaultDtlsRoleOffer = DTLSRoleAuto)func ( DTLSRole) () string {switch {case DTLSRoleAuto:return "auto"case DTLSRoleClient:return "client"case DTLSRoleServer:return "server"default:return ErrUnknownType.Error()}}// Iterate a SessionDescription from a remote to determine if an explicit// role can been determined from it. The decision is made from the first role we we parse.// If no role can be found we return DTLSRoleAuto.func dtlsRoleFromRemoteSDP( *sdp.SessionDescription) DTLSRole {if == nil {return DTLSRoleAuto}for , := range .MediaDescriptions {for , := range .Attributes {if .Key == "setup" {switch .Value {case sdp.ConnectionRoleActive.String():return DTLSRoleClientcase sdp.ConnectionRolePassive.String():return DTLSRoleServerdefault:return DTLSRoleAuto}}}}return DTLSRoleAuto}func connectionRoleFromDtlsRole( DTLSRole) sdp.ConnectionRole {switch {case DTLSRoleClient:return sdp.ConnectionRoleActivecase DTLSRoleServer:return sdp.ConnectionRolePassivecase DTLSRoleAuto:return sdp.ConnectionRoleActpassdefault:return sdp.ConnectionRole(0)}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |