re-enable consistency checks on clock rate of tracks (#382)

This commit is contained in:
Alessandro Ros
2023-08-25 18:33:44 +02:00
committed by GitHub
parent 72aa55a012
commit 608f149fd4
2 changed files with 14 additions and 29 deletions

View File

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

View File

@@ -1,7 +1,6 @@
package formats package formats
import ( import (
"fmt"
"strconv" "strconv"
"strings" "strings"
@@ -34,22 +33,20 @@ 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.
type Generic struct { type Generic struct {
@@ -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 {