MCPcopy Create free account
hub / github.com/Roy3838/Observer / switchCameraDevice

Method switchCameraDevice

app/src/utils/streamManager.ts:321–344  ·  view source on GitHub ↗

Switch to a different camera device (stops current stream and re-acquires with new device)

(deviceId: string)

Source from the content-addressed store, hash-verified

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

Callers 3

handleSwitchCameraFunction · 0.80
handleSwitchCameraFunction · 0.80
captureCameraFunction · 0.80

Calls 6

teardownCameraStreamMethod · 0.95
ensureMasterStreamMethod · 0.95
isWebFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected