mirror of
https://github.com/aler9/gortsplib
synced 2025-10-26 16:50:32 +08:00
rename maxPacketSize into udpMaxPayloadSize (#249)
This commit is contained in:
@@ -71,7 +71,7 @@ func (ct *clientFormat) stop() {
|
||||
}
|
||||
|
||||
func (ct *clientFormat) writePacketRTPWithNTP(pkt *rtp.Packet, ntp time.Time) error {
|
||||
byts := make([]byte, maxPacketSize)
|
||||
byts := make([]byte, udpMaxPayloadSize)
|
||||
n, err := pkt.MarshalTo(byts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -118,7 +118,7 @@ func (cm *clientMedia) start() {
|
||||
|
||||
cm.tcpRTPFrame = &base.InterleavedFrame{Channel: cm.tcpChannel}
|
||||
cm.tcpRTCPFrame = &base.InterleavedFrame{Channel: cm.tcpChannel + 1}
|
||||
cm.tcpBuffer = make([]byte, maxPacketSize+4)
|
||||
cm.tcpBuffer = make([]byte, udpMaxPayloadSize+4)
|
||||
}
|
||||
|
||||
for _, ct := range cm.formats {
|
||||
@@ -222,9 +222,9 @@ func (cm *clientMedia) readRTCPTCPPlay(payload []byte) error {
|
||||
now := time.Now()
|
||||
atomic.StoreInt64(cm.c.tcpLastFrameTime, now.Unix())
|
||||
|
||||
if len(payload) > maxPacketSize {
|
||||
if len(payload) > udpMaxPayloadSize {
|
||||
cm.c.OnDecodeError(fmt.Errorf("RTCP packet size (%d) is greater than maximum allowed (%d)",
|
||||
len(payload), maxPacketSize))
|
||||
len(payload), udpMaxPayloadSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -246,9 +246,9 @@ func (cm *clientMedia) readRTPTCPRecord(payload []byte) error {
|
||||
}
|
||||
|
||||
func (cm *clientMedia) readRTCPTCPRecord(payload []byte) error {
|
||||
if len(payload) > maxPacketSize {
|
||||
if len(payload) > udpMaxPayloadSize {
|
||||
cm.c.OnDecodeError(fmt.Errorf("RTCP packet size (%d) is greater than maximum allowed (%d)",
|
||||
len(payload), maxPacketSize))
|
||||
len(payload), udpMaxPayloadSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ func (cm *clientMedia) readRTPUDPPlay(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(cm.c.BytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
cm.c.OnDecodeError(fmt.Errorf("RTP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func (cm *clientMedia) readRTCPUDPPlay(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(cm.c.BytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
cm.c.OnDecodeError(fmt.Errorf("RTCP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
@@ -332,7 +332,7 @@ func (cm *clientMedia) readRTCPUDPRecord(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(cm.c.BytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
cm.c.OnDecodeError(fmt.Errorf("RTCP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func (u *clientUDPListener) runReader(forPlay bool) {
|
||||
}
|
||||
|
||||
for {
|
||||
buf := make([]byte, maxPacketSize+1)
|
||||
buf := make([]byte, udpMaxPayloadSize+1)
|
||||
n, addr, err := u.pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -5,7 +5,7 @@ const (
|
||||
udpKernelReadBufferSize = 0x80000
|
||||
|
||||
// 1500 (UDP MTU) - 20 (IP header) - 8 (UDP header)
|
||||
maxPacketSize = 1472
|
||||
udpMaxPayloadSize = 1472
|
||||
|
||||
// same size as GStreamer's rtspsrc
|
||||
multicastTTL = 16
|
||||
|
||||
@@ -82,7 +82,7 @@ func (sm *serverSessionMedia) start() {
|
||||
|
||||
sm.tcpRTPFrame = &base.InterleavedFrame{Channel: sm.tcpChannel}
|
||||
sm.tcpRTCPFrame = &base.InterleavedFrame{Channel: sm.tcpChannel + 1}
|
||||
sm.tcpBuffer = make([]byte, maxPacketSize+4)
|
||||
sm.tcpBuffer = make([]byte, udpMaxPayloadSize+4)
|
||||
}
|
||||
|
||||
if *sm.ss.setuppedTransport == TransportUDP {
|
||||
@@ -154,7 +154,7 @@ func (sm *serverSessionMedia) readRTCPUDPPlay(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(sm.ss.bytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
sm.ss.onDecodeError(fmt.Errorf("RTCP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (sm *serverSessionMedia) readRTPUDPRecord(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(sm.ss.bytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
sm.ss.onDecodeError(fmt.Errorf("RTP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (sm *serverSessionMedia) readRTCPUDPRecord(payload []byte) error {
|
||||
|
||||
atomic.AddUint64(sm.ss.bytesReceived, uint64(plen))
|
||||
|
||||
if plen == (maxPacketSize + 1) {
|
||||
if plen == (udpMaxPayloadSize + 1) {
|
||||
sm.ss.onDecodeError(fmt.Errorf("RTCP packet is too big to be read with UDP"))
|
||||
return nil
|
||||
}
|
||||
@@ -245,9 +245,9 @@ func (sm *serverSessionMedia) readRTPTCPPlay(payload []byte) error {
|
||||
}
|
||||
|
||||
func (sm *serverSessionMedia) readRTCPTCPPlay(payload []byte) error {
|
||||
if len(payload) > maxPacketSize {
|
||||
if len(payload) > udpMaxPayloadSize {
|
||||
sm.ss.onDecodeError(fmt.Errorf("RTCP packet size (%d) is greater than maximum allowed (%d)",
|
||||
len(payload), maxPacketSize))
|
||||
len(payload), udpMaxPayloadSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -282,9 +282,9 @@ func (sm *serverSessionMedia) readRTPTCPRecord(payload []byte) error {
|
||||
}
|
||||
|
||||
func (sm *serverSessionMedia) readRTCPTCPRecord(payload []byte) error {
|
||||
if len(payload) > maxPacketSize {
|
||||
if len(payload) > udpMaxPayloadSize {
|
||||
sm.ss.onDecodeError(fmt.Errorf("RTCP packet size (%d) is greater than maximum allowed (%d)",
|
||||
len(payload), maxPacketSize))
|
||||
len(payload), udpMaxPayloadSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func (sm *serverStreamMedia) allocateMulticastHandler(s *Server) error {
|
||||
}
|
||||
|
||||
func (sm *serverStreamMedia) WritePacketRTPWithNTP(ss *ServerStream, pkt *rtp.Packet, ntp time.Time) {
|
||||
byts := make([]byte, maxPacketSize)
|
||||
byts := make([]byte, udpMaxPayloadSize)
|
||||
n, err := pkt.MarshalTo(byts)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -183,7 +183,7 @@ func (u *serverUDPListener) runReader() {
|
||||
}
|
||||
|
||||
for {
|
||||
buf := make([]byte, maxPacketSize+1)
|
||||
buf := make([]byte, udpMaxPayloadSize+1)
|
||||
n, addr, err := u.pc.ReadFromUDP(buf)
|
||||
if err != nil {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user