icecomponent.go 1.4 KB

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