fix: restore Windows webcam stream support by conditionally delegating to frontend events
All checks were successful
Deploy on Master Change / deploy (push) Successful in 38s
All checks were successful
Deploy on Master Change / deploy (push) Successful in 38s
This commit is contained in:
@@ -1267,6 +1267,12 @@ func (a *App) startWebcamStream() {
|
||||
a.streamCamStop = make(chan struct{})
|
||||
a.mu.Unlock()
|
||||
|
||||
if !camera.IsNative {
|
||||
log.Println("[WS] Platform is non-darwin, delegating webcam stream to frontend events")
|
||||
runtime.EventsEmit(a.ctx, "start_webcam_stream")
|
||||
return
|
||||
}
|
||||
|
||||
if err := camera.StartCapture(); err != nil {
|
||||
log.Printf("[WS] Failed to start native camera: %v", err)
|
||||
a.mu.Lock()
|
||||
@@ -1328,7 +1334,16 @@ func (a *App) stopWebcamStream() {
|
||||
return
|
||||
}
|
||||
a.isStreamingCam = false
|
||||
close(a.streamCamStop)
|
||||
if a.streamCamStop != nil {
|
||||
close(a.streamCamStop)
|
||||
}
|
||||
|
||||
if !camera.IsNative {
|
||||
log.Println("[WS] Platform is non-darwin, stopping frontend webcam stream via event")
|
||||
runtime.EventsEmit(a.ctx, "stop_webcam_stream")
|
||||
return
|
||||
}
|
||||
|
||||
camera.StopCapture()
|
||||
log.Println("[WS] Webcam native streaming stopped.")
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package camera
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -framework AVFoundation -framework Foundation -framework CoreImage -framework CoreMedia -framework CoreVideo -framework AppKit
|
||||
#cgo LDFLAGS: -framework AVFoundation -framework Foundation -framework CoreImage -framework CoreMedia -framework CoreVideo -framework ImageIO -framework AppKit
|
||||
#include <stdlib.h>
|
||||
|
||||
int StartNativeCamera(void);
|
||||
@@ -17,6 +17,8 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const IsNative = true
|
||||
|
||||
// StartCapture starts native camera capture via AVCaptureSession
|
||||
func StartCapture() error {
|
||||
ret := C.StartNativeCamera()
|
||||
|
||||
@@ -4,6 +4,8 @@ package camera
|
||||
|
||||
import "log"
|
||||
|
||||
const IsNative = false
|
||||
|
||||
// StartCapture is a no-op on non-darwin platforms (Windows uses different webcam API)
|
||||
func StartCapture() error {
|
||||
log.Println("[CAMERA] Native camera capture not supported on this platform")
|
||||
|
||||
Reference in New Issue
Block a user