rtptime: fix crash in case of packets from tracks with invalid clock rate (#400)

This commit is contained in:
Alessandro Ros
2023-09-02 20:45:30 +02:00
committed by GitHub
parent a887f070bf
commit cc450b92a0
2 changed files with 13 additions and 0 deletions

View File

@@ -71,6 +71,10 @@ func (d *GlobalDecoder) Decode(
track GlobalDecoderTrack, track GlobalDecoderTrack,
pkt *rtp.Packet, pkt *rtp.Packet,
) (time.Duration, bool) { ) (time.Duration, bool) {
if track.ClockRate() == 0 {
return 0, false
}
d.mutex.Lock() d.mutex.Lock()
defer d.mutex.Unlock() defer d.mutex.Unlock()

View File

@@ -138,3 +138,12 @@ func TestGlobalDecoder(t *testing.T) {
require.Equal(t, true, ok) require.Equal(t, true, ok)
require.Equal(t, 6*time.Second, pts) require.Equal(t, 6*time.Second, pts)
} }
func TestGlobalDecoderInvalidClockRate(t *testing.T) {
g := NewGlobalDecoder()
tr := &dummyTrack{clockRate: 0, ptsEqualsDTS: true}
_, ok := g.Decode(tr, &rtp.Packet{Header: rtp.Header{Timestamp: 90000}})
require.Equal(t, false, ok)
}