-
Notifications
You must be signed in to change notification settings - Fork 18
/
iceinfo.go
86 lines (69 loc) · 1.52 KB
/
iceinfo.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package sdp
import (
"encoding/hex"
"math/rand"
)
type ICEInfo struct {
ufrag string
password string
lite bool
endOfCandidates bool
}
func NewICEInfo(ufrag, password string) *ICEInfo {
return &ICEInfo{
ufrag: ufrag,
password: password,
lite: false,
endOfCandidates: false,
}
}
func GenerateICEInfo(lite bool) *ICEInfo {
ufrag := make([]byte, 8)
password := make([]byte, 24)
rand.Read(ufrag)
rand.Read(password)
return &ICEInfo{
ufrag: hex.EncodeToString(ufrag),
password: hex.EncodeToString(password),
lite: lite,
endOfCandidates: false,
}
}
func ICEInfoGenerate(lite bool) *ICEInfo {
ufrag := make([]byte, 8)
password := make([]byte, 24)
rand.Read(ufrag)
rand.Read(password)
return &ICEInfo{
ufrag: hex.EncodeToString(ufrag),
password: hex.EncodeToString(password),
lite: lite,
endOfCandidates: false,
}
}
func (c *ICEInfo) Clone() *ICEInfo {
return &ICEInfo{
ufrag: c.ufrag,
password: c.password,
lite: c.lite,
endOfCandidates: c.endOfCandidates,
}
}
func (c *ICEInfo) GetUfrag() string {
return c.ufrag
}
func (c *ICEInfo) GetPassword() string {
return c.password
}
func (c *ICEInfo) IsLite() bool {
return c.lite
}
func (c *ICEInfo) SetLite(lite bool) {
c.lite = lite
}
func (c *ICEInfo) IsEndOfCandidate() bool {
return c.endOfCandidates
}
func (c *ICEInfo) SetEndOfCandidate(endOfCandidate bool) {
c.endOfCandidates = endOfCandidate
}