Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ArrayIndexOutOfBoundsException: length=228; index=228 #99

Closed
hujinhuahjh opened this issue Dec 24, 2024 · 1 comment
Closed

Comments

@hujinhuahjh
Copy link

When I use this library to play an RTSP stream, it always throws an error:
java.lang.ArrayIndexOutOfBoundsException: length=228; index=228
at com.alexvas.utils.VideoCodecUtils.isAnyKeyFrame(VideoCodecUtils.kt:307)
at com.alexvas.rtsp.widget.RtspProcessor$proxyClientListener$1.onRtspVideoNalUnitReceived(RtspProcessor.kt:210)
at com.alexvas.rtsp.RtspClient.readRtpData(RtspClient.java:735)
at com.alexvas.rtsp.RtspClient.execute(RtspClient.java:542)
at com.alexvas.rtsp.widget.RtspProcessor$RtspThread.run(RtspProcessor.kt:348)

I am using your demo and have tried both software decoding, hardware decoding, and other Android devices; all of them result in errors.

I modify the code in VideoCodeUtils.kt (in 308): val nalUnitTypeOctet = data[nalUnitOffset]
to
val nalUnitTypeOctet = try {
data[nalUnitOffset]
} catch (e: ArrayIndexOutOfBoundsException) {
return false
}
it works well

@alexeyvasilyev
Copy link
Owner

Thanks for letting me know. try/catch is not the best way for fixing it since it creates overhead. I fixed slightly differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants