Ant-Media-Server icon indicating copy to clipboard operation
Ant-Media-Server copied to clipboard

switchVideoCameraCapture shouldn't stop the track unless really needed...

Open MaZZly opened this issue 1 year ago • 1 comments

Short description

media_manager.js:

    switchVideoCameraCapture(streamId, deviceId, onEndedCallback) {
        //stop the track because in some android devices need to close the current camera stream
        if (this.localStream && this.localStream.getVideoTracks().length > 0) {
            var videoTrack = this.localStream.getVideoTracks()[0];
            videoTrack.stop();
        } else {
            Logger.warn("There is no video track in local stream");
        }

If this is only happening on "some Android devices", it should only stop the existing track on those...

Why stop the stream for all other clients where the bug would not appear... Now there is a black screen in between when switching cameras, which is not nice UX.


Also, if we wanted to call setVideoCameraSource manually, e.g. to choose facingMode or similar, why is the same logic not applied there? I'm guessing the same bug happens there if the existing track is not stopped first...

Expected behavior

  • Only close the existing track if needed.
  • Also handle this on setVideoCameraSource

Actual behavior

  • Always closes existing track (even when not needed)
  • It never closes existing track when using setVideoCameraSource

MaZZly avatar Jan 22 '24 08:01 MaZZly

Thank you @MaZZly for the feedback. I am taking this to plan to check.

burak-58 avatar Jan 22 '24 09:01 burak-58