github.com/pion/webrtc/v4@v4.0.1/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  	// ICEComponentUnknown is the enum's zero-value
    12  	ICEComponentUnknown ICEComponent = iota
    13  
    14  	// ICEComponentRTP indicates that the ICE Transport is used for RTP (or
    15  	// RTCP multiplexing), as defined in
    16  	// https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols
    17  	// multiplexed with RTP (e.g. data channel) share its component ID. This
    18  	// represents the component-id value 1 when encoded in candidate-attribute.
    19  	ICEComponentRTP
    20  
    21  	// ICEComponentRTCP indicates that the ICE Transport is used for RTCP as
    22  	// defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This
    23  	// represents the component-id value 2 when encoded in candidate-attribute.
    24  	ICEComponentRTCP
    25  )
    26  
    27  // This is done this way because of a linter.
    28  const (
    29  	iceComponentRTPStr  = "rtp"
    30  	iceComponentRTCPStr = "rtcp"
    31  )
    32  
    33  func newICEComponent(raw string) ICEComponent {
    34  	switch raw {
    35  	case iceComponentRTPStr:
    36  		return ICEComponentRTP
    37  	case iceComponentRTCPStr:
    38  		return ICEComponentRTCP
    39  	default:
    40  		return ICEComponentUnknown
    41  	}
    42  }
    43  
    44  func (t ICEComponent) String() string {
    45  	switch t {
    46  	case ICEComponentRTP:
    47  		return iceComponentRTPStr
    48  	case ICEComponentRTCP:
    49  		return iceComponentRTCPStr
    50  	default:
    51  		return ErrUnknownType.Error()
    52  	}
    53  }