Source File
sdptype.go
Belonging Package
github.com/pion/webrtc/v4
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage webrtcimport ()// SDPType describes the type of an SessionDescription.type SDPType intconst (// SDPTypeUnknown is the enum's zero-value.SDPTypeUnknown SDPType = iota// SDPTypeOffer indicates that a description MUST be treated as an SDP offer.SDPTypeOffer// SDPTypePranswer indicates that a description MUST be treated as an// SDP answer, but not a final answer. A description used as an SDP// pranswer may be applied as a response to an SDP offer, or an update to// a previously sent SDP pranswer.SDPTypePranswer// SDPTypeAnswer indicates that a description MUST be treated as an SDP// final answer, and the offer-answer exchange MUST be considered complete.// A description used as an SDP answer may be applied as a response to an// SDP offer or as an update to a previously sent SDP pranswer.SDPTypeAnswer// SDPTypeRollback indicates that a description MUST be treated as// canceling the current SDP negotiation and moving the SDP offer and// answer back to what it was in the previous stable state. Note the// local or remote SDP descriptions in the previous stable state could be// null if there has not yet been a successful offer-answer negotiation.SDPTypeRollback)// This is done this way because of a linter.const (sdpTypeOfferStr = "offer"sdpTypePranswerStr = "pranswer"sdpTypeAnswerStr = "answer"sdpTypeRollbackStr = "rollback")// NewSDPType creates an SDPType from a string.func ( string) SDPType {switch {case sdpTypeOfferStr:return SDPTypeOffercase sdpTypePranswerStr:return SDPTypePranswercase sdpTypeAnswerStr:return SDPTypeAnswercase sdpTypeRollbackStr:return SDPTypeRollbackdefault:return SDPTypeUnknown}}func ( SDPType) () string {switch {case SDPTypeOffer:return sdpTypeOfferStrcase SDPTypePranswer:return sdpTypePranswerStrcase SDPTypeAnswer:return sdpTypeAnswerStrcase SDPTypeRollback:return sdpTypeRollbackStrdefault:return ErrUnknownType.Error()}}// MarshalJSON enables JSON marshaling of a SDPType.func ( SDPType) () ([]byte, error) {return json.Marshal(.String())}// UnmarshalJSON enables JSON unmarshaling of a SDPType.func ( *SDPType) ( []byte) error {var stringif := json.Unmarshal(, &); != nil {return}switch strings.ToLower() {default:return ErrUnknownTypecase "offer":* = SDPTypeOffercase "pranswer":* = SDPTypePranswercase "answer":* = SDPTypeAnswercase "rollback":* = SDPTypeRollback}return nil}
![]() |
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. |