Ant-Media-Server
Ant-Media-Server copied to clipboard
switchVideoCameraCapture shouldn't stop the track unless really needed...
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
Thank you @MaZZly for the feedback. I am taking this to plan to check.