forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_multicast_writer_format.go
More file actions
57 lines (48 loc) · 1.31 KB
/
server_multicast_writer_format.go
File metadata and controls
57 lines (48 loc) · 1.31 KB
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 gortsplib
import (
"time"
"github.com/bluenviron/gortsplib/v5/pkg/format"
"github.com/bluenviron/gortsplib/v5/pkg/liberrors"
"github.com/bluenviron/gortsplib/v5/pkg/rtpsender"
"github.com/pion/rtcp"
"github.com/pion/rtp"
)
type serverMulticastWriterFormat struct {
senderReportPeriod time.Duration
timeNow func() time.Time
disableRTCPSenderReports bool
smm *serverMulticastWriterMedia
format format.Format
rtpSender *rtpsender.Sender
}
func (smf *serverMulticastWriterFormat) initialize() {
smf.rtpSender = &rtpsender.Sender{
ClockRate: smf.format.ClockRate(),
Period: smf.senderReportPeriod,
TimeNow: smf.timeNow,
WritePacketRTCP: func(pkt rtcp.Packet) {
if !smf.disableRTCPSenderReports {
smf.smm.writePacketRTCP(pkt) //nolint:errcheck
}
},
}
smf.rtpSender.Initialize()
}
func (smf *serverMulticastWriterFormat) close() {
smf.rtpSender.Close()
}
func (smf *serverMulticastWriterFormat) writePacketRTPEncoded(
pkt *rtp.Packet,
ntp time.Time,
ptsEqualsDTS bool,
payload []byte,
) error {
smf.rtpSender.ProcessPacket(pkt, ntp, ptsEqualsDTS)
ok := smf.smm.writer.Push(func() error {
return smf.smm.rtpl.write(payload, smf.smm.rtpAddr)
})
if !ok {
return liberrors.ErrServerWriteQueueFull{}
}
return nil
}