feat: support fast switch camera for LocalVideoTrack. (#239)
* feat: support fast switch camera for LocalVideoTrack. * remove unused import.
This commit is contained in:
@@ -116,13 +116,18 @@ extension LocalVideoTrackExt on LocalVideoTrack {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> switchCamera(String deviceId) async {
|
Future<void> switchCamera(String deviceId, {bool fastSwitch = false}) async {
|
||||||
final options = currentOptions;
|
final options = currentOptions;
|
||||||
if (options is! CameraCaptureOptions) {
|
if (options is! CameraCaptureOptions) {
|
||||||
logger.warning('Not a camera track');
|
logger.warning('Not a camera track');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fastSwitch) {
|
||||||
|
await rtc.Helper.switchCamera(mediaStreamTrack, deviceId, mediaStream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await restartTrack(
|
await restartTrack(
|
||||||
options.copyWith(deviceId: deviceId),
|
options.copyWith(deviceId: deviceId),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user