Skip to content

Comments

fix: do not mute track on camera flip#1671

Merged
santhoshvai merged 7 commits intomainfrom
switch-camera-without-stop
Feb 5, 2025
Merged

fix: do not mute track on camera flip#1671
santhoshvai merged 7 commits intomainfrom
switch-camera-without-stop

Conversation

@santhoshvai
Copy link
Member

@santhoshvai santhoshvai commented Feb 4, 2025

Goal

This change avoids sending mute to SFU when camera is flipped -- this makes flip faster

React Native

The avatar image wont be shown at all, as track is flipped internally

Untitled.mov

React - web mobile

We stop previous track. do not send mute signal to SFU now. We momentarily see the avatar.

screen-20250204-114443.mp4

@santhoshvai santhoshvai changed the title fix: do not stop track on camera flip fix: do not mute track on camera flip Feb 4, 2025
// web mobile
this.state.setDirection(direction);
// Providing both device id and direction doesn't work, so we deselect the device
this.state.setDevice(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go outside of this if.

videoTrack._switchCamera();
} else {
const constraints = {
facingMode: direction === 'front' ? 'user' : 'environment',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add ...this.constraints here? Otherwise we lose target resolution constraint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for RN it is unnecessary, the native lib stores the old resoltion constriants..

};
videoTrack.applyConstraints(constraints);
}
this.state.setDirection(direction);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since setMediaStream is not called in this case, there's a slight change of behavior: deviceId is not set to an actual deviceId from track settings. I don't know if it's important for RN though.

Copy link
Member Author

@santhoshvai santhoshvai Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not necessary for RN, the change of camera deviceId happens under the hood, it just takes index values internally

@santhoshvai santhoshvai merged commit 963eb4d into main Feb 5, 2025
19 checks passed
@santhoshvai santhoshvai deleted the switch-camera-without-stop branch February 5, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants