Switch to a different camera device (stops current stream and re-acquires with new device)
(deviceId: string)
| 316 | |
| 317 | /** Switch to a different camera device (stops current stream and re-acquires with new device) */ |
| 318 | public async switchCameraDevice(deviceId: string): Promise<void> { |
| 319 | Logger.info("StreamManager", `Switching camera to device: ${deviceId}`); |
| 320 | |
| 321 | // Save the preference |
| 322 | this.setPreferredCameraDevice(deviceId); |
| 323 | |
| 324 | // Get all agents currently using the camera |
| 325 | const cameraUsers = Array.from(this.userSets.get('camera') || []); |
| 326 | |
| 327 | // Teardown current camera stream |
| 328 | this.teardownCameraStream(); |
| 329 | |
| 330 | // Re-acquire camera with new device for all users |
| 331 | if (cameraUsers.length > 0) { |
| 332 | try { |
| 333 | const captureImpl = isWeb() ? browserStreamCapture : tauriStreamCapture; |
| 334 | await this.ensureMasterStream('camera', captureImpl); |
| 335 | Logger.info("StreamManager", "Camera switched successfully."); |
| 336 | } catch (error) { |
| 337 | Logger.error("StreamManager", "Failed to switch camera device.", error); |
| 338 | throw error; |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | // --- Frame Capture API --- |
| 344 |
no test coverage detected