make WritePacket*() return errors when write queue is full (#388)

This commit is contained in:
Alessandro Ros
2023-08-26 18:09:45 +02:00
committed by GitHub
parent 9453e55f3d
commit 3bdae4ed46
14 changed files with 127 additions and 37 deletions

View File

@@ -2,6 +2,8 @@ package gortsplib
import (
"net"
"github.com/bluenviron/gortsplib/v4/pkg/liberrors"
)
type serverMulticastWriter struct {
@@ -62,14 +64,24 @@ func (h *serverMulticastWriter) ip() net.IP {
return h.rtpl.ip()
}
func (h *serverMulticastWriter) writePacketRTP(payload []byte) {
h.writer.queue(func() {
func (h *serverMulticastWriter) writePacketRTP(payload []byte) error {
ok := h.writer.push(func() {
h.rtpl.write(payload, h.rtpAddr) //nolint:errcheck
})
if !ok {
return liberrors.ErrServerWriteQueueFull{}
}
return nil
}
func (h *serverMulticastWriter) writePacketRTCP(payload []byte) {
h.writer.queue(func() {
func (h *serverMulticastWriter) writePacketRTCP(payload []byte) error {
ok := h.writer.push(func() {
h.rtcpl.write(payload, h.rtcpAddr) //nolint:errcheck
})
if !ok {
return liberrors.ErrServerWriteQueueFull{}
}
return nil
}