diff --git a/client.go b/client.go index 15378853..b71fe76c 100644 --- a/client.go +++ b/client.go @@ -207,11 +207,6 @@ type OnPacketRTCPFunc func(rtcp.Packet) // OnPacketRTCPAnyFunc is the prototype of the callback passed to OnPacketRTCPAny(). type OnPacketRTCPAnyFunc func(*media.Media, rtcp.Packet) -// ClientLogFunc is the prototype of the log function. -// -// Deprecated: Log() is deprecated. -type ClientLogFunc func(level LogLevel, format string, args ...interface{}) - // Client is a RTSP client. type Client struct { // @@ -257,8 +252,6 @@ type Client struct { BytesReceived *uint64 // pointer to a variable that stores sent bytes. BytesSent *uint64 - // Deprecated: disabling redirects doesn't improve security. - RedirectDisable bool // // system functions (all optional) @@ -283,8 +276,6 @@ type Client struct { OnPacketLost ClientOnPacketLostFunc // called when a non-fatal decode error occurs. OnDecodeError ClientOnDecodeErrorFunc - // Deprecated: replaced by OnTransportSwitch, OnPacketLost, OnDecodeError - Log ClientLogFunc // // private @@ -383,29 +374,14 @@ func (c *Client) Start(scheme string, host string) error { c.OnResponse = func(*base.Response) { } } - if c.Log != nil && c.OnTransportSwitch == nil { - c.OnTransportSwitch = func(err error) { - c.Log(LogLevelWarn, "%v", err) - } - } if c.OnTransportSwitch == nil { c.OnTransportSwitch = func(err error) { } } - if c.Log != nil && c.OnPacketLost == nil { - c.OnPacketLost = func(err error) { - c.Log(LogLevelWarn, "%v", err) - } - } if c.OnPacketLost == nil { c.OnPacketLost = func(err error) { } } - if c.Log != nil && c.OnDecodeError == nil { - c.OnDecodeError = func(err error) { - c.Log(LogLevelWarn, "%v", err) - } - } if c.OnDecodeError == nil { c.OnDecodeError = func(err error) { } @@ -1016,8 +992,7 @@ func (c *Client) doDescribe(u *url.URL) (media.Medias, *url.URL, *base.Response, if res.StatusCode != base.StatusOK { // redirect - if !c.RedirectDisable && - res.StatusCode >= base.StatusMovedPermanently && + if res.StatusCode >= base.StatusMovedPermanently && res.StatusCode <= base.StatusUseProxy && len(res.Header["Location"]) == 1 { c.reset() diff --git a/loglevel.go b/loglevel.go deleted file mode 100644 index 04ac5cef..00000000 --- a/loglevel.go +++ /dev/null @@ -1,16 +0,0 @@ -package gortsplib - -// LogLevel is a log level. -// -// Deprecated: Log() is deprecated. -type LogLevel int - -// Log levels. -// -// Deprecated: Log() is deprecated. -const ( - LogLevelDebug LogLevel = iota + 1 - LogLevelInfo - LogLevelWarn - LogLevelError -) diff --git a/pkg/auth/validate.go b/pkg/auth/validate.go index e76aa314..614a0004 100644 --- a/pkg/auth/validate.go +++ b/pkg/auth/validate.go @@ -1,6 +1,7 @@ package auth import ( + "crypto/md5" "crypto/rand" "encoding/hex" "fmt" @@ -10,6 +11,12 @@ import ( "github.com/bluenviron/gortsplib/v4/pkg/url" ) +func md5Hex(in string) string { + h := md5.New() + h.Write([]byte(in)) + return hex.EncodeToString(h.Sum(nil)) +} + // GenerateNonce2 generates a nonce that can be used in Validate(). func GenerateNonce2() (string, error) { byts := make([]byte, 16) @@ -21,17 +28,6 @@ func GenerateNonce2() (string, error) { return hex.EncodeToString(byts), nil } -// GenerateNonce generates a nonce that can be used in Validate(). -// -// Deprecated: use GenerateNonce2. -func GenerateNonce() string { - v, err := GenerateNonce2() - if err != nil { - panic(err) - } - return v -} - // GenerateWWWAuthenticate generates a WWW-Authenticate header. func GenerateWWWAuthenticate(methods []headers.AuthMethod, realm string, nonce string) base.HeaderValue { if methods == nil { diff --git a/pkg/auth/validator.go b/pkg/auth/validator.go deleted file mode 100644 index a1ea7846..00000000 --- a/pkg/auth/validator.go +++ /dev/null @@ -1,194 +0,0 @@ -package auth - -import ( - "crypto/md5" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "fmt" - "strings" - - "github.com/bluenviron/gortsplib/v4/pkg/base" - "github.com/bluenviron/gortsplib/v4/pkg/headers" - "github.com/bluenviron/gortsplib/v4/pkg/url" -) - -func md5Hex(in string) string { - h := md5.New() - h.Write([]byte(in)) - return hex.EncodeToString(h.Sum(nil)) -} - -func sha256Base64(in string) string { - h := sha256.New() - h.Write([]byte(in)) - return base64.StdEncoding.EncodeToString(h.Sum(nil)) -} - -// Validator allows to validate credentials generated by a Sender. -// -// Deprecated: Validator{} has been replaced by Validate() -type Validator struct { - user string - userHashed bool - pass string - passHashed bool - methods []headers.AuthMethod - realm string - nonce string -} - -// NewValidator allocates a Validator. -// If methods is nil, the Basic and Digest methods are used. -// -// Deprecated: Validator{} has been replaced by Validate() -func NewValidator(user string, pass string, methods []headers.AuthMethod) *Validator { - if methods == nil { - methods = []headers.AuthMethod{headers.AuthBasic, headers.AuthDigest} - } - - userHashed := false - if strings.HasPrefix(user, "sha256:") { - user = strings.TrimPrefix(user, "sha256:") - userHashed = true - } - - passHashed := false - if strings.HasPrefix(pass, "sha256:") { - pass = strings.TrimPrefix(pass, "sha256:") - passHashed = true - } - - // if credentials are hashed, only basic auth is supported - if userHashed || passHashed { - methods = []headers.AuthMethod{headers.AuthBasic} - } - - nonce := GenerateNonce() - - return &Validator{ - user: user, - userHashed: userHashed, - pass: pass, - passHashed: passHashed, - methods: methods, - realm: "IPCAM", - nonce: nonce, - } -} - -// Header generates the WWW-Authenticate header needed by a client to -// authenticate. -// -// Deprecated: Validator{} has been replaced by Validate() -func (va *Validator) Header() base.HeaderValue { - var ret base.HeaderValue - for _, m := range va.methods { - switch m { - case headers.AuthBasic: - ret = append(ret, (&headers.Authenticate{ - Method: headers.AuthBasic, - Realm: &va.realm, - }).Marshal()...) - - case headers.AuthDigest: - ret = append(ret, headers.Authenticate{ - Method: headers.AuthDigest, - Realm: &va.realm, - Nonce: &va.nonce, - }.Marshal()...) - } - } - return ret -} - -// ValidateRequest validates a request sent by a client. -// -// Deprecated: Validator{} has been replaced by Validate() -func (va *Validator) ValidateRequest(req *base.Request, baseURL *url.URL) error { - var auth headers.Authorization - err := auth.Unmarshal(req.Header["Authorization"]) - if err != nil { - return err - } - - switch auth.Method { - case headers.AuthBasic: - if !va.userHashed { - if auth.BasicUser != va.user { - return fmt.Errorf("wrong response") - } - } else { - if sha256Base64(auth.BasicUser) != va.user { - return fmt.Errorf("wrong response") - } - } - - if !va.passHashed { - if auth.BasicPass != va.pass { - return fmt.Errorf("wrong response") - } - } else { - if sha256Base64(auth.BasicPass) != va.pass { - return fmt.Errorf("wrong response") - } - } - - default: // headers.AuthDigest - if auth.DigestValues.Realm == nil { - return fmt.Errorf("realm is missing") - } - - if auth.DigestValues.Nonce == nil { - return fmt.Errorf("nonce is missing") - } - - if auth.DigestValues.Username == nil { - return fmt.Errorf("username is missing") - } - - if auth.DigestValues.URI == nil { - return fmt.Errorf("uri is missing") - } - - if auth.DigestValues.Response == nil { - return fmt.Errorf("response is missing") - } - - if *auth.DigestValues.Nonce != va.nonce { - return fmt.Errorf("wrong nonce") - } - - if *auth.DigestValues.Realm != va.realm { - return fmt.Errorf("wrong realm") - } - - if *auth.DigestValues.Username != va.user { - return fmt.Errorf("wrong username") - } - - ur := req.URL - - if *auth.DigestValues.URI != ur.String() { - // in SETUP requests, VLC strips the control attribute. - // try again with the base URL. - if baseURL != nil { - ur = baseURL - if *auth.DigestValues.URI != ur.String() { - return fmt.Errorf("wrong URL") - } - } else { - return fmt.Errorf("wrong URL") - } - } - - response := md5Hex(md5Hex(va.user+":"+va.realm+":"+va.pass) + - ":" + va.nonce + ":" + md5Hex(string(req.Method)+":"+ur.String())) - - if *auth.DigestValues.Response != response { - return fmt.Errorf("wrong response") - } - } - - return nil -} diff --git a/pkg/auth/validator_test.go b/pkg/auth/validator_test.go deleted file mode 100644 index f43537b0..00000000 --- a/pkg/auth/validator_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package auth - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/bluenviron/gortsplib/v4/pkg/base" -) - -func TestValidatorErrors(t *testing.T) { - for _, ca := range []struct { - name string - hv base.HeaderValue - err string - }{ - { - "invalid auth", - base.HeaderValue{`Invalid`}, - "invalid authorization header", - }, - { - "digest missing realm", - base.HeaderValue{`Digest `}, - "realm is missing", - }, - { - "digest missing nonce", - base.HeaderValue{`Digest realm=123`}, - "nonce is missing", - }, - { - "digest missing username", - base.HeaderValue{`Digest realm=123,nonce=123`}, - "username is missing", - }, - { - "digest missing uri", - base.HeaderValue{`Digest realm=123,nonce=123,username=123`}, - "uri is missing", - }, - { - "digest missing response", - base.HeaderValue{`Digest realm=123,nonce=123,username=123,uri=123`}, - "response is missing", - }, - { - "digest wrong nonce", - base.HeaderValue{`Digest realm=123,nonce=123,username=123,uri=123,response=123`}, - "wrong nonce", - }, - { - "digest wrong realm", - base.HeaderValue{`Digest realm=123,nonce=abcde,username=123,uri=123,response=123`}, - "wrong realm", - }, - } { - t.Run(ca.name, func(t *testing.T) { - va := NewValidator("myuser", "mypass", nil) - va.nonce = "abcde" - err := va.ValidateRequest(&base.Request{ - Method: base.Describe, - URL: nil, - Header: base.Header{ - "Authorization": ca.hv, - }, - }, nil) - require.EqualError(t, err, ca.err) - }) - } -} diff --git a/pkg/formats/av1.go b/pkg/formats/av1.go index b39445aa..5a947b08 100644 --- a/pkg/formats/av1.go +++ b/pkg/formats/av1.go @@ -60,13 +60,6 @@ func (f *AV1) Codec() string { return "AV1" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *AV1) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *AV1) ClockRate() int { return 90000 @@ -104,14 +97,6 @@ func (f *AV1) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *AV1) CreateDecoder() *rtpav1.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *AV1) CreateDecoder2() (*rtpav1.Decoder, error) { d := &rtpav1.Decoder{} @@ -124,14 +109,6 @@ func (f *AV1) CreateDecoder2() (*rtpav1.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *AV1) CreateEncoder() *rtpav1.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *AV1) CreateEncoder2() (*rtpav1.Encoder, error) { e := &rtpav1.Encoder{ diff --git a/pkg/formats/av1_test.go b/pkg/formats/av1_test.go index ce4d327b..82319a1d 100644 --- a/pkg/formats/av1_test.go +++ b/pkg/formats/av1_test.go @@ -11,7 +11,7 @@ func TestAV1Attributes(t *testing.T) { format := &AV1{ PayloadTyp: 100, } - require.Equal(t, "AV1", format.String()) + require.Equal(t, "AV1", format.Codec()) require.Equal(t, 90000, format.ClockRate()) require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{})) } diff --git a/pkg/formats/format.go b/pkg/formats/format.go index 688fa94b..8e475a89 100644 --- a/pkg/formats/format.go +++ b/pkg/formats/format.go @@ -24,9 +24,6 @@ type Format interface { // Codec returns the codec name. Codec() string - // Deprecated: replaced by Codec(). - String() string - // ClockRate returns the clock rate. ClockRate() int diff --git a/pkg/formats/g711.go b/pkg/formats/g711.go index 105ea8a5..ebaadea9 100644 --- a/pkg/formats/g711.go +++ b/pkg/formats/g711.go @@ -23,13 +23,6 @@ func (f *G711) Codec() string { return "G711" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *G711) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *G711) ClockRate() int { return 8000 @@ -61,14 +54,6 @@ func (f *G711) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *G711) CreateDecoder() *rtpsimpleaudio.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *G711) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { d := &rtpsimpleaudio.Decoder{ @@ -83,14 +68,6 @@ func (f *G711) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *G711) CreateEncoder() *rtpsimpleaudio.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *G711) CreateEncoder2() (*rtpsimpleaudio.Encoder, error) { e := &rtpsimpleaudio.Encoder{ diff --git a/pkg/formats/g722.go b/pkg/formats/g722.go index 60853730..0fb62824 100644 --- a/pkg/formats/g722.go +++ b/pkg/formats/g722.go @@ -19,13 +19,6 @@ func (f *G722) Codec() string { return "G722" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *G722) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *G722) ClockRate() int { return 8000 @@ -51,14 +44,6 @@ func (f *G722) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *G722) CreateDecoder() *rtpsimpleaudio.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *G722) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { d := &rtpsimpleaudio.Decoder{ @@ -73,14 +58,6 @@ func (f *G722) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *G722) CreateEncoder() *rtpsimpleaudio.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *G722) CreateEncoder2() (*rtpsimpleaudio.Encoder, error) { e := &rtpsimpleaudio.Encoder{ diff --git a/pkg/formats/g726.go b/pkg/formats/g726.go index a15fb9f8..c0028c52 100644 --- a/pkg/formats/g726.go +++ b/pkg/formats/g726.go @@ -41,13 +41,6 @@ func (f *G726) Codec() string { return "G726" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *G726) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *G726) ClockRate() int { return 8000 diff --git a/pkg/formats/generic.go b/pkg/formats/generic.go index 2f8bb48a..74d338b2 100644 --- a/pkg/formats/generic.go +++ b/pkg/formats/generic.go @@ -80,13 +80,6 @@ func (f *Generic) Codec() string { return "Generic" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *Generic) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *Generic) ClockRate() int { return f.ClockRat diff --git a/pkg/formats/h264.go b/pkg/formats/h264.go index ac0f9ab3..95c269a3 100644 --- a/pkg/formats/h264.go +++ b/pkg/formats/h264.go @@ -65,13 +65,6 @@ func (f *H264) Codec() string { return "H264" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *H264) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *H264) ClockRate() int { return 90000 @@ -172,14 +165,6 @@ func (f *H264) PTSEqualsDTS(pkt *rtp.Packet) bool { return false } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *H264) CreateDecoder() *rtph264.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *H264) CreateDecoder2() (*rtph264.Decoder, error) { d := &rtph264.Decoder{ @@ -194,14 +179,6 @@ func (f *H264) CreateDecoder2() (*rtph264.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *H264) CreateEncoder() *rtph264.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *H264) CreateEncoder2() (*rtph264.Encoder, error) { e := &rtph264.Encoder{ diff --git a/pkg/formats/h265.go b/pkg/formats/h265.go index ea3b39eb..d075d2ad 100644 --- a/pkg/formats/h265.go +++ b/pkg/formats/h265.go @@ -67,13 +67,6 @@ func (f *H265) Codec() string { return "H265" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *H265) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *H265) ClockRate() int { return 90000 @@ -171,14 +164,6 @@ func (f *H265) PTSEqualsDTS(pkt *rtp.Packet) bool { return false } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *H265) CreateDecoder() *rtph265.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *H265) CreateDecoder2() (*rtph265.Decoder, error) { d := &rtph265.Decoder{ @@ -193,14 +178,6 @@ func (f *H265) CreateDecoder2() (*rtph265.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *H265) CreateEncoder() *rtph265.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *H265) CreateEncoder2() (*rtph265.Encoder, error) { e := &rtph265.Encoder{ diff --git a/pkg/formats/lpcm.go b/pkg/formats/lpcm.go index b1cbc36b..03de4e9e 100644 --- a/pkg/formats/lpcm.go +++ b/pkg/formats/lpcm.go @@ -58,13 +58,6 @@ func (f *LPCM) Codec() string { return "LPCM" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *LPCM) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *LPCM) ClockRate() int { return f.SampleRate @@ -103,14 +96,6 @@ func (f *LPCM) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *LPCM) CreateDecoder() *rtplpcm.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *LPCM) CreateDecoder2() (*rtplpcm.Decoder, error) { d := &rtplpcm.Decoder{ @@ -127,14 +112,6 @@ func (f *LPCM) CreateDecoder2() (*rtplpcm.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *LPCM) CreateEncoder() *rtplpcm.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *LPCM) CreateEncoder2() (*rtplpcm.Encoder, error) { e := &rtplpcm.Encoder{ diff --git a/pkg/formats/mjpeg.go b/pkg/formats/mjpeg.go index 56811451..8844f867 100644 --- a/pkg/formats/mjpeg.go +++ b/pkg/formats/mjpeg.go @@ -19,13 +19,6 @@ func (f *MJPEG) Codec() string { return "M-JPEG" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MJPEG) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MJPEG) ClockRate() int { return 90000 @@ -51,14 +44,6 @@ func (f *MJPEG) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *MJPEG) CreateDecoder() *rtpmjpeg.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *MJPEG) CreateDecoder2() (*rtpmjpeg.Decoder, error) { d := &rtpmjpeg.Decoder{} @@ -71,14 +56,6 @@ func (f *MJPEG) CreateDecoder2() (*rtpmjpeg.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *MJPEG) CreateEncoder() *rtpmjpeg.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *MJPEG) CreateEncoder2() (*rtpmjpeg.Encoder, error) { e := &rtpmjpeg.Encoder{} diff --git a/pkg/formats/mpeg1_audio.go b/pkg/formats/mpeg1_audio.go index cc66e185..6d9ebe28 100644 --- a/pkg/formats/mpeg1_audio.go +++ b/pkg/formats/mpeg1_audio.go @@ -19,13 +19,6 @@ func (f *MPEG1Audio) Codec() string { return "MPEG-1/2 Audio" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEG1Audio) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEG1Audio) ClockRate() int { return 90000 @@ -51,14 +44,6 @@ func (f *MPEG1Audio) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *MPEG1Audio) CreateDecoder() *rtpmpeg1audio.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *MPEG1Audio) CreateDecoder2() (*rtpmpeg1audio.Decoder, error) { d := &rtpmpeg1audio.Decoder{} @@ -71,14 +56,6 @@ func (f *MPEG1Audio) CreateDecoder2() (*rtpmpeg1audio.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *MPEG1Audio) CreateEncoder() *rtpmpeg1audio.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *MPEG1Audio) CreateEncoder2() (*rtpmpeg1audio.Encoder, error) { e := &rtpmpeg1audio.Encoder{} @@ -90,8 +67,3 @@ func (f *MPEG1Audio) CreateEncoder2() (*rtpmpeg1audio.Encoder, error) { return e, nil } - -// MPEG2Audio is an alias for MPEG1Audio. -// -// Deprecated: replaced by MPEG1Audio. -type MPEG2Audio = MPEG1Audio diff --git a/pkg/formats/mpeg1_video.go b/pkg/formats/mpeg1_video.go index 2c43c9cc..1e861446 100644 --- a/pkg/formats/mpeg1_video.go +++ b/pkg/formats/mpeg1_video.go @@ -17,13 +17,6 @@ func (f *MPEG1Video) Codec() string { return "MPEG-1/2 Video" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEG1Video) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEG1Video) ClockRate() int { return 90000 @@ -48,8 +41,3 @@ func (f *MPEG1Video) FMTP() map[string]string { func (f *MPEG1Video) PTSEqualsDTS(*rtp.Packet) bool { return true } - -// MPEG2Video is an alias for MPEG1Video. -// -// Deprecated: replaced by MPEG1Video. -type MPEG2Video = MPEG1Video diff --git a/pkg/formats/mpeg4_audio_generic.go b/pkg/formats/mpeg4_audio_generic.go index 5bffe4fa..b1205446 100644 --- a/pkg/formats/mpeg4_audio_generic.go +++ b/pkg/formats/mpeg4_audio_generic.go @@ -103,13 +103,6 @@ func (f *MPEG4AudioGeneric) Codec() string { return "MPEG-4 Audio" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEG4AudioGeneric) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEG4AudioGeneric) ClockRate() int { return f.Config.SampleRate @@ -176,14 +169,6 @@ func (f *MPEG4AudioGeneric) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *MPEG4AudioGeneric) CreateDecoder() *rtpmpeg4audio.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *MPEG4AudioGeneric) CreateDecoder2() (*rtpmpeg4audio.Decoder, error) { d := &rtpmpeg4audio.Decoder{ @@ -201,14 +186,6 @@ func (f *MPEG4AudioGeneric) CreateDecoder2() (*rtpmpeg4audio.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *MPEG4AudioGeneric) CreateEncoder() *rtpmpeg4audio.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *MPEG4AudioGeneric) CreateEncoder2() (*rtpmpeg4audio.Encoder, error) { e := &rtpmpeg4audio.Encoder{ diff --git a/pkg/formats/mpeg4_audio_latm.go b/pkg/formats/mpeg4_audio_latm.go index 3d367f1c..5645ef39 100644 --- a/pkg/formats/mpeg4_audio_latm.go +++ b/pkg/formats/mpeg4_audio_latm.go @@ -90,13 +90,6 @@ func (f *MPEG4AudioLATM) Codec() string { return "MPEG-4 Audio" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEG4AudioLATM) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEG4AudioLATM) ClockRate() int { return f.Config.Programs[0].Layers[0].AudioSpecificConfig.SampleRate @@ -164,14 +157,6 @@ func (f *MPEG4AudioLATM) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *MPEG4AudioLATM) CreateDecoder() *rtpmpeg4audiolatm.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *MPEG4AudioLATM) CreateDecoder2() (*rtpmpeg4audiolatm.Decoder, error) { d := &rtpmpeg4audiolatm.Decoder{ @@ -186,14 +171,6 @@ func (f *MPEG4AudioLATM) CreateDecoder2() (*rtpmpeg4audiolatm.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *MPEG4AudioLATM) CreateEncoder() *rtpmpeg4audiolatm.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *MPEG4AudioLATM) CreateEncoder2() (*rtpmpeg4audiolatm.Encoder, error) { e := &rtpmpeg4audiolatm.Encoder{ diff --git a/pkg/formats/mpeg4_video_es.go b/pkg/formats/mpeg4_video_es.go index cf8ff6aa..5e582731 100644 --- a/pkg/formats/mpeg4_video_es.go +++ b/pkg/formats/mpeg4_video_es.go @@ -56,13 +56,6 @@ func (f *MPEG4VideoES) Codec() string { return "MPEG-4 Video" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEG4VideoES) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEG4VideoES) ClockRate() int { return 90000 @@ -93,14 +86,6 @@ func (f *MPEG4VideoES) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *MPEG4VideoES) CreateDecoder() *rtpmpeg4video.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *MPEG4VideoES) CreateDecoder2() (*rtpmpeg4video.Decoder, error) { d := &rtpmpeg4video.Decoder{} @@ -113,14 +98,6 @@ func (f *MPEG4VideoES) CreateDecoder2() (*rtpmpeg4video.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *MPEG4VideoES) CreateEncoder() *rtpmpeg4video.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *MPEG4VideoES) CreateEncoder2() (*rtpmpeg4video.Encoder, error) { e := &rtpmpeg4video.Encoder{ diff --git a/pkg/formats/mpegts.go b/pkg/formats/mpegts.go index b68c48c0..2050edcb 100644 --- a/pkg/formats/mpegts.go +++ b/pkg/formats/mpegts.go @@ -17,13 +17,6 @@ func (f *MPEGTS) Codec() string { return "MPEG-TS" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *MPEGTS) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *MPEGTS) ClockRate() int { return 90000 diff --git a/pkg/formats/opus.go b/pkg/formats/opus.go index 8842dbca..1831561d 100644 --- a/pkg/formats/opus.go +++ b/pkg/formats/opus.go @@ -49,13 +49,6 @@ func (f *Opus) Codec() string { return "Opus" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *Opus) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *Opus) ClockRate() int { // RFC7587: the RTP timestamp is incremented with a 48000 Hz @@ -93,14 +86,6 @@ func (f *Opus) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *Opus) CreateDecoder() *rtpsimpleaudio.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *Opus) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { d := &rtpsimpleaudio.Decoder{ @@ -115,14 +100,6 @@ func (f *Opus) CreateDecoder2() (*rtpsimpleaudio.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *Opus) CreateEncoder() *rtpsimpleaudio.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *Opus) CreateEncoder2() (*rtpsimpleaudio.Encoder, error) { e := &rtpsimpleaudio.Encoder{ diff --git a/pkg/formats/rtpav1/decoder.go b/pkg/formats/rtpav1/decoder.go index 0c0641ee..33985930 100644 --- a/pkg/formats/rtpav1/decoder.go +++ b/pkg/formats/rtpav1/decoder.go @@ -51,13 +51,6 @@ func (d *Decoder) Init() error { return nil } -// Decode decodes OBUs from a RTP packet. -// -// Deprecated: this method returns incomplete temporal units. -func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, time.Duration, error) { - return d.decodeOBUs(pkt) -} - func (d *Decoder) decodeOBUs(pkt *rtp.Packet) ([][]byte, time.Duration, error) { var av1header codecs.AV1Packet _, err := av1header.Unmarshal(pkt.Payload) diff --git a/pkg/formats/rtph264/decoder.go b/pkg/formats/rtph264/decoder.go index d2582102..3909c29b 100644 --- a/pkg/formats/rtph264/decoder.go +++ b/pkg/formats/rtph264/decoder.go @@ -59,13 +59,6 @@ func (d *Decoder) Init() error { return nil } -// Decode decodes NALUs from a RTP packet. -// -// Deprecated: this method returns incomplete access units. -func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, time.Duration, error) { - return d.decodeNALUs(pkt) -} - func (d *Decoder) decodeNALUs(pkt *rtp.Packet) ([][]byte, time.Duration, error) { if len(pkt.Payload) < 1 { d.fragments = d.fragments[:0] // discard pending fragments diff --git a/pkg/formats/rtph265/decoder.go b/pkg/formats/rtph265/decoder.go index 72410048..9739188a 100644 --- a/pkg/formats/rtph265/decoder.go +++ b/pkg/formats/rtph265/decoder.go @@ -57,13 +57,6 @@ func (d *Decoder) Init() error { return nil } -// Decode decodes NALUs from a RTP packet. -// -// Deprecated: this method returns incomplete access units. -func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, time.Duration, error) { - return d.decodeNALUs(pkt) -} - func (d *Decoder) decodeNALUs(pkt *rtp.Packet) ([][]byte, time.Duration, error) { if len(pkt.Payload) < 2 { d.fragments = d.fragments[:0] // discard pending fragments diff --git a/pkg/formats/rtpmpeg2audio/rtpmpeg2audio.go b/pkg/formats/rtpmpeg2audio/rtpmpeg2audio.go deleted file mode 100644 index ef24bad4..00000000 --- a/pkg/formats/rtpmpeg2audio/rtpmpeg2audio.go +++ /dev/null @@ -1,26 +0,0 @@ -// Package rtpmpeg2audio contains a RTP/MPEG-1/2 Audio decoder and encoder. -package rtpmpeg2audio - -import ( - "github.com/bluenviron/gortsplib/v4/pkg/formats/rtpmpeg1audio" -) - -// ErrMorePacketsNeeded is an alis for rtpmpeg1audio.ErrMorePacketsNeeded. -// -// Deprecated: replaced by rtpmpeg1audio.ErrMorePacketsNeeded. -var ErrMorePacketsNeeded = rtpmpeg1audio.ErrMorePacketsNeeded - -// ErrNonStartingPacketAndNoPrevious is an alis for rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious. -// -// Deprecated: replaced by rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious. -var ErrNonStartingPacketAndNoPrevious = rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious - -// Decoder is an alis for rtpmpeg1audio.Decoder. -// -// Deprecated: replaced by rtpmpeg1audio.Decoder. -type Decoder = rtpmpeg1audio.Decoder - -// Encoder is an alis for rtpmpeg1audio.Encoder. -// -// Deprecated: replaced by rtpmpeg1audio.Encoder. -type Encoder = rtpmpeg1audio.Encoder diff --git a/pkg/formats/vorbis.go b/pkg/formats/vorbis.go index 7e05295b..18c0d472 100644 --- a/pkg/formats/vorbis.go +++ b/pkg/formats/vorbis.go @@ -61,13 +61,6 @@ func (f *Vorbis) Codec() string { return "Vorbis" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *Vorbis) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *Vorbis) ClockRate() int { return f.SampleRate diff --git a/pkg/formats/vp8.go b/pkg/formats/vp8.go index aadbf72d..39cfaa83 100644 --- a/pkg/formats/vp8.go +++ b/pkg/formats/vp8.go @@ -50,13 +50,6 @@ func (f *VP8) Codec() string { return "VP8" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *VP8) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *VP8) ClockRate() int { return 90000 @@ -92,14 +85,6 @@ func (f *VP8) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *VP8) CreateDecoder() *rtpvp8.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *VP8) CreateDecoder2() (*rtpvp8.Decoder, error) { d := &rtpvp8.Decoder{} @@ -112,14 +97,6 @@ func (f *VP8) CreateDecoder2() (*rtpvp8.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *VP8) CreateEncoder() *rtpvp8.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *VP8) CreateEncoder2() (*rtpvp8.Encoder, error) { e := &rtpvp8.Encoder{ diff --git a/pkg/formats/vp9.go b/pkg/formats/vp9.go index 32a9a4f8..865608dd 100644 --- a/pkg/formats/vp9.go +++ b/pkg/formats/vp9.go @@ -60,13 +60,6 @@ func (f *VP9) Codec() string { return "VP9" } -// String implements Format. -// -// Deprecated: replaced by Codec(). -func (f *VP9) String() string { - return f.Codec() -} - // ClockRate implements Format. func (f *VP9) ClockRate() int { return 90000 @@ -104,14 +97,6 @@ func (f *VP9) PTSEqualsDTS(*rtp.Packet) bool { return true } -// CreateDecoder creates a decoder able to decode the content of the format. -// -// Deprecated: this has been replaced by CreateDecoder2() that can also return an error. -func (f *VP9) CreateDecoder() *rtpvp9.Decoder { - d, _ := f.CreateDecoder2() - return d -} - // CreateDecoder2 creates a decoder able to decode the content of the format. func (f *VP9) CreateDecoder2() (*rtpvp9.Decoder, error) { d := &rtpvp9.Decoder{} @@ -124,14 +109,6 @@ func (f *VP9) CreateDecoder2() (*rtpvp9.Decoder, error) { return d, nil } -// CreateEncoder creates an encoder able to encode the content of the format. -// -// Deprecated: this has been replaced by CreateEncoder2() that can also return an error. -func (f *VP9) CreateEncoder() *rtpvp9.Encoder { - e, _ := f.CreateEncoder2() - return e -} - // CreateEncoder2 creates an encoder able to encode the content of the format. func (f *VP9) CreateEncoder2() (*rtpvp9.Encoder, error) { e := &rtpvp9.Encoder{ diff --git a/server_handler.go b/server_handler.go index 511dbb4d..6ec8a5b8 100644 --- a/server_handler.go +++ b/server_handler.go @@ -194,21 +194,6 @@ type ServerHandlerOnSetParameter interface { OnSetParameter(*ServerHandlerOnSetParameterCtx) (*base.Response, error) } -// ServerHandlerOnWarningCtx is the context of OnWarning. -// -// Deprecated: ServerHandlerOnWarning is deprecated. -type ServerHandlerOnWarningCtx struct { - Session *ServerSession - Error error -} - -// ServerHandlerOnWarning can be implemented by a ServerHandler. -// -// Deprecated: replaced by OnPacketLost, OnDecodeError. -type ServerHandlerOnWarning interface { - OnWarning(*ServerHandlerOnWarningCtx) -} - // ServerHandlerOnPacketLostCtx is the context of OnPacketLost. type ServerHandlerOnPacketLostCtx struct { Session *ServerSession diff --git a/server_session.go b/server_session.go index 5a940c36..bbd3175b 100644 --- a/server_session.go +++ b/server_session.go @@ -251,11 +251,6 @@ func (ss *ServerSession) onPacketLost(err error) { Session: ss, Error: err, }) - } else if h, ok := ss.s.Handler.(ServerHandlerOnWarning); ok { - h.OnWarning(&ServerHandlerOnWarningCtx{ - Session: ss, - Error: err, - }) } } @@ -265,11 +260,6 @@ func (ss *ServerSession) onDecodeError(err error) { Session: ss, Error: err, }) - } else if h, ok := ss.s.Handler.(ServerHandlerOnWarning); ok { - h.OnWarning(&ServerHandlerOnWarningCtx{ - Session: ss, - Error: err, - }) } }