github.com/pion/webrtc/v3@v3.2.24/icecomponent.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package webrtc 5 6 // ICEComponent describes if the ice transport is used for RTP 7 // (or RTCP multiplexing). 8 type ICEComponent int 9 10 const ( 11 // ICEComponentRTP indicates that the ICE Transport is used for RTP (or 12 // RTCP multiplexing), as defined in 13 // https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols 14 // multiplexed with RTP (e.g. data channel) share its component ID. This 15 // represents the component-id value 1 when encoded in candidate-attribute. 16 ICEComponentRTP ICEComponent = iota + 1 17 18 // ICEComponentRTCP indicates that the ICE Transport is used for RTCP as 19 // defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This 20 // represents the component-id value 2 when encoded in candidate-attribute. 21 ICEComponentRTCP 22 ) 23 24 // This is done this way because of a linter. 25 const ( 26 iceComponentRTPStr = "rtp" 27 iceComponentRTCPStr = "rtcp" 28 ) 29 30 func newICEComponent(raw string) ICEComponent { 31 switch raw { 32 case iceComponentRTPStr: 33 return ICEComponentRTP 34 case iceComponentRTCPStr: 35 return ICEComponentRTCP 36 default: 37 return ICEComponent(Unknown) 38 } 39 } 40 41 func (t ICEComponent) String() string { 42 switch t { 43 case ICEComponentRTP: 44 return iceComponentRTPStr 45 case ICEComponentRTCP: 46 return iceComponentRTCPStr 47 default: 48 return ErrUnknownType.Error() 49 } 50 }