mirror of
https://github.com/aler9/gortsplib
synced 2025-10-31 02:26:57 +08:00
rtph264: reset decoder state in case of error
This commit is contained in:
@@ -141,15 +141,18 @@ func (d *Decoder) Decode(byts []byte) ([]*NALUAndTimestamp, error) {
|
|||||||
pkt := rtp.Packet{}
|
pkt := rtp.Packet{}
|
||||||
err := pkt.Unmarshal(byts)
|
err := pkt.Unmarshal(byts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.state = decoderStateInitial
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pkt.Payload) < 2 {
|
if len(pkt.Payload) < 2 {
|
||||||
|
d.state = decoderStateInitial
|
||||||
return nil, fmt.Errorf("Invalid FU-A packet")
|
return nil, fmt.Errorf("Invalid FU-A packet")
|
||||||
}
|
}
|
||||||
|
|
||||||
typ := NALUType(pkt.Payload[0] & 0x1F)
|
typ := NALUType(pkt.Payload[0] & 0x1F)
|
||||||
if typ != NALUTypeFuA {
|
if typ != NALUTypeFuA {
|
||||||
|
d.state = decoderStateInitial
|
||||||
return nil, fmt.Errorf("non-starting NALU is not FU-A")
|
return nil, fmt.Errorf("non-starting NALU is not FU-A")
|
||||||
}
|
}
|
||||||
end := (pkt.Payload[1] >> 6) & 0x01
|
end := (pkt.Payload[1] >> 6) & 0x01
|
||||||
|
|||||||
Reference in New Issue
Block a user