private async Task LoadSettings()
        {
            _voipChannel.InitializeRTC();

            SignalingServerPort = int.Parse(SignalingSettings.SignalingServerPort);
            SignalingServerHost = SignalingSettings.SignalingServerHost;
            Domain = RegistrationSettings.Domain;
#if WIN10
            AppInsightsEnabled = SignalingSettings.AppInsightsEnabled;
#endif
            if (_localSettings.Values[nameof(NtpServerIP)] != null)
            {
                NtpServerIP = (string)_localSettings.Values[nameof(NtpServerIP)];
            }

            if (_localSettings.Values[nameof(RTCTraceServerIp)] != null)
            {
                RTCTraceServerIp = (string)_localSettings.Values[nameof(RTCTraceServerIp)];
            }

            if (_localSettings.Values[nameof(RTCTraceServerPort)] != null)
            {
                RTCTraceServerPort = (string)_localSettings.Values[nameof(RTCTraceServerPort)];
            }

            Cameras        = new ObservableCollection <MediaDevice>(_mediaSettings.GetVideoCaptureDevices().Devices);
            SelectedCamera = null;
            if (_localSettings.Values[nameof(SelectedCamera)] != null)
            {
                var id     = (string)_localSettings.Values[nameof(SelectedCamera)];
                var camera = Cameras.SingleOrDefault(c => c.Id.Equals(id));
                if (camera != null)
                {
                    SelectedCamera = camera;
                }
            }
            if (SelectedCamera == null && Cameras.Count > 0)
            {
                SelectedCamera = Cameras.First();
            }
            _mediaSettings.SetVideoDevice(SelectedCamera);

            Microphones        = new ObservableCollection <MediaDevice>(_mediaSettings.GetAudioCaptureDevices().Devices);
            SelectedMicrophone = null;
            if (_localSettings.Values[nameof(SelectedMicrophone)] != null)
            {
                var id  = (string)_localSettings.Values[nameof(SelectedMicrophone)];
                var mic = Microphones.SingleOrDefault(m => m.Id.Equals(id));
                if (mic != null)
                {
                    SelectedMicrophone = mic;
                }
            }
            if (SelectedMicrophone == null && Microphones.Count > 0)
            {
                SelectedMicrophone = Microphones.First();
            }
            _mediaSettings.SetAudioDevice(SelectedMicrophone);

            AudioCodecs = new ObservableCollection <CodecInfo>();
            var audioCodecList = _mediaSettings.GetAudioCodecs();
            foreach (var audioCodec in audioCodecList.Codecs)
            {
                if (!incompatibleAudioCodecs.Contains(audioCodec.Name + audioCodec.Clockrate))
                {
                    AudioCodecs.Add(audioCodec);
                }
            }
            SelectedAudioCodec = null;
            if (_localSettings.Values[nameof(SelectedAudioCodec)] != null)
            {
                var audioCodecId = (int)_localSettings.Values[nameof(SelectedAudioCodec)];
                var audioCodec   = AudioCodecs.SingleOrDefault(a => a.Id.Equals(audioCodecId));
                if (audioCodec != null)
                {
                    SelectedAudioCodec = audioCodec;
                }
            }
            if (SelectedAudioCodec == null && AudioCodecs.Count > 0)
            {
                SelectedAudioCodec = AudioCodecs.First();
            }
            _mediaSettings.SetAudioCodec(SelectedAudioCodec);

            var videoCodecList = _mediaSettings.GetVideoCodecs().Codecs.OrderBy(codec =>
            {
                switch (codec.Name)
                {
                case "VP8": return(1);

                case "VP9": return(2);

                case "H264": return(3);

                default: return(99);
                }
            });
            VideoCodecs        = new ObservableCollection <CodecInfo>(videoCodecList);
            SelectedVideoCodec = null;
            if (_localSettings.Values[nameof(SelectedVideoCodec)] != null)
            {
                var videoCodecId = (int)_localSettings.Values[nameof(SelectedVideoCodec)];
                var videoCodec   = VideoCodecs.SingleOrDefault(v => v.Id.Equals(videoCodecId));
                if (videoCodec != null)
                {
                    SelectedVideoCodec = videoCodec;
                }
            }
            if (SelectedVideoCodec == null && VideoCodecs.Count > 0)
            {
                SelectedVideoCodec = VideoCodecs.First();
            }
            _mediaSettings.SetVideoCodec(SelectedVideoCodec);

            AudioPlayoutDevices = new ObservableCollection <MediaDevice>(_mediaSettings.GetAudioPlayoutDevices().Devices);
            string savedAudioPlayoutDeviceId = null;
            SelectedAudioPlayoutDevice = null;
            if (_localSettings.Values[nameof(SelectedAudioPlayoutDevice)] != null)
            {
                savedAudioPlayoutDeviceId = (string)_localSettings.Values[nameof(SelectedAudioPlayoutDevice)];
                var playoutDevice = AudioPlayoutDevices.SingleOrDefault(a => a.Id.Equals(savedAudioPlayoutDeviceId));
                if (playoutDevice != null)
                {
                    SelectedAudioPlayoutDevice = playoutDevice;
                }
            }
            if (SelectedAudioPlayoutDevice == null && AudioPlayoutDevices.Count > 0)
            {
                SelectedAudioPlayoutDevice = AudioPlayoutDevices.First();
            }
            _mediaSettings.SetAudioPlayoutDevice(SelectedAudioPlayoutDevice);

            IceServers = new ObservableCollection <IceServerViewModel>(
                IceServerSettings.IceServers.Select(ices => new IceServerViewModel(ices)));
        }