alexeyvasilyev / rtsp-client-android

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

Switch two camera #84

Closed DongPhamBK closed 1 month ago

DongPhamBK commented 2 months ago

I need to switch between 2 rtsp links on the same RtspSurfaceView. When I do this (refer to the code below). But the video is wrong and seems to show a combination of images between the 2 rtsp links. Can you suggest any ideas, thanks!

Ex: fun switchCamera(url: String){ if (binding.svVideo.isStarted()) { binding.svVideo.stop() }

        val uri = Uri.parse(url)
        binding.svVideo.apply {
            init(uri, liveViewModel.rtspUsername.value, liveViewModel.rtspPassword.value, "rtsp-client-android")
            debug = true
            start(true, true)
        }
    }
alexeyvasilyev commented 2 months ago

So, your start RtspSurfaceView with url1, then stop it, assign url2 and start it again. Am I right?

Looks like stop() method was not called.

Tried to reproduce the issue on demo app LiveFragment and everything works as expected (no any issues).

DongPhamBK commented 1 month ago

I tried delaying a bit before switching between the 2 urls, and it worked, maybe the problem is with my device, it's quite weak. Thank you for your feedback.