package dezukvm import ( "encoding/json" "net/http" ) func (d *DezukVM) HandleVideoStreams(w http.ResponseWriter, r *http.Request, instanceUuid string) { targetInstance, err := d.GetInstanceByUUID(instanceUuid) if err != nil { http.Error(w, "Instance with specified UUID not found", http.StatusNotFound) return } targetInstance.usbCaptureDevice.ServeVideoStream(w, r) } func (d *DezukVM) HandleAudioStreams(w http.ResponseWriter, r *http.Request, instanceUuid string) { targetInstance, err := d.GetInstanceByUUID(instanceUuid) if err != nil { http.Error(w, "Instance with specified UUID not found", http.StatusNotFound) return } targetInstance.usbCaptureDevice.AudioStreamingHandler(w, r) } func (d *DezukVM) HandleHIDEvents(w http.ResponseWriter, r *http.Request, instanceUuid string) { targetInstance, err := d.GetInstanceByUUID(instanceUuid) if err != nil { http.Error(w, "Instance with specified UUID not found", http.StatusNotFound) return } targetInstance.usbKVMController.HIDWebSocketHandler(w, r) } func (d *DezukVM) HandleListInstances(w http.ResponseWriter, r *http.Request) { instances := []map[string]interface{}{} for _, instance := range d.UsbKvmInstance { instances = append(instances, map[string]interface{}{ "uuid": instance.UUID(), "video_capture_dev": instance.Config.VideoCaptureDevicePath, "audio_capture_dev": instance.Config.AudioCaptureDevicePath, "video_resolution_width": instance.Config.CaptureVideoResolutionWidth, "video_resolution_height": instance.Config.CaptureeVideoResolutionHeight, "video_framerate": instance.Config.CaptureeVideoFPS, "audio_sample_rate": instance.Config.CaptureAudioSampleRate, "audio_channels": instance.Config.CaptureAudioChannels, "stream_info": instance.usbCaptureDevice.GetStreamInfo(), "usb_kvm_device": instance.Config.USBKVMDevicePath, "aux_mcu_device": instance.Config.AuxMCUDevicePath, "usb_mass_storage_side": instance.auxMCUController.GetUSBMassStorageSide(), }) } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(instances) }