simplify connClientUDPListener

This commit is contained in:
aler9
2020-09-23 22:09:17 +02:00
parent 46ea598b35
commit 592bd7451c
2 changed files with 24 additions and 19 deletions

View File

@@ -3,31 +3,23 @@ package gortsplib
import (
"net"
"strconv"
"sync/atomic"
"time"
)
type connClientUDPListener struct {
c *ConnClient
pc net.PacketConn
trackId int
streamType StreamType
publisherIp net.IP
publisherPort int
udpFrameReadBuf *MultiBuffer
}
func newConnClientUDPListener(c *ConnClient, port int, trackId int, streamType StreamType) (*connClientUDPListener, error) {
func newConnClientUDPListener(c *ConnClient, port int) (*connClientUDPListener, error) {
pc, err := c.conf.ListenPacket("udp", ":"+strconv.FormatInt(int64(port), 10))
if err != nil {
return nil, err
}
return &connClientUDPListener{
c: c,
pc: pc,
trackId: trackId,
streamType: streamType,
udpFrameReadBuf: NewMultiBuffer(c.conf.ReadBufferCount, 2048),
}, nil
}
@@ -50,10 +42,6 @@ func (l *connClientUDPListener) read() ([]byte, error) {
continue
}
atomic.StoreInt64(l.c.udpLastFrameTimes[l.trackId], time.Now().Unix())
l.c.rtcpReceivers[l.trackId].OnFrame(l.streamType, buf[:n])
return buf[:n], nil
}
}