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

Method switchCameraDevice

app/src/utils/streamManager.ts:318–341  ·  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

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

Callers 2

handleSwitchCameraFunction · 0.80
handleSwitchCameraFunction · 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