alexeyvasilyev / rtsp-client-android

Lightweight low-latency RTSP client library for Android
Apache License 2.0
245 stars 67 forks source link

sync for HW decoder #43

Open sam21abc opened 2 years ago

sam21abc commented 2 years ago

this library works with most of phones but facing problem with some devices like samung m31 or pixel 5 phone. I was explored but still not getting any solution.

 val inIndex: Int = decoder.dequeueInputBuffer(10000L)
                if (inIndex >= 0) {
                    // fill inputBuffers[inputBufferIndex] with valid data
                    val byteBuffer: ByteBuffer? = decoder.getInputBuffer(inIndex)
                    byteBuffer?.rewind()

                    try {
                        val frame = videoFrameQueue.pop()
                        if (frame != null) {
                            byteBuffer!!.put(frame.bytesData, frame.offset, frame.length)
                            //decodeFrame(frame.data)
                            decoder.queueInputBuffer(
                                inIndex,
                                frame.offset,
                                frame.length,
                                frame.timestamp,
                                0
                            )

                        }
                    } catch (e: InterruptedException) {
                    }

every time got error to the val inIndex: Int = decoder.dequeueInputBuffer(10000L) line:

AndroidRuntime: FATAL EXCEPTION: RTSP video thread 
java.lang.IllegalStateException
        at android.media.MediaCodec.native_dequeueInputBuffer(Native Method)
        at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2855)
        at videoStream.codec.VideoDecodeThread.run(VideoDecodeThread.kt:63)

let me know any hardware dependency or unsupported video codec / format. pls help asp.