forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtcrtptransceiverdirection.go
62 lines (54 loc) · 2.16 KB
/
rtcrtptransceiverdirection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package webrtc
// RTCRtpTransceiverDirection indicates the direction of the RTCRtpTransceiver.
type RTCRtpTransceiverDirection int
const (
// RTCRtpTransceiverDirectionSendrecv indicates the RTCRtpSender will offer
// to send RTP and RTCRtpReceiver the will offer to receive RTP.
RTCRtpTransceiverDirectionSendrecv RTCRtpTransceiverDirection = iota + 1
// RTCRtpTransceiverDirectionSendonly indicates the RTCRtpSender will offer
// to send RTP.
RTCRtpTransceiverDirectionSendonly
// RTCRtpTransceiverDirectionRecvonly indicates the RTCRtpReceiver the will
// offer to receive RTP.
RTCRtpTransceiverDirectionRecvonly
// RTCRtpTransceiverDirectionInactive indicates the RTCRtpSender won't offer
// to send RTP and RTCRtpReceiver the won't offer to receive RTP.
RTCRtpTransceiverDirectionInactive
)
// This is done this way because of a linter.
const (
rtcRtpTransceiverDirectionSendrecvStr = "sendrecv"
rtcRtpTransceiverDirectionSendonlyStr = "sendonly"
rtcRtpTransceiverDirectionRecvonlyStr = "recvonly"
rtcRtpTransceiverDirectionInactiveStr = "inactive"
)
// NewRTCRtpTransceiverDirection defines a procedure for creating a new
// RTCRtpTransceiverDirection from a raw string naming the transceiver direction.
func NewRTCRtpTransceiverDirection(raw string) RTCRtpTransceiverDirection {
switch raw {
case rtcRtpTransceiverDirectionSendrecvStr:
return RTCRtpTransceiverDirectionSendrecv
case rtcRtpTransceiverDirectionSendonlyStr:
return RTCRtpTransceiverDirectionSendonly
case rtcRtpTransceiverDirectionRecvonlyStr:
return RTCRtpTransceiverDirectionRecvonly
case rtcRtpTransceiverDirectionInactiveStr:
return RTCRtpTransceiverDirectionInactive
default:
return RTCRtpTransceiverDirection(Unknown)
}
}
func (t RTCRtpTransceiverDirection) String() string {
switch t {
case RTCRtpTransceiverDirectionSendrecv:
return rtcRtpTransceiverDirectionSendrecvStr
case RTCRtpTransceiverDirectionSendonly:
return rtcRtpTransceiverDirectionSendonlyStr
case RTCRtpTransceiverDirectionRecvonly:
return rtcRtpTransceiverDirectionRecvonlyStr
case RTCRtpTransceiverDirectionInactive:
return rtcRtpTransceiverDirectionInactiveStr
default:
return ErrUnknownType.Error()
}
}