remove StreamType

This commit is contained in:
aler9
2021-11-12 16:45:49 +01:00
committed by Alessandro Ros
parent 029ebd5dea
commit 9ba761298d
4 changed files with 6 additions and 43 deletions

View File

@@ -1438,7 +1438,7 @@ func (c *Client) doSetup(
rtpListener.remotePort = thRes.ServerPorts[0]
}
rtpListener.trackID = trackID
rtpListener.streamType = StreamTypeRTP
rtpListener.isRTP = true
cct.udpRTPListener = rtpListener
rtcpListener.remoteReadIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
@@ -1448,7 +1448,7 @@ func (c *Client) doSetup(
rtcpListener.remotePort = thRes.ServerPorts[1]
}
rtcpListener.trackID = trackID
rtcpListener.streamType = StreamTypeRTCP
rtcpListener.isRTP = false
cct.udpRTCPListener = rtcpListener
case TransportUDPMulticast:
@@ -1457,7 +1457,7 @@ func (c *Client) doSetup(
rtpListener.remoteZone = ""
rtpListener.remotePort = thRes.Ports[0]
rtpListener.trackID = trackID
rtpListener.streamType = StreamTypeRTP
rtpListener.isRTP = true
cct.udpRTPListener = rtpListener
rtcpListener.remoteReadIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
@@ -1465,7 +1465,7 @@ func (c *Client) doSetup(
rtcpListener.remoteZone = ""
rtcpListener.remotePort = thRes.Ports[1]
rtcpListener.trackID = trackID
rtcpListener.streamType = StreamTypeRTCP
rtcpListener.isRTP = false
cct.udpRTCPListener = rtcpListener
case TransportTCP:

View File

@@ -36,7 +36,7 @@ type clientUDPListener struct {
remoteZone string
remotePort int
trackID int
streamType StreamType
isRTP bool
running bool
frameBuffer *multibuffer.MultiBuffer
lastFrameTime *int64
@@ -167,7 +167,7 @@ func (l *clientUDPListener) run() {
now := time.Now()
atomic.StoreInt64(l.lastFrameTime, now.Unix())
if l.streamType == StreamTypeRTP {
if l.isRTP {
l.c.tracks[l.trackID].rtcpReceiver.ProcessPacketRTP(now, buf[:n])
l.c.OnPacketRTP(l.c, l.trackID, buf[:n])
} else {

View File

@@ -1,25 +0,0 @@
package gortsplib
// StreamType is a stream type.
type StreamType int
const (
// StreamTypeRTP means that the stream contains RTP packets
StreamTypeRTP StreamType = iota
// StreamTypeRTCP means that the stream contains RTCP packets
StreamTypeRTCP
)
var streamTypeLabels = map[StreamType]string{
StreamTypeRTP: "RTP",
StreamTypeRTCP: "RTCP",
}
// String implements fmt.Stringer
func (st StreamType) String() string {
if l, ok := streamTypeLabels[st]; ok {
return l
}
return "unknown"
}

View File

@@ -1,12 +0,0 @@
package gortsplib
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestStreamType(t *testing.T) {
require.NotEqual(t, "unknown", StreamTypeRTP.String())
require.Equal(t, "unknown", StreamType(4).String())
}