public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ConfigItemKey key = ConfigItemKey.Unknown; if (values[0] != null) { Enum.TryParse <ConfigItemKey>(values[0].ToString(), out key); } string value = values[1] == null ? null : values[1] as string; ConfigChangedItem item = new ConfigChangedItem() { key = key, value = value }; return(item); }
private void RefreshResolutionsAsync(ConfigChangedItem configChangedItem) { if (configChangedItem.value == NonExclusiveItem) { return; } VideoDeviceInfo videoDeviceInfo = _sdkService.GetVideoDeviceInfos(configChangedItem.value); if (configChangedItem.key == ConfigItemKey.MainCamera) { if (videoDeviceInfo.FormatCount > 0) { MeetingConfigParameter.UserCameraSetting.ResolutionList.Clear(); VideoFormat videoFormat = videoDeviceInfo.Formats[0]; for (int i = 0; i < videoFormat.sizeCount; i++) { string resolution = $"{videoFormat.VideoSizes[i].Width}*{videoFormat.VideoSizes[i].Height}"; if (!MeetingConfigParameter.UserCameraSetting.ResolutionList.Contains(resolution)) { MeetingConfigParameter.UserCameraSetting.ResolutionList.Add(resolution); } } } if ( MeetingConfigParameter.UserCameraSetting.ResolutionList.Contains( GlobalData.Instance.AggregatedConfig.MainCamera.Resolution)) { MeetingConfigResult.MainCamera.Resolution = GlobalData.Instance.AggregatedConfig.MainCamera.Resolution; } else if (MeetingConfigParameter.UserCameraSetting.ResolutionList.Count > 0) { MeetingConfigResult.MainCamera.Resolution = MeetingConfigParameter.UserCameraSetting.ResolutionList[0]; } } if (configChangedItem.key == ConfigItemKey.SecondaryCamera) { if (videoDeviceInfo.FormatCount > 0) { MeetingConfigParameter.DataCameraSetting.ResolutionList.Clear(); VideoFormat videoFormat = videoDeviceInfo.Formats[0]; for (int i = 0; i < videoFormat.sizeCount; i++) { string resolution = $"{videoFormat.VideoSizes[i].Width}*{videoFormat.VideoSizes[i].Height}"; if (!MeetingConfigParameter.DataCameraSetting.ResolutionList.Contains(resolution)) { MeetingConfigParameter.DataCameraSetting.ResolutionList.Add(resolution); } } } if ( MeetingConfigParameter.DataCameraSetting.ResolutionList.Contains( GlobalData.Instance.AggregatedConfig.SecondaryCamera.Resolution)) { MeetingConfigResult.SecondaryCamera.Resolution = GlobalData.Instance.AggregatedConfig.SecondaryCamera.Resolution; } else if (MeetingConfigParameter.DataCameraSetting.ResolutionList.Count > 0) { MeetingConfigResult.SecondaryCamera.Resolution = MeetingConfigParameter.DataCameraSetting.ResolutionList[0]; } } }
private async Task ConfigItemChangedAsync(ConfigChangedItem configChangedItem) { if (string.IsNullOrEmpty(configChangedItem.value)) { return; } await Task.Run(async() => { switch (configChangedItem.key) { case ConfigItemKey.MainCamera: await RefreshExclusiveDataSourceAsync(ConfigItemKey.MainCamera, configChangedItem.value); _sdkService.SetDefaultDevice(1, configChangedItem.value); await _meetingConfigView.Dispatcher.BeginInvoke(new Action(() => { RefreshResolutionsAsync(configChangedItem); })); break; case ConfigItemKey.MainCameraResolution: string[] mainResolution = configChangedItem.value.Split('*'); _sdkService.SetVideoResolution(1, int.Parse(mainResolution[0]), int.Parse(mainResolution[1])); break; case ConfigItemKey.MainCameraCodeRate: _sdkService.SetVideoBitRate(1, int.Parse(configChangedItem.value)); break; case ConfigItemKey.SecondaryCamera: await RefreshExclusiveDataSourceAsync(ConfigItemKey.SecondaryCamera, configChangedItem.value); _sdkService.SetDefaultDevice(2, configChangedItem.value); await _meetingConfigView.Dispatcher.BeginInvoke(new Action(() => { RefreshResolutionsAsync(configChangedItem); })); break; case ConfigItemKey.SecondaryCameraResolution: string[] secondaryResolution = configChangedItem.value.Split('*'); _sdkService.SetVideoResolution(2, int.Parse(secondaryResolution[0]), int.Parse(secondaryResolution[1])); break; case ConfigItemKey.SecondaryCameraCodeRate: _sdkService.SetVideoBitRate(2, int.Parse(configChangedItem.value)); break; case ConfigItemKey.MainMicrophone: await RefreshExclusiveDataSourceAsync(ConfigItemKey.MainMicrophone, configChangedItem.value); _sdkService.SetDefaultDevice(3, configChangedItem.value); break; case ConfigItemKey.SecondaryMicrophone: await RefreshExclusiveDataSourceAsync(ConfigItemKey.SecondaryMicrophone, configChangedItem.value); _sdkService.SetDefaultDevice(5, configChangedItem.value); break; case ConfigItemKey.Speaker: _sdkService.SetDefaultDevice(4, configChangedItem.value); break; case ConfigItemKey.AudioSampleRate: _sdkService.SetAudioSampleRate(int.Parse(configChangedItem.value)); break; case ConfigItemKey.AudioCodeRate: _sdkService.SetAudioBitRate(int.Parse(configChangedItem.value)); break; case ConfigItemKey.LiveResolution: break; case ConfigItemKey.LiveCodeRate: break; case ConfigItemKey.Unknown: default: break; } SaveConfig(); }); }
private void RefreshResolutionsAsync(ConfigChangedItem configChangedItem) { if (configChangedItem.value == NonExclusiveItem) { return; } Camera videoDeviceInfo = _sdkService.GetCameraInfo(configChangedItem.value); if (configChangedItem.key == ConfigItemKey.MainCamera) { if (videoDeviceInfo.CameraParameters.Count > 0) { MeetingConfigParameter.UserCameraSetting.ResolutionList.Clear(); CameraParameter cameraParameter = videoDeviceInfo.CameraParameters[0]; foreach (Size t in cameraParameter.VideoSizes) { string resolution = $"{t.Width}*{t.Height}"; if (!MeetingConfigParameter.UserCameraSetting.ResolutionList.Contains(resolution)) { MeetingConfigParameter.UserCameraSetting.ResolutionList.Add(resolution); } } } if ( MeetingConfigParameter.UserCameraSetting.ResolutionList.Contains( GlobalData.Instance.AggregatedConfig.MainCamera.Resolution)) { MeetingConfigResult.MainCamera.Resolution = GlobalData.Instance.AggregatedConfig.MainCamera.Resolution; } else if (MeetingConfigParameter.UserCameraSetting.ResolutionList.Count > 0) { MeetingConfigResult.MainCamera.Resolution = MeetingConfigParameter.UserCameraSetting.ResolutionList[0]; } } if (configChangedItem.key == ConfigItemKey.SecondaryCamera) { if (videoDeviceInfo.CameraParameters.Count > 0) { MeetingConfigParameter.DataCameraSetting.ResolutionList.Clear(); CameraParameter cameraParameter = videoDeviceInfo.CameraParameters[0]; foreach (Size t in cameraParameter.VideoSizes) { string resolution = $"{t.Width}*{t.Height}"; if (!MeetingConfigParameter.DataCameraSetting.ResolutionList.Contains(resolution)) { MeetingConfigParameter.DataCameraSetting.ResolutionList.Add(resolution); } } } if ( MeetingConfigParameter.DataCameraSetting.ResolutionList.Contains( GlobalData.Instance.AggregatedConfig.SecondaryCamera.Resolution)) { MeetingConfigResult.SecondaryCamera.Resolution = GlobalData.Instance.AggregatedConfig.SecondaryCamera.Resolution; } else if (MeetingConfigParameter.DataCameraSetting.ResolutionList.Count > 0) { MeetingConfigResult.SecondaryCamera.Resolution = MeetingConfigParameter.DataCameraSetting.ResolutionList[0]; } } }