icecomponent.go 1.3 KB

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