diff --git a/.golangci.yml b/.golangci.yml index 1911cbfc..77c31197 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -56,11 +56,11 @@ linters: - (github.com/datarhei/gosrt.Conn).Close - (github.com/datarhei/gosrt.Conn).SetReadDeadline - (github.com/datarhei/gosrt.Conn).SetWriteDeadline - - (*github.com/bluenviron/gortsplib/v4.Client).Close - - (*github.com/bluenviron/gortsplib/v4.Server).Close - - (*github.com/bluenviron/gortsplib/v4.ServerSession).Close - - (*github.com/bluenviron/gortsplib/v4.ServerStream).Close - - (*github.com/bluenviron/gortsplib/v4.ServerConn).Close + - (*github.com/bluenviron/gortsplib/v5.Client).Close + - (*github.com/bluenviron/gortsplib/v5.Server).Close + - (*github.com/bluenviron/gortsplib/v5.ServerSession).Close + - (*github.com/bluenviron/gortsplib/v5.ServerStream).Close + - (*github.com/bluenviron/gortsplib/v5.ServerConn).Close govet: enable-all: true diff --git a/README.md b/README.md index 2481eed6..a11fbd85 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Lint](https://github.com/bluenviron/gortsplib/actions/workflows/lint.yml/badge.svg)](https://github.com/bluenviron/gortsplib/actions/workflows/lint.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/bluenviron/gortsplib)](https://goreportcard.com/report/github.com/bluenviron/gortsplib) [![CodeCov](https://codecov.io/gh/bluenviron/gortsplib/branch/main/graph/badge.svg)](https://app.codecov.io/gh/bluenviron/gortsplib/tree/main) -[![PkgGoDev](https://pkg.go.dev/badge/github.com/bluenviron/gortsplib/v4)](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4#pkg-index) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/bluenviron/gortsplib/v5)](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5#pkg-index) RTSP client and server library for the Go programming language, written for [MediaMTX](https://github.com/bluenviron/mediamtx). @@ -104,7 +104,7 @@ Features: ## API Documentation -[Click to open the API Documentation](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4#pkg-index) +[Click to open the API Documentation](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5#pkg-index) ## RTP Payload Formats @@ -114,37 +114,37 @@ In RTSP, media streams are transmitted by using RTP packets, which are encoded i |format|documentation|encoder and decoder available| |------|-------------|-----------------------------| -|AV1|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#AV1)|:heavy_check_mark:| -|VP9|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#VP9)|:heavy_check_mark:| -|VP8|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#VP8)|:heavy_check_mark:| -|H265|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#H265)|:heavy_check_mark:| -|H264|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#H264)|:heavy_check_mark:| -|MPEG-4 Video (H263, Xvid)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEG4Video)|:heavy_check_mark:| -|MPEG-1/2 Video|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEG1Video)|:heavy_check_mark:| -|M-JPEG|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MJPEG)|:heavy_check_mark:| +|AV1|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#AV1)|:heavy_check_mark:| +|VP9|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#VP9)|:heavy_check_mark:| +|VP8|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#VP8)|:heavy_check_mark:| +|H265|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#H265)|:heavy_check_mark:| +|H264|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#H264)|:heavy_check_mark:| +|MPEG-4 Video (H263, Xvid)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEG4Video)|:heavy_check_mark:| +|MPEG-1/2 Video|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEG1Video)|:heavy_check_mark:| +|M-JPEG|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MJPEG)|:heavy_check_mark:| ### Audio |format|documentation|encoder and decoder available| |------|-------------|-----------------------------| -|Opus|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#Opus)|:heavy_check_mark:| -|Vorbis|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#Vorbis)|| -|MPEG-4 Audio (AAC)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEG4Audio)|:heavy_check_mark:| -|MPEG-4 Audio LATM (AAC-LATM)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEG4AudioLATM)|:heavy_check_mark:| -|MPEG-1/2 Audio (MP3)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEG1Audio)|:heavy_check_mark:| -|AC-3|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#AC3)|:heavy_check_mark:| -|Speex|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#Speex)|| -|G726|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#G726)|| -|G722|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#G722)|:heavy_check_mark:| -|G711 (PCMA, PCMU)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#G711)|:heavy_check_mark:| -|LPCM|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#LPCM)|:heavy_check_mark:| +|Opus|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#Opus)|:heavy_check_mark:| +|Vorbis|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#Vorbis)|| +|MPEG-4 Audio (AAC)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEG4Audio)|:heavy_check_mark:| +|MPEG-4 Audio LATM (AAC-LATM)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEG4AudioLATM)|:heavy_check_mark:| +|MPEG-1/2 Audio (MP3)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEG1Audio)|:heavy_check_mark:| +|AC-3|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#AC3)|:heavy_check_mark:| +|Speex|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#Speex)|| +|G726|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#G726)|| +|G722|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#G722)|:heavy_check_mark:| +|G711 (PCMA, PCMU)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#G711)|:heavy_check_mark:| +|LPCM|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#LPCM)|:heavy_check_mark:| ### Other |format|documentation|encoder and decoder available| |------|-------------|-----------------------------| -|MPEG-TS|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#MPEGTS)|| -|KLV|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v4/pkg/format#KLV)|:heavy_check_mark:| +|MPEG-TS|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#MPEGTS)|| +|KLV|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v5/pkg/format#KLV)|:heavy_check_mark:| ## Specifications diff --git a/client.go b/client.go index 2513bafb..6f06518a 100644 --- a/client.go +++ b/client.go @@ -23,20 +23,20 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/internal/asyncprocessor" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/bytecounter" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/rtpreceiver" - "github.com/bluenviron/gortsplib/v4/pkg/rtpsender" - "github.com/bluenviron/gortsplib/v4/pkg/rtptime" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/internal/asyncprocessor" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/bytecounter" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/rtpreceiver" + "github.com/bluenviron/gortsplib/v5/pkg/rtpsender" + "github.com/bluenviron/gortsplib/v5/pkg/rtptime" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) const ( @@ -84,14 +84,6 @@ func clientExtractExistingSSRCs(setuppedMedias map[*description.Media]*clientMed return ret } -// avoid an int64 overflow and preserve resolution by splitting division into two parts: -// first add the integer part, then the decimal part. -func multiplyAndDivide(v, m, d time.Duration) time.Duration { - secs := v / d - dec := v % d - return (secs*m + dec*m/d) -} - // convert an URL into an address, in particular: // * add default port // * handle IPv6 with or without square brackets. @@ -417,11 +409,6 @@ type ClientOnResponseFunc func(*base.Response) // ClientOnTransportSwitchFunc is the prototype of Client.OnTransportSwitch. type ClientOnTransportSwitchFunc func(err error) -// ClientOnPacketLostFunc is the prototype of Client.OnPacketLost. -// -// Deprecated: replaced by ClientOnPacketsLostFunc -type ClientOnPacketLostFunc func(err error) - // ClientOnPacketsLostFunc is the prototype of Client.OnPacketsLost. type ClientOnPacketsLostFunc func(lost uint64) @@ -467,7 +454,7 @@ type Client struct { // transport protocol (UDP, Multicast or TCP). // If nil, it is chosen automatically (first UDP, then, if it fails, TCP). // It defaults to nil. - Transport *TransportProtocol + Protocol *Protocol // enable communication with servers which don't provide UDP server ports // or use different server ports than the announced ones. // This can be a security issue. @@ -495,14 +482,6 @@ type Client struct { DisableRTCPSenderReports bool // explicitly request back channels to the server. RequestBackChannels bool - // pointer to a variable that stores received bytes. - // - // Deprecated: use Client.Stats() - BytesReceived *uint64 - // pointer to a variable that stores sent bytes. - // - // Deprecated: use Client.Stats() - BytesSent *uint64 // // system functions (all optional) @@ -528,10 +507,6 @@ type Client struct { // called when the transport protocol changes. OnTransportSwitch ClientOnTransportSwitchFunc // called when the client detects lost packets. - // - // Deprecated: replaced by OnPacketsLost - OnPacketLost ClientOnPacketLostFunc - // called when the client detects lost packets. OnPacketsLost ClientOnPacketsLostFunc // called when a non-fatal decode error occurs. OnDecodeError ClientOnDecodeErrorFunc @@ -575,7 +550,7 @@ type Client struct { writerMutex sync.RWMutex writer *asyncprocessor.Processor reader *clientReader - timeDecoder *rtptime.GlobalDecoder2 + timeDecoder *rtptime.GlobalDecoder mustClose bool tcpFrame *base.InterleavedFrame tcpBuffer []byte @@ -600,16 +575,7 @@ type Client struct { } // Start initializes the connection to a server. -// -// Deprecated: replaced by Start2. -func (c *Client) Start(scheme string, host string) error { - c.Scheme = scheme - c.Host = host - return c.Start2() -} - -// Start2 initializes the connection to a server. -func (c *Client) Start2() error { +func (c *Client) Start() error { // RTSP parameters if c.ReadTimeout == 0 { c.ReadTimeout = 10 * time.Second @@ -664,11 +630,6 @@ func (c *Client) Start2() error { log.Println(err.Error()) } } - if c.OnPacketLost != nil { - c.OnPacketsLost = func(lost uint64) { - c.OnPacketLost(liberrors.ErrClientRTPPacketsLost{Lost: uint(lost)}) //nolint:staticcheck - } - } if c.OnPacketsLost == nil { c.OnPacketsLost = func(lost uint64) { log.Printf("%d RTP %s lost", @@ -709,17 +670,8 @@ func (c *Client) Start2() error { c.checkTimeoutTimer = emptyTimer() c.keepAlivePeriod = 30 * time.Second c.keepAliveTimer = emptyTimer() - - if c.BytesReceived != nil { - c.bytesReceived = c.BytesReceived - } else { - c.bytesReceived = new(uint64) - } - if c.BytesSent != nil { - c.bytesSent = c.BytesSent - } else { - c.bytesSent = new(uint64) - } + c.bytesReceived = new(uint64) + c.bytesSent = new(uint64) c.chOptions = make(chan optionsReq) c.chDescribe = make(chan describeReq) @@ -749,7 +701,7 @@ func (c *Client) StartRecording(address string, desc *description.Session) error c.Scheme = u.Scheme c.Host = u.Host - err = c.Start2() + err = c.Start() if err != nil { return err } @@ -1063,7 +1015,7 @@ func (c *Client) trySwitchingProtocol() error { } func (c *Client) startTransportRoutines() { - c.timeDecoder = &rtptime.GlobalDecoder2{} + c.timeDecoder = &rtptime.GlobalDecoder{} c.timeDecoder.Initialize() for _, cm := range c.setuppedMedias { @@ -1334,7 +1286,7 @@ func (c *Client) isInTCPTimeout() bool { func (c *Client) doCheckTimeout() error { if c.setuppedTransport.Protocol == TransportUDP || c.setuppedTransport.Protocol == TransportUDPMulticast { - if c.checkTimeoutInitial && !c.backChannelSetupped && c.Transport == nil { + if c.checkTimeoutInitial && !c.backChannelSetupped && c.Protocol == nil { c.checkTimeoutInitial = false if !c.atLeastOneUDPPacketHasBeenReceived() { @@ -1539,7 +1491,7 @@ func (c *Client) doAnnounce(u *base.URL, desc *description.Session) (*base.Respo return nil, err } - if c.Transport != nil && *c.Transport == TransportUDPMulticast { + if c.Protocol != nil && *c.Protocol == TransportUDPMulticast { return nil, fmt.Errorf("recording with UDP multicast is not supported") } @@ -1558,7 +1510,7 @@ func (c *Client) doAnnounce(u *base.URL, desc *description.Session) (*base.Respo return nil, err } - byts, err := desc.Marshal(false) + byts, err := desc.Marshal() if err != nil { return nil, err } @@ -1633,7 +1585,7 @@ func (c *Client) doSetup( th.Mode = &v } - var protocol TransportProtocol + var protocol Protocol switch { // use transport from previous SETUP calls @@ -1642,8 +1594,8 @@ func (c *Client) doSetup( th.Profile = c.setuppedTransport.Profile // use transport from config, secure flag from server - case c.Transport != nil: - protocol = *c.Transport + case c.Protocol != nil: + protocol = *c.Protocol if isSecure(medi.Profile) && c.Scheme == "rtsps" { th.Profile = headers.TransportProfileSAVP } else { @@ -1813,7 +1765,7 @@ func (c *Client) doSetup( if res.StatusCode != base.StatusOK { // switch transport automatically if res.StatusCode == base.StatusUnsupportedTransport && - c.setuppedTransport == nil && c.Transport == nil { + c.setuppedTransport == nil && c.Protocol == nil { c.OnTransportSwitch(liberrors.ErrClientSwitchToTCP2{}) c.setuppedTransport = &SessionTransport{ Protocol: TransportTCP, @@ -1836,7 +1788,7 @@ func (c *Client) doSetup( case TransportUDP, TransportUDPMulticast: if thRes.Protocol == headers.TransportProtocolTCP { // switch transport automatically - if c.setuppedTransport == nil && c.Transport == nil { + if c.setuppedTransport == nil && c.Protocol == nil { c.OnTransportSwitch(liberrors.ErrClientSwitchToTCP2{}) c.baseURL = baseURL @@ -2358,18 +2310,6 @@ func (c *Client) Pause() (*base.Response, error) { } } -// Seek asks the server to re-start the stream from a specific timestamp. -// -// Deprecated: will be removed in next version. Equivalent to using Pause() followed by Play(). -func (c *Client) Seek(ra *headers.Range) (*base.Response, error) { - _, err := c.Pause() - if err != nil { - return nil, err - } - - return c.Play(ra) -} - // OnPacketRTPAny sets a callback that is called when a RTP packet is read from any setupped media. func (c *Client) OnPacketRTPAny(cb OnPacketRTPAnyFunc) { for _, cm := range c.setuppedMedias { @@ -2438,23 +2378,7 @@ func (c *Client) WritePacketRTCP(medi *description.Media, pkt rtcp.Packet) error // PacketPTS returns the PTS (presentation timestamp) of an incoming RTP packet. // It is computed by decoding the packet timestamp and sychronizing it with other tracks. -// -// Deprecated: replaced by PacketPTS2. -func (c *Client) PacketPTS(medi *description.Media, pkt *rtp.Packet) (time.Duration, bool) { - cm := c.setuppedMedias[medi] - ct := cm.formats[pkt.PayloadType] - - v, ok := c.timeDecoder.Decode(ct.format, pkt) - if !ok { - return 0, false - } - - return multiplyAndDivide(time.Duration(v), time.Second, time.Duration(ct.format.ClockRate())), true -} - -// PacketPTS2 returns the PTS (presentation timestamp) of an incoming RTP packet. -// It is computed by decoding the packet timestamp and sychronizing it with other tracks. -func (c *Client) PacketPTS2(medi *description.Media, pkt *rtp.Packet) (int64, bool) { +func (c *Client) PacketPTS(medi *description.Media, pkt *rtp.Packet) (int64, bool) { cm := c.setuppedMedias[medi] ct := cm.formats[pkt.PayloadType] return c.timeDecoder.Decode(ct.format, pkt) @@ -2468,8 +2392,8 @@ func (c *Client) PacketNTP(medi *description.Media, pkt *rtp.Packet) (time.Time, return ct.rtpReceiver.PacketNTP(pkt.Timestamp) } -// Transport2 returns transport details. -func (c *Client) Transport2() *ClientTransport { +// Transport returns transport details. +func (c *Client) Transport() *ClientTransport { c.propsMutex.RLock() defer c.propsMutex.RUnlock() @@ -2486,8 +2410,8 @@ func (c *Client) Stats() *ClientStats { c.propsMutex.RLock() defer c.propsMutex.RUnlock() - mediaStats := func() map[*description.Media]StatsSessionMedia { //nolint:dupl - ret := make(map[*description.Media]StatsSessionMedia, len(c.setuppedMedias)) + mediaStats := func() map[*description.Media]SessionStatsMedia { //nolint:dupl + ret := make(map[*description.Media]SessionStatsMedia, len(c.setuppedMedias)) for med, sm := range c.setuppedMedias { ret[med] = SessionStatsMedia{ diff --git a/client_format.go b/client_format.go index 4e8bdb06..9bde04f0 100644 --- a/client_format.go +++ b/client_format.go @@ -7,10 +7,10 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/rtpreceiver" - "github.com/bluenviron/gortsplib/v4/pkg/rtpsender" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/rtpreceiver" + "github.com/bluenviron/gortsplib/v5/pkg/rtpsender" ) type clientFormat struct { @@ -53,7 +53,7 @@ func (cf *clientFormat) initialize() { } else { cf.rtpReceiver = &rtpreceiver.Receiver{ ClockRate: cf.format.ClockRate(), - LocalSSRC: &cf.localSSRC, + LocalSSRC: cf.localSSRC, UnrealiableTransport: (cf.cm.udpRTPListener != nil), Period: cf.cm.c.receiverReportPeriod, TimeNow: cf.cm.c.timeNow, @@ -94,7 +94,7 @@ func (cf *clientFormat) remoteSSRC() (uint32, bool) { func (cf *clientFormat) readPacketRTP(pkt *rtp.Packet) { now := cf.cm.c.timeNow() - pkts, lost, err := cf.rtpReceiver.ProcessPacket2(pkt, now, cf.format.PTSEqualsDTS(pkt)) + pkts, lost, err := cf.rtpReceiver.ProcessPacket(pkt, now, cf.format.PTSEqualsDTS(pkt)) if err != nil { cf.cm.onPacketRTPDecodeError(err) return diff --git a/client_media.go b/client_media.go index 44a68568..20c15c6e 100644 --- a/client_media.go +++ b/client_media.go @@ -10,8 +10,8 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) func createUDPListenerPair( diff --git a/client_play_test.go b/client_play_test.go index 53e7d7a1..d04cc0b1 100644 --- a/client_play_test.go +++ b/client_play_test.go @@ -18,14 +18,14 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/net/ipv4" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" ) @@ -38,7 +38,7 @@ func mediasToSDP(medias []*description.Media) []byte { m.Control = "trackID=" + strconv.FormatInt(int64(i), 10) } - byts, err := desc.Marshal(false) + byts, err := desc.Marshal() if err != nil { panic(err) } @@ -71,7 +71,7 @@ func readAll(c *Client, ur string, cb func(*description.Media, format.Format, *r c.Scheme = u.Scheme c.Host = u.Host - err = c.Start2() + err = c.Start() if err != nil { return err } @@ -339,16 +339,23 @@ func TestClientPlay(t *testing.T) { err2 = forma.Init() require.NoError(t, err2) + var profile headers.TransportProfile + if ca.secure == "secure" { + profile = headers.TransportProfileSAVP + } else { + profile = headers.TransportProfileAVP + } + medias := []*description.Media{ { Type: "application", Formats: []format.Format{forma}, - Secure: ca.secure == "secure", + Profile: profile, }, { Type: "application", Formats: []format.Format{forma}, - Secure: ca.secure == "secure", + Profile: profile, }, } @@ -600,7 +607,7 @@ func TestClientPlay(t *testing.T) { Scheme: u.Scheme, Host: u.Host, TLSConfig: &tls.Config{InsecureSkipVerify: true}, - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { switch ca.transport { case "udp": v := TransportUDP @@ -617,7 +624,7 @@ func TestClientPlay(t *testing.T) { }(), } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -627,7 +634,7 @@ func TestClientPlay(t *testing.T) { // test that properties can be accessed in parallel go func() { c.Stats() - c.Transport2() + c.Transport() }() err = c.SetupAll(sd.BaseURL, sd.Medias) @@ -814,7 +821,7 @@ func TestClientPlaySRTPVariants(t *testing.T) { require.Equal(t, (*headers.TransportMode)(nil), inTH.Mode) th := headers.Transport{ - Secure: true, + Profile: headers.TransportProfileSAVP, } v := headers.TransportDeliveryUnicast @@ -876,14 +883,16 @@ func TestClientPlaySRTPVariants(t *testing.T) { require.Equal(t, base.Teardown, req.Method) }() - c := Client{ - TLSConfig: &tls.Config{InsecureSkipVerify: true}, - } - u, err := base.ParseURL("rtsps://127.0.0.1:8554/stream") require.NoError(t, err) - err = c.Start(u.Scheme, u.Host) + c := Client{ + Scheme: u.Scheme, + Host: u.Host, + TLSConfig: &tls.Config{InsecureSkipVerify: true}, + } + + err = c.Start() require.NoError(t, err) defer c.Close() @@ -1030,12 +1039,12 @@ func TestClientPlayPartial(t *testing.T) { require.NoError(t, err) c := Client{ - Scheme: u.Scheme, - Host: u.Host, - Transport: ptrOf(TransportTCP), + Scheme: u.Scheme, + Host: u.Host, + Protocol: ptrOf(TransportTCP), } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -1978,7 +1987,7 @@ func TestClientPlayDifferentInterleavedIDs(t *testing.T) { packetRecv := make(chan struct{}) c := Client{ - Transport: ptrOf(TransportTCP), + Protocol: ptrOf(TransportTCP), } err = readAll(&c, "rtsp://localhost:8554/teststream", @@ -2412,7 +2421,7 @@ func TestClientPlayPausePlay(t *testing.T) { packetRecv := make(chan struct{}) c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if transport == "udp" { v := TransportUDP return &v @@ -2731,7 +2740,7 @@ func TestClientPlayErrorTimeout(t *testing.T) { }() c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { switch transport { case "udp": v := TransportUDP @@ -2867,7 +2876,7 @@ func TestClientPlayIgnoreTCPInvalidMedia(t *testing.T) { recv := make(chan struct{}) c := Client{ - Transport: ptrOf(TransportTCP), + Protocol: ptrOf(TransportTCP), } err = readAll(&c, "rtsp://localhost:8554/teststream", @@ -3020,7 +3029,7 @@ func TestClientPlayKeepAlive(t *testing.T) { v := TransportTCP c := Client{ - Transport: &v, + Protocol: &v, OnResponse: func(_ *base.Response) { m++ if ca != "no response" { @@ -3118,7 +3127,7 @@ func TestClientPlayDifferentSource(t *testing.T) { Protocol: headers.TransportProtocolUDP, ClientPorts: inTH.ClientPorts, ServerPorts: &[2]int{34556, 34557}, - Source: ptrOf(net.ParseIP("127.0.1.1")), + Source2: ptrOf("127.0.1.1"), } l1, err2 := net.ListenPacket("udp", "127.0.1.1:34556") @@ -3165,7 +3174,7 @@ func TestClientPlayDifferentSource(t *testing.T) { }() c := Client{ - Transport: ptrOf(TransportUDP), + Protocol: ptrOf(TransportUDP), } err = readAll(&c, "rtsp://localhost:8554/test/stream?param=value", @@ -3409,7 +3418,7 @@ func TestClientPlayDecodeErrors(t *testing.T) { }() c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if ca.proto == "udp" { v := TransportUDP return &v @@ -3893,7 +3902,7 @@ func TestClientPlayBackChannel(t *testing.T) { Scheme: u.Scheme, Host: u.Host, RequestBackChannels: true, - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if transport == "tcp" { return ptrOf(TransportTCP) } @@ -3903,7 +3912,7 @@ func TestClientPlayBackChannel(t *testing.T) { receiverReportPeriod: 750 * time.Millisecond, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -3962,7 +3971,7 @@ func TestClientPlaySetupErrorBackChannel(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() diff --git a/client_reader.go b/client_reader.go index a275d304..be2c9bf9 100644 --- a/client_reader.go +++ b/client_reader.go @@ -3,8 +3,8 @@ package gortsplib import ( "sync" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) type clientReader struct { diff --git a/client_record_test.go b/client_record_test.go index 6da2cec5..549f18ab 100644 --- a/client_record_test.go +++ b/client_record_test.go @@ -16,14 +16,14 @@ import ( "github.com/pion/rtp" "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) var testH264Media = &description.Media{ @@ -80,7 +80,7 @@ func record(c *Client, ur string, medias []*description.Media, cb func(*descript c.Scheme = u.Scheme c.Host = u.Host - err = c.Start2() + err = c.Start() if err != nil { return err } @@ -417,7 +417,7 @@ func TestClientRecord(t *testing.T) { TLSConfig: &tls.Config{ InsecureSkipVerify: true, }, - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if ca.transport == "udp" { v := TransportUDP return &v @@ -587,7 +587,7 @@ func TestClientRecordSocketError(t *testing.T) { TLSConfig: &tls.Config{ InsecureSkipVerify: true, }, - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if transport == "udp" { v := TransportUDP return &v @@ -731,7 +731,7 @@ func TestClientRecordPauseRecordSerial(t *testing.T) { }() c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if transport == "udp" { v := TransportUDP return &v @@ -890,7 +890,7 @@ func TestClientRecordPauseRecordParallel(t *testing.T) { }() c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if transport == "udp" { v := TransportUDP return &v @@ -1215,7 +1215,7 @@ func TestClientRecordDecodeErrors(t *testing.T) { }() c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if ca.proto == "udp" { v := TransportUDP return &v @@ -1389,7 +1389,7 @@ func TestClientRecordRTCPReport(t *testing.T) { var curTimeMutex sync.Mutex c := Client{ - Transport: func() *TransportProtocol { + Protocol: func() *Protocol { if ca == "udp" { v := TransportUDP return &v @@ -1536,7 +1536,7 @@ func TestClientRecordIgnoreTCPRTPPackets(t *testing.T) { rtcpReceived := make(chan struct{}) c := Client{ - Transport: ptrOf(TransportTCP), + Protocol: ptrOf(TransportTCP), } medias := []*description.Media{testH264Media} diff --git a/client_test.go b/client_test.go index 0e11abe8..308f6a34 100644 --- a/client_test.go +++ b/client_test.go @@ -12,11 +12,11 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/internal/base64streamreader" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" + "github.com/bluenviron/gortsplib/v5/internal/base64streamreader" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" ) func mustParseURL(s string) *base.URL { @@ -65,7 +65,7 @@ func TestClientClose(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) c.Close() @@ -127,7 +127,7 @@ func TestClientCloseDuringRequest(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) optionsDone := make(chan struct{}) @@ -200,7 +200,7 @@ func TestClientSession(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -280,7 +280,7 @@ func TestClientAuth(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -359,7 +359,7 @@ func TestClientCSeq(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -425,7 +425,7 @@ func TestClientDescribeCharset(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -515,7 +515,7 @@ func TestClientReplyToServerRequest(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -583,7 +583,7 @@ func TestClientRelativeContentBase(t *testing.T) { Host: u.Host, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() @@ -764,7 +764,7 @@ func TestClientHTTPTunnel(t *testing.T) { }, } - err = c.Start2() + err = c.Start() require.NoError(t, err) defer c.Close() diff --git a/client_udp_listener.go b/client_udp_listener.go index eb78dcb0..1860fcf9 100644 --- a/client_udp_listener.go +++ b/client_udp_listener.go @@ -9,8 +9,8 @@ import ( "syscall" "time" - "github.com/bluenviron/gortsplib/v4/pkg/multicast" - "github.com/bluenviron/gortsplib/v4/pkg/readbuffer" + "github.com/bluenviron/gortsplib/v5/pkg/multicast" + "github.com/bluenviron/gortsplib/v5/pkg/readbuffer" ) func ptrOf[T any](v T) *T { diff --git a/conn_stats.go b/conn_stats.go index 073f6b3d..c6c728b5 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -1,10 +1,5 @@ package gortsplib -// StatsConn are connection statistics. -// -// Deprecated: renamed into ConnStats. -type StatsConn = ConnStats - // ConnStats are connection statistics. type ConnStats struct { // received bytes diff --git a/conn_transport.go b/conn_transport.go index 1735c74c..1129ab96 100644 --- a/conn_transport.go +++ b/conn_transport.go @@ -1,5 +1,14 @@ package gortsplib +// Tunnel is a tunneling method. +type Tunnel int + +// tunneling methods. +const ( + TunnelNone Tunnel = iota + TunnelHTTP +) + // ConnTransport contains details about the transport of a connection. type ConnTransport struct { Tunnel Tunnel diff --git a/examples/client-play-backchannel/main.go b/examples/client-play-backchannel/main.go index 6443dfd5..66178ae2 100644 --- a/examples/client-play-backchannel/main.go +++ b/examples/client-play-backchannel/main.go @@ -6,10 +6,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/g711" "github.com/pion/rtp" ) @@ -61,7 +61,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-format-av1-to-jpeg/main.go b/examples/client-play-format-av1-to-jpeg/main.go index 9b7c1a12..792d1d23 100644 --- a/examples/client-play-format-av1-to-jpeg/main.go +++ b/examples/client-play-format-av1-to-jpeg/main.go @@ -11,10 +11,10 @@ import ( "strconv" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpav1" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpav1" "github.com/bluenviron/mediacommon/v2/pkg/codecs/av1" "github.com/pion/rtp" ) @@ -58,7 +58,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-format-av1/main.go b/examples/client-play-format-av1/main.go index 422bd7e7..e91a0911 100644 --- a/examples/client-play-format-av1/main.go +++ b/examples/client-play-format-av1/main.go @@ -6,10 +6,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpav1" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpav1" "github.com/bluenviron/mediacommon/v2/pkg/codecs/av1" "github.com/pion/rtp" ) @@ -35,7 +35,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -79,7 +79,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-g711/main.go b/examples/client-play-format-g711/main.go index 5bc01d42..ec0c1992 100644 --- a/examples/client-play-format-g711/main.go +++ b/examples/client-play-format-g711/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/g711" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -63,7 +63,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-h264-mpeg4audio-to-disk/main.go b/examples/client-play-format-h264-mpeg4audio-to-disk/main.go index d24a5e3d..a7f2bbce 100644 --- a/examples/client-play-format-h264-mpeg4audio-to-disk/main.go +++ b/examples/client-play-format-h264-mpeg4audio-to-disk/main.go @@ -5,10 +5,10 @@ import ( "errors" "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" "github.com/pion/rtp" ) @@ -30,7 +30,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -89,7 +89,7 @@ func main() { // called when a H264/RTP packet arrives c.OnPacketRTP(h264Media, h264Format, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(h264Media, pkt) + pts, ok := c.PacketPTS(h264Media, pkt) if !ok { log.Printf("waiting for timestamp") return @@ -117,7 +117,7 @@ func main() { // called when a MPEG-4 audio / RTP packet arrives c.OnPacketRTP(mpeg4AudioMedia, mpeg4AudioFormat, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(mpeg4AudioMedia, pkt) + pts, ok := c.PacketPTS(mpeg4AudioMedia, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-h264-mpeg4audio-to-disk/mpegts_muxer.go b/examples/client-play-format-h264-mpeg4audio-to-disk/mpegts_muxer.go index d385c97e..47ca9329 100644 --- a/examples/client-play-format-h264-mpeg4audio-to-disk/mpegts_muxer.go +++ b/examples/client-play-format-h264-mpeg4audio-to-disk/mpegts_muxer.go @@ -5,7 +5,7 @@ import ( "os" "sync" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" ) diff --git a/examples/client-play-format-h264-to-disk/main.go b/examples/client-play-format-h264-to-disk/main.go index 500f0af4..22f0d805 100644 --- a/examples/client-play-format-h264-to-disk/main.go +++ b/examples/client-play-format-h264-to-disk/main.go @@ -5,10 +5,10 @@ import ( "errors" "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" "github.com/pion/rtp" ) @@ -30,7 +30,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -76,7 +76,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-h264-to-jpeg/main.go b/examples/client-play-format-h264-to-jpeg/main.go index 57b93243..d8962557 100644 --- a/examples/client-play-format-h264-to-jpeg/main.go +++ b/examples/client-play-format-h264-to-jpeg/main.go @@ -11,10 +11,10 @@ import ( "strconv" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264" "github.com/pion/rtp" ) @@ -58,7 +58,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-format-h264/main.go b/examples/client-play-format-h264/main.go index 066cb272..37554cca 100644 --- a/examples/client-play-format-h264/main.go +++ b/examples/client-play-format-h264/main.go @@ -6,10 +6,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264" "github.com/pion/rtp" ) @@ -35,7 +35,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -87,7 +87,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-h265-to-disk/main.go b/examples/client-play-format-h265-to-disk/main.go index f85ce094..9954fd3b 100644 --- a/examples/client-play-format-h265-to-disk/main.go +++ b/examples/client-play-format-h265-to-disk/main.go @@ -5,10 +5,10 @@ import ( "errors" "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph265" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph265" "github.com/pion/rtp" ) @@ -30,7 +30,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -77,7 +77,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-h265-to-jpeg/main.go b/examples/client-play-format-h265-to-jpeg/main.go index f94d24d2..97fb8c10 100644 --- a/examples/client-play-format-h265-to-jpeg/main.go +++ b/examples/client-play-format-h265-to-jpeg/main.go @@ -11,10 +11,10 @@ import ( "strconv" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph265" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph265" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265" "github.com/pion/rtp" ) @@ -58,7 +58,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-format-h265/main.go b/examples/client-play-format-h265/main.go index 9396a2bc..4a7bb1e8 100644 --- a/examples/client-play-format-h265/main.go +++ b/examples/client-play-format-h265/main.go @@ -6,10 +6,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph265" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph265" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265" "github.com/pion/rtp" ) @@ -35,7 +35,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -90,7 +90,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-lpcm/main.go b/examples/client-play-format-lpcm/main.go index 04481057..1f3534b2 100644 --- a/examples/client-play-format-lpcm/main.go +++ b/examples/client-play-format-lpcm/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -28,7 +28,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -62,7 +62,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-mjpeg/main.go b/examples/client-play-format-mjpeg/main.go index 19bc5437..ef97008d 100644 --- a/examples/client-play-format-mjpeg/main.go +++ b/examples/client-play-format-mjpeg/main.go @@ -7,10 +7,10 @@ import ( "image/jpeg" "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpmjpeg" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpmjpeg" "github.com/pion/rtp" ) @@ -33,7 +33,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -67,7 +67,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-mpeg4audio-to-disk/main.go b/examples/client-play-format-mpeg4audio-to-disk/main.go index d0e4d816..4ff7f2ab 100644 --- a/examples/client-play-format-mpeg4audio-to-disk/main.go +++ b/examples/client-play-format-mpeg4audio-to-disk/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -79,7 +79,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-mpeg4audio-to-disk/mpegts_muxer.go b/examples/client-play-format-mpeg4audio-to-disk/mpegts_muxer.go index f122a239..1643e3cf 100644 --- a/examples/client-play-format-mpeg4audio-to-disk/mpegts_muxer.go +++ b/examples/client-play-format-mpeg4audio-to-disk/mpegts_muxer.go @@ -4,7 +4,7 @@ import ( "bufio" "os" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" ) diff --git a/examples/client-play-format-mpeg4audio/main.go b/examples/client-play-format-mpeg4audio/main.go index 8dd54bc9..83122d12 100644 --- a/examples/client-play-format-mpeg4audio/main.go +++ b/examples/client-play-format-mpeg4audio/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -28,7 +28,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -62,7 +62,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-opus-to-disk/main.go b/examples/client-play-format-opus-to-disk/main.go index 840c04c9..a03e33ae 100644 --- a/examples/client-play-format-opus-to-disk/main.go +++ b/examples/client-play-format-opus-to-disk/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -79,7 +79,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-opus-to-disk/mpegts_muxer.go b/examples/client-play-format-opus-to-disk/mpegts_muxer.go index cc3b1b1d..b1a19ec5 100644 --- a/examples/client-play-format-opus-to-disk/mpegts_muxer.go +++ b/examples/client-play-format-opus-to-disk/mpegts_muxer.go @@ -4,7 +4,7 @@ import ( "bufio" "os" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" ) diff --git a/examples/client-play-format-opus/main.go b/examples/client-play-format-opus/main.go index 92e977ca..ef862137 100644 --- a/examples/client-play-format-opus/main.go +++ b/examples/client-play-format-opus/main.go @@ -4,9 +4,9 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -28,7 +28,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -62,7 +62,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-vp8/main.go b/examples/client-play-format-vp8/main.go index 3a5abdb1..978f1927 100644 --- a/examples/client-play-format-vp8/main.go +++ b/examples/client-play-format-vp8/main.go @@ -6,10 +6,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp8" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpvp8" "github.com/pion/rtp" ) @@ -34,7 +34,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -76,7 +76,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-format-vp9/main.go b/examples/client-play-format-vp9/main.go index aa786325..9740e3a8 100644 --- a/examples/client-play-format-vp9/main.go +++ b/examples/client-play-format-vp9/main.go @@ -6,10 +6,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp9" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpvp9" "github.com/pion/rtp" ) @@ -34,7 +34,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -76,7 +76,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := c.PacketPTS2(medi, pkt) + pts, ok := c.PacketPTS(medi, pkt) if !ok { log.Printf("waiting for timestamp") return diff --git a/examples/client-play-options/main.go b/examples/client-play-options/main.go index 50379502..6bb264c2 100644 --- a/examples/client-play-options/main.go +++ b/examples/client-play-options/main.go @@ -5,10 +5,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtcp" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { Scheme: u.Scheme, Host: u.Host, // transport protocol (UDP, Multicast or TCP). If nil, it is chosen automatically - Transport: nil, + Protocol: nil, // timeout of read operations ReadTimeout: 10 * time.Second, // timeout of write operations @@ -37,7 +37,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-pause/main.go b/examples/client-play-pause/main.go index 2e20eb95..a83da43e 100644 --- a/examples/client-play-pause/main.go +++ b/examples/client-play-pause/main.go @@ -5,10 +5,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtcp" "github.com/pion/rtp" ) @@ -32,7 +32,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-play-timestamp/main.go b/examples/client-play-timestamp/main.go index 1596853e..73fa1b42 100644 --- a/examples/client-play-timestamp/main.go +++ b/examples/client-play-timestamp/main.go @@ -4,10 +4,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } @@ -50,7 +50,7 @@ func main() { // called when a RTP packet arrives c.OnPacketRTPAny(func(medi *description.Media, _ format.Format, pkt *rtp.Packet) { // get the PTS (presentation timestamp) of the packet - pts, ptsAvailable := c.PacketPTS2(medi, pkt) + pts, ptsAvailable := c.PacketPTS(medi, pkt) log.Printf("PTS: available=%v, value=%v\n", ptsAvailable, pts) // get the NTP (absolute timestamp) of the packet diff --git a/examples/client-play-to-record/main.go b/examples/client-play-to-record/main.go index 3f61f267..511e4229 100644 --- a/examples/client-play-to-record/main.go +++ b/examples/client-play-to-record/main.go @@ -4,10 +4,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = reader.Start2() + err = reader.Start() if err != nil { panic(err) } diff --git a/examples/client-play/main.go b/examples/client-play/main.go index 1b0fea75..a9cac266 100644 --- a/examples/client-play/main.go +++ b/examples/client-play/main.go @@ -4,10 +4,10 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtcp" "github.com/pion/rtp" ) @@ -29,7 +29,7 @@ func main() { } // connect to the server - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-query/main.go b/examples/client-query/main.go index 0ea401eb..a8ed082a 100644 --- a/examples/client-query/main.go +++ b/examples/client-query/main.go @@ -4,8 +4,8 @@ package main import ( "log" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // This example shows how to: @@ -23,7 +23,7 @@ func main() { Host: u.Host, } - err = c.Start2() + err = c.Start() if err != nil { panic(err) } diff --git a/examples/client-record-format-av1/main.go b/examples/client-record-format-av1/main.go index 7d274ffb..05914e05 100644 --- a/examples/client-record-format-av1/main.go +++ b/examples/client-record-format-av1/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/client-record-format-g711/main.go b/examples/client-record-format-g711/main.go index 175dce57..9ee90c03 100644 --- a/examples/client-record-format-g711/main.go +++ b/examples/client-record-format-g711/main.go @@ -6,9 +6,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/g711" "github.com/pion/rtp" ) diff --git a/examples/client-record-format-h264-from-disk/main.go b/examples/client-record-format-h264-from-disk/main.go index cc3af984..b28810c5 100644 --- a/examples/client-record-format-h264-from-disk/main.go +++ b/examples/client-record-format-h264-from-disk/main.go @@ -10,9 +10,9 @@ import ( "os" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" "github.com/pion/rtp" ) diff --git a/examples/client-record-format-h264/main.go b/examples/client-record-format-h264/main.go index aa4d99f1..ed1c72bb 100644 --- a/examples/client-record-format-h264/main.go +++ b/examples/client-record-format-h264/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/client-record-format-h265/main.go b/examples/client-record-format-h265/main.go index a03dd483..bc71a04e 100644 --- a/examples/client-record-format-h265/main.go +++ b/examples/client-record-format-h265/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/client-record-format-lpcm/main.go b/examples/client-record-format-lpcm/main.go index 0b9f114f..d3149456 100644 --- a/examples/client-record-format-lpcm/main.go +++ b/examples/client-record-format-lpcm/main.go @@ -6,9 +6,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) diff --git a/examples/client-record-format-mjpeg/main.go b/examples/client-record-format-mjpeg/main.go index 193c33d5..7fa00388 100644 --- a/examples/client-record-format-mjpeg/main.go +++ b/examples/client-record-format-mjpeg/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) diff --git a/examples/client-record-format-mpeg4audio/main.go b/examples/client-record-format-mpeg4audio/main.go index 79b6d5b6..f8b8a6cd 100644 --- a/examples/client-record-format-mpeg4audio/main.go +++ b/examples/client-record-format-mpeg4audio/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" ) diff --git a/examples/client-record-format-mpeg4audio/mp4a_encoder.go b/examples/client-record-format-mpeg4audio/mp4a_encoder.go index 3d59ccea..025610dc 100644 --- a/examples/client-record-format-mpeg4audio/mp4a_encoder.go +++ b/examples/client-record-format-mpeg4audio/mp4a_encoder.go @@ -20,7 +20,7 @@ func frameLineSize(frame *C.AVFrame) *C.int { return (*C.int)(unsafe.Pointer(&frame.linesize[0])) } -func bigEndianS16ToFloat32(samples []byte) ([]byte, error) { +func bigEndianS16ToFloat3(samples []byte) ([]byte, error) { sampleCount := len(samples) / 2 outSize := len(samples) * 2 outSamples := make([]byte, outSize) @@ -112,7 +112,7 @@ func (d *mp4aEncoder) close() { // encode encodes LPCM samples into Opus packets. func (d *mp4aEncoder) encode(samples []byte) ([][]byte, int64, error) { // convert from big-endian signed 16-bit integer to float32 - samples, err := bigEndianS16ToFloat32(samples) + samples, err := bigEndianS16ToFloat3(samples) if err != nil { return nil, 0, err } diff --git a/examples/client-record-format-opus/main.go b/examples/client-record-format-opus/main.go index 49377140..a031668a 100644 --- a/examples/client-record-format-opus/main.go +++ b/examples/client-record-format-opus/main.go @@ -8,10 +8,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpsimpleaudio" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpsimpleaudio" "github.com/bluenviron/mediacommon/v2/pkg/codecs/opus" "github.com/pion/rtp" ) @@ -54,7 +54,7 @@ func encodeMultiple(rtpEnc *rtpsimpleaudio.Encoder, opusPkts [][]byte) ([]*rtp.P ret[i].Timestamp += pts - pts += uint32(opus.PacketDuration2(opusPkt)) + pts += uint32(opus.PacketDuration(opusPkt)) } return ret, nil } diff --git a/examples/client-record-format-vp8/main.go b/examples/client-record-format-vp8/main.go index 95de1e06..99ba9b95 100644 --- a/examples/client-record-format-vp8/main.go +++ b/examples/client-record-format-vp8/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/client-record-format-vp9/main.go b/examples/client-record-format-vp9/main.go index 436313fe..6952dd7f 100644 --- a/examples/client-record-format-vp9/main.go +++ b/examples/client-record-format-vp9/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/client-record-options/main.go b/examples/client-record-options/main.go index f28eb918..142b473f 100644 --- a/examples/client-record-options/main.go +++ b/examples/client-record-options/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: @@ -55,7 +55,7 @@ func main() { // Client allows to set additional client options c := &gortsplib.Client{ // transport protocol (UDP or TCP). If nil, it is chosen automatically - Transport: nil, + Protocol: nil, // timeout of read operations ReadTimeout: 10 * time.Second, // timeout of write operations diff --git a/examples/client-record-pause/main.go b/examples/client-record-pause/main.go index 1b271453..0f1ad51c 100644 --- a/examples/client-record-pause/main.go +++ b/examples/client-record-pause/main.go @@ -8,9 +8,9 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/proxy-backchannel/client.go b/examples/proxy-backchannel/client.go index ac944232..a746be64 100644 --- a/examples/proxy-backchannel/client.go +++ b/examples/proxy-backchannel/client.go @@ -4,10 +4,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -61,7 +61,7 @@ func (c *client) read() error { } // connect to the server - err = rc.Start2() + err = rc.Start() if err != nil { return err } diff --git a/examples/proxy-backchannel/server.go b/examples/proxy-backchannel/server.go index 9bae5d52..d5c108b6 100644 --- a/examples/proxy-backchannel/server.go +++ b/examples/proxy-backchannel/server.go @@ -4,10 +4,10 @@ import ( "log" "sync" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) diff --git a/examples/proxy/client.go b/examples/proxy/client.go index eaf56110..2f678293 100644 --- a/examples/proxy/client.go +++ b/examples/proxy/client.go @@ -4,10 +4,10 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -47,7 +47,7 @@ func (c *client) read() error { } // connect to the server - err = rc.Start2() + err = rc.Start() if err != nil { return err } diff --git a/examples/proxy/server.go b/examples/proxy/server.go index e544afc2..ca1cd6fb 100644 --- a/examples/proxy/server.go +++ b/examples/proxy/server.go @@ -4,9 +4,9 @@ import ( "log" "sync" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" ) type server struct { diff --git a/examples/server-auth/main.go b/examples/server-auth/main.go index b004790b..7b87c8e3 100644 --- a/examples/server-auth/main.go +++ b/examples/server-auth/main.go @@ -7,11 +7,11 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) // This example shows how to: diff --git a/examples/server-play-backchannel/audio_streamer.go b/examples/server-play-backchannel/audio_streamer.go index b7ba5220..4352761f 100644 --- a/examples/server-play-backchannel/audio_streamer.go +++ b/examples/server-play-backchannel/audio_streamer.go @@ -5,8 +5,8 @@ import ( "log" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/g711" "github.com/pion/rtp" ) diff --git a/examples/server-play-backchannel/main.go b/examples/server-play-backchannel/main.go index 885159b0..a0774612 100644 --- a/examples/server-play-backchannel/main.go +++ b/examples/server-play-backchannel/main.go @@ -5,10 +5,10 @@ import ( "log" "sync" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) @@ -78,7 +78,7 @@ func (sh *serverHandler) OnPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Re // called when receiving a RTP packet ctx.Session.OnPacketRTPAny(func(m *description.Media, _ format.Format, pkt *rtp.Packet) { // decode timestamp - pts, ok := ctx.Session.PacketPTS2(m, pkt) + pts, ok := ctx.Session.PacketPTS(m, pkt) if !ok { return } diff --git a/examples/server-play-format-h264-from-disk/file_streamer.go b/examples/server-play-format-h264-from-disk/file_streamer.go index 5329cfe2..8b1f9a1a 100644 --- a/examples/server-play-format-h264-from-disk/file_streamer.go +++ b/examples/server-play-format-h264-from-disk/file_streamer.go @@ -9,8 +9,8 @@ import ( "os" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" "github.com/pion/rtp" ) diff --git a/examples/server-play-format-h264-from-disk/main.go b/examples/server-play-format-h264-from-disk/main.go index 6101b626..3f6ea112 100644 --- a/examples/server-play-format-h264-from-disk/main.go +++ b/examples/server-play-format-h264-from-disk/main.go @@ -5,10 +5,10 @@ import ( "log" "sync" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/server-record-format-h264-to-disk/main.go b/examples/server-record-format-h264-to-disk/main.go index 17f1d5fd..939c7217 100644 --- a/examples/server-record-format-h264-to-disk/main.go +++ b/examples/server-record-format-h264-to-disk/main.go @@ -8,11 +8,11 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" ) // This example shows how to: @@ -132,7 +132,7 @@ func (sh *serverHandler) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*bas // called when receiving a RTP packet ctx.Session.OnPacketRTP(sh.media, sh.format, func(pkt *rtp.Packet) { // decode timestamp - pts, ok := ctx.Session.PacketPTS2(sh.media, pkt) + pts, ok := ctx.Session.PacketPTS(sh.media, pkt) if !ok { return } diff --git a/examples/server-secure/main.go b/examples/server-secure/main.go index 1f2b0201..b79adff1 100644 --- a/examples/server-secure/main.go +++ b/examples/server-secure/main.go @@ -8,10 +8,10 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/examples/server/main.go b/examples/server/main.go index 1f138410..5ede0346 100644 --- a/examples/server/main.go +++ b/examples/server/main.go @@ -7,10 +7,10 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // This example shows how to: diff --git a/go.mod b/go.mod index be891bd1..35c3b10b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/bluenviron/gortsplib/v4 +module github.com/bluenviron/gortsplib/v5 go 1.24.0 diff --git a/internal/asyncprocessor/async_processor.go b/internal/asyncprocessor/async_processor.go index 9731bf10..550299ac 100644 --- a/internal/asyncprocessor/async_processor.go +++ b/internal/asyncprocessor/async_processor.go @@ -4,7 +4,7 @@ package asyncprocessor import ( "context" - "github.com/bluenviron/gortsplib/v4/pkg/ringbuffer" + "github.com/bluenviron/gortsplib/v5/pkg/ringbuffer" ) // Processor is an asynchronous queue processor diff --git a/internal/teste2e/client_vs_server_test.go b/internal/teste2e/client_vs_server_test.go index f00f2af6..9255937d 100644 --- a/internal/teste2e/client_vs_server_test.go +++ b/internal/teste2e/client_vs_server_test.go @@ -9,10 +9,10 @@ import ( "testing" "time" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" "github.com/stretchr/testify/require" ) @@ -172,7 +172,7 @@ func TestClientVsServer(t *testing.T) { publisherTunnel = gortsplib.TunnelNone } - var publisherProto gortsplib.Transport + var publisherProto gortsplib.Protocol switch ca.publisherProto { case "udp": publisherProto = gortsplib.TransportUDP @@ -183,7 +183,7 @@ func TestClientVsServer(t *testing.T) { publisher := &gortsplib.Client{ TLSConfig: &tls.Config{InsecureSkipVerify: true}, Tunnel: publisherTunnel, - Transport: &publisherProto, + Protocol: &publisherProto, } err = publisher.StartRecording(ca.publisherScheme+"://127.0.0.1:8554/test/stream?key=val", desc) require.NoError(t, err) @@ -198,7 +198,7 @@ func TestClientVsServer(t *testing.T) { readerTunnel = gortsplib.TunnelNone } - var readerProto gortsplib.Transport + var readerProto gortsplib.Protocol switch ca.readerProto { case "udp": readerProto = gortsplib.TransportUDP @@ -216,9 +216,9 @@ func TestClientVsServer(t *testing.T) { Host: u.Host, TLSConfig: &tls.Config{InsecureSkipVerify: true}, Tunnel: readerTunnel, - Transport: &readerProto, + Protocol: &readerProto, } - err = reader.Start2() + err = reader.Start() require.NoError(t, err) defer reader.Close() diff --git a/internal/teste2e/sample_server_test.go b/internal/teste2e/sample_server_test.go index 500acbea..31a698bc 100644 --- a/internal/teste2e/sample_server_test.go +++ b/internal/teste2e/sample_server_test.go @@ -7,10 +7,10 @@ import ( "fmt" "sync" - "github.com/bluenviron/gortsplib/v4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/pion/rtp" ) diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index e0d5c36b..ba826bee 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) func mustParseURL(s string) *base.URL { @@ -19,19 +19,19 @@ func mustParseURL(s string) *base.URL { func TestCombined(t *testing.T) { for _, c1 := range []struct { name string - methods []ValidateMethod + methods []VerifyMethod }{ { "basic", - []ValidateMethod{ValidateMethodBasic}, + []VerifyMethod{VerifyMethodBasic}, }, { "digest md5", - []ValidateMethod{ValidateMethodDigestMD5}, + []VerifyMethod{VerifyMethodDigestMD5}, }, { "digest sha256", - []ValidateMethod{ValidateMethodSHA256}, + []VerifyMethod{VerifyMethodDigestSHA256}, }, { "all", @@ -52,20 +52,22 @@ func TestCombined(t *testing.T) { nonce, err := GenerateNonce() require.NoError(t, err) - se, err := NewSender( - GenerateWWWAuthenticate(c1.methods, "IPCAM", nonce), - func() string { + se := &Sender{ + WWWAuth: GenerateWWWAuthenticate(c1.methods, "IPCAM", nonce), + User: func() string { if conf == "wronguser" { return "test1user" } return "testuser" }(), - func() string { + Pass: func() string { if conf == "wrongpass" { return "test1pass" } return "testpass" - }()) + }(), + } + err = se.Initialize() require.NoError(t, err) req := &base.Request{ @@ -81,7 +83,7 @@ func TestCombined(t *testing.T) { req.URL = mustParseURL("rtsp://myhost/mypath") - err = Validate(req, "testuser", "testpass", c1.methods, "IPCAM", nonce) + err = Verify(req, "testuser", "testpass", c1.methods, "IPCAM", nonce) if conf != "nofail" { require.Error(t, err) diff --git a/pkg/auth/sender.go b/pkg/auth/sender.go index 1efcf38f..2b2c04c6 100644 --- a/pkg/auth/sender.go +++ b/pkg/auth/sender.go @@ -3,23 +3,10 @@ package auth import ( "fmt" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/headers" ) -// NewSender allocates a Sender. -// -// Deprecated: replaced by Sender.Initialize(). -func NewSender(wwwAuth base.HeaderValue, user string, pass string) (*Sender, error) { - s := &Sender{ - WWWAuth: wwwAuth, - User: user, - Pass: pass, - } - err := s.Initialize() - return s, err -} - // Sender allows to send credentials. // It requires a WWW-Authenticate header (provided by the server) // and a set of credentials. diff --git a/pkg/auth/sender_test.go b/pkg/auth/sender_test.go index 8eceb22e..9c4753dd 100644 --- a/pkg/auth/sender_test.go +++ b/pkg/auth/sender_test.go @@ -3,7 +3,7 @@ package auth import ( "testing" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" "github.com/stretchr/testify/require" ) @@ -84,7 +84,12 @@ var casesSender = []struct { func TestSender(t *testing.T) { for _, ca := range casesSender { t.Run(ca.name, func(t *testing.T) { - se, err := NewSender(ca.wwwAuthenticate, "myuser", "mypass") + se := &Sender{ + WWWAuth: ca.wwwAuthenticate, + User: "myuser", + Pass: "mypass", + } + err := se.Initialize() require.NoError(t, err) req := &base.Request{ @@ -104,7 +109,12 @@ func FuzzSender(f *testing.F) { } f.Fuzz(func(_ *testing.T, a string) { - se, err := NewSender(base.HeaderValue{a}, "myuser", "mypass") + se := &Sender{ + WWWAuth: base.HeaderValue{a}, + User: "myuser", + Pass: "mypass", + } + err := se.Initialize() if err != nil { return } diff --git a/pkg/auth/validate.go b/pkg/auth/validate.go deleted file mode 100644 index 23acc701..00000000 --- a/pkg/auth/validate.go +++ /dev/null @@ -1,33 +0,0 @@ -package auth - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/base" -) - -// ValidateMethod is a validation method. -// -// Deprecated: replaced by VerifyMethod -type ValidateMethod = VerifyMethod - -// validation methods. -// -// Deprecated. -const ( - ValidateMethodBasic = VerifyMethodBasic - ValidateMethodDigestMD5 = VerifyMethodDigestMD5 - ValidateMethodSHA256 = VerifyMethodDigestSHA256 -) - -// Validate validates a request sent by a client. -// -// Deprecated: replaced by Verify. -func Validate( - req *base.Request, - user string, - pass string, - methods []ValidateMethod, - realm string, - nonce string, -) error { - return Verify(req, user, pass, methods, realm, nonce) -} diff --git a/pkg/auth/verify.go b/pkg/auth/verify.go index 0a5d3621..74029417 100644 --- a/pkg/auth/verify.go +++ b/pkg/auth/verify.go @@ -8,8 +8,8 @@ import ( "regexp" "slices" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/headers" ) var reControlAttribute = regexp.MustCompile("^(.+/)trackID=[0-9]+$") diff --git a/pkg/auth/verify_test.go b/pkg/auth/verify_test.go index 0a243389..0326b604 100644 --- a/pkg/auth/verify_test.go +++ b/pkg/auth/verify_test.go @@ -3,7 +3,7 @@ package auth import ( "testing" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" "github.com/stretchr/testify/require" ) diff --git a/pkg/auth/www_authenticate.go b/pkg/auth/www_authenticate.go index 076f3d78..851c3f20 100644 --- a/pkg/auth/www_authenticate.go +++ b/pkg/auth/www_authenticate.go @@ -1,12 +1,12 @@ package auth import ( - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/headers" ) // GenerateWWWAuthenticate generates a WWW-Authenticate header. -func GenerateWWWAuthenticate(methods []ValidateMethod, realm string, nonce string) base.HeaderValue { +func GenerateWWWAuthenticate(methods []VerifyMethod, realm string, nonce string) base.HeaderValue { if methods == nil { // disable VerifyMethodDigestSHA256 unless explicitly set // since it prevents FFmpeg from authenticating @@ -19,13 +19,13 @@ func GenerateWWWAuthenticate(methods []ValidateMethod, realm string, nonce strin var a base.HeaderValue switch m { - case ValidateMethodBasic: + case VerifyMethodBasic: a = headers.Authenticate{ Method: headers.AuthMethodBasic, Realm: realm, }.Marshal() - case ValidateMethodDigestMD5: + case VerifyMethodDigestMD5: aa := headers.AuthAlgorithmMD5 a = headers.Authenticate{ Method: headers.AuthMethodDigest, diff --git a/pkg/base/path.go b/pkg/base/path.go deleted file mode 100644 index 537adc2c..00000000 --- a/pkg/base/path.go +++ /dev/null @@ -1,17 +0,0 @@ -package base - -import ( - "strings" -) - -// PathSplitQuery splits a path from a query. -// -// Deprecated: not useful anymore. -func PathSplitQuery(pathAndQuery string) (string, string) { - i := strings.Index(pathAndQuery, "?") - if i >= 0 { - return pathAndQuery[:i], pathAndQuery[i+1:] - } - - return pathAndQuery, "" -} diff --git a/pkg/base/path_test.go b/pkg/base/path_test.go deleted file mode 100644 index c110d412..00000000 --- a/pkg/base/path_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package base - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestPathSplitQuery(t *testing.T) { - for _, ca := range []struct { - a string - b string - c string - }{ - { - "test?a=b", - "test", - "a=b", - }, - { - "test", - "test", - "", - }, - } { - b, c := PathSplitQuery(ca.a) - require.Equal(t, ca.b, b) - require.Equal(t, ca.c, c) - } -} diff --git a/pkg/base/url.go b/pkg/base/url.go index 5f915453..4ee6f71d 100644 --- a/pkg/base/url.go +++ b/pkg/base/url.go @@ -74,23 +74,6 @@ func (u *URL) CloneWithoutCredentials() *URL { }) } -// RTSPPathAndQuery returns the path and query of a RTSP URL. -// -// Deprecated: not useful anymore. -func (u *URL) RTSPPathAndQuery() (string, bool) { - var pathAndQuery string - if u.RawPath != "" { - pathAndQuery = u.RawPath - } else { - pathAndQuery = u.Path - } - if u.RawQuery != "" { - pathAndQuery += "?" + u.RawQuery - } - - return pathAndQuery, true -} - // Hostname returns u.Host, stripping any valid port number if present. // // If the result is enclosed in square brackets, as literal IPv6 addresses are, diff --git a/pkg/base/url_test.go b/pkg/base/url_test.go index 84878649..822ac9eb 100644 --- a/pkg/base/url_test.go +++ b/pkg/base/url_test.go @@ -110,56 +110,3 @@ func TestURLCloneWithoutCredentials(t *testing.T) { Path: "/test/stream", }, u2) } - -func TestURLRTSPPathAndQuery(t *testing.T) { - for _, ca := range []struct { - name string - u *URL - b string - }{ - { - "standard", - mustParseURL("rtsp://localhost:8554/teststream/trackID=1"), - "/teststream/trackID=1", - }, - { - "subpath", - mustParseURL("rtsp://localhost:8554/test/stream/trackID=1"), - "/test/stream/trackID=1", - }, - { - "path and query", - mustParseURL("rtsp://192.168.1.99:554/test?user=tmp&password=BagRep1&channel=1&stream=0.sdp/trackID=1"), - "/test?user=tmp&password=BagRep1&channel=1&stream=0.sdp/trackID=1", - }, - { - "path and query with special chars", - mustParseURL("rtsp://192.168.1.99:554/te!st?user=tmp&password=BagRep1!&channel=1&stream=0.sdp/trackID=1"), - "/te!st?user=tmp&password=BagRep1!&channel=1&stream=0.sdp/trackID=1", - }, - { - "path and query attached", - mustParseURL("rtsp://192.168.1.99:554/user=tmp&password=BagRep1!&channel=1&stream=0.sdp/trackID=1"), - "/user=tmp&password=BagRep1!&channel=1&stream=0.sdp/trackID=1", - }, - { - "no path", - mustParseURL("rtsp://192.168.1.99:554"), - "", - }, - { - "single slash", - mustParseURL("rtsp://192.168.1.99:554/"), - "/", - }, - { - "no slash and query", - mustParseURL("rtsp://192.168.1.99:554?testing"), - "?testing", - }, - } { - b, ok := ca.u.RTSPPathAndQuery() - require.Equal(t, true, ok) - require.Equal(t, ca.b, b) - } -} diff --git a/pkg/conn/conn.go b/pkg/conn/conn.go index 235338ff..d42d4885 100644 --- a/pkg/conn/conn.go +++ b/pkg/conn/conn.go @@ -5,7 +5,7 @@ import ( "bufio" "io" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // Conn is a RTSP connection. diff --git a/pkg/conn/conn_test.go b/pkg/conn/conn_test.go index cc4efa22..e287a64e 100644 --- a/pkg/conn/conn_test.go +++ b/pkg/conn/conn_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) func mustParseURL(s string) *base.URL { diff --git a/pkg/description/media.go b/pkg/description/media.go index f2292812..78fe1eae 100644 --- a/pkg/description/media.go +++ b/pkg/description/media.go @@ -13,10 +13,10 @@ import ( psdp "github.com/pion/sdp/v3" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" ) func getAttribute(attributes []psdp.Attribute, key string) string { @@ -79,11 +79,6 @@ type Media struct { // Whether this media is a back channel. IsBackChannel bool - // Whether the transport is secure. - // - // Deprecated: replaced by Profile - Secure bool - // RTP Profile. Profile headers.TransportProfile @@ -109,10 +104,8 @@ func (m *Media) Unmarshal(md *psdp.MediaDescription) error { m.IsBackChannel = isBackChannel(md.Attributes) if slices.Contains(md.MediaName.Protos, "SAVP") { - m.Secure = true m.Profile = headers.TransportProfileSAVP } else { - m.Secure = false m.Profile = headers.TransportProfileAVP } @@ -154,22 +147,7 @@ func (m *Media) Unmarshal(md *psdp.MediaDescription) error { } // Marshal encodes the media in SDP format. -// -// Deprecated: replaced by Marshal2. -func (m Media) Marshal() *psdp.MediaDescription { - ret, err := m.Marshal2() - if err != nil { - panic(err) - } - return ret -} - -// Marshal2 encodes the media in SDP format. -func (m Media) Marshal2() (*psdp.MediaDescription, error) { - if m.Secure { - m.Profile = headers.TransportProfileSAVP - } - +func (m Media) Marshal() (*psdp.MediaDescription, error) { var protos []string if m.Profile == headers.TransportProfileSAVP { diff --git a/pkg/description/media_test.go b/pkg/description/media_test.go index 8f3915d7..9d1ce952 100644 --- a/pkg/description/media_test.go +++ b/pkg/description/media_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) func mustParseURL(s string) *base.URL { diff --git a/pkg/description/session.go b/pkg/description/session.go index cc022bc1..b0d62ef8 100644 --- a/pkg/description/session.go +++ b/pkg/description/session.go @@ -7,9 +7,9 @@ import ( psdp "github.com/pion/sdp/v3" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) func atLeastOneHasMID(medias []*Media) bool { @@ -141,8 +141,7 @@ func (d *Session) Unmarshal(ssd *sdp.SessionDescription) error { } // Marshal encodes the description in SDP format. -// The argument is deprecated and has no effect. Set Session.Multicast to enable multicast. -func (d Session) Marshal(_ bool) ([]byte, error) { +func (d Session) Marshal() ([]byte, error) { var sessionName psdp.SessionName if d.Title != "" { sessionName = psdp.SessionName(d.Title) @@ -200,7 +199,7 @@ func (d Session) Marshal(_ bool) ([]byte, error) { sout.MediaDescriptions = make([]*psdp.MediaDescription, len(d.Medias)) for i, media := range d.Medias { - med, err := media.Marshal2() + med, err := media.Marshal() if err != nil { return nil, err } diff --git a/pkg/description/session_test.go b/pkg/description/session_test.go index d5e5875f..0d1a5e5c 100644 --- a/pkg/description/session_test.go +++ b/pkg/description/session_test.go @@ -5,10 +5,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) var casesSession = []struct { @@ -313,7 +313,6 @@ var casesSession = []struct { Formats: []format.Format{ &format.Opus{ PayloadTyp: 111, - IsStereo: false, ChannelCount: 1, }, &format.Generic{ @@ -726,7 +725,6 @@ var casesSession = []struct { { Type: "video", Control: "trackID=0", - Secure: true, Profile: headers.TransportProfileSAVP, Formats: []format.Format{&format.H264{ PayloadTyp: 96, @@ -763,7 +761,6 @@ var casesSession = []struct { { Type: "video", Control: "trackID=0", - Secure: true, Profile: headers.TransportProfileSAVP, KeyMgmtMikey: &mikey.Message{ //nolint:dupl Header: mikey.Header{ @@ -850,7 +847,7 @@ func TestSessionUnmarshal(t *testing.T) { func TestSessionMarshal(t *testing.T) { for _, ca := range casesSession { t.Run(ca.name, func(t *testing.T) { - byts, err := ca.desc.Marshal(false) + byts, err := ca.desc.Marshal() require.NoError(t, err) require.Equal(t, ca.out, string(byts)) }) @@ -887,7 +884,6 @@ func TestSessionFindFormat(t *testing.T) { Formats: []format.Format{ &format.Opus{ PayloadTyp: 111, - IsStereo: true, ChannelCount: 2, }, }, @@ -975,7 +971,7 @@ func FuzzSessionUnmarshal(f *testing.F) { require.NotZero(t, len(desc.Medias)) - _, err = desc.Marshal(false) + _, err = desc.Marshal() require.NoError(t, err) }) } diff --git a/pkg/format/ac3.go b/pkg/format/ac3.go index f7d75cf6..388efaf2 100644 --- a/pkg/format/ac3.go +++ b/pkg/format/ac3.go @@ -7,7 +7,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpac3" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpac3" ) // AC3 is the RTP format for the AC-3 codec. diff --git a/pkg/format/av1.go b/pkg/format/av1.go index d1d8eac6..83f8f35d 100644 --- a/pkg/format/av1.go +++ b/pkg/format/av1.go @@ -6,7 +6,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpav1" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpav1" ) // AV1 is the RTP format for the AV1 codec. diff --git a/pkg/format/format_test.go b/pkg/format/format_test.go index 87be5e8f..8a63b85d 100644 --- a/pkg/format/format_test.go +++ b/pkg/format/format_test.go @@ -3,7 +3,7 @@ package format import ( "testing" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/stretchr/testify/require" ) @@ -638,7 +638,6 @@ var casesFormat = []struct { "a=fmtp:96 sprop-stereo=1\n", &Opus{ PayloadTyp: 96, - IsStereo: true, ChannelCount: 2, }, 96, diff --git a/pkg/format/g711.go b/pkg/format/g711.go index 2d39bd8b..520f775d 100644 --- a/pkg/format/g711.go +++ b/pkg/format/g711.go @@ -7,7 +7,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtplpcm" ) // G711 is the RTP format for the G711 codec, encoded with mu-law or A-law. diff --git a/pkg/format/g722.go b/pkg/format/g722.go index 4b8e65ab..5be25273 100644 --- a/pkg/format/g722.go +++ b/pkg/format/g722.go @@ -3,7 +3,7 @@ package format import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpsimpleaudio" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpsimpleaudio" ) // G722 is the RTP format for the G722 codec. diff --git a/pkg/format/h264.go b/pkg/format/h264.go index 5a6f7afd..a89ab00b 100644 --- a/pkg/format/h264.go +++ b/pkg/format/h264.go @@ -11,7 +11,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph264" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph264" "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264" ) diff --git a/pkg/format/h265.go b/pkg/format/h265.go index a39e1a1c..b4dc2be9 100644 --- a/pkg/format/h265.go +++ b/pkg/format/h265.go @@ -10,7 +10,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtph265" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtph265" ) // H265 is the RTP format for the H265 codec. diff --git a/pkg/format/klv.go b/pkg/format/klv.go index 8132bc90..1c68b4dd 100644 --- a/pkg/format/klv.go +++ b/pkg/format/klv.go @@ -3,7 +3,7 @@ package format import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpklv" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpklv" ) // KLV is the RTP format for KLV data. diff --git a/pkg/format/lpcm.go b/pkg/format/lpcm.go index 3d350dac..74764829 100644 --- a/pkg/format/lpcm.go +++ b/pkg/format/lpcm.go @@ -7,7 +7,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtplpcm" ) // LPCM is the RTP format for the LPCM codec. diff --git a/pkg/format/mjpeg.go b/pkg/format/mjpeg.go index 6c388ffb..d54f148b 100644 --- a/pkg/format/mjpeg.go +++ b/pkg/format/mjpeg.go @@ -3,7 +3,7 @@ package format //nolint:dupl import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpmjpeg" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpmjpeg" ) // MJPEG is the RTP format for the Motion-JPEG codec. diff --git a/pkg/format/mpeg1_audio.go b/pkg/format/mpeg1_audio.go index 9e52c859..6c548428 100644 --- a/pkg/format/mpeg1_audio.go +++ b/pkg/format/mpeg1_audio.go @@ -3,7 +3,7 @@ package format //nolint:dupl import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1audio" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpmpeg1audio" ) // MPEG1Audio is the RTP format for a MPEG-1/2 Audio codec. diff --git a/pkg/format/mpeg1_video.go b/pkg/format/mpeg1_video.go index b86073b6..39835a84 100644 --- a/pkg/format/mpeg1_video.go +++ b/pkg/format/mpeg1_video.go @@ -3,7 +3,7 @@ package format //nolint:dupl import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1video" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpmpeg1video" ) // MPEG1Video is the RTP format for a MPEG-1/2 Video codec. diff --git a/pkg/format/mpeg4_audio.go b/pkg/format/mpeg4_audio.go index 1532277d..54d14a61 100644 --- a/pkg/format/mpeg4_audio.go +++ b/pkg/format/mpeg4_audio.go @@ -9,7 +9,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg4audio" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpmpeg4audio" ) // MPEG4Audio is the RTP format for a MPEG-4 Audio codec. @@ -197,10 +197,3 @@ func (f *MPEG4Audio) CreateEncoder() (*rtpmpeg4audio.Encoder, error) { return e, nil } - -// GetConfig returns the MPEG-4 Audio configuration. -// -// Deprecated: redundant. Use f.Config. -func (f *MPEG4Audio) GetConfig() *mpeg4audio.Config { - return f.Config -} diff --git a/pkg/format/mpeg4_audio_latm.go b/pkg/format/mpeg4_audio_latm.go index d6a5c4cd..0f3b1b9c 100644 --- a/pkg/format/mpeg4_audio_latm.go +++ b/pkg/format/mpeg4_audio_latm.go @@ -8,7 +8,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpfragmented" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpfragmented" ) func allLayersHaveSameTypeRateChannelsExtType(c *mpeg4audio.StreamMuxConfig) bool { diff --git a/pkg/format/mpeg4_audio_test.go b/pkg/format/mpeg4_audio_test.go index 72dba4c0..fd1821df 100644 --- a/pkg/format/mpeg4_audio_test.go +++ b/pkg/format/mpeg4_audio_test.go @@ -24,11 +24,6 @@ func TestMPEG4AudioAttributes(t *testing.T) { require.Equal(t, "MPEG-4 Audio", format.Codec()) require.Equal(t, 48000, format.ClockRate()) require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{})) - require.Equal(t, &mpeg4audio.AudioSpecificConfig{ - Type: mpeg4audio.ObjectTypeAACLC, - SampleRate: 48000, - ChannelCount: 2, - }, format.GetConfig()) } func TestMPEG4AudioDecEncoder(t *testing.T) { diff --git a/pkg/format/mpeg4_video.go b/pkg/format/mpeg4_video.go index babb0162..1061ff60 100644 --- a/pkg/format/mpeg4_video.go +++ b/pkg/format/mpeg4_video.go @@ -10,7 +10,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4video" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpfragmented" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpfragmented" ) // MPEG4Video is the RTP format for a MPEG-4 Video codec. diff --git a/pkg/format/opus.go b/pkg/format/opus.go index b3757439..c928b6c9 100644 --- a/pkg/format/opus.go +++ b/pkg/format/opus.go @@ -7,7 +7,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpsimpleaudio" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpsimpleaudio" ) // Opus is the RTP format for the Opus codec. @@ -16,10 +16,6 @@ import ( type Opus struct { PayloadTyp uint8 ChannelCount int - - // - // Deprecated: replaced by ChannelCount. - IsStereo bool } func (f *Opus) unmarshal(ctx *unmarshalContext) error { @@ -43,13 +39,11 @@ func (f *Opus) unmarshal(ctx *unmarshalContext) error { // assume mono f.ChannelCount = 1 - f.IsStereo = false for key, val := range ctx.fmtp { if key == "sprop-stereo" { if val == "1" { f.ChannelCount = 2 - f.IsStereo = true } } } @@ -107,7 +101,7 @@ func (f *Opus) FMTP() map[string]string { if f.ChannelCount <= 2 { return map[string]string{ "sprop-stereo": func() string { - if f.ChannelCount == 2 || (f.ChannelCount == 0 && f.IsStereo) { + if f.ChannelCount == 2 { return "1" } return "0" diff --git a/pkg/format/opus_test.go b/pkg/format/opus_test.go index 21690cc1..66961205 100644 --- a/pkg/format/opus_test.go +++ b/pkg/format/opus_test.go @@ -9,8 +9,8 @@ import ( func TestOpusAttributes(t *testing.T) { format := &Opus{ - PayloadTyp: 96, - IsStereo: true, + PayloadTyp: 96, + ChannelCount: 2, } require.Equal(t, "Opus", format.Codec()) require.Equal(t, 48000, format.ClockRate()) diff --git a/pkg/format/rtpmpeg4video/decoder.go b/pkg/format/rtpmpeg4video/decoder.go deleted file mode 100644 index b1621c7a..00000000 --- a/pkg/format/rtpmpeg4video/decoder.go +++ /dev/null @@ -1,15 +0,0 @@ -package rtpmpeg4video - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpfragmented" -) - -// ErrMorePacketsNeeded is returned when more packets are needed. -// -// Deprecated: replaced by rtpfragmented.ErrMorePacketsNeeded -var ErrMorePacketsNeeded = rtpfragmented.ErrMorePacketsNeeded - -// Decoder is a RTP/MPEG-4 Video decoder. -// -// Deprecated: replaced by rtpfragmented.Decoder -type Decoder = rtpfragmented.Decoder diff --git a/pkg/format/rtpmpeg4video/decoder_test.go b/pkg/format/rtpmpeg4video/decoder_test.go deleted file mode 100644 index 54f62d0d..00000000 --- a/pkg/format/rtpmpeg4video/decoder_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package rtpmpeg4video - -import ( - "errors" - "testing" - - "github.com/pion/rtp" - "github.com/stretchr/testify/require" -) - -func TestDecode(t *testing.T) { - for _, ca := range cases { - t.Run(ca.name, func(t *testing.T) { - d := &Decoder{} - err := d.Init() - require.NoError(t, err) - - var frame []byte - - for _, pkt := range ca.pkts { - frame, err = d.Decode(pkt) - if errors.Is(err, ErrMorePacketsNeeded) { - continue - } - - require.NoError(t, err) - } - - require.Equal(t, ca.frame, frame) - }) - } -} - -func TestDecodeErrorMissingPacket(t *testing.T) { - d := &Decoder{} - err := d.Init() - require.NoError(t, err) - - _, err = d.Decode(&rtp.Packet{ - Header: rtp.Header{ - Version: 2, - Marker: false, - PayloadType: 96, - SequenceNumber: 17645, - SSRC: 0x9dbb7812, - }, - Payload: []byte{0x01, 0x02, 0x03, 0x04}, - }) - require.Equal(t, ErrMorePacketsNeeded, err) - - _, err = d.Decode(&rtp.Packet{ - Header: rtp.Header{ - Version: 2, - Marker: false, - PayloadType: 96, - SequenceNumber: 17647, - SSRC: 0x9dbb7812, - }, - Payload: []byte{0x01, 0x02, 0x03, 0x04}, - }) - require.EqualError(t, err, "discarding frame since a RTP packet is missing") -} - -func FuzzDecoder(f *testing.F) { - f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { - d := &Decoder{} - err := d.Init() - require.NoError(t, err) - - d.Decode(&rtp.Packet{ //nolint:errcheck - Header: rtp.Header{ - Version: 2, - Marker: am, - PayloadType: 96, - SequenceNumber: 17645, - Timestamp: 2289527317, - SSRC: 0x9dbb7812, - }, - Payload: a, - }) - - d.Decode(&rtp.Packet{ //nolint:errcheck - Header: rtp.Header{ - Version: 2, - Marker: bm, - PayloadType: 96, - SequenceNumber: 17646, - Timestamp: 2289527317, - SSRC: 0x9dbb7812, - }, - Payload: b, - }) - }) -} diff --git a/pkg/format/rtpmpeg4video/encoder.go b/pkg/format/rtpmpeg4video/encoder.go deleted file mode 100644 index c7e65d2b..00000000 --- a/pkg/format/rtpmpeg4video/encoder.go +++ /dev/null @@ -1,10 +0,0 @@ -package rtpmpeg4video - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpfragmented" -) - -// Encoder is a RTP/MPEG-4 Video encoder. -// -// Deprecated: replaced by rtpfragmented.Encoder -type Encoder = rtpfragmented.Encoder diff --git a/pkg/format/rtpmpeg4video/encoder_test.go b/pkg/format/rtpmpeg4video/encoder_test.go deleted file mode 100644 index ef7ecc24..00000000 --- a/pkg/format/rtpmpeg4video/encoder_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package rtpmpeg4video - -import ( - "bytes" - "testing" - - "github.com/pion/rtp" - "github.com/stretchr/testify/require" -) - -func ptrOf[T any](v T) *T { - return &v -} - -var cases = []struct { - name string - frame []byte - pkts []*rtp.Packet -}{ - { - "single", - []byte{0x01, 0x02, 0x03, 0x04}, - []*rtp.Packet{ - { - Header: rtp.Header{ - Version: 2, - Marker: true, - PayloadType: 96, - SequenceNumber: 17645, - SSRC: 0x9dbb7812, - }, - Payload: []byte{ - 0x01, 0x02, 0x03, 0x04, - }, - }, - }, - }, - { - "fragmented", - bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 150/4), - []*rtp.Packet{ - { - Header: rtp.Header{ - Version: 2, - Marker: false, - PayloadType: 96, - SequenceNumber: 17645, - SSRC: 0x9dbb7812, - }, - Payload: bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 100/4), - }, - { - Header: rtp.Header{ - Version: 2, - Marker: true, - PayloadType: 96, - SequenceNumber: 17646, - SSRC: 0x9dbb7812, - }, - Payload: bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 50/4), - }, - }, - }, -} - -func TestEncode(t *testing.T) { - for _, ca := range cases { - t.Run(ca.name, func(t *testing.T) { - e := &Encoder{ - PayloadType: 96, - SSRC: ptrOf(uint32(0x9dbb7812)), - InitialSequenceNumber: ptrOf(uint16(0x44ed)), - PayloadMaxSize: 100, - } - err := e.Init() - require.NoError(t, err) - - pkts, err := e.Encode(ca.frame) - require.NoError(t, err) - require.Equal(t, ca.pkts, pkts) - }) - } -} - -func TestEncodeRandomInitialState(t *testing.T) { - e := &Encoder{ - PayloadType: 96, - } - err := e.Init() - require.NoError(t, err) - require.NotEqual(t, nil, e.SSRC) - require.NotEqual(t, nil, e.InitialSequenceNumber) -} diff --git a/pkg/format/rtpmpeg4video/rtpmpeg4video.go b/pkg/format/rtpmpeg4video/rtpmpeg4video.go deleted file mode 100644 index 1acba5b7..00000000 --- a/pkg/format/rtpmpeg4video/rtpmpeg4video.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package rtpmpeg4video contains a RTP/MPEG-4 Video decoder and encoder. -package rtpmpeg4video diff --git a/pkg/format/vp8.go b/pkg/format/vp8.go index 0240a773..9c7e4885 100644 --- a/pkg/format/vp8.go +++ b/pkg/format/vp8.go @@ -6,7 +6,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp8" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpvp8" ) // VP8 is the RTP format for the VP8 codec. diff --git a/pkg/format/vp9.go b/pkg/format/vp9.go index 34c8d7be..9e767850 100644 --- a/pkg/format/vp9.go +++ b/pkg/format/vp9.go @@ -6,7 +6,7 @@ import ( "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp9" + "github.com/bluenviron/gortsplib/v5/pkg/format/rtpvp9" ) // VP9 is the RTP format for the VP9 codec. diff --git a/pkg/headers/authenticate.go b/pkg/headers/authenticate.go index ee453ca3..2c61c0f7 100644 --- a/pkg/headers/authenticate.go +++ b/pkg/headers/authenticate.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // AuthMethod is an authentication method. diff --git a/pkg/headers/authenticate_test.go b/pkg/headers/authenticate_test.go index be5d05ab..a258fd53 100644 --- a/pkg/headers/authenticate_test.go +++ b/pkg/headers/authenticate_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) func ptrOf[T any](v T) *T { diff --git a/pkg/headers/authorization.go b/pkg/headers/authorization.go index 8a81383e..59d7ce00 100644 --- a/pkg/headers/authorization.go +++ b/pkg/headers/authorization.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // Authorization is an Authorization header. @@ -20,11 +20,6 @@ type Authorization struct { // Basic authentication fields // - // user - // - // Deprecated: replaced by Username. - BasicUser string - // password BasicPass string @@ -92,7 +87,6 @@ func (h *Authorization) Unmarshal(v base.HeaderValue) error { } h.Username, h.BasicPass = tmp2[0], tmp2[1] - h.BasicUser = h.Username } else { // digest kvs, err := keyValParse(v0, ',') if err != nil { @@ -153,9 +147,6 @@ func (h *Authorization) Unmarshal(v base.HeaderValue) error { // Marshal encodes an Authorization header. func (h Authorization) Marshal() base.HeaderValue { if h.Method == AuthMethodBasic { - if h.BasicUser != "" { - h.Username = h.BasicUser - } return base.HeaderValue{"Basic " + base64.StdEncoding.EncodeToString([]byte(h.Username+":"+h.BasicPass))} } diff --git a/pkg/headers/authorization_test.go b/pkg/headers/authorization_test.go index 1a4b6793..0c4293d8 100644 --- a/pkg/headers/authorization_test.go +++ b/pkg/headers/authorization_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) var casesAuthorization = []struct { @@ -21,7 +21,6 @@ var casesAuthorization = []struct { Authorization{ Method: AuthMethodBasic, Username: "myuser", - BasicUser: "myuser", BasicPass: "mypass", }, }, diff --git a/pkg/headers/key_mgmt.go b/pkg/headers/key_mgmt.go index 20c73826..1eaa364e 100644 --- a/pkg/headers/key_mgmt.go +++ b/pkg/headers/key_mgmt.go @@ -4,8 +4,8 @@ import ( "encoding/base64" "fmt" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" ) // KeyMgmt is a KeyMgmt header. diff --git a/pkg/headers/key_mgmt_test.go b/pkg/headers/key_mgmt_test.go index 7a685e64..dfcdcd6c 100644 --- a/pkg/headers/key_mgmt_test.go +++ b/pkg/headers/key_mgmt_test.go @@ -3,8 +3,8 @@ package headers import ( "testing" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" "github.com/stretchr/testify/require" ) diff --git a/pkg/headers/range.go b/pkg/headers/range.go index a57a0a6f..4771865d 100644 --- a/pkg/headers/range.go +++ b/pkg/headers/range.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) func leadingZero(v uint) string { diff --git a/pkg/headers/range_test.go b/pkg/headers/range_test.go index c15ff180..fef66478 100644 --- a/pkg/headers/range_test.go +++ b/pkg/headers/range_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) var casesRange = []struct { diff --git a/pkg/headers/rtp_info.go b/pkg/headers/rtp_info.go index 8f55783a..46d2f963 100644 --- a/pkg/headers/rtp_info.go +++ b/pkg/headers/rtp_info.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // RTPInfoEntry is an entry of a RTP-Info header. diff --git a/pkg/headers/rtp_info_test.go b/pkg/headers/rtp_info_test.go index e9df94a9..73430768 100644 --- a/pkg/headers/rtp_info_test.go +++ b/pkg/headers/rtp_info_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) var casesRTPInfo = []struct { diff --git a/pkg/headers/session.go b/pkg/headers/session.go index e081faf8..9c672a00 100644 --- a/pkg/headers/session.go +++ b/pkg/headers/session.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // Session is a Session header. diff --git a/pkg/headers/session_test.go b/pkg/headers/session_test.go index 12c51116..14981480 100644 --- a/pkg/headers/session_test.go +++ b/pkg/headers/session_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) var casesSession = []struct { diff --git a/pkg/headers/transport.go b/pkg/headers/transport.go index 39d5384f..67ba0682 100644 --- a/pkg/headers/transport.go +++ b/pkg/headers/transport.go @@ -3,11 +3,10 @@ package headers import ( "encoding/hex" "fmt" - "net" "strconv" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) func parsePorts(val string) (*[2]int, error) { @@ -56,16 +55,6 @@ const ( TransportProtocolTCP ) -// String implements fmt.Stringer. -// -// Deprecated: not used anymore. -func (p TransportProtocol) String() string { - if p == TransportProtocolUDP { - return "RTP/AVP" - } - return "RTP/AVP/TCP" -} - // TransportDelivery is a delivery method. type TransportDelivery int @@ -75,16 +64,6 @@ const ( TransportDeliveryMulticast ) -// String implements fmt.Stringer. -// -// Deprecated: not used anymore. -func (d TransportDelivery) String() string { - if d == TransportDeliveryUnicast { - return "unicast" - } - return "multicast" -} - // TransportMode is a transport mode. type TransportMode int @@ -125,11 +104,6 @@ func (m TransportMode) String() string { // Transport is a Transport header. type Transport struct { - // Whether the secure variant is active. - // - // Deprecated: replaced by Profile. - Secure bool - // profile. Profile TransportProfile @@ -139,19 +113,9 @@ type Transport struct { // (optional) delivery method. Delivery *TransportDelivery - // (optional) Source IP. - // - // Deprecated: replaced by Source2 - Source *net.IP - // (optional) Source IP/host. Source2 *string - // (optional) destination IP. - // - // Deprecated: replaced by Destination2 - Destination *net.IP - // (optional) destination IP/host. Destination2 *string @@ -210,12 +174,10 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error { case "RTP/SAVP", "RTP/SAVP/UDP": h.Protocol = TransportProtocolUDP - h.Secure = true h.Profile = TransportProfileSAVP profileFound = true case "RTP/SAVP/TCP": - h.Secure = true h.Profile = TransportProfileSAVP h.Protocol = TransportProtocolTCP profileFound = true @@ -230,17 +192,11 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error { case "source": if v != "" { - if ip := net.ParseIP(v); ip != nil { - h.Source = &ip - } h.Source2 = &v } case "destination": if v != "" { - if ip := net.ParseIP(v); ip != nil { - h.Destination = &ip - } h.Destination2 = &v } @@ -318,10 +274,6 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error { func (h Transport) Marshal() base.HeaderValue { var rets []string - if h.Secure { - h.Profile = TransportProfileSAVP - } - var profile string switch { @@ -351,20 +303,10 @@ func (h Transport) Marshal() base.HeaderValue { rets = append(rets, delivery) } - if h.Source != nil { - v := h.Source.String() - h.Source2 = &v - } - if h.Source2 != nil { rets = append(rets, "source="+*h.Source2) } - if h.Destination != nil { - v := h.Destination.String() - h.Destination2 = &v - } - if h.Destination2 != nil { rets = append(rets, "destination="+*h.Destination2) } diff --git a/pkg/headers/transport_test.go b/pkg/headers/transport_test.go index 52859086..92de0a78 100644 --- a/pkg/headers/transport_test.go +++ b/pkg/headers/transport_test.go @@ -1,12 +1,11 @@ package headers import ( - "net" "testing" "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) var casesTransport = []struct { @@ -44,7 +43,6 @@ var casesTransport = []struct { Transport{ Protocol: TransportProtocolUDP, Delivery: ptrOf(TransportDeliveryMulticast), - Destination: ptrOf(net.ParseIP("225.219.201.15")), Destination2: ptrOf("225.219.201.15"), TTL: ptrOf(uint(127)), Ports: &[2]int{7000, 7001}, @@ -82,7 +80,6 @@ var casesTransport = []struct { Mode: ptrOf(TransportModeRecord), ClientPorts: &[2]int{14186, 14187}, ServerPorts: &[2]int{5000, 5001}, - Source: ptrOf(net.ParseIP("127.0.0.1")), Source2: ptrOf("127.0.0.1"), }, }, @@ -153,7 +150,6 @@ var casesTransport = []struct { Transport{ Protocol: TransportProtocolUDP, Delivery: ptrOf(TransportDeliveryUnicast), - Source: ptrOf(net.ParseIP("172.16.8.2")), Source2: ptrOf("172.16.8.2"), ClientPorts: &[2]int{14236, 14237}, ServerPorts: &[2]int{56002, 56003}, @@ -165,7 +161,6 @@ var casesTransport = []struct { base.HeaderValue{`RTP/SAVP;unicast;client_port=3456-3457;mode=play`}, Transport{ Protocol: TransportProtocolUDP, - Secure: true, Profile: TransportProfileSAVP, Delivery: ptrOf(TransportDeliveryUnicast), ClientPorts: &[2]int{3456, 3457}, @@ -178,7 +173,6 @@ var casesTransport = []struct { base.HeaderValue{`RTP/SAVP/TCP;interleaved=0-1`}, Transport{ Protocol: TransportProtocolTCP, - Secure: true, Profile: TransportProfileSAVP, InterleavedIDs: &[2]int{0, 1}, }, diff --git a/pkg/headers/transports.go b/pkg/headers/transports.go index d6a39a19..06e11468 100644 --- a/pkg/headers/transports.go +++ b/pkg/headers/transports.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // Transports is a Transport header with multiple transports. diff --git a/pkg/headers/transports_test.go b/pkg/headers/transports_test.go index 181f3962..cb6433e4 100644 --- a/pkg/headers/transports_test.go +++ b/pkg/headers/transports_test.go @@ -3,7 +3,7 @@ package headers import ( "testing" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" "github.com/stretchr/testify/require" ) diff --git a/pkg/liberrors/client.go b/pkg/liberrors/client.go index 5b7b1c8b..da958a9f 100644 --- a/pkg/liberrors/client.go +++ b/pkg/liberrors/client.go @@ -3,7 +3,7 @@ package liberrors import ( "fmt" - "github.com/bluenviron/gortsplib/v4/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/base" ) // ErrClientTerminated is an error that can be returned by a client. @@ -223,16 +223,6 @@ func (e ErrClientUnsupportedScheme) Error() string { return fmt.Sprintf("unsupported scheme: %v", e.Scheme) } -// ErrClientRTSPSTCP is an error that can be returned by a client. -// -// Deprecated: not used anymore. -type ErrClientRTSPSTCP struct{} - -// Error implements the error interface. -func (e ErrClientRTSPSTCP) Error() string { - return "RTSPS can be used only with TCP" -} - // ErrClientUnhandledMethod is an error that can be returned by a client. type ErrClientUnhandledMethod struct { Method base.Method @@ -251,25 +241,6 @@ func (e ErrClientWriteQueueFull) Error() string { return "write queue is full" } -// ErrClientRTPPacketsLost is an error that can be returned by a client. -// -// Deprecated: will be removed in next version. -type ErrClientRTPPacketsLost struct { - Lost uint -} - -// Error implements the error interface. -func (e ErrClientRTPPacketsLost) Error() string { - return fmt.Sprintf("%d RTP %s lost", - e.Lost, - func() string { - if e.Lost == 1 { - return "packet" - } - return "packets" - }()) -} - // ErrClientRTPPacketUnknownPayloadType is an error that can be returned by a client. type ErrClientRTPPacketUnknownPayloadType struct { PayloadType uint8 diff --git a/pkg/liberrors/server.go b/pkg/liberrors/server.go index 987886a3..6f5f87d7 100644 --- a/pkg/liberrors/server.go +++ b/pkg/liberrors/server.go @@ -4,7 +4,7 @@ import ( "fmt" "net" - "github.com/bluenviron/gortsplib/v4/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/headers" ) // ErrServerTerminated is an error that can be returned by a server. @@ -138,16 +138,11 @@ func (e ErrServerInvalidKeyMgmtHeader) Error() string { return fmt.Sprintf("invalid KeyMgmt header: %s", e.Wrapped.Error()) } -// ErrServerMediasDifferentProtocols is an error that can be returned by a server. -// -// Deprecated: replaced by ErrServerMediasDifferentTransports. -type ErrServerMediasDifferentProtocols = ErrServerMediasDifferentTransports - // ErrServerMediasDifferentTransports is an error that can be returned by a server. type ErrServerMediasDifferentTransports struct{} // Error implements the error interface. -func (e ErrServerMediasDifferentProtocols) Error() string { +func (e ErrServerMediasDifferentTransports) Error() string { return "can't setup medias with different transports" } @@ -253,11 +248,6 @@ func (e ErrServerUnexpectedResponse) Error() string { // ErrServerWriteQueueFull is an error that can be returned by a server. type ErrServerWriteQueueFull = ErrClientWriteQueueFull -// ErrServerRTPPacketsLost is an error that can be returned by a server. -// -// Deprecated: will be removed in next version. -type ErrServerRTPPacketsLost = ErrClientRTPPacketsLost - // ErrServerRTPPacketUnknownPayloadType is an error that can be returned by a server. type ErrServerRTPPacketUnknownPayloadType = ErrClientRTPPacketUnknownPayloadType diff --git a/pkg/multibuffer/multibuffer.go b/pkg/multibuffer/multibuffer.go deleted file mode 100644 index aa7c4bb2..00000000 --- a/pkg/multibuffer/multibuffer.go +++ /dev/null @@ -1,32 +0,0 @@ -// Package multibuffer contains a buffer with multiple levels. -package multibuffer - -// MultiBuffer implements software multi buffering, that allows to reuse -// existing buffers without creating new ones, improving performance. -// -// Deprecated: not used anymore, will be removed in next version. -type MultiBuffer struct { - count uint64 - buffers [][]byte - cur uint64 -} - -// New allocates a MultiBuffer. -func New(count uint64, size uint64) *MultiBuffer { - buffers := make([][]byte, count) - for i := uint64(0); i < count; i++ { - buffers[i] = make([]byte, size) - } - - return &MultiBuffer{ - count: count, - buffers: buffers, - } -} - -// Next gets the current buffer and sets the next buffer as the current one. -func (mb *MultiBuffer) Next() []byte { - ret := mb.buffers[mb.cur%mb.count] - mb.cur++ - return ret -} diff --git a/pkg/multibuffer/multibuffer_test.go b/pkg/multibuffer/multibuffer_test.go deleted file mode 100644 index 518b47ae..00000000 --- a/pkg/multibuffer/multibuffer_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package multibuffer - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func Test(t *testing.T) { - mb := New(2, 4) - - b := mb.Next() - copy(b, []byte{0x01, 0x02, 0x03, 0x04}) - - b = mb.Next() - copy(b, []byte{0x05, 0x06, 0x07, 0x08}) - - b = mb.Next() - require.Equal(t, []byte{0x01, 0x02, 0x03, 0x04}, b) - - b = mb.Next() - require.Equal(t, []byte{0x05, 0x06, 0x07, 0x08}, b) -} diff --git a/pkg/multicast/multicast.go b/pkg/multicast/multicast.go index be1fc1f8..6a75378c 100644 --- a/pkg/multicast/multicast.go +++ b/pkg/multicast/multicast.go @@ -2,7 +2,6 @@ package multicast import ( - "fmt" "net" "syscall" ) @@ -13,37 +12,3 @@ type Conn interface { SetReadBuffer(int) error SyscallConn() (syscall.RawConn, error) } - -// InterfaceForSource returns a multicast-capable interface that can communicate with given IP. -// -// Deprecated: not used anymore. -func InterfaceForSource(ip net.IP) (*net.Interface, error) { - if ip.Equal(net.ParseIP("127.0.0.1")) { - return nil, fmt.Errorf("IP 127.0.0.1 can't be used as source of a multicast stream. Use the LAN IP of your PC") - } - - intfs, err := net.Interfaces() - if err != nil { - return nil, err - } - - for _, intf := range intfs { - if (intf.Flags & net.FlagMulticast) == 0 { - continue - } - - var addrs []net.Addr - addrs, err = intf.Addrs() - if err == nil { - for _, addr := range addrs { - var ipnet *net.IPNet - _, ipnet, err = net.ParseCIDR(addr.String()) - if err == nil && ipnet.Contains(ip) { - return &intf, nil - } - } - } - } - - return nil, fmt.Errorf("found no interface that is multicast-capable and can communicate with IP %v", ip) -} diff --git a/pkg/rtcpreceiver/rtcpreceiver.go b/pkg/rtcpreceiver/rtcpreceiver.go deleted file mode 100644 index 3e04a3f8..00000000 --- a/pkg/rtcpreceiver/rtcpreceiver.go +++ /dev/null @@ -1,9 +0,0 @@ -// Package rtcpreceiver contains a utility to generate RTCP receiver reports. -package rtcpreceiver - -import "github.com/bluenviron/gortsplib/v4/pkg/rtpreceiver" - -// RTCPReceiver is a utility to receive RTP packets. -// -// Deprecated: replaced by rtpreceiver.Receiver -type RTCPReceiver = rtpreceiver.Receiver diff --git a/pkg/rtcpsender/rtcpsender.go b/pkg/rtcpsender/rtcpsender.go deleted file mode 100644 index 9f7d8cb5..00000000 --- a/pkg/rtcpsender/rtcpsender.go +++ /dev/null @@ -1,9 +0,0 @@ -// Package rtcpsender contains a utility to generate RTCP sender reports. -package rtcpsender - -import "github.com/bluenviron/gortsplib/v4/pkg/rtpsender" - -// RTCPSender is a utility to send RTP packets. -// -// Deprecated: replaced by rtpsender.Sender -type RTCPSender = rtpsender.Sender diff --git a/pkg/rtplossdetector/lossdetector.go b/pkg/rtplossdetector/lossdetector.go deleted file mode 100644 index a18c3be3..00000000 --- a/pkg/rtplossdetector/lossdetector.go +++ /dev/null @@ -1,40 +0,0 @@ -// Package rtplossdetector implements an algorithm that detects lost packets. -package rtplossdetector - -import ( - "github.com/pion/rtp" -) - -// LossDetector detects lost packets. -// -// Deprecated: merged into rtcpreceiver.Receiver. -type LossDetector struct { - initialized bool - expectedSeqNum uint16 -} - -// New allocates a LossDetector. -// -// Deprecated: Useless. -func New() *LossDetector { - return &LossDetector{} -} - -// Process processes a RTP packet. -// It returns the number of lost packets. -func (r *LossDetector) Process(pkt *rtp.Packet) uint { - if !r.initialized { - r.initialized = true - r.expectedSeqNum = pkt.SequenceNumber + 1 - return 0 - } - - if pkt.SequenceNumber != r.expectedSeqNum { - diff := pkt.SequenceNumber - r.expectedSeqNum - r.expectedSeqNum = pkt.SequenceNumber + 1 - return uint(diff) - } - - r.expectedSeqNum = pkt.SequenceNumber + 1 - return 0 -} diff --git a/pkg/rtplossdetector/lossdetector_test.go b/pkg/rtplossdetector/lossdetector_test.go deleted file mode 100644 index 6f81cb07..00000000 --- a/pkg/rtplossdetector/lossdetector_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package rtplossdetector - -import ( - "testing" - - "github.com/pion/rtp" - "github.com/stretchr/testify/require" -) - -func TestLossDetector(t *testing.T) { - d := New() - - c := d.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65530, - }, - }) - require.Equal(t, uint(0), c) - - c = d.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65531, - }, - }) - require.Equal(t, uint(0), c) - - c = d.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65535, - }, - }) - require.Equal(t, uint(3), c) -} diff --git a/pkg/rtpreceiver/receiver.go b/pkg/rtpreceiver/receiver.go index c40ca47b..9e7b2292 100644 --- a/pkg/rtpreceiver/receiver.go +++ b/pkg/rtpreceiver/receiver.go @@ -2,25 +2,15 @@ package rtpreceiver import ( - "crypto/rand" "fmt" "sync" "time" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" "github.com/pion/rtcp" "github.com/pion/rtp" ) -func randUint32() (uint32, error) { - var b [4]byte - _, err := rand.Read(b[:]) - if err != nil { - return 0, err - } - return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3]), nil -} - // Receiver is a utility to receive RTP packets. It is in charge of: // - removing packets with wrong SSRC // - removing duplicate packets (when transport is unreliable) @@ -32,7 +22,7 @@ type Receiver struct { ClockRate int // Local SSRC - LocalSSRC *uint32 + LocalSSRC uint32 // Whether the transport is unrealiable. // This enables removing duplicate packets and reordering packets. @@ -79,43 +69,8 @@ type Receiver struct { done chan struct{} } -// New allocates a Receiver. -// -// Deprecated: replaced by Initialize(). -func New( - clockRate int, - receiverSSRC *uint32, - period time.Duration, - timeNow func() time.Time, - writePacketRTCP func(rtcp.Packet), -) (*Receiver, error) { - rr := &Receiver{ - ClockRate: clockRate, - LocalSSRC: receiverSSRC, - Period: period, - TimeNow: timeNow, - WritePacketRTCP: writePacketRTCP, - } - err := rr.Initialize() - if err != nil { - return nil, err - } - - return rr, nil -} - // Initialize initializes Receiver. func (rr *Receiver) Initialize() error { - // Deprecated: passing a nil LocalSSRC will be deprecated from next version. - // Please use a fixed LocalSSRC. - if rr.LocalSSRC == nil { - v, err := randUint32() - if err != nil { - return err - } - rr.LocalSSRC = &v - } - if rr.BufferSize == 0 { rr.BufferSize = 64 } @@ -177,7 +132,7 @@ func (rr *Receiver) report() rtcp.Packet { system := rr.TimeNow() report := &rtcp.ReceiverReport{ - SSRC: *rr.LocalSSRC, + SSRC: rr.LocalSSRC, Reports: []rtcp.ReceptionReport{ { SSRC: rr.remoteSSRC, @@ -207,17 +162,9 @@ func (rr *Receiver) report() rtcp.Packet { return report } -// ProcessPacket extracts the needed data from RTP packets. -// -// Deprecated: replaced by ProcessPacket2. -func (rr *Receiver) ProcessPacket(pkt *rtp.Packet, system time.Time, ptsEqualsDTS bool) error { - _, _, err := rr.ProcessPacket2(pkt, system, ptsEqualsDTS) - return err -} - -// ProcessPacket2 processes an incoming RTP packet. +// ProcessPacket processes an incoming RTP packet. // It returns reordered packets and number of lost packets. -func (rr *Receiver) ProcessPacket2( +func (rr *Receiver) ProcessPacket( pkt *rtp.Packet, system time.Time, ptsEqualsDTS bool, @@ -423,17 +370,6 @@ func (rr *Receiver) PacketNTP(ts uint32) (time.Time, bool) { return rr.packetNTPUnsafe(ts) } -// SenderSSRC returns the SSRC of incoming RTP packets. -// -// Deprecated: replaced by Stats(). -func (rr *Receiver) SenderSSRC() (uint32, bool) { - stats := rr.Stats() - if stats == nil { - return 0, false - } - return stats.RemoteSSRC, true -} - // Stats are statistics. type Stats struct { RemoteSSRC uint32 diff --git a/pkg/rtpreceiver/receiver_test.go b/pkg/rtpreceiver/receiver_test.go index afde87d0..8cfb80dc 100644 --- a/pkg/rtpreceiver/receiver_test.go +++ b/pkg/rtpreceiver/receiver_test.go @@ -9,14 +9,10 @@ import ( "github.com/stretchr/testify/require" ) -func ptrOf[T any](v T) *T { - return &v -} - func TestErrorInvalidPeriod(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, } err := rr.Initialize() require.EqualError(t, err, "invalid Period") @@ -25,7 +21,7 @@ func TestErrorInvalidPeriod(t *testing.T) { func TestErrorDifferentSSRC(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, } err := rr.Initialize() @@ -44,7 +40,7 @@ func TestErrorDifferentSSRC(t *testing.T) { Payload: []byte("\x00\x00"), } ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -59,14 +55,14 @@ func TestErrorDifferentSSRC(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.EqualError(t, err, "received packet with wrong SSRC 754623214, expected 1434523") } func TestStatsBeforeData(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, } err := rr.Initialize() @@ -87,7 +83,7 @@ func TestStandard(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, UnrealiableTransport: ca == "unrealiable", Period: 500 * time.Millisecond, TimeNow: func() time.Time { @@ -113,7 +109,7 @@ func TestStandard(t *testing.T) { Payload: []byte("\x00\x00"), } ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) stats := rr.Stats() @@ -157,7 +153,7 @@ func TestStandard(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -172,7 +168,7 @@ func TestStandard(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) pkt := <-pktGenerated @@ -204,7 +200,7 @@ func TestZeroClockRate(t *testing.T) { rr := &Receiver{ ClockRate: 0, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, TimeNow: func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 22, 0, time.UTC) @@ -232,7 +228,7 @@ func TestZeroClockRate(t *testing.T) { Payload: []byte("\x00\x00"), } ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) stats = rr.Stats() @@ -271,7 +267,7 @@ func TestZeroClockRate(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -286,7 +282,7 @@ func TestZeroClockRate(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) select { @@ -308,7 +304,7 @@ func TestSequenceNumberOverflow(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 250 * time.Millisecond, TimeNow: func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) @@ -356,7 +352,7 @@ func TestSequenceNumberOverflow(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -371,7 +367,7 @@ func TestSequenceNumberOverflow(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) <-rtcpGenerated @@ -382,7 +378,7 @@ func TestJitter(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, TimeNow: func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 22, 0, time.UTC) @@ -429,7 +425,7 @@ func TestJitter(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -444,7 +440,7 @@ func TestJitter(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -459,7 +455,7 @@ func TestJitter(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 22, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, false) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, false) require.NoError(t, err) <-rtcpGenerated @@ -470,7 +466,7 @@ func TestReliablePacketsLost(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, TimeNow: func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) @@ -521,7 +517,7 @@ func TestReliablePacketsLost(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -536,7 +532,7 @@ func TestReliablePacketsLost(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) <-done @@ -547,7 +543,7 @@ func TestReliableOverflowAndPacketsLost(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, Period: 500 * time.Millisecond, TimeNow: func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) @@ -598,7 +594,7 @@ func TestReliableOverflowAndPacketsLost(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) rtpPkt = rtp.Packet{ @@ -613,7 +609,7 @@ func TestReliableOverflowAndPacketsLost(t *testing.T) { Payload: []byte("\x00\x00"), } ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC) - err = rr.ProcessPacket(&rtpPkt, ts, true) + _, _, err = rr.ProcessPacket(&rtpPkt, ts, true) require.NoError(t, err) <-done @@ -771,7 +767,7 @@ func TestUnrealiableReorder(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, UnrealiableTransport: true, Period: 500 * time.Millisecond, } @@ -784,7 +780,7 @@ func TestUnrealiableReorder(t *testing.T) { for _, entry := range sequence { var out []*rtp.Packet var missing uint64 - out, missing, err = rr.ProcessPacket2(entry.in, time.Time{}, true) + out, missing, err = rr.ProcessPacket(entry.in, time.Time{}, true) require.NoError(t, err) require.Equal(t, entry.out, out) require.Equal(t, uint64(0), missing) @@ -796,7 +792,7 @@ func TestUnrealiableBufferFull(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, UnrealiableTransport: true, Period: 500 * time.Millisecond, WritePacketRTCP: func(p rtcp.Packet) { @@ -823,7 +819,7 @@ func TestUnrealiableBufferFull(t *testing.T) { sn := uint16(1564) toMiss := uint64(34) - out, missing, err := rr.ProcessPacket2(&rtp.Packet{ + out, missing, err := rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: sn, }, @@ -840,7 +836,7 @@ func TestUnrealiableBufferFull(t *testing.T) { var expected []*rtp.Packet for i := uint64(0); i < 64-toMiss; i++ { - out, missing, err = rr.ProcessPacket2(&rtp.Packet{ + out, missing, err = rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: sn + uint16(toMiss), }, @@ -857,7 +853,7 @@ func TestUnrealiableBufferFull(t *testing.T) { sn++ } - out, missing, err = rr.ProcessPacket2(&rtp.Packet{ + out, missing, err = rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: sn + uint16(toMiss), }, @@ -880,7 +876,7 @@ func TestUnrealiableReset(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, UnrealiableTransport: true, Period: 500 * time.Millisecond, WritePacketRTCP: func(p rtcp.Packet) { @@ -898,7 +894,7 @@ func TestUnrealiableReset(t *testing.T) { require.NoError(t, err) defer rr.Close() - _, _, err = rr.ProcessPacket2(&rtp.Packet{ + _, _, err = rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: 50000, }, @@ -910,7 +906,7 @@ func TestUnrealiableReset(t *testing.T) { for range 64 { var out []*rtp.Packet var missing uint64 - out, missing, err = rr.ProcessPacket2(&rtp.Packet{ + out, missing, err = rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: sn, }, @@ -921,7 +917,7 @@ func TestUnrealiableReset(t *testing.T) { sn++ } - out, missing, err := rr.ProcessPacket2(&rtp.Packet{ + out, missing, err := rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: sn, }, @@ -942,7 +938,7 @@ func TestUnrealiableCustomBufferSize(t *testing.T) { rr := &Receiver{ ClockRate: 90000, - LocalSSRC: ptrOf(uint32(0x65f83afb)), + LocalSSRC: 0x65f83afb, UnrealiableTransport: true, BufferSize: customSize, Period: 500 * time.Millisecond, @@ -956,7 +952,7 @@ func TestUnrealiableCustomBufferSize(t *testing.T) { // Process first packet; behaves as usual. firstSeq := uint16(50) - out, missing, err := rr.ProcessPacket2(&rtp.Packet{ + out, missing, err := rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: firstSeq, }, @@ -973,7 +969,7 @@ func TestUnrealiableCustomBufferSize(t *testing.T) { // Now, send a packet with a gap larger than the custom buffer size. // For BufferSize = 128, let's send a packet with SequenceNumber = 51 + 130 = 181. nextSeq := uint16(181) - out, missing, err = rr.ProcessPacket2(&rtp.Packet{ + out, missing, err = rr.ProcessPacket(&rtp.Packet{ Header: rtp.Header{ SequenceNumber: nextSeq, }, diff --git a/pkg/rtpreorderer/reorderer.go b/pkg/rtpreorderer/reorderer.go deleted file mode 100644 index fcfc6b91..00000000 --- a/pkg/rtpreorderer/reorderer.go +++ /dev/null @@ -1,150 +0,0 @@ -// Package rtpreorderer implements a filter to reorder incoming RTP packets. -package rtpreorderer - -import ( - "github.com/pion/rtp" -) - -const ( - defaultBufferSize = 64 -) - -// Reorderer filters incoming RTP packets, in order to -// - order packets -// - remove duplicate packets -// -// Deprecated: merged into rtcpreceiver.Receiver. -type Reorderer struct { - initialized bool - expectedSeqNum uint16 - buffer []*rtp.Packet - absPos uint16 - negativeCount int - - // Maximum number of packets to buffer for reordering - BufferSize int -} - -// New allocates a Reorderer. -// -// Deprecated: replaced by Initialize(). -func New() *Reorderer { - r := &Reorderer{} - r.Initialize() - return r -} - -// Initialize initializes a Reorderer. -func (r *Reorderer) Initialize() { - if r.BufferSize == 0 { - r.BufferSize = defaultBufferSize - } - r.buffer = make([]*rtp.Packet, r.BufferSize) -} - -// Process processes a RTP packet. -// It returns a sequence of ordered packets and the number of lost packets. -func (r *Reorderer) Process(pkt *rtp.Packet) ([]*rtp.Packet, uint) { - if !r.initialized { - r.initialized = true - r.expectedSeqNum = pkt.SequenceNumber + 1 - return []*rtp.Packet{pkt}, 0 - } - - relPos := int16(pkt.SequenceNumber - r.expectedSeqNum) - - // packet is a duplicate or has been sent - // before the first packet processed by Reorderer. - // discard. - if relPos < 0 { - r.negativeCount++ - - // stream has been resetted, therefore reset reorderer too - if r.negativeCount > r.BufferSize { - r.negativeCount = 0 - - // clear buffer - for i := uint16(0); i < uint16(r.BufferSize); i++ { - p := (r.absPos + i) & (uint16(r.BufferSize) - 1) - r.buffer[p] = nil - } - - // reset position - r.expectedSeqNum = pkt.SequenceNumber + 1 - return []*rtp.Packet{pkt}, 0 - } - - return nil, 0 - } - r.negativeCount = 0 - - // there's a missing packet and buffer is full. - // return entire buffer and clear it. - if relPos >= int16(r.BufferSize) { - n := 1 - for i := uint16(0); i < uint16(r.BufferSize); i++ { - p := (r.absPos + i) & (uint16(r.BufferSize) - 1) - if r.buffer[p] != nil { - n++ - } - } - - ret := make([]*rtp.Packet, n) - pos := 0 - - for i := uint16(0); i < uint16(r.BufferSize); i++ { - p := (r.absPos + i) & (uint16(r.BufferSize) - 1) - if r.buffer[p] != nil { - ret[pos], r.buffer[p] = r.buffer[p], nil - pos++ - } - } - - ret[pos] = pkt - - r.expectedSeqNum = pkt.SequenceNumber + 1 - return ret, uint(int(relPos) - n + 1) - } - - // there's a missing packet - if relPos != 0 { - p := (r.absPos + uint16(relPos)) & (uint16(r.BufferSize) - 1) - - // current packet is a duplicate. discard - if r.buffer[p] != nil { - return nil, 0 - } - - // put current packet in buffer - r.buffer[p] = pkt - return nil, 0 - } - - // all packets have been received correctly. - // return them - - n := uint16(1) - for { - p := (r.absPos + n) & (uint16(r.BufferSize) - 1) - if r.buffer[p] == nil { - break - } - n++ - } - - ret := make([]*rtp.Packet, n) - - ret[0] = pkt - r.absPos++ - r.absPos &= (uint16(r.BufferSize) - 1) - - for i := uint16(1); i < n; i++ { - ret[i], r.buffer[r.absPos] = r.buffer[r.absPos], nil - r.absPos++ - r.absPos &= (uint16(r.BufferSize) - 1) - } - - r.expectedSeqNum = pkt.SequenceNumber + n - - return ret, 0 -} diff --git a/pkg/rtpreorderer/reorderer_test.go b/pkg/rtpreorderer/reorderer_test.go deleted file mode 100644 index 3dfb3d26..00000000 --- a/pkg/rtpreorderer/reorderer_test.go +++ /dev/null @@ -1,303 +0,0 @@ -package rtpreorderer - -import ( - "testing" - - "github.com/pion/rtp" - "github.com/stretchr/testify/require" -) - -func TestReorder(t *testing.T) { - sequence := []struct { - in *rtp.Packet - out []*rtp.Packet - }{ - { - // first packet - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65530, - }, - }, - []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: 65530, - }, - }}, - }, - { - // packet sent before first packet - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65529, - }, - }, - []*rtp.Packet(nil), - }, - { - // ok - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65531, - }, - }, - []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: 65531, - }, - }}, - }, - { - // duplicated - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65531, - }, - }, - []*rtp.Packet(nil), - }, - { - // gap - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65535, - }, - }, - []*rtp.Packet(nil), - }, - { - // unordered - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65533, - PayloadType: 96, - }, - }, - []*rtp.Packet(nil), - }, - { - // unordered + duplicated - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65533, - PayloadType: 97, - }, - }, - []*rtp.Packet(nil), - }, - { - // unordered - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65532, - }, - }, - []*rtp.Packet{ - { - Header: rtp.Header{ - SequenceNumber: 65532, - }, - }, - { - Header: rtp.Header{ - SequenceNumber: 65533, - PayloadType: 96, - }, - }, - }, - }, - { - // unordered - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 65534, - }, - }, - []*rtp.Packet{ - { - Header: rtp.Header{ - SequenceNumber: 65534, - }, - }, - { - Header: rtp.Header{ - SequenceNumber: 65535, - }, - }, - }, - }, - { - // overflow + gap - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 1, - }, - }, - []*rtp.Packet(nil), - }, - { - // unordered - &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: 0, - }, - }, - []*rtp.Packet{ - { - Header: rtp.Header{ - SequenceNumber: 0, - }, - }, - { - Header: rtp.Header{ - SequenceNumber: 1, - }, - }, - }, - }, - } - - r := &Reorderer{} - r.Initialize() - r.absPos = 40 - - for _, entry := range sequence { - out, missing := r.Process(entry.in) - require.Equal(t, entry.out, out) - require.Equal(t, uint(0), missing) - } -} - -func TestBufferIsFull(t *testing.T) { - r := &Reorderer{} - r.Initialize() - r.absPos = 25 - sn := uint16(1564) - toMiss := uint(34) - - out, missing := r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }) - require.Equal(t, []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }}, out) - require.Equal(t, uint(0), missing) - sn++ - - var expected []*rtp.Packet - - for i := uint(0); i < 64-toMiss; i++ { - out, missing = r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn + uint16(toMiss), - }, - }) - require.Equal(t, []*rtp.Packet(nil), out) - require.Equal(t, uint(0), missing) - - expected = append(expected, &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn + uint16(toMiss), - }, - }) - sn++ - } - - out, missing = r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn + uint16(toMiss), - }, - }) - require.Equal(t, toMiss, missing) - - expected = append(expected, &rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn + uint16(toMiss), - }, - }) - - require.Equal(t, expected, out) -} - -func TestReset(t *testing.T) { - r := &Reorderer{} - r.Initialize() - sn := uint16(1234) - - r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }) - - sn = 0xF234 - for i := 0; i < 64; i++ { - out, missing := r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }) - require.Equal(t, []*rtp.Packet(nil), out) - require.Equal(t, uint(0), missing) - sn++ - } - - out, missing := r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }) - require.Equal(t, []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: sn, - }, - }}, out) - require.Equal(t, uint(0), missing) -} - -func TestCustomBufferSize(t *testing.T) { - customSize := 128 - r := &Reorderer{ - BufferSize: customSize, - } - r.Initialize() - - // Set absPos to an arbitrary value. - r.absPos = 10 - - // Process first packet; behaves as usual. - firstSeq := uint16(50) - out, missing := r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: firstSeq, - }, - }) - require.Equal(t, []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: firstSeq, - }, - }}, out) - require.Equal(t, uint(0), missing) - - // At this point, expectedSeqNum == firstSeq + 1 (i.e. 51). - // Now, send a packet with a gap larger than the custom buffer size. - // For BufferSize = 128, let's send a packet with SequenceNumber = 51 + 130 = 181. - nextSeq := uint16(181) - out, missing = r.Process(&rtp.Packet{ - Header: rtp.Header{ - SequenceNumber: nextSeq, - }, - }) - // Since there are no packets buffered, n remains 1. - // relPos = 181 - 51 = 130; so missing should be 130 - require.Equal(t, uint(130), missing) - require.Equal(t, []*rtp.Packet{{ - Header: rtp.Header{ - SequenceNumber: nextSeq, - }, - }}, out) -} diff --git a/pkg/rtpsender/sender.go b/pkg/rtpsender/sender.go index 67f1409a..ea1b23b5 100644 --- a/pkg/rtpsender/sender.go +++ b/pkg/rtpsender/sender.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" "github.com/pion/rtcp" "github.com/pion/rtp" ) @@ -34,26 +34,6 @@ type Sender struct { done chan struct{} } -// New allocates a Sender. -// -// Deprecated: replaced by Initialize(). -func New( - clockRate int, - period time.Duration, - timeNow func() time.Time, - writePacketRTCP func(rtcp.Packet), -) *Sender { - rs := &Sender{ - ClockRate: clockRate, - Period: period, - TimeNow: timeNow, - WritePacketRTCP: writePacketRTCP, - } - rs.Initialize() - - return rs -} - // Initialize initializes a Sender. func (rs *Sender) Initialize() { if rs.TimeNow == nil { @@ -132,36 +112,8 @@ func (rs *Sender) ProcessPacket(pkt *rtp.Packet, ntp time.Time, ptsEqualsDTS boo rs.octetCount += uint32(len(pkt.Payload)) } -// SenderSSRC returns the SSRC of outgoing RTP packets. -// -// Deprecated: replaced by Stats(). -func (rs *Sender) SenderSSRC() (uint32, bool) { - stats := rs.Stats() - if stats == nil { - return 0, false - } - - return stats.LocalSSRC, true -} - -// LastPacketData returns metadata of the last RTP packet. -// -// Deprecated: replaced by Stats(). -func (rs *Sender) LastPacketData() (uint16, uint32, time.Time, bool) { - stats := rs.Stats() - if stats == nil { - return 0, 0, time.Time{}, false - } - - return stats.LastSequenceNumber, stats.LastRTP, stats.LastNTP, true -} - // Stats are statistics. type Stats struct { - // Deprecated: this is not a statistics anymore but a fixed parameter. - // it will be removed in next version. - LocalSSRC uint32 - LastSequenceNumber uint16 LastRTP uint32 LastNTP time.Time @@ -177,7 +129,6 @@ func (rs *Sender) Stats() *Stats { } return &Stats{ - LocalSSRC: rs.localSSRC, LastSequenceNumber: rs.lastSequenceNumber, LastRTP: rs.lastTimeRTP, LastNTP: rs.lastTimeNTP, diff --git a/pkg/rtpsender/sender_test.go b/pkg/rtpsender/sender_test.go index b9c3beb3..2263b744 100644 --- a/pkg/rtpsender/sender_test.go +++ b/pkg/rtpsender/sender_test.go @@ -101,7 +101,6 @@ func TestSender(t *testing.T) { stats = rs.Stats() require.Equal(t, &Stats{ - LocalSSRC: 0xba9da416, LastSequenceNumber: 948, LastRTP: 1287987768, LastNTP: time.Date(2008, time.May, 20, 22, 15, 21, 0, time.UTC), @@ -161,7 +160,6 @@ func TestSenderZeroClockRate(t *testing.T) { stats = rs.Stats() require.Equal(t, &Stats{ - LocalSSRC: 0xba9da416, LastSequenceNumber: 946, LastRTP: 1287987768, LastNTP: time.Date(2008, time.May, 20, 22, 15, 20, 0, time.UTC), diff --git a/pkg/rtptime/encoder.go b/pkg/rtptime/encoder.go deleted file mode 100644 index cf5103f4..00000000 --- a/pkg/rtptime/encoder.go +++ /dev/null @@ -1,61 +0,0 @@ -package rtptime - -import ( - "crypto/rand" - "time" -) - -func divCeil(n, d uint64) uint64 { - v := n / d - if (n % d) != 0 { - v++ - } - return v -} - -func randUint32() (uint32, error) { - var b [4]byte - _, err := rand.Read(b[:]) - if err != nil { - return 0, err - } - return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3]), nil -} - -// Encoder is a RTP timestamp encoder. -// -// Deprecated: not used anymore. -type Encoder struct { - // Clock rate. - ClockRate int - - // (optional) initial timestamp. - // It defaults to a random value. - InitialTimestamp *uint32 - - clockRateTD time.Duration - initialTimestampTD time.Duration -} - -// Initialize initializes an Encoder. -func (e *Encoder) Initialize() error { - e.clockRateTD = time.Duration(e.ClockRate) - - if e.InitialTimestamp == nil { - v, err := randUint32() - if err != nil { - return err - } - e.InitialTimestamp = &v - } - - e.initialTimestampTD = time.Duration(divCeil(uint64(*e.InitialTimestamp)*uint64(time.Second), uint64(e.ClockRate))) - - return nil -} - -// Encode encodes a timestamp. -func (e *Encoder) Encode(ts time.Duration) uint32 { - ts += e.initialTimestampTD - return uint32(multiplyAndDivide(ts, e.clockRateTD, time.Second)) -} diff --git a/pkg/rtptime/encoder_test.go b/pkg/rtptime/encoder_test.go deleted file mode 100644 index 94679898..00000000 --- a/pkg/rtptime/encoder_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package rtptime - -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" -) - -func ptrOf[T any](v T) *T { - return &v -} - -func TestEncoder(t *testing.T) { - e := &Encoder{ - ClockRate: 90000, - InitialTimestamp: ptrOf(uint32(12345)), - } - err := e.Initialize() - require.NoError(t, err) - - ts := e.Encode(0) - require.Equal(t, uint32(12345), ts) - - ts = e.Encode(3 * time.Second / 2) - require.Equal(t, uint32(12345+135000), ts) -} - -func BenchmarkEncoder(b *testing.B) { - e := &Encoder{ - ClockRate: 90000, - InitialTimestamp: ptrOf(uint32(12345)), - } - e.Initialize() //nolint:errcheck - - for i := 0; i < b.N; i++ { - e.Encode(200 * time.Second) - } -} diff --git a/pkg/rtptime/global_decoder.go b/pkg/rtptime/global_decoder.go index a11cad46..c50cba57 100644 --- a/pkg/rtptime/global_decoder.go +++ b/pkg/rtptime/global_decoder.go @@ -1,6 +1,8 @@ +// Package rtptime contains a time decoder. package rtptime import ( + "sync" "time" "github.com/pion/rtp" @@ -10,72 +12,93 @@ var timeNow = time.Now // avoid an int64 overflow and preserve resolution by splitting division into two parts: // first add the integer part, then the decimal part. -func multiplyAndDivide(v, m, d time.Duration) time.Duration { +func multiplyAndDivide(v, m, d int64) int64 { secs := v / d dec := v % d return (secs*m + dec*m/d) } type globalDecoderTrackData struct { - startPTS time.Duration - clockRate time.Duration - overall time.Duration - prev uint32 + overall int64 + prev uint32 } -func newGlobalDecoderTrackData( - startPTS time.Duration, - clockRate int, - startTimestamp uint32, -) *globalDecoderTrackData { - return &globalDecoderTrackData{ - startPTS: startPTS, - clockRate: time.Duration(clockRate), - prev: startTimestamp, - } -} - -func (d *globalDecoderTrackData) decode(ts uint32) time.Duration { - diff := int32(ts - d.prev) +func (d *globalDecoderTrackData) decode(ts uint32) int64 { + d.overall += int64(int32(ts - d.prev)) d.prev = ts - d.overall += time.Duration(diff) - - return d.startPTS + multiplyAndDivide(d.overall, time.Second, d.clockRate) + return d.overall } -// GlobalDecoderTrack is a track (RTSP format or WebRTC track) of a GlobalDecoder. -// -// Deprecated: replaced by GlobalDecoderTrack2 +// GlobalDecoderTrack is a track (RTSP format or WebRTC track) of GlobalDecoder. type GlobalDecoderTrack interface { ClockRate() int PTSEqualsDTS(*rtp.Packet) bool } // GlobalDecoder is a RTP timestamp decoder. -// -// Deprecated: replaced by GlobalDecoder2. type GlobalDecoder struct { - wrapped *GlobalDecoder2 + mutex sync.Mutex + leadingTrack GlobalDecoderTrack + startNTP time.Time + startPTS int64 + startPTSClockRate int64 + tracks map[GlobalDecoderTrack]*globalDecoderTrackData } -// NewGlobalDecoder allocates a GlobalDecoder. -// -// Deprecated: replaced by NewGlobalDecoder2. -func NewGlobalDecoder() *GlobalDecoder { - return &GlobalDecoder{ - wrapped: NewGlobalDecoder2(), - } +// Initialize initializes a GlobalDecoder. +func (d *GlobalDecoder) Initialize() { + d.tracks = make(map[GlobalDecoderTrack]*globalDecoderTrackData) } // Decode decodes a timestamp. func (d *GlobalDecoder) Decode( track GlobalDecoderTrack, pkt *rtp.Packet, -) (time.Duration, bool) { - v, ok := d.wrapped.Decode(track, pkt) - if !ok { +) (int64, bool) { + if track.ClockRate() == 0 { return 0, false } - return multiplyAndDivide(time.Duration(v), time.Second, time.Duration(track.ClockRate())), true + d.mutex.Lock() + defer d.mutex.Unlock() + + df, ok := d.tracks[track] + + // never seen before track + if !ok { + if !track.PTSEqualsDTS(pkt) { + return 0, false + } + + now := timeNow() + + if d.leadingTrack == nil { + d.leadingTrack = track + d.startNTP = now + d.startPTS = 0 + d.startPTSClockRate = int64(track.ClockRate()) + } + + // start from the PTS of the leading track + startPTS := multiplyAndDivide(d.startPTS, int64(track.ClockRate()), d.startPTSClockRate) + startPTS += multiplyAndDivide(int64(now.Sub(d.startNTP)), int64(track.ClockRate()), int64(time.Second)) + + d.tracks[track] = &globalDecoderTrackData{ + overall: startPTS, + prev: pkt.Timestamp, + } + + return startPTS, true + } + + pts := df.decode(pkt.Timestamp) + + // update startNTP / startPTS + if d.leadingTrack == track && track.PTSEqualsDTS(pkt) { + now := timeNow() + d.startNTP = now + d.startPTS = pts + } + + return pts, true } diff --git a/pkg/rtptime/global_decoder2.go b/pkg/rtptime/global_decoder2.go deleted file mode 100644 index 30f68988..00000000 --- a/pkg/rtptime/global_decoder2.go +++ /dev/null @@ -1,110 +0,0 @@ -package rtptime - -import ( - "sync" - "time" - - "github.com/pion/rtp" -) - -// avoid an int64 overflow and preserve resolution by splitting division into two parts: -// first add the integer part, then the decimal part. -func multiplyAndDivide2(v, m, d int64) int64 { - secs := v / d - dec := v % d - return (secs*m + dec*m/d) -} - -type globalDecoder2TrackData struct { - overall int64 - prev uint32 -} - -func (d *globalDecoder2TrackData) decode(ts uint32) int64 { - d.overall += int64(int32(ts - d.prev)) - d.prev = ts - return d.overall -} - -// GlobalDecoder2Track is a track (RTSP format or WebRTC track) of GlobalDecoder2. -type GlobalDecoder2Track interface { - ClockRate() int - PTSEqualsDTS(*rtp.Packet) bool -} - -// NewGlobalDecoder2 allocates a GlobalDecoder. -// -// Deprecated: replaced by GlobalDecoder2.Initialize(). -func NewGlobalDecoder2() *GlobalDecoder2 { - d := &GlobalDecoder2{} - d.Initialize() - return d -} - -// GlobalDecoder2 is a RTP timestamp decoder. -type GlobalDecoder2 struct { - mutex sync.Mutex - leadingTrack GlobalDecoderTrack - startNTP time.Time - startPTS int64 - startPTSClockRate int64 - tracks map[GlobalDecoder2Track]*globalDecoder2TrackData -} - -// Initialize initializes a GlobalDecoder2. -func (d *GlobalDecoder2) Initialize() { - d.tracks = make(map[GlobalDecoder2Track]*globalDecoder2TrackData) -} - -// Decode decodes a timestamp. -func (d *GlobalDecoder2) Decode( - track GlobalDecoder2Track, - pkt *rtp.Packet, -) (int64, bool) { - if track.ClockRate() == 0 { - return 0, false - } - - d.mutex.Lock() - defer d.mutex.Unlock() - - df, ok := d.tracks[track] - - // never seen before track - if !ok { - if !track.PTSEqualsDTS(pkt) { - return 0, false - } - - now := timeNow() - - if d.leadingTrack == nil { - d.leadingTrack = track - d.startNTP = now - d.startPTS = 0 - d.startPTSClockRate = int64(track.ClockRate()) - } - - // start from the PTS of the leading track - startPTS := multiplyAndDivide2(d.startPTS, int64(track.ClockRate()), d.startPTSClockRate) - startPTS += multiplyAndDivide2(int64(now.Sub(d.startNTP)), int64(track.ClockRate()), int64(time.Second)) - - d.tracks[track] = &globalDecoder2TrackData{ - overall: startPTS, - prev: pkt.Timestamp, - } - - return startPTS, true - } - - pts := df.decode(pkt.Timestamp) - - // update startNTP / startPTS - if d.leadingTrack == track && track.PTSEqualsDTS(pkt) { - now := timeNow() - d.startNTP = now - d.startPTS = pts - } - - return pts, true -} diff --git a/pkg/rtptime/global_decoder_test.go b/pkg/rtptime/global_decoder_test.go index fdc782b2..43781ae7 100644 --- a/pkg/rtptime/global_decoder_test.go +++ b/pkg/rtptime/global_decoder_test.go @@ -8,85 +8,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestDecoderNegativeDiff(t *testing.T) { - i := uint32(0) - d := newGlobalDecoderTrackData(0, 90000, i) - - i += 90000 * 2 - pts := d.decode(i) - require.Equal(t, 2*time.Second, pts) - - i -= 90000 * 1 - pts = d.decode(i) - require.Equal(t, 1*time.Second, pts) - - i += 90000 * 2 - pts = d.decode(i) - require.Equal(t, 3*time.Second, pts) -} - -func TestDecoderOverflow(t *testing.T) { - secs := time.Duration(0) - i := uint32(0xFFFFFFFF - 90000 + 1) - d := newGlobalDecoderTrackData(0, 90000, i) - - const stride = 1500 - lim := uint32(uint64(0xFFFFFFFF + 1 - (stride * 90000))) - - for n := 0; n < 100; n++ { - // overflow - i += 90000 * stride - secs += stride - pts := d.decode(i) - require.Equal(t, secs*time.Second, pts) - - // reach 2^32 slowly - secs += stride - i += 90000 * stride - for ; i < lim; i += 90000 * stride { - pts = d.decode(i) - require.Equal(t, secs*time.Second, pts) - secs += stride - } - } -} - -func TestDecoderOverflowAndBack(t *testing.T) { - d := newGlobalDecoderTrackData(0, 90000, 0xFFFFFFFF-90000+1) - - pts := d.decode(90000) - require.Equal(t, 2*time.Second, pts) - - pts = d.decode(0xFFFFFFFF - 90000 + 1) - require.Equal(t, time.Duration(0), pts) - - pts = d.decode(0xFFFFFFFF - 90000 + 1 - 90000) - require.Equal(t, -1*time.Second, pts) - - pts = d.decode(0xFFFFFFFF - 90000 + 1) - require.Equal(t, time.Duration(0), pts) - - pts = d.decode(90000) - require.Equal(t, 2*time.Second, pts) -} - -func BenchmarkDecoder(b *testing.B) { - for i := 0; i < b.N; i++ { - func() { - n := uint32(0) - d := newGlobalDecoderTrackData(0, 90000, n) - for j := 0; j < 200; j++ { - if (j % 2) == 0 { - n += 90000 - } else { - n -= 45000 - } - d.decode(n) - } - }() - } -} - type dummyTrack struct { clockRate int ptsEqualsDTS bool @@ -101,7 +22,8 @@ func (t *dummyTrack) PTSEqualsDTS(*rtp.Packet) bool { } func TestGlobalDecoder(t *testing.T) { - g := NewGlobalDecoder() + g := &GlobalDecoder{} + g.Initialize() t1 := &dummyTrack{clockRate: 90000} t2 := &dummyTrack{clockRate: 48000, ptsEqualsDTS: true} @@ -116,7 +38,7 @@ func TestGlobalDecoder(t *testing.T) { t1.ptsEqualsDTS = true pts, ok := g.Decode(t1, &rtp.Packet{Header: rtp.Header{Timestamp: 22500}}) require.Equal(t, true, ok) - require.Equal(t, time.Duration(0), pts) + require.Equal(t, int64(0), pts) timeNow = func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC) @@ -124,7 +46,7 @@ func TestGlobalDecoder(t *testing.T) { pts, ok = g.Decode(t1, &rtp.Packet{Header: rtp.Header{Timestamp: 22500 + 90000}}) require.Equal(t, true, ok) - require.Equal(t, 1*time.Second, pts) + require.Equal(t, int64(90000), pts) timeNow = func() time.Time { return time.Date(2008, 0o5, 20, 22, 15, 25, 0, time.UTC) @@ -132,15 +54,16 @@ func TestGlobalDecoder(t *testing.T) { pts, ok = g.Decode(t2, &rtp.Packet{Header: rtp.Header{Timestamp: 33100}}) require.Equal(t, true, ok) - require.Equal(t, 5*time.Second, pts) + require.Equal(t, int64(240000), pts) pts, ok = g.Decode(t2, &rtp.Packet{Header: rtp.Header{Timestamp: 33100 + 48000}}) require.Equal(t, true, ok) - require.Equal(t, 6*time.Second, pts) + require.Equal(t, int64(288000), pts) } func TestGlobalDecoderInvalidClockRate(t *testing.T) { - g := NewGlobalDecoder() + g := &GlobalDecoder{} + g.Initialize() tr := &dummyTrack{clockRate: 0, ptsEqualsDTS: true} diff --git a/pkg/rtptime/rtptime.go b/pkg/rtptime/rtptime.go deleted file mode 100644 index 1f120317..00000000 --- a/pkg/rtptime/rtptime.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package rtptime contains a time decoder and encoder. -package rtptime diff --git a/pkg/url/path.go b/pkg/url/path.go deleted file mode 100644 index 5376c42e..00000000 --- a/pkg/url/path.go +++ /dev/null @@ -1,12 +0,0 @@ -package url - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/base" -) - -// PathSplitQuery splits a path from a query. -// -// Deprecated: replaced by base.PathSplitQuery -func PathSplitQuery(pathAndQuery string) (string, string) { - return base.PathSplitQuery(pathAndQuery) -} diff --git a/pkg/url/url.go b/pkg/url/url.go deleted file mode 100644 index af25e117..00000000 --- a/pkg/url/url.go +++ /dev/null @@ -1,20 +0,0 @@ -// Package url is deprecated. -package url - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/base" -) - -// URL is a RTSP URL. -// This is basically an HTTP URL with some additional functions to handle -// control attributes. -// -// Deprecated: replaced by base.URL -type URL = base.URL - -// Parse parses a RTSP URL. -// -// Deprecated: replaced by base.ParseURL -func Parse(s string) (*URL, error) { - return base.ParseURL(s) -} diff --git a/server.go b/server.go index f7966568..1d8147a2 100644 --- a/server.go +++ b/server.go @@ -10,9 +10,9 @@ import ( "sync" "time" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) const ( diff --git a/server_conn.go b/server_conn.go index 22d737d8..a8d5e7f5 100644 --- a/server_conn.go +++ b/server_conn.go @@ -13,15 +13,15 @@ import ( "sync" "time" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/bytecounter" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/bytecounter" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" ) func getSessionID(header base.Header) string { @@ -166,6 +166,13 @@ func prepareForDescribe( } } + var profile headers.TransportProfile + if secure { + profile = headers.TransportProfileSAVP + } else { + profile = headers.TransportProfileAVP + } + out.Medias = append(out.Medias, &description.Media{ Type: medi.Type, ID: medi.ID, @@ -173,7 +180,7 @@ func prepareForDescribe( // we have to use trackID=number in order to support clients // like the Grandstream GXV3500. Control: "trackID=" + strconv.FormatInt(int64(i), 10), - Secure: secure, + Profile: profile, KeyMgmtMikey: keyMgmtMikey, Formats: medi.Formats, }) @@ -251,20 +258,6 @@ func (sc *ServerConn) NetConn() net.Conn { return sc.nconn } -// BytesReceived returns the number of read bytes. -// -// Deprecated: replaced by Stats() -func (sc *ServerConn) BytesReceived() uint64 { - return sc.bc.BytesReceived() -} - -// BytesSent returns the number of written bytes. -// -// Deprecated: replaced by Stats() -func (sc *ServerConn) BytesSent() uint64 { - return sc.bc.BytesSent() -} - // SetUserData sets some user data associated with the connection. func (sc *ServerConn) SetUserData(v interface{}) { sc.userData = v @@ -513,7 +506,7 @@ func (sc *ServerConn) handleRequestInner(req *base.Request) (*base.Response, err } var byts []byte - byts, err = desc.Marshal(false) + byts, err = desc.Marshal() if err != nil { return &base.Response{ StatusCode: base.StatusInternalServerError, diff --git a/server_conn_reader.go b/server_conn_reader.go index 149b76b1..25b0776c 100644 --- a/server_conn_reader.go +++ b/server_conn_reader.go @@ -9,9 +9,9 @@ import ( "net/http" "time" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" "github.com/bluenviron/mediacommon/v2/pkg/rewindablereader" ) diff --git a/server_handler.go b/server_handler.go index bd816ac5..010145c3 100644 --- a/server_handler.go +++ b/server_handler.go @@ -1,8 +1,8 @@ package gortsplib import ( - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" ) // ServerHandler is the interface implemented by all the server handlers. @@ -99,15 +99,11 @@ type ServerHandlerOnAnnounce interface { // ServerHandlerOnSetupCtx is the context of OnSetup. type ServerHandlerOnSetupCtx struct { - Session *ServerSession - Conn *ServerConn - Request *base.Request - Path string - Query string - - // Deprecated: replaced by Transport2. - Transport TransportProtocol - + Session *ServerSession + Conn *ServerConn + Request *base.Request + Path string + Query string Transport2 *SessionTransport } @@ -196,22 +192,6 @@ type ServerHandlerOnSetParameter interface { OnSetParameter(*ServerHandlerOnSetParameterCtx) (*base.Response, error) } -// ServerHandlerOnPacketLostCtx is the context of OnPacketLost. -// -// Deprecated: replaced by ServerHandlerOnPacketsLostCtx -type ServerHandlerOnPacketLostCtx struct { - Session *ServerSession - Error error -} - -// ServerHandlerOnPacketLost can be implemented by a ServerHandler. -// -// Deprecated: replaced by ServerHandlerOnPacketsLost -type ServerHandlerOnPacketLost interface { - // called when the server detects lost packets. - OnPacketLost(*ServerHandlerOnPacketLostCtx) -} - // ServerHandlerOnPacketsLostCtx is the context of OnPacketsLost. type ServerHandlerOnPacketsLostCtx struct { Session *ServerSession diff --git a/server_http_tunnel.go b/server_http_tunnel.go index 32b77381..54ccc968 100644 --- a/server_http_tunnel.go +++ b/server_http_tunnel.go @@ -6,7 +6,7 @@ import ( "net" "time" - "github.com/bluenviron/gortsplib/v4/internal/base64streamreader" + "github.com/bluenviron/gortsplib/v5/internal/base64streamreader" ) type serverHTTPTunnel struct { diff --git a/server_multicast_writer.go b/server_multicast_writer.go index 3dcd8834..e5381bf9 100644 --- a/server_multicast_writer.go +++ b/server_multicast_writer.go @@ -4,8 +4,8 @@ import ( "context" "net" - "github.com/bluenviron/gortsplib/v4/internal/asyncprocessor" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/internal/asyncprocessor" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) type serverMulticastWriter struct { diff --git a/server_play_test.go b/server_play_test.go index b41eeed7..8602f2eb 100644 --- a/server_play_test.go +++ b/server_play_test.go @@ -18,14 +18,14 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/net/ipv4" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) func multicastCapableIP(t *testing.T) string { @@ -669,8 +669,6 @@ func TestServerPlay(t *testing.T) { ctx.Session.Path() ctx.Session.Query() ctx.Session.Stream() - ctx.Session.SetuppedTransport() - ctx.Session.SetuppedSecure() ctx.Session.Transport() }() @@ -681,27 +679,37 @@ func TestServerPlay(t *testing.T) { onPlay: func(ctx *ServerHandlerOnPlayCtx) (*base.Response, error) { require.NotNil(t, ctx.Conn.Session()) + var proto Protocol switch ca.transport { case "udp": - v := TransportUDP - require.Equal(t, &v, ctx.Session.SetuppedTransport()) + proto = TransportUDP case "tcp": - v := TransportTCP - require.Equal(t, &v, ctx.Session.SetuppedTransport()) + proto = TransportTCP case "multicast": - v := TransportUDPMulticast - require.Equal(t, &v, ctx.Session.SetuppedTransport()) + proto = TransportUDPMulticast } - require.Equal(t, "param=value", ctx.Session.SetuppedQuery()) - require.Equal(t, stream.Description().Medias, ctx.Session.SetuppedMedias()) + var profile headers.TransportProfile + if ca.secure == "secure" { + profile = headers.TransportProfileSAVP + } else { + profile = headers.TransportProfileAVP + } + + require.Equal(t, &SessionTransport{ + Protocol: proto, + Profile: profile, + }, ctx.Session.Transport()) + + require.Equal(t, "param=value", ctx.Session.Query()) + require.Equal(t, stream.Desc.Medias, ctx.Session.Medias()) // send RTCP packets directly to the session. // these are sent after the response, only if onPlay returns StatusOK. if ca.transport != "multicast" { - err := ctx.Session.WritePacketRTCP(stream.Description().Medias[0], &testRTCPPacket) + err := ctx.Session.WritePacketRTCP(stream.Desc.Medias[0], &testRTCPPacket) require.NoError(t, err) } @@ -711,7 +719,7 @@ func TestServerPlay(t *testing.T) { return } - require.Equal(t, stream.Description().Medias[0], medi) + require.Equal(t, stream.Desc.Medias[0], medi) require.Equal(t, &testRTCPPacket, pkt) close(framesReceived) }) @@ -721,9 +729,9 @@ func TestServerPlay(t *testing.T) { // ServerStream.WritePacket*() go func() { time.Sleep(500 * time.Millisecond) - err := stream.WritePacketRTCP(stream.Description().Medias[0], &testRTCPPacket) + err := stream.WritePacketRTCP(stream.Desc.Medias[0], &testRTCPPacket) require.NoError(t, err) - err = stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err = stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) }() @@ -1124,7 +1132,7 @@ func TestServerPlaySocketError(t *testing.T) { defer t.Stop() for range t.C { - err := stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) if err != nil { return } @@ -1494,7 +1502,7 @@ func TestServerPlayRTCPReport(t *testing.T) { curTimeMutex.Unlock() err = stream.WritePacketRTPWithNTP( - stream.Description().Medias[0], + stream.Desc.Medias[0], &rtp.Packet{ Header: rtp.Header{ Version: 2, @@ -1625,7 +1633,7 @@ func TestServerPlayTCPResponseBeforeFrames(t *testing.T) { go func() { defer close(writerDone) - err := stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) ti := time.NewTicker(50 * time.Millisecond) @@ -1634,7 +1642,7 @@ func TestServerPlayTCPResponseBeforeFrames(t *testing.T) { for { select { case <-ti.C: - err = stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err = stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) case <-writerTerminate: return @@ -1721,7 +1729,7 @@ func TestServerPlayPause(t *testing.T) { for { select { case <-ti.C: - err := stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) case <-writerTerminate: return @@ -1820,10 +1828,10 @@ func TestServerPlayPlayPausePausePlay(t *testing.T) { select { case <-ti.C: if ca == "stream" { - err := stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) } else { - err := ctx.Session.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := ctx.Session.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) } @@ -2181,9 +2189,9 @@ func TestServerPlayPartialMedias(t *testing.T) { onPlay: func(_ *ServerHandlerOnPlayCtx) (*base.Response, error) { go func() { time.Sleep(500 * time.Millisecond) - err := stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err := stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) - err = stream.WritePacketRTP(stream.Description().Medias[1], &testRTPPacket) + err = stream.WritePacketRTP(stream.Desc.Medias[1], &testRTPPacket) require.NoError(t, err) }() @@ -2334,7 +2342,7 @@ func TestServerPlayAdditionalInfos(t *testing.T) { require.NoError(t, err) defer stream.Close() - err = stream.WritePacketRTP(stream.Description().Medias[0], &rtp.Packet{ + err = stream.WritePacketRTP(stream.Desc.Medias[0], &rtp.Packet{ Header: rtp.Header{ Version: 2, PayloadType: 96, @@ -2370,7 +2378,7 @@ func TestServerPlayAdditionalInfos(t *testing.T) { require.NotNil(t, ssrcs[0]) require.NotNil(t, ssrcs[1]) - err = stream.WritePacketRTP(stream.Description().Medias[1], &rtp.Packet{ + err = stream.WritePacketRTP(stream.Desc.Medias[1], &rtp.Packet{ Header: rtp.Header{ Version: 2, PayloadType: 96, @@ -2489,7 +2497,7 @@ func TestServerPlayNoInterleavedIDs(t *testing.T) { doPlay(t, conn, "rtsp://localhost:8554/teststream", session) for i := range 2 { - err = stream.WritePacketRTP(stream.Description().Medias[i], &testRTPPacket) + err = stream.WritePacketRTP(stream.Desc.Medias[i], &testRTPPacket) require.NoError(t, err) var f *base.InterleavedFrame @@ -2575,7 +2583,7 @@ func TestServerPlayStreamStats(t *testing.T) { doPlay(t, conn, "rtsp://localhost:8554/teststream", session) } - err = stream.WritePacketRTP(stream.Description().Medias[0], &testRTPPacket) + err = stream.WritePacketRTP(stream.Desc.Medias[0], &testRTPPacket) require.NoError(t, err) st := stream.Stats() @@ -2583,14 +2591,14 @@ func TestServerPlayStreamStats(t *testing.T) { BytesSent: 32, RTPPacketsSent: 2, Medias: map[*description.Media]ServerStreamStatsMedia{ - stream.Description().Medias[0]: { + stream.Desc.Medias[0]: { BytesSent: 32, RTCPPacketsSent: 0, Formats: map[format.Format]ServerStreamStatsFormat{ - stream.Description().Medias[0].Formats[0]: { + stream.Desc.Medias[0].Formats[0]: { RTPPacketsSent: 2, - LocalSSRC: st.Medias[stream.Description().Medias[0]]. - Formats[stream.Description().Medias[0].Formats[0]].LocalSSRC, + LocalSSRC: st.Medias[stream.Desc.Medias[0]]. + Formats[stream.Desc.Medias[0].Formats[0]].LocalSSRC, }, }, }, diff --git a/server_record_test.go b/server_record_test.go index 63eda07a..926c7165 100644 --- a/server_record_test.go +++ b/server_record_test.go @@ -15,14 +15,14 @@ import ( psdp "github.com/pion/sdp/v3" "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) func doAnnounce(t *testing.T, conn *conn.Conn, u string, medias []*description.Media) { @@ -341,7 +341,7 @@ func TestServerRecordPath(t *testing.T) { media := testH264Media media.Control = ca.control - enc, err := media.Marshal2() + enc, err := media.Marshal() require.NoError(t, err) sout := &sdp.SessionDescription{ @@ -621,18 +621,29 @@ func TestServerRecord(t *testing.T) { }, nil, nil }, onRecord: func(ctx *ServerHandlerOnRecordCtx) (*base.Response, error) { + var proto Protocol switch ca.transport { case "udp": - v := TransportUDP - require.Equal(t, &v, ctx.Session.SetuppedTransport()) + proto = TransportUDP case "tcp": - v := TransportTCP - require.Equal(t, &v, ctx.Session.SetuppedTransport()) + proto = TransportTCP } - require.Equal(t, "param=value", ctx.Session.SetuppedQuery()) - require.Equal(t, ctx.Session.AnnouncedDescription().Medias, ctx.Session.SetuppedMedias()) + var profile headers.TransportProfile + if ca.secure == "secure" { + profile = headers.TransportProfileSAVP + } else { + profile = headers.TransportProfileAVP + } + + require.Equal(t, &SessionTransport{ + Protocol: proto, + Profile: profile, + }, ctx.Session.Transport()) + + require.Equal(t, "param=value", ctx.Session.Query()) + require.Equal(t, ctx.Session.AnnouncedDescription().Medias, ctx.Session.Medias()) // queue sending of RTCP packets. // these are sent after the response, only if onRecord returns StatusOK. diff --git a/server_session.go b/server_session.go index 75fd35ee..504704d0 100644 --- a/server_session.go +++ b/server_session.go @@ -17,18 +17,18 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/internal/asyncprocessor" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/mikey" - "github.com/bluenviron/gortsplib/v4/pkg/ntp" - "github.com/bluenviron/gortsplib/v4/pkg/rtpreceiver" - "github.com/bluenviron/gortsplib/v4/pkg/rtpsender" - "github.com/bluenviron/gortsplib/v4/pkg/rtptime" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/internal/asyncprocessor" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/mikey" + "github.com/bluenviron/gortsplib/v5/pkg/ntp" + "github.com/bluenviron/gortsplib/v5/pkg/rtpreceiver" + "github.com/bluenviron/gortsplib/v5/pkg/rtpsender" + "github.com/bluenviron/gortsplib/v5/pkg/rtptime" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) type readFunc func([]byte) bool @@ -447,7 +447,7 @@ type ServerSession struct { udpCheckStreamTimer *time.Timer writerMutex sync.RWMutex writer *asyncprocessor.Processor - timeDecoder *rtptime.GlobalDecoder2 + timeDecoder *rtptime.GlobalDecoder tcpFrame *base.InterleavedFrame tcpBuffer []byte @@ -485,28 +485,6 @@ func (ss *ServerSession) Close() { ss.ctxCancel() } -// BytesReceived returns the number of read bytes. -// -// Deprecated: replaced by Stats() -func (ss *ServerSession) BytesReceived() uint64 { - v := uint64(0) - for _, sm := range ss.setuppedMedias { - v += atomic.LoadUint64(sm.bytesReceived) - } - return v -} - -// BytesSent returns the number of written bytes. -// -// Deprecated: replaced by Stats() -func (ss *ServerSession) BytesSent() uint64 { - v := uint64(0) - for _, sm := range ss.setuppedMedias { - v += atomic.LoadUint64(sm.bytesSent) - } - return v -} - // State returns the state of the session. func (ss *ServerSession) State() ServerSessionState { ss.propsMutex.RLock() @@ -515,41 +493,6 @@ func (ss *ServerSession) State() ServerSessionState { return ss.state } -// SetuppedTransport returns the transport negotiated during SETUP. -// -// Deprecated: replaced by Transport. -func (ss *ServerSession) SetuppedTransport() *TransportProtocol { - ss.propsMutex.RLock() - defer ss.propsMutex.RUnlock() - - if ss.setuppedTransport == nil { - return nil - } - return &ss.setuppedTransport.Protocol -} - -// SetuppedSecure returns whether a secure profile is in use. -// If this is false, it does not mean that the stream is not secure, since -// there are some combinations that are secure nonetheless, like RTSPS+TCP+unsecure. -// -// Deprecated: replaced by Transport. -func (ss *ServerSession) SetuppedSecure() bool { - ss.propsMutex.RLock() - defer ss.propsMutex.RUnlock() - - if ss.setuppedTransport == nil { - return false - } - return isSecure(ss.setuppedTransport.Profile) -} - -// SetuppedStream returns the stream associated with the session. -// -// Deprecated: replaced by Stream. -func (ss *ServerSession) SetuppedStream() *ServerStream { - return ss.Stream() -} - // Stream returns the stream associated with the session. func (ss *ServerSession) Stream() *ServerStream { ss.propsMutex.RLock() @@ -558,13 +501,6 @@ func (ss *ServerSession) Stream() *ServerStream { return ss.setuppedStream } -// SetuppedPath returns the path sent during SETUP or ANNOUNCE. -// -// Deprecated: replaced by Path. -func (ss *ServerSession) SetuppedPath() string { - return ss.Path() -} - // Path returns the path sent during SETUP or ANNOUNCE. func (ss *ServerSession) Path() string { ss.propsMutex.RLock() @@ -573,13 +509,6 @@ func (ss *ServerSession) Path() string { return ss.setuppedPath } -// SetuppedQuery returns the query sent during SETUP or ANNOUNCE. -// -// Deprecated: replaced by Query. -func (ss *ServerSession) SetuppedQuery() string { - return ss.Query() -} - // Query returns the query sent during SETUP or ANNOUNCE. func (ss *ServerSession) Query() string { ss.propsMutex.RLock() @@ -596,13 +525,6 @@ func (ss *ServerSession) AnnouncedDescription() *description.Session { return ss.announcedDesc } -// SetuppedMedias returns the setupped medias. -// -// Deprecated: replaced by Medias. -func (ss *ServerSession) SetuppedMedias() []*description.Media { - return ss.Medias() -} - // Medias returns setupped medias. func (ss *ServerSession) Medias() []*description.Media { ss.propsMutex.RLock() @@ -635,12 +557,12 @@ func (ss *ServerSession) Transport() *SessionTransport { } // Stats returns server session statistics. -func (ss *ServerSession) Stats() *StatsSession { +func (ss *ServerSession) Stats() *SessionStats { ss.propsMutex.RLock() defer ss.propsMutex.RUnlock() - mediaStats := func() map[*description.Media]StatsSessionMedia { //nolint:dupl - ret := make(map[*description.Media]StatsSessionMedia, len(ss.setuppedMedias)) + mediaStats := func() map[*description.Media]SessionStatsMedia { //nolint:dupl + ret := make(map[*description.Media]SessionStatsMedia, len(ss.setuppedMedias)) for med, sm := range ss.setuppedMedias { ret[med] = SessionStatsMedia{ @@ -1207,7 +1129,7 @@ func (ss *ServerSession) handleRequestInner(sc *ServerConn, req *base.Request) ( query = ss.setuppedQuery } - var protocol TransportProtocol + var protocol Protocol switch inTH.Protocol { case headers.TransportProtocolUDP: @@ -1300,12 +1222,11 @@ func (ss *ServerSession) handleRequestInner(sc *ServerConn, req *base.Request) ( } res, stream, err := ss.s.Handler.(ServerHandlerOnSetup).OnSetup(&ServerHandlerOnSetupCtx{ - Session: ss, - Conn: sc, - Request: req, - Path: path, - Query: query, - Transport: protocol, + Session: ss, + Conn: sc, + Request: req, + Path: path, + Query: query, Transport2: &SessionTransport{ Protocol: protocol, Profile: inTH.Profile, @@ -1596,7 +1517,7 @@ func (ss *ServerSession) handleRequestInner(sc *ServerConn, req *base.Request) ( v := ss.s.timeNow().Unix() ss.udpLastPacketTime = &v - ss.timeDecoder = &rtptime.GlobalDecoder2{} + ss.timeDecoder = &rtptime.GlobalDecoder{} ss.timeDecoder.Initialize() for _, sm := range ss.setuppedMedias { @@ -1691,7 +1612,7 @@ func (ss *ServerSession) handleRequestInner(sc *ServerConn, req *base.Request) ( v := ss.s.timeNow().Unix() ss.udpLastPacketTime = &v - ss.timeDecoder = &rtptime.GlobalDecoder2{} + ss.timeDecoder = &rtptime.GlobalDecoder{} ss.timeDecoder.Initialize() for _, sm := range ss.setuppedMedias { @@ -1913,23 +1834,7 @@ func (ss *ServerSession) WritePacketRTCP(medi *description.Media, pkt rtcp.Packe // PacketPTS returns the PTS (presentation timestamp) of an incoming RTP packet. // It is computed by decoding the packet timestamp and sychronizing it with other tracks. -// -// Deprecated: replaced by PacketPTS2. -func (ss *ServerSession) PacketPTS(medi *description.Media, pkt *rtp.Packet) (time.Duration, bool) { - sm := ss.setuppedMedias[medi] - sf := sm.formats[pkt.PayloadType] - - v, ok := ss.timeDecoder.Decode(sf.format, pkt) - if !ok { - return 0, false - } - - return multiplyAndDivide(time.Duration(v), time.Second, time.Duration(sf.format.ClockRate())), true -} - -// PacketPTS2 returns the PTS (presentation timestamp) of an incoming RTP packet. -// It is computed by decoding the packet timestamp and sychronizing it with other tracks. -func (ss *ServerSession) PacketPTS2(medi *description.Media, pkt *rtp.Packet) (int64, bool) { +func (ss *ServerSession) PacketPTS(medi *description.Media, pkt *rtp.Packet) (int64, bool) { sm := ss.setuppedMedias[medi] sf := sm.formats[pkt.PayloadType] return ss.timeDecoder.Decode(sf.format, pkt) diff --git a/server_session_format.go b/server_session_format.go index 4d080afd..c4e0ee8c 100644 --- a/server_session_format.go +++ b/server_session_format.go @@ -8,9 +8,9 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/rtpreceiver" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/rtpreceiver" ) type serverSessionFormat struct { @@ -43,7 +43,7 @@ func (sf *serverSessionFormat) initialize() { if sf.sm.ss.state == ServerSessionStatePreRecord || sf.sm.media.IsBackChannel { sf.rtpReceiver = &rtpreceiver.Receiver{ ClockRate: sf.format.ClockRate(), - LocalSSRC: &sf.localSSRC, + LocalSSRC: sf.localSSRC, UnrealiableTransport: udp, Period: sf.sm.ss.s.receiverReportPeriod, TimeNow: sf.sm.ss.s.timeNow, @@ -78,7 +78,7 @@ func (sf *serverSessionFormat) remoteSSRC() (uint32, bool) { } func (sf *serverSessionFormat) readPacketRTP(pkt *rtp.Packet, now time.Time) { - pkts, lost, err := sf.rtpReceiver.ProcessPacket2(pkt, now, sf.format.PTSEqualsDTS(pkt)) + pkts, lost, err := sf.rtpReceiver.ProcessPacket(pkt, now, sf.format.PTSEqualsDTS(pkt)) if err != nil { sf.sm.onPacketRTPDecodeError(err) return @@ -92,11 +92,6 @@ func (sf *serverSessionFormat) readPacketRTP(pkt *rtp.Packet, now time.Time) { Session: sf.sm.ss, Lost: lost, }) - } else if h, ok2 := sf.sm.ss.s.Handler.(ServerHandlerOnPacketLost); ok2 { - h.OnPacketLost(&ServerHandlerOnPacketLostCtx{ - Session: sf.sm.ss, - Error: liberrors.ErrServerRTPPacketsLost{Lost: uint(lost)}, //nolint:staticcheck - }) } else { log.Printf("%d RTP %s lost", lost, diff --git a/server_session_media.go b/server_session_media.go index 247175ce..fa06aa3f 100644 --- a/server_session_media.go +++ b/server_session_media.go @@ -10,8 +10,8 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) type serverSessionMedia struct { diff --git a/server_stream.go b/server_stream.go index a12029a2..0cf54fb5 100644 --- a/server_stream.go +++ b/server_stream.go @@ -10,9 +10,9 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" ) func serverStreamExtractExistingSSRCs(medias map[*description.Media]*serverStreamMedia) []uint32 { @@ -25,21 +25,6 @@ func serverStreamExtractExistingSSRCs(medias map[*description.Media]*serverStrea return ret } -// NewServerStream allocates a ServerStream. -// -// Deprecated: replaced by ServerStream.Initialize(). -func NewServerStream(s *Server, desc *description.Session) *ServerStream { - st := &ServerStream{ - Server: s, - Desc: desc, - } - err := st.Initialize() - if err != nil { - panic(err) - } - return st -} - // ServerStream represents a data stream. // This is in charge of // - storing stream description and statistics @@ -135,24 +120,6 @@ func (st *ServerStream) Close() { } } -// BytesSent returns the number of written bytes. -// -// Deprecated: replaced by Stats() -func (st *ServerStream) BytesSent() uint64 { - v := uint64(0) - for _, me := range st.medias { - v += atomic.LoadUint64(me.bytesSent) - } - return v -} - -// Description returns the description of the stream. -// -// Deprecated: use ServerStream.Desc. -func (st *ServerStream) Description() *description.Session { - return st.Desc -} - // Stats returns stream statistics. func (st *ServerStream) Stats() *ServerStreamStats { mediaStats := func() map[*description.Media]ServerStreamStatsMedia { @@ -211,7 +178,7 @@ func (st *ServerStream) Stats() *ServerStreamStats { func (st *ServerStream) readerAdd( ss *ServerSession, clientPorts *[2]int, - protocol TransportProtocol, + protocol Protocol, ) error { st.mutex.Lock() defer st.mutex.Unlock() diff --git a/server_stream_format.go b/server_stream_format.go index 1cabc276..2b3c5d14 100644 --- a/server_stream_format.go +++ b/server_stream_format.go @@ -8,8 +8,8 @@ import ( "github.com/pion/rtcp" "github.com/pion/rtp" - "github.com/bluenviron/gortsplib/v4/pkg/format" - "github.com/bluenviron/gortsplib/v4/pkg/rtpsender" + "github.com/bluenviron/gortsplib/v5/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/rtpsender" ) func randUint32() (uint32, error) { diff --git a/server_stream_media.go b/server_stream_media.go index 4c41fd12..905c1c5c 100644 --- a/server_stream_media.go +++ b/server_stream_media.go @@ -4,7 +4,7 @@ import ( "fmt" "sync/atomic" - "github.com/bluenviron/gortsplib/v4/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/description" "github.com/pion/rtcp" ) diff --git a/server_stream_stats.go b/server_stream_stats.go index e83a1ecf..a3784ff2 100644 --- a/server_stream_stats.go +++ b/server_stream_stats.go @@ -1,8 +1,8 @@ package gortsplib import ( - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) // ServerStreamStatsFormat are stream format statistics. diff --git a/server_test.go b/server_test.go index a241d1f1..6172c180 100644 --- a/server_test.go +++ b/server_test.go @@ -13,13 +13,13 @@ import ( "github.com/stretchr/testify/require" - "github.com/bluenviron/gortsplib/v4/pkg/auth" - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/conn" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/liberrors" - "github.com/bluenviron/gortsplib/v4/pkg/sdp" + "github.com/bluenviron/gortsplib/v5/pkg/auth" + "github.com/bluenviron/gortsplib/v5/pkg/base" + "github.com/bluenviron/gortsplib/v5/pkg/conn" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/headers" + "github.com/bluenviron/gortsplib/v5/pkg/liberrors" + "github.com/bluenviron/gortsplib/v5/pkg/sdp" ) var serverCert = []byte(`-----BEGIN CERTIFICATE----- diff --git a/server_udp_listener.go b/server_udp_listener.go index 3aeb5855..bc36f09c 100644 --- a/server_udp_listener.go +++ b/server_udp_listener.go @@ -7,8 +7,8 @@ import ( "sync" "time" - "github.com/bluenviron/gortsplib/v4/pkg/multicast" - "github.com/bluenviron/gortsplib/v4/pkg/readbuffer" + "github.com/bluenviron/gortsplib/v5/pkg/multicast" + "github.com/bluenviron/gortsplib/v5/pkg/readbuffer" ) type clientAddr struct { diff --git a/session_stats.go b/session_stats.go index 3b7cca20..a289c832 100644 --- a/session_stats.go +++ b/session_stats.go @@ -3,25 +3,10 @@ package gortsplib import ( "time" - "github.com/bluenviron/gortsplib/v4/pkg/description" - "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v5/pkg/description" + "github.com/bluenviron/gortsplib/v5/pkg/format" ) -// StatsSessionFormat are session format statistics. -// -// Deprecated: replaced by SessionStatsFormat -type StatsSessionFormat = SessionStatsFormat - -// StatsSessionMedia are session media statistics. -// -// Deprecated: replaced by SessionStatsMedia -type StatsSessionMedia = SessionStatsMedia - -// StatsSession are session statistics. -// -// Deprecated: replaced by SessionStats. -type StatsSession = SessionStats - // SessionStatsFormat are session format statistics. type SessionStatsFormat struct { // number of RTP packets correctly received and processed diff --git a/session_transport.go b/session_transport.go index a3acc3ab..2a023f26 100644 --- a/session_transport.go +++ b/session_transport.go @@ -1,9 +1,33 @@ package gortsplib -import "github.com/bluenviron/gortsplib/v4/pkg/headers" +import "github.com/bluenviron/gortsplib/v5/pkg/headers" + +// Protocol is a RTSP transport protocol. +type Protocol int + +// transport protocols. +const ( + TransportUDP Protocol = iota + TransportUDPMulticast + TransportTCP +) + +var transportLabels = map[Protocol]string{ + TransportUDP: "UDP", + TransportUDPMulticast: "UDP-multicast", + TransportTCP: "TCP", +} + +// String implements fmt.Stringer. +func (t Protocol) String() string { + if l, ok := transportLabels[t]; ok { + return l + } + return "unknown" +} // SessionTransport contains details about the transport of a session. type SessionTransport struct { - Protocol TransportProtocol + Protocol Protocol Profile headers.TransportProfile } diff --git a/transport_protocol_test.go b/session_transport_test.go similarity index 72% rename from transport_protocol_test.go rename to session_transport_test.go index 8082a51d..4c1b40e7 100644 --- a/transport_protocol_test.go +++ b/session_transport_test.go @@ -6,10 +6,10 @@ import ( "github.com/stretchr/testify/require" ) -func TestTransportProtocolString(t *testing.T) { +func TestProtocolString(t *testing.T) { tr := TransportUDPMulticast require.NotEqual(t, "unknown", tr.String()) - tr = TransportProtocol(15) + tr = Protocol(15) require.Equal(t, "unknown", tr.String()) } diff --git a/transport_protocol.go b/transport_protocol.go deleted file mode 100644 index 66398a0f..00000000 --- a/transport_protocol.go +++ /dev/null @@ -1,30 +0,0 @@ -package gortsplib - -// Transport is a RTSP transport protocol. -// -// Deprecated: renamed into TransportProtocol. -type Transport = TransportProtocol - -// TransportProtocol is a RTSP transport protocol. -type TransportProtocol int - -// transport protocols. -const ( - TransportUDP TransportProtocol = iota - TransportUDPMulticast - TransportTCP -) - -var transportLabels = map[TransportProtocol]string{ - TransportUDP: "UDP", - TransportUDPMulticast: "UDP-multicast", - TransportTCP: "TCP", -} - -// String implements fmt.Stringer. -func (t TransportProtocol) String() string { - if l, ok := transportLabels[t]; ok { - return l - } - return "unknown" -} diff --git a/tunnel.go b/tunnel.go deleted file mode 100644 index f3f58648..00000000 --- a/tunnel.go +++ /dev/null @@ -1,10 +0,0 @@ -package gortsplib - -// Tunnel is a tunnel method. -type Tunnel int - -// tunnel methods. -const ( - TunnelNone Tunnel = iota - TunnelHTTP -)