remove StreamType from base

This commit is contained in:
aler9
2021-10-30 16:39:02 +02:00
committed by Alessandro Ros
parent 6d340cdf39
commit e8e2059b0d
5 changed files with 27 additions and 43 deletions

View File

@@ -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++
}

View File

@@ -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"
}

View File

@@ -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

View File

@@ -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"
}

View File

@@ -1,4 +1,4 @@
package base
package gortsplib
import (
"testing"