示例#1
0
        public VideoSettingModel(VideoSettingView view)
        {
            _view             = view;
            _cameraDeviceList = new List <VideoDeviceModel>();
            _docDeviceList    = new List <VideoDeviceModel>();
            _s = new InputSimulator();

            _configManager    = new ConfigManager();
            _meetingSdkAgent  = DependencyResolver.Current.GetService <IMeetingSdkAgent>();
            _localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>();

            _deviceNameAccessor = DependencyResolver.Current.GetService <IDeviceNameAccessor>();
            _deviceConfigLoader = DependencyResolver.Current.GetService <IDeviceConfigLoader>();

            CameraDeviceList = new ObservableCollection <string>();
            DocDeviceList    = new ObservableCollection <string>();

            CameraColorSpaces = new ObservableCollection <VideoFormatModel>();
            DocColorSpaces    = new ObservableCollection <VideoFormatModel>();

            VedioParameterVgaList    = new ObservableCollection <string>();
            DocParameterVgaList      = new ObservableCollection <string>();
            VedioParameterRatesList  = new ObservableCollection <int>();
            LoadCommand              = new DelegateCommand(Loading);
            WindowKeyDownCommand     = new DelegateCommand <object>(WindowKeyDownHandler);
            CheckCameraDeviceCommand = DelegateCommand.FromAsyncHandler(CheckCameraDeviceAsync);
            CheckDocDeviceCommand    = DelegateCommand.FromAsyncHandler(CheckDocDeviceAsync);

            //CheckCameraColorSpaceCommand = new DelegateCommand(CheckCameraColorSpace);
            //CheckDocColorSpaceCommand = new DelegateCommand(CheckDocColorSpace);

            GoBackCommand = new DelegateCommand(GoBack);
        }
 private void SaveSetting()
 {
     try
     {
         var       newIp = $"{ServerIp1}.{ServerIp2}.{ServerIp3}.{ServerIp4}";
         IPAddress ip;
         if (!IPAddress.TryParse(newIp, out ip) || ServerPort < 0 || ServerPort > 65535)
         {
             //不合法
         }
         else
         {
             if (_configManager == null)
             {
                 _configManager = new ConfigManager {
                     ServerInfo = new ServerInfo()
                 };
             }
             _configManager.ServerInfo.BmsServerPort = ServerPort;
             _configManager.ServerInfo.ServerIp      = newIp;
             _localDataManager.SaveSettingConfigData(_configManager);
             //新IP地址与配置中保存的不一致们需要重启
         }
     }
     catch (Exception ex)
     {
         Log.Logger.Error($"基础设置SaveSetting() exception:{ex}");
         MessageQueueManager.Instance.AddError(MessageManager.SaveError);
     }
 }
 private async Task Loading()
 {
     await _view.Dispatcher.BeginInvoke(new Action(() =>
     {
         try
         {
             //本地保存的配置
             _configManager = _localDataManager.GetSettingConfigData() ??
                              new ConfigManager {
                 ServerInfo = new ServerInfo()
                 {
                     BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort, ServerIp = GlobalData.Instance.LocalSetting.ServerIp
                 }
             };
             if (_configManager.ServerInfo == null)
             {
                 _configManager.ServerInfo = new ServerInfo();
             }
             if (string.IsNullOrEmpty(_configManager.ServerInfo.ServerIp))
             {
                 return;
             }
             ServerIp1 = int.Parse(_configManager.ServerInfo.ServerIp.Split('.')[0]);
             ServerIp2 = int.Parse(_configManager.ServerInfo.ServerIp.Split('.')[1]);
             ServerIp3 = int.Parse(_configManager.ServerInfo.ServerIp.Split('.')[2]);
             ServerIp4 = int.Parse(_configManager.ServerInfo.ServerIp.Split('.')[3]);
             ServerPort = _configManager.ServerInfo.BmsServerPort;
         }
         catch (Exception ex)
         {
             Log.Logger.Error($"基础设置加载信息发生异常 exception:{ex}");
             MessageQueueManager.Instance.AddError(MessageManager.LoadingError);
         }
     }));
 }
示例#4
0
 public void SaveSettingConfigData(ConfigManager config)
 {
     try
     {
         var filePath = _dataFilePath + "/Config.xml";
         SerializeHelper.Serialize(config, typeof(ConfigManager), filePath);
         GlobalData.Instance.ConfigManager = config;
     }
     catch (Exception ex)
     {
         Log.Logger.Debug($"配置文件处理异常:{ex.Message}");
     }
 }
示例#5
0
        private async Task Loading()
        {
            try
            {
                _configManager = _localDataManager.GetSettingConfigData() ?? new ConfigManager()
                {
                    ServerInfo = new ServerInfo()
                    {
                        BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort, ServerIp = GlobalData.Instance.LocalSetting.ServerIp
                    }
                };
                if (_configManager?.NetInfo == null)
                {
                    _configManager.NetInfo = new NetInfo();
                }
                if (_configManager?.ServerInfo == null)
                {
                    _configManager.ServerInfo = new ServerInfo();
                }
                //实时网络信息
                await GetNetInfos();
                await BindDataSource();

                var defaultNefInfo = _netInfos.FirstOrDefault(o => o.AdapterName == _configManager.NetInfo?.AdapterName);
                if (defaultNefInfo != null)
                {
                    await SetDefaultSetting(_configManager.NetInfo);
                }
                else
                {
                    await SetDefaultSetting(_netInfos.FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"网络设置加载信息发生异常 exception:{ex}");
                MessageQueueManager.Instance.AddError(MessageManager.LoadingError);
            }
        }
示例#6
0
        private async Task SetDefaultSetting()
        {
            await _view.Dispatcher.BeginInvoke(new Action(() =>
            {
                //本地保存的配置
                _configManager = _localDataManager.GetSettingConfigData() ?? new ConfigManager()
                {
                    ServerInfo = new ServerInfo()
                    {
                        BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort, ServerIp = GlobalData.Instance.LocalSetting.ServerIp
                    }
                };
                if (_configManager.LocalLiveStreamInfo == null)
                {
                    _configManager.LocalLiveStreamInfo = new LiveStreamInfo();
                }
                if (_configManager.RecordInfo == null)
                {
                    _configManager.RecordInfo = new RecordInfo();
                }
                if (_configManager.RemoteLiveStreamInfo == null)
                {
                    _configManager.RemoteLiveStreamInfo = new LiveStreamInfo();
                }

                SelectedLiveDisplay =
                    $"{_configManager.LocalLiveStreamInfo.LiveStreamDisplayWidth}*{_configManager.LocalLiveStreamInfo.LiveStreamDisplayHeight}";
                SelectedLiveRate = _configManager.LocalLiveStreamInfo.LiveStreamBitRate;
                SelectedRemoteDisplay =
                    $"{_configManager.RemoteLiveStreamInfo.LiveStreamDisplayWidth}*{_configManager.RemoteLiveStreamInfo.LiveStreamDisplayHeight}";
                SelectedRemoteRate = _configManager.RemoteLiveStreamInfo.LiveStreamBitRate;
                SelectedLocalResolution =
                    $"{_configManager.RecordInfo.RecordDisplayWidth}*{_configManager.RecordInfo.RecordDisplayHeight}";
                SelectedLocalBitrate = _configManager.RecordInfo.RecordBitRate;
                SelectedLocalPath = _configManager.RecordInfo.RecordDirectory;
            }));
        }
示例#7
0
        private void SaveSetting()
        {
            try
            {
                if (_configManager == null)
                {
                    _configManager = new ConfigManager
                    {
                        LocalLiveStreamInfo  = new LiveStreamInfo(),
                        RemoteLiveStreamInfo = new LiveStreamInfo(),
                        RecordInfo           = new RecordInfo()
                    };
                }

                _configManager.LocalLiveStreamInfo.LiveStreamBitRate       = SelectedLiveRate;
                _configManager.LocalLiveStreamInfo.LiveStreamDisplayHeight = int.Parse(SelectedLiveDisplay.Split('*')[1]);
                _configManager.LocalLiveStreamInfo.LiveStreamDisplayWidth  = int.Parse(SelectedLiveDisplay.Split('*')[0]);

                _configManager.RemoteLiveStreamInfo.LiveStreamBitRate       = SelectedRemoteRate;
                _configManager.RemoteLiveStreamInfo.LiveStreamDisplayHeight =
                    int.Parse(SelectedRemoteDisplay.Split('*')[1]);
                _configManager.RemoteLiveStreamInfo.LiveStreamDisplayWidth = int.Parse(SelectedRemoteDisplay.Split('*')[0]);


                _configManager.RecordInfo.RecordBitRate       = SelectedLocalBitrate;
                _configManager.RecordInfo.RecordDirectory     = SelectedLocalPath;
                _configManager.RecordInfo.RecordDisplayWidth  = int.Parse(SelectedLocalResolution.Split('*')[0]);
                _configManager.RecordInfo.RecordDisplayHeight = int.Parse(SelectedLocalResolution.Split('*')[1]);

                _localDataManager.SaveSettingConfigData(_configManager);
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"直播设置SaveSetting() exception:{ex}");
                MessageQueueManager.Instance.AddError(MessageManager.SaveError);
            }
        }
示例#8
0
        private void Loading()
        {
            try
            {
                //获取本地保存的配置
                _configManager = _localDataManager.GetSettingConfigData() ?? new ConfigManager()
                {
                    ServerInfo = new ServerInfo()
                    {
                        BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort, ServerIp = GlobalData.Instance.LocalSetting.ServerIp
                    }
                };

                if (_configManager == null)
                {
                    MessageQueueManager.Instance.AddError("读取配置文件时出错!");
                    return;
                }

                if (_configManager.MainVideoInfo == null)
                {
                    _configManager.MainVideoInfo = new VideoInfo();
                }
                if (_configManager.DocVideoInfo == null)
                {
                    _configManager.DocVideoInfo = new VideoInfo();
                }

                CameraDeviceList.Clear();
                DocDeviceList.Clear();

                CameraColorSpaces.Clear();
                DocColorSpaces.Clear();

                VedioParameterVgaList.Clear();
                DocParameterVgaList.Clear();
                VedioParameterRatesList.Clear();


                //摄像头设备
                var cameraList = _meetingSdkAgent.GetVideoDevices();

                if (cameraList.Result == null)
                {
                    MessageQueueManager.Instance.AddError("无法获取本机设备信息!");
                    return;
                }

                _cameraDeviceList = cameraList.Result.ToList();

                string log = "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\r\n";
                foreach (var cameraDevice in _cameraDeviceList)
                {
                    log += $"name:{cameraDevice.DeviceName}, ";

                    foreach (var format in cameraDevice.VideoFormatModels)
                    {
                        log += $"{format.ColorspaceName}\r\n";

                        foreach (var size in format.SizeModels)
                        {
                            log += $"size:{size.Width}*{size.Height}\r\n";
                        }
                    }
                }

                log += "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\r\n";

                Log.Logger.Information(log);

                var docCameraList = _meetingSdkAgent.GetVideoDevices();

                _docDeviceList = docCameraList.Result.ToList();

                //码率
                var settingLocalData = _localDataManager.GetSettingParameter();
                if (settingLocalData != null)
                {
                    var rateList = settingLocalData.VedioParameterRates;
                    rateList.ForEach(v => { VedioParameterRatesList.Add(v.VideoBitRate); });
                }
                _cameraDeviceList.ForEach(c => { CameraDeviceList.Add(c.DeviceName); });
                _docDeviceList.ForEach(d => { DocDeviceList.Add(d.DeviceName); });
                CameraDeviceList.Add("");
                DocDeviceList.Add("");
                SetDefaultSetting();

                if (_cameraDeviceList.All(o => o.DeviceName != SelectedCameraDevice))
                {
                    SelectedCameraDevice = string.Empty;
                }
                if (_docDeviceList.All(o => o.DeviceName != SelectedDocDevice))
                {
                    SelectedDocDevice = string.Empty;
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"视频设置加载信息发生异常 exception:{ex}");
                MessageQueueManager.Instance.AddError(MessageManager.LoadingError);
            }
        }