public static void HandleGetWebcams(GetWebcams command, Client client) { var deviceInfo = new Dictionary <string, List <Resolution> >(); var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo videoCaptureDevice in videoCaptureDevices) { List <Size> supportedResolutions = new List <Size>(); var device = new VideoCaptureDevice(videoCaptureDevice.MonikerString); foreach (var resolution in device.VideoCapabilities) { supportedResolutions.Add(resolution.FrameSize); } List <Resolution> res = new List <Resolution>(supportedResolutions.Count); foreach (var r in supportedResolutions) { res.Add(new Resolution { Height = r.Height, Width = r.Width }); } deviceInfo.Add(videoCaptureDevice.Name, res); } if (deviceInfo.Count > 0) { client.Send(new GetWebcamsResponse { Webcams = deviceInfo }); } }
public static void HandleGetWebcams(GetWebcams command, Client client) { var result = new List <string>(); var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo videoCaptureDevice in videoCaptureDevices) { result.Add(videoCaptureDevice.Name); } if (result.Count > 0) { new GetWebcamsResponse(result).Execute(client); } }
public static void HandleGetWebcams(GetWebcams command, Client client) { var deviceInfo = new Dictionary <string, List <Size> >(); var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo videoCaptureDevice in videoCaptureDevices) { List <Size> supportedResolutions = new List <Size>(); var device = new VideoCaptureDevice(videoCaptureDevice.MonikerString); foreach (var resolution in device.VideoCapabilities) { supportedResolutions.Add(resolution.FrameSize); } deviceInfo.Add(videoCaptureDevice.Name, supportedResolutions); } if (deviceInfo.Count > 0) { new GetWebcamsResponse(deviceInfo).Execute(client); } }