diff --git a/clientconn.go b/clientconn.go index 4d2cbeec..9bc35a38 100644 --- a/clientconn.go +++ b/clientconn.go @@ -604,10 +604,10 @@ func (cc *ClientConn) runBackgroundPlayTCP() error { } channel := frame.Channel - streamType := base.StreamTypeRTP + streamType := StreamTypeRTP if (channel % 2) != 0 { channel-- - streamType = base.StreamTypeRTCP + streamType = StreamTypeRTCP } trackID, ok := cc.tracksByChannel[channel] @@ -736,10 +736,10 @@ func (cc *ClientConn) runBackgroundRecordTCP() error { } channel := frame.Channel - streamType := base.StreamTypeRTP + streamType := StreamTypeRTP if (channel % 2) != 0 { channel-- - streamType = base.StreamTypeRTCP + streamType = StreamTypeRTCP } trackID, ok := cc.tracksByChannel[channel] @@ -1525,7 +1525,7 @@ func (cc *ClientConn) doPlay(ra *headers.Range, isSwitchingProtocol bool) (*base // the user calls ReadFrames() cc.readCBSet = make(chan struct{}) copy := cc.readCBSet - cc.readCB = func(trackID int, streamType base.StreamType, payload []byte) { + cc.readCB = func(trackID int, streamType StreamType, payload []byte) { select { case <-copy: case <-cc.ctx.Done(): @@ -1580,7 +1580,7 @@ func (cc *ClientConn) doRecord() (*base.Response, error) { // when publishing, calling ReadFrames() is not mandatory // use an empty callback - cc.readCB = func(trackID int, streamType base.StreamType, payload []byte) { + cc.readCB = func(trackID int, streamType StreamType, payload []byte) { } cc.backgroundStart(false) @@ -1705,7 +1705,7 @@ func (cc *ClientConn) WriteFrame(trackID int, streamType StreamType, payload []b default: // TCP channel := cc.tracks[trackID].tcpChannel - if streamType == base.StreamTypeRTCP { + if streamType == StreamTypeRTCP { channel++ } diff --git a/pkg/base/streamtype.go b/pkg/base/streamtype.go deleted file mode 100644 index 59b5c4a4..00000000 --- a/pkg/base/streamtype.go +++ /dev/null @@ -1,25 +0,0 @@ -package base - -// 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" -} diff --git a/serverconn.go b/serverconn.go index fb865b0c..a640c1cd 100644 --- a/serverconn.go +++ b/serverconn.go @@ -146,10 +146,10 @@ func (sc *ServerConn) run() { switch what.(type) { case *base.InterleavedFrame: channel := frame.Channel - streamType := base.StreamTypeRTP + streamType := StreamTypeRTP if (channel % 2) != 0 { channel-- - streamType = base.StreamTypeRTCP + streamType = StreamTypeRTCP } // forward frame only if it has been set up diff --git a/streamtype.go b/streamtype.go index 727ecd09..18600226 100644 --- a/streamtype.go +++ b/streamtype.go @@ -1,16 +1,25 @@ package gortsplib -import ( - "github.com/aler9/gortsplib/pkg/base" -) - -// StreamType is the stream type. -type StreamType = base.StreamType +// StreamType is a stream type. +type StreamType int const ( // StreamTypeRTP means that the stream contains RTP packets - StreamTypeRTP StreamType = base.StreamTypeRTP + StreamTypeRTP StreamType = iota // StreamTypeRTCP means that the stream contains RTCP packets - StreamTypeRTCP StreamType = base.StreamTypeRTCP + 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" +} diff --git a/pkg/base/streamtype_test.go b/streamtype_test.go similarity index 92% rename from pkg/base/streamtype_test.go rename to streamtype_test.go index bc7546e2..d72c4cb5 100644 --- a/pkg/base/streamtype_test.go +++ b/streamtype_test.go @@ -1,4 +1,4 @@ -package base +package gortsplib import ( "testing"