-
Notifications
You must be signed in to change notification settings - Fork 18
/
simulcastinfo.go
57 lines (45 loc) · 1.36 KB
/
simulcastinfo.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
package sdp
type SimulcastInfo struct {
send [][]*SimulcastStreamInfo
recv [][]*SimulcastStreamInfo
}
func NewSimulcastInfo() *SimulcastInfo {
info := &SimulcastInfo{}
info.send = make([][]*SimulcastStreamInfo, 0)
info.recv = make([][]*SimulcastStreamInfo, 0)
return info
}
func (s *SimulcastInfo) Clone() *SimulcastInfo {
cloned := new(SimulcastInfo)
cloned.send = make([][]*SimulcastStreamInfo, len(s.send))
cloned.recv = make([][]*SimulcastStreamInfo, len(s.recv))
for i := range s.send {
cloned.send[i] = make([]*SimulcastStreamInfo, len(s.send[i]))
copy(cloned.send[i], s.send[i])
}
for i := range s.recv {
cloned.recv[i] = make([]*SimulcastStreamInfo, len(s.recv[i]))
copy(cloned.recv[i], s.recv[i])
}
return cloned
}
func (s *SimulcastInfo) AddSimulcastAlternativeStreams(direction DirectionWay, streams []*SimulcastStreamInfo) {
if direction == SEND {
s.send = append(s.send, streams)
} else {
s.recv = append(s.recv, streams)
}
}
func (s *SimulcastInfo) AddSimulcastStream(direction DirectionWay, stream *SimulcastStreamInfo) {
if direction == SEND {
s.send = append(s.send, []*SimulcastStreamInfo{stream})
} else {
s.recv = append(s.recv, []*SimulcastStreamInfo{stream})
}
}
func (s *SimulcastInfo) GetSimulcastStreams(direction DirectionWay) [][]*SimulcastStreamInfo {
if direction == SEND {
return s.send
}
return s.recv
}