mirror of
https://github.com/aler9/gortsplib
synced 2025-10-12 18:40:07 +08:00
simplify connClientUDPListener
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user