Skip invalid bytes in connection read #653
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates the connection reading to skip invalid bytes and probes for the interleaved frame/request/response magic bytes.
gortsplib currently dies when trying to play this whereas ffmpeg and VLC are both able to skip over invalid bytes and continue decoding. This change updates the logic so gortsplib mirrors the ffmpeg/VLC behavior.
Context: I am working with this camera https://www.axis.com/products/canon-vb-h47 which seems to throw this error on RTSP play:
I traced it down to some weird packet behavior from the camera, specifically it seems to send:
I suspect that the random garbage bytes are some corrupted interleaved frame that's missing the header. I do not know why.
Packet capture from gortsplib here if you are curious: axis.pcap.gz
The end of the interleaved frame has these garbage bytes:
after which gortsplib errors and a TEARDOWN is sent.