Example #1
0
        private async Task RefreshExclusiveDataSourceAsync(ConfigItemKey configItemKey, string exclusiveItem)
        {
            await _meetingConfigView.Dispatcher.BeginInvoke(new Action(() =>
            {
                switch (configItemKey)
                {
                case ConfigItemKey.MainCamera:

                    string tempSecondaryCamera = MeetingConfigResult.SecondaryCamera.Name;

                    SecondaryCameras.Clear();

                    CachedCameras.ForEach((camera) =>
                    {
                        if (camera != exclusiveItem)
                        {
                            SecondaryCameras.Add(camera);
                        }
                    });
                    if (!SecondaryCameras.Contains(NonExclusiveItem))
                    {
                        SecondaryCameras.Add(NonExclusiveItem);
                    }
                    MeetingConfigResult.SecondaryCamera.Name = tempSecondaryCamera;

                    break;

                case ConfigItemKey.SecondaryCamera:

                    string tempMainCamera = MeetingConfigResult.MainCamera.Name;
                    MainCameras.Clear();
                    CachedCameras.ForEach((camera) =>
                    {
                        if (camera != exclusiveItem)
                        {
                            MainCameras.Add(camera);
                        }
                    });

                    if (!MainCameras.Contains(NonExclusiveItem))
                    {
                        MainCameras.Add(NonExclusiveItem);
                    }
                    MeetingConfigResult.MainCamera.Name = tempMainCamera;

                    break;

                case ConfigItemKey.MainMicrophone:
                    string tempSecondaryMic = MeetingConfigResult.AudioConfig.SecondaryMicrophone;

                    SecondaryMicrophones.Clear();

                    CachedMicrophones.ForEach((mic) =>
                    {
                        if (mic != exclusiveItem)
                        {
                            SecondaryMicrophones.Add(mic);
                        }
                    });

                    if (!SecondaryMicrophones.Contains(NonExclusiveItem))
                    {
                        SecondaryMicrophones.Add(NonExclusiveItem);
                    }

                    MeetingConfigResult.AudioConfig.SecondaryMicrophone = tempSecondaryMic;
                    break;

                case ConfigItemKey.SecondaryMicrophone:
                    string tempMainMic = MeetingConfigResult.AudioConfig.MainMicrophone;

                    MainMicrophones.Clear();
                    CachedMicrophones.ForEach((mic) =>
                    {
                        if (mic != exclusiveItem)
                        {
                            MainMicrophones.Add(mic);
                        }
                    });

                    if (!MainMicrophones.Contains(NonExclusiveItem))
                    {
                        MainMicrophones.Add(NonExclusiveItem);
                    }
                    MeetingConfigResult.AudioConfig.MainMicrophone = tempMainMic;
                    break;

                case ConfigItemKey.Unknown:
                default:
                    break;
                }
            }));
        }
Example #2
0
        private async Task AutoSelectConfigAsync()
        {
            await _meetingConfigView.Dispatcher.BeginInvoke(new Action(async() =>
            {
                if (string.IsNullOrEmpty(MeetingConfigResult.MainCamera.Resolution))
                {
                    MeetingConfigResult.MainCamera.Resolution =
                        MeetingConfigParameter.UserCameraSetting.ResolutionList.Count > 0
                            ? MeetingConfigParameter.UserCameraSetting.ResolutionList[0]
                            : null;
                }

                if (string.IsNullOrEmpty(MeetingConfigResult.MainCamera.CodeRate))
                {
                    MeetingConfigResult.MainCamera.CodeRate =
                        MeetingConfigParameter.UserCameraSetting.BitRateList.Count > 0
                            ? MeetingConfigParameter.UserCameraSetting.BitRateList[0]
                            : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.SecondaryCamera.Resolution))
                {
                    MeetingConfigResult.SecondaryCamera.Resolution =
                        MeetingConfigParameter.DataCameraSetting.ResolutionList.Count > 0
                            ? MeetingConfigParameter.DataCameraSetting.ResolutionList[0]
                            : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.SecondaryCamera.CodeRate))
                {
                    MeetingConfigResult.SecondaryCamera.CodeRate =
                        MeetingConfigParameter.DataCameraSetting.BitRateList.Count > 0
                            ? MeetingConfigParameter.DataCameraSetting.BitRateList[0]
                            : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.AudioConfig.Speaker))
                {
                    MeetingConfigResult.AudioConfig.Speaker = Speakers.Count > 0 ? Speakers[0] : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.AudioConfig.SampleRate))
                {
                    MeetingConfigResult.AudioConfig.SampleRate = MeetingConfigParameter.Audio.SampleRateList.Count > 0
                        ? MeetingConfigParameter.Audio.SampleRateList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.AudioConfig.CodeRate))
                {
                    MeetingConfigResult.AudioConfig.CodeRate = MeetingConfigParameter.Audio.BitRateList.Count > 0
                        ? MeetingConfigParameter.Audio.BitRateList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.LocalLiveConfig.Resolution))
                {
                    MeetingConfigResult.LocalLiveConfig.Resolution = MeetingConfigParameter.Live.ResolutionList.Count >
                                                                     0
                        ? MeetingConfigParameter.Live.ResolutionList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.LocalLiveConfig.CodeRate))
                {
                    MeetingConfigResult.LocalLiveConfig.CodeRate = MeetingConfigParameter.Live.BitRateList.Count > 0
                        ? MeetingConfigParameter.Live.BitRateList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.RemoteLiveConfig.Resolution))
                {
                    MeetingConfigResult.RemoteLiveConfig.Resolution = MeetingConfigParameter.Live.ResolutionList.Count >
                                                                      0
                        ? MeetingConfigParameter.Live.ResolutionList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.RemoteLiveConfig.CodeRate))
                {
                    MeetingConfigResult.RemoteLiveConfig.CodeRate = MeetingConfigParameter.Live.BitRateList.Count > 0
                        ? MeetingConfigParameter.Live.BitRateList[0]
                        : null;
                }

                if (string.IsNullOrEmpty(MeetingConfigResult.RecordConfig.Resolution))
                {
                    MeetingConfigResult.RecordConfig.Resolution = MeetingConfigParameter.Live.ResolutionList.Count > 0
                        ? MeetingConfigParameter.Live.ResolutionList[0]
                        : null;
                }
                if (string.IsNullOrEmpty(MeetingConfigResult.RecordConfig.CodeRate))
                {
                    MeetingConfigResult.RecordConfig.CodeRate = MeetingConfigParameter.Live.BitRateList.Count > 0
                        ? MeetingConfigParameter.Live.BitRateList[0]
                        : null;
                }


                //exclusive1
                if (string.IsNullOrEmpty(MeetingConfigResult.MainCamera.Name) && MainCameras.Count > 0)
                {
                    MeetingConfigResult.MainCamera.Name = MainCameras[0];

                    RefreshResolutionsAsync(new ConfigChangedItem()
                    {
                        key = ConfigItemKey.MainCamera,
                        value = MainCameras[0]
                    });

                    if (MainCameras[0] != NonExclusiveItem)
                    {
                        SecondaryCameras.Remove(MainCameras[0]);
                    }
                }

                //exclusive1
                if (string.IsNullOrEmpty(MeetingConfigResult.SecondaryCamera.Name) && SecondaryCameras.Count > 0)
                {
                    MeetingConfigResult.SecondaryCamera.Name = SecondaryCameras[0];

                    RefreshResolutionsAsync(new ConfigChangedItem()
                    {
                        key = ConfigItemKey.SecondaryCamera,
                        value = SecondaryCameras[0]
                    });

                    if (SecondaryCameras[0] != NonExclusiveItem)
                    {
                        MainCameras.Remove(SecondaryCameras[0]);
                    }
                }

                //exclusive2
                if (string.IsNullOrEmpty(MeetingConfigResult.AudioConfig.MainMicrophone) && MainMicrophones.Count > 0)
                {
                    MeetingConfigResult.AudioConfig.MainMicrophone = MainMicrophones[0];

                    if (MainMicrophones[0] != NonExclusiveItem)
                    {
                        SecondaryMicrophones.Remove(MainMicrophones[0]);
                    }
                }

                //exclusive2
                if (string.IsNullOrEmpty(MeetingConfigResult.AudioConfig.SecondaryMicrophone) &&
                    SecondaryMicrophones.Count > 0)
                {
                    MeetingConfigResult.AudioConfig.SecondaryMicrophone = SecondaryMicrophones[0];

                    if (SecondaryMicrophones[0] != NonExclusiveItem)
                    {
                        MainMicrophones.Remove(SecondaryMicrophones[0]);
                    }
                }


                if (MainCameras.Contains(MeetingConfigResult.MainCamera.Name))
                {
                    await
                    RefreshExclusiveDataSourceAsync(ConfigItemKey.MainCamera, MeetingConfigResult.MainCamera.Name);

                    RefreshResolutionsAsync(new ConfigChangedItem()
                    {
                        key = ConfigItemKey.MainCamera,
                        value = MeetingConfigResult.MainCamera.Name
                    });
                }

                if (SecondaryCameras.Contains(MeetingConfigResult.SecondaryCamera.Name))
                {
                    await
                    RefreshExclusiveDataSourceAsync(ConfigItemKey.SecondaryCamera,
                                                    MeetingConfigResult.SecondaryCamera.Name);

                    RefreshResolutionsAsync(new ConfigChangedItem()
                    {
                        key = ConfigItemKey.SecondaryCamera,
                        value = MeetingConfigResult.SecondaryCamera.Name
                    });
                }

                if (MainMicrophones.Contains(MeetingConfigResult.AudioConfig.MainMicrophone))
                {
                    await
                    RefreshExclusiveDataSourceAsync(ConfigItemKey.MainMicrophone,
                                                    MeetingConfigResult.AudioConfig.MainMicrophone);
                }

                if (SecondaryMicrophones.Contains(MeetingConfigResult.AudioConfig.SecondaryMicrophone))
                {
                    await
                    RefreshExclusiveDataSourceAsync(ConfigItemKey.SecondaryMicrophone,
                                                    MeetingConfigResult.AudioConfig.SecondaryMicrophone);
                }

                if (string.IsNullOrEmpty(MeetingConfigResult.RecordConfig.RecordPath))
                {
                    MeetingConfigResult.RecordConfig.RecordPath =
                        Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
                }

                SaveConfig();
            }));
        }