public override string GetSummaryAsText(CameraSummary summary) { string result = ""; string alias = summary.Alias; SpecificInfo info = summary.Specific as SpecificInfo; if (info != null && info.MediaTypeIndex >= 0) { VideoCaptureDevice device = new VideoCaptureDevice(summary.Identifier); Dictionary <int, MediaType> mediaTypes = MediaTypeImporter.Import(device); if (mediaTypes.ContainsKey(info.MediaTypeIndex)) { Size size = mediaTypes[info.MediaTypeIndex].FrameSize; float fps = (float)info.SelectedFramerate; string compression = mediaTypes[info.MediaTypeIndex].Compression; result = string.Format("{0} - {1}×{2} @ {3:0.##} fps ({4}).", alias, size.Width, size.Height, fps, compression); } else { result = string.Format("{0}", alias); } } else { result = string.Format("{0}", alias); } return(result); }
private void InitializeMediaTypes(CameraSummary summary) { device = new VideoCaptureDevice(summary.Identifier); if (device.VideoCapabilities == null || device.VideoCapabilities.Length == 0) { canStreamConfig = false; return; } SpecificInfo info = summary.Specific as SpecificInfo; if (info != null) { selectedMediaTypeIndex = info.MediaTypeIndex; selectedFramerate = info.SelectedFramerate; } else { // First configuration of the device. // We should be using the default parameters. VideoCapabilities[] caps = device.VideoCapabilities; if (caps.Length == 0) { log.ErrorFormat("Cannot get any media type for the device."); return; } selectedMediaTypeIndex = caps[0].Index; selectedFramerate = caps[selectedMediaTypeIndex].AverageFrameRate; } mediaTypes = MediaTypeImporter.Import(device); if (mediaTypes == null || mediaTypes.Count == 0) { canStreamConfig = false; return; } // Ensure indexing by selected media type is valid. if (!mediaTypes.ContainsKey(selectedMediaTypeIndex)) { log.ErrorFormat("Mediatype index not found, using first media type."); selectedMediaTypeIndex = mediaTypes[0].MediaTypeIndex; } organizer.Organize(mediaTypes, MediaTypeImporter.GetSupportedFramerates(device)); canStreamConfig = true; }
private void InitializeMediaTypes(CameraSummary summary) { device = new VideoCaptureDevice(summary.Identifier); if (device.VideoCapabilities == null || device.VideoCapabilities.Length == 0) { canStreamConfig = false; return; } SpecificInfo info = summary.Specific as SpecificInfo; if (info != null) { selectedMediaTypeIndex = info.MediaTypeIndex; selectedFramerate = info.SelectedFramerate; } mediaTypes = MediaTypeImporter.Import(device); if (mediaTypes == null || mediaTypes.Count == 0) { canStreamConfig = false; return; } // Ensure indexing by selected media type is valid. if (!mediaTypes.ContainsKey(selectedMediaTypeIndex)) { selectedMediaTypeIndex = mediaTypes[0].MediaTypeIndex; log.ErrorFormat("Mediatype index not found, using first media type."); } organizer.Organize(mediaTypes, MediaTypeImporter.GetSupportedFramerates(device)); canStreamConfig = true; }