-
Notifications
You must be signed in to change notification settings - Fork 197
/
server_stream_media.go
61 lines (52 loc) · 1.14 KB
/
server_stream_media.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
package gortsplib
import (
"github.com/bluenviron/gortsplib/v4/pkg/description"
)
type serverStreamMedia struct {
st *ServerStream
media *description.Media
trackID int
formats map[uint8]*serverStreamFormat
multicastWriter *serverMulticastWriter
}
func (sm *serverStreamMedia) initialize() {
sm.formats = make(map[uint8]*serverStreamFormat)
for _, forma := range sm.media.Formats {
sf := &serverStreamFormat{
sm: sm,
format: forma,
}
sf.initialize()
sm.formats[forma.PayloadType()] = sf
}
}
func (sm *serverStreamMedia) close() {
for _, tr := range sm.formats {
if tr.rtcpSender != nil {
tr.rtcpSender.Close()
}
}
if sm.multicastWriter != nil {
sm.multicastWriter.close()
}
}
func (sm *serverStreamMedia) writePacketRTCP(byts []byte) error {
// send unicast
for r := range sm.st.activeUnicastReaders {
sm, ok := r.setuppedMedias[sm.media]
if ok {
err := sm.writePacketRTCP(byts)
if err != nil {
r.onStreamWriteError(err)
}
}
}
// send multicast
if sm.multicastWriter != nil {
err := sm.multicastWriter.writePacketRTCP(byts)
if err != nil {
return err
}
}
return nil
}