I am attempting to display a list of MediaStream
objects in a RecyclerView
. Currently, my peer is giving me all of the MediaStream
objects upon our initial handshake, and I am able to display them in a list view item that has a custom TextureView
. The problem arises when I am given a large number of streams to scroll through. I eventually crash after scrolling through enough list items.
I have tried to use the MediaStream#dispose()
function when my list item is being recycled. This seems to avoid the issue of using too many decoder resources, but it also makes the stream unable to be viewed again. If the user wants to scroll to a stream that has been disposed of, my app crashes with the exception MediaStreamTrack has been disposed.
when trying to enable the MediaStream
's VideoTrack
.
I expected the combination of removing the sink from the video track videoTrack?.removeSink(cameraStreamView)
as well as invoking the release()
function on the EglRenderer within my TextureView would be enough to clean up the MediaStream in onViewRecycled()
.
private fun destroyCameraStream() {
videoTrack?.removeSink(cameraStreamView)
cameraStreamView.release()
}
fun release() {
eglRenderer.release()
}
However, after scrolling down the list far enough, I get the error:
Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
I think this is due to the fact that I am not fully cleaning up and releasing my Codecs as I spin them up along the way, and I run out of resources.
Does anyone know if there is a certain function to call in order to correctly clean up MediaStream
resources/the codecs used to decode them? Is there any documentation that talks about this type of situation?
Thanks!