mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
fix crash in client-read-h264-save-to-disk
This commit is contained in:
@@ -61,6 +61,7 @@ func (e *mpegtsEncoder) encode(nalus [][]byte, pts time.Duration) error {
|
|||||||
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
|
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nonIDRPresent := false
|
||||||
idrPresent := false
|
idrPresent := false
|
||||||
|
|
||||||
for _, nalu := range nalus {
|
for _, nalu := range nalus {
|
||||||
@@ -84,11 +85,18 @@ func (e *mpegtsEncoder) encode(nalus [][]byte, pts time.Duration) error {
|
|||||||
if e.sps != nil && e.pps != nil {
|
if e.sps != nil && e.pps != nil {
|
||||||
filteredNALUs = append(filteredNALUs, e.sps, e.pps)
|
filteredNALUs = append(filteredNALUs, e.sps, e.pps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case h264.NALUTypeNonIDR:
|
||||||
|
nonIDRPresent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredNALUs = append(filteredNALUs, nalu)
|
filteredNALUs = append(filteredNALUs, nalu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !nonIDRPresent && !idrPresent {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var dts time.Duration
|
var dts time.Duration
|
||||||
|
|
||||||
if !e.firstIDRReceived {
|
if !e.firstIDRReceived {
|
||||||
|
Reference in New Issue
Block a user