mirror of
https://github.com/aler9/gortsplib
synced 2025-10-27 17:21:22 +08:00
re-enable consistency checks on clock rate of tracks (#382)
This commit is contained in:
@@ -890,19 +890,6 @@ var casesFormat = []struct {
|
|||||||
"custom",
|
"custom",
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"application invalid rtpmap 2",
|
|
||||||
"application",
|
|
||||||
98,
|
|
||||||
"custom/aaa",
|
|
||||||
nil,
|
|
||||||
&Generic{
|
|
||||||
PayloadTyp: 98,
|
|
||||||
RTPMa: "custom/aaa",
|
|
||||||
},
|
|
||||||
"custom/aaa",
|
|
||||||
nil,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshal(t *testing.T) {
|
func TestUnmarshal(t *testing.T) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package formats
|
package formats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -34,21 +33,19 @@ func findClockRate(payloadType uint8, rtpMap string) (int, error) {
|
|||||||
// get clock rate from rtpmap
|
// get clock rate from rtpmap
|
||||||
// https://tools.ietf.org/html/rfc4566
|
// https://tools.ietf.org/html/rfc4566
|
||||||
// a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding parameters>]
|
// a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding parameters>]
|
||||||
if rtpMap == "" {
|
if rtpMap != "" {
|
||||||
return 0, fmt.Errorf("attribute 'rtpmap' not found")
|
if tmp := strings.Split(rtpMap, "/"); len(tmp) >= 2 {
|
||||||
}
|
|
||||||
|
|
||||||
tmp := strings.Split(rtpMap, "/")
|
|
||||||
if len(tmp) != 2 && len(tmp) != 3 {
|
|
||||||
return 0, fmt.Errorf("invalid rtpmap (%v)", rtpMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
v, err := strconv.ParseUint(tmp[1], 10, 31)
|
v, err := strconv.ParseUint(tmp[1], 10, 31)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return int(v), nil
|
return int(v), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no clock rate was found.
|
||||||
|
// do not throw an error, but return zero, that disables RTCP sender and receiver reports.
|
||||||
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic is a generic RTP format.
|
// Generic is a generic RTP format.
|
||||||
@@ -63,8 +60,9 @@ type Generic struct {
|
|||||||
|
|
||||||
// Init computes the clock rate of the format. It is mandatory to call it.
|
// Init computes the clock rate of the format. It is mandatory to call it.
|
||||||
func (f *Generic) Init() error {
|
func (f *Generic) Init() error {
|
||||||
f.ClockRat, _ = findClockRate(f.PayloadTyp, f.RTPMa)
|
var err error
|
||||||
return nil
|
f.ClockRat, err = findClockRate(f.PayloadTyp, f.RTPMa)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Generic) unmarshal(payloadType uint8, _ string, _ string, rtpmap string, fmtp map[string]string) error {
|
func (f *Generic) unmarshal(payloadType uint8, _ string, _ string, rtpmap string, fmtp map[string]string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user