mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
rtptime: fix crash in case of packets from tracks with invalid clock rate (#400)
This commit is contained in:
@@ -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()
|
||||||
|
|
||||||
|
@@ -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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user