rtsp-client-android icon indicating copy to clipboard operation
rtsp-client-android copied to clipboard

After few minutes streams gets stops and app force close.

Open ahmedchoteri opened this issue 4 years ago • 11 comments
trafficstars

After few minutes streams gets stops and app force close.

2021-01-23 19:41:43.355 31496-31550/com.alexvas.rtsp.demo E/AndroidRuntime: FATAL EXCEPTION: Thread-4 Process: com.alexvas.rtsp.demo, PID: 31496 java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueInputBuffer(Native Method) at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2786) at com.alexvas.rtsp.demo.decode.VideoDecodeThread.run(VideoDecodeThread.kt:31)

above exception is appear at bellow code in VideoDecodeThread

val inIndex: Int = decoder.dequeueInputBuffer(10000L)

ahmedchoteri avatar Jan 23 '21 14:01 ahmedchoteri

This is not a library issue. This is demo app issue. I will check that.

alexeyvasilyev avatar Jan 23 '21 14:01 alexeyvasilyev

Yeah ok.

ahmedchoteri avatar Jan 24 '21 01:01 ahmedchoteri

Any answers about this issue, @alexeyvasilyev ? I'm facing the same issue...

LeandroVanolli avatar May 18 '21 17:05 LeandroVanolli

@LeandroVanolli What Android device? What RTSP camera model? Have you tried to reboot Android device?

alexeyvasilyev-wyze avatar May 18 '21 20:05 alexeyvasilyev-wyze

Hello @alexeyvasilyev-wyze . Thank you for replying.

I realized that streaming does not stop on its own, but stops when the wi-fi connection becomes unstable. At first, I can see packet loss causing some delay in streaming, and sometimes the streaming stops, and it doesn't work anymore until we stop streaming by clicking "stop" and "start" again. I want to know how to prevent the permanent streming stop caused by an unstable connection. Maybe if some method is called when that happens, I can make the app restart streaming from that method.

Thank you!

LeandroVanolli avatar May 19 '21 19:05 LeandroVanolli

@alexeyvasilyev I'm testing the app trying to find out the issue. Below you can see that the frames can't be pushed to the queue because the queue is full, At the same time, the decoder doesn't has any frame to decode.

image

As I said before, it happens easily when the connection becomes unstable. Sometimes, the app stops the decoder thread and needs to be restarted, and this way is ok, because the user will know this information by a toast.

I'm trying to solve, but I don't have enought experience in Kotlin and Android programming.

LeandroVanolli avatar May 20 '21 19:05 LeandroVanolli

Any news about the issue? @alexeyvasilyev Are you working on it?

LeandroVanolli avatar May 24 '21 11:05 LeandroVanolli

No news.

alexeyvasilyev avatar May 24 '21 11:05 alexeyvasilyev

W/System.err: java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueInputBuffer(Native Method) at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2319) at com.alexvas.rtsp.demo.decode.VideoDecodeThread.run(VideoDecodeThread.kt:38) java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2379) at com.alexvas.rtsp.demo.decode.VideoDecodeThread.run(VideoDecodeThread.kt:71) E/AndroidRuntime: FATAL EXCEPTION: Thread-4683 Process: com.alexvas.rtsp.demo, PID: 24368 java.lang.IllegalStateException at android.media.MediaCodec.native_stop(Native Method) at android.media.MediaCodec.stop(MediaCodec.java:1901) at com.alexvas.rtsp.demo.decode.VideoDecodeThread.run(VideoDecodeThread.kt:98)

line : val outIndex = decoder.dequeueOutputBuffer(bufferInfo, 9000) where it throws error!

so the connections keeps on dropping again and again and when you keep trying to reconnect it throws this error

AadityaRathod97 avatar Jun 30 '21 12:06 AadityaRathod97

Hey, Hi The Stream keeps getting disconnected frequently and throws this error

W/System.err: java.net.SocketTimeoutException at java.net.PlainSocketImpl.read(PlainSocketImpl.java:484) at java.net.PlainSocketImpl.-wrap0(PlainSocketImpl.java) at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237) at com.alexvas.utils.NetUtils.readData(NetUtils.java:229) at com.alexvas.rtsp.RtspClient.readRtpData(RtspClient.java:586) at com.alexvas.rtsp.RtspClient.execute(RtspClient.java:495) W/System.err: at com.alexvas.rtsp.demo.ui.live.LiveFragment$RtspThread.run(LiveFragment.kt:334) E/LiveFragment: onRtspFailed(message="null")

and also in between MediaCodec.INFO_TRY_AGAIN_LATER -> if (DEBUG) Log.d(TAG, "No output from decoder available") No output from decoder available No output from decoder available No output from decoder available even when the stream is active and streaming, the app keeps throwing those two errors

AadityaRathod97 avatar Jul 05 '21 13:07 AadityaRathod97

Any news on this? This is a serious issue. I just tried a temporary fix which is increate timeout from default value (5000) to 10000 which made it little stable. Change timeout value timeout=10000; line no 75 NetUtils.java

alionteo avatar Sep 14 '22 11:09 alionteo