public PublishLiveStreamParameter GetLiveParam() { ConfigManager configManager = _localDataManager.GetSettingConfigData(); try { LiveParam = new PublishLiveStreamParameter { LiveParameter = new LiveParameter() { AudioBitrate = 64, BitsPerSample = 16, Channels = 1, IsLive = true, IsRecord = false, SampleRate = 8000, VideoBitrate = configManager.RemoteLiveStreamInfo.LiveStreamBitRate, Width = configManager.RemoteLiveStreamInfo.LiveStreamDisplayWidth, Height = configManager.RemoteLiveStreamInfo.LiveStreamDisplayHeight } }; } catch (Exception ex) { Log.Logger.Error($"【get server push live param exception】:{ex}"); return(null); } return(LiveParam); }
public bool AddRecord() { try { var course = GlobalData.Instance.Course; if (course == null) { return(false); } var config = _localDataManager.GetSettingConfigData(); var ip = $"{config.ServerInfo.ServerIp}:{config.ServerInfo.BmsServerPort}"; var fileOutId = $"{course.MeetingId}_{DateTime.Now:yyyymmddhhmmss}"; var data = $"{{\"classroomid\":\"{GlobalData.Instance.Classroom.Id}\",\"curriculumId\":\"{course.Id}\",\"classno\":\"{course.MeetingId}\",\"recordfilecid\":\"{fileOutId}\"}}"; var url = $"http://{ip}/SupperSchool/startrecord"; Log.Logger.Debug($"调用接口startrecord: url={url}"); var response = HttpManager.HttpPostData(url, data); Log.Logger.Debug($"调用接口startrecord返回数据:{url},参数:{data}"); if (string.IsNullOrEmpty(response)) { return(false); } var temp = JsonConvert.DeserializeObject(response, typeof(ReturnMessage)) as ReturnMessage; return(temp != null && temp.Status == "0"); } catch (Exception ex) { Log.Logger.Error($"调用接口startrecord异常:{ex.Message}"); return(false); } }
private void LoadLocalConfiger() { GlobalData.Instance.LocalSetting = _localDataManager.GetSettingConfig() ?? new LocalSetting(); GlobalData.Instance.ConfigManager = new ConfigManager() { AudioInfo = new AudioInfo(), LocalLiveStreamInfo = new LiveStreamInfo(), NetInfo = new NetInfo(), RecordInfo = new RecordInfo(), RemoteLiveStreamInfo = new LiveStreamInfo(), ServerInfo = new ServerInfo(), MainVideoInfo = new VideoInfo(), DocVideoInfo = new VideoInfo() }; var localDataConfig = _localDataManager.GetSettingConfigData(); if (localDataConfig != null) { if (localDataConfig.ServerInfo == null || localDataConfig.ServerInfo.BmsServerPort == 0) { localDataConfig.ServerInfo = new ServerInfo() { ServerIp = GlobalData.Instance.LocalSetting.ServerIp, BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort }; _localDataManager.SaveSettingConfigData(localDataConfig); } GlobalData.Instance.ConfigManager = localDataConfig; } else { localDataConfig = GlobalData.Instance.ConfigManager; localDataConfig.ServerInfo = new ServerInfo() { ServerIp = GlobalData.Instance.LocalSetting.ServerIp, BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort }; _localDataManager.SaveSettingConfigData(localDataConfig); GlobalData.Instance.ConfigManager = _localDataManager.GetSettingConfigData(); } }
private bool CheckConnectToSever() { //获取服务器ip、端口 var configData = _localDataManager.GetSettingConfigData(); return(configData?.ServerInfo != null && PingServer(string.Empty, $"{configData.ServerInfo.ServerIp}:{configData.ServerInfo.BmsServerPort}")); }
public bool GetLiveParam() { ConfigManager configManager = _localDataManager.GetSettingConfigData(); try { if (configManager?.LocalLiveStreamInfo == null) { return(false); } LiveParam = new PublishLiveStreamParameter { LiveParameter = new LiveParameter() { AudioBitrate = 64, BitsPerSample = 16, Channels = 2, IsLive = true, IsRecord = false, SampleRate = 48000, VideoBitrate = configManager.LocalLiveStreamInfo.LiveStreamBitRate, Width = configManager.LocalLiveStreamInfo.LiveStreamDisplayWidth, Height = configManager.LocalLiveStreamInfo.LiveStreamDisplayHeight, Url1 = GlobalData.Instance.Classroom.RemotePushStreamUrl } }; } catch (Exception ex) { Log.Logger.Error($"【get server push live param exception】:{ex}"); return(false); } return(true); }
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); } })); }
public static VideoInfo GetVideoInfo(string sourceName) { VideoInfo videoInfo = null; ILocalDataManager localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>(); ConfigManager configManager = localDataManager.GetSettingConfigData(); if (sourceName == configManager.MainVideoInfo.VideoDevice) { return(configManager.MainVideoInfo); } if (sourceName == configManager.DocVideoInfo.VideoDevice) { return(configManager.DocVideoInfo); } if (sourceName == "DesktopCapture") { videoInfo.DisplayWidth = 1280; videoInfo.DisplayHeight = 720; videoInfo.VideoBitRate = 1200; videoInfo.ColorSpace = (int)VideoColorSpace.YUY2; return(videoInfo); } return(videoInfo); }
private void Loading() { try { //获取本地保存的配置 _configManager = _localDataManager.GetSettingConfigData() ?? new ConfigManager { AudioInfo = new AudioInfo(), ServerInfo = new ServerInfo() { BmsServerPort = GlobalData.Instance.LocalSetting.BmsServerPort, ServerIp = GlobalData.Instance.LocalSetting.ServerIp } }; if (_configManager.AudioInfo == null) { _configManager.AudioInfo = new AudioInfo(); } var parameterData = _localDataManager.GetSettingParameter(); //设备 var audioSourceList = _meetingSdkAgent.GetMicrophones(); var docSourceList = _meetingSdkAgent.GetMicrophones(); var audioOutPutList = _meetingSdkAgent.GetLoudSpeakers(); var sampleRateList = parameterData.AudioParameterSampleRates; var aac = parameterData.AudioParameterAACs; //装载数据源 audioSourceList.Result.ToList().ForEach(a => { AudioSource.Add(a); }); docSourceList.Result.ToList().ForEach(d => { DocAudioSource.Add(d); }); audioOutPutList.Result.ToList().ForEach(o => { AudioOutPutDevice.Add(o); }); aac.ForEach(o => { Aac.Add(o.AAC); }); sampleRateList.ForEach(o => { SampleRate.Add(o.SampleRate); }); AudioSource.Add(string.Empty); DocAudioSource.Add(string.Empty); //设置默认选项 SetDefaultSetting(); if (audioSourceList.Result.All(o => o != SelectedAudioSource)) { SelectedAudioSource = string.Empty; } if (docSourceList.Result.All(o => o != SelectedDocAudioSource)) { SelectedDocAudioSource = string.Empty; } if (audioOutPutList.Result.All(o => o != SelectedAudioOutPutDevice)) { SelectedAudioOutPutDevice = string.Empty; } } catch (Exception ex) { Log.Logger.Error($"音频设置加载信息发生异常 exception:{ex}"); MessageQueueManager.Instance.AddError(MessageManager.LoadingError); } }
public static AudioInfo GetAudioInfo(string sourceName) { AudioInfo audioInfo = null; ILocalDataManager localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>(); ConfigManager configManager = localDataManager.GetSettingConfigData(); if (sourceName == configManager.AudioInfo.AudioSammpleDevice || sourceName == configManager.AudioInfo.DocAudioSammpleDevice) { return(configManager.AudioInfo); } audioInfo = new AudioInfo() { AAC = 64000, SampleRate = 48000, }; return(audioInfo); }
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); } }
public bool GetRecordParam() { ConfigManager configManager = _localDataManager.GetSettingConfigData(); try { if (configManager?.RecordInfo == null) { return(false); } RecordParam = new PublishLiveStreamParameter() { LiveParameter = new LiveParameter() { AudioBitrate = 64, BitsPerSample = 16, Channels = 2, SampleRate = configManager.AudioInfo.SampleRate, VideoBitrate = configManager.RecordInfo.RecordBitRate, Width = configManager.RecordInfo.RecordDisplayWidth, Height = configManager.RecordInfo.RecordDisplayHeight, IsRecord = true, IsLive = false, FilePath = configManager.RecordInfo.RecordDirectory, }, MediaType = MediaType.StreamMedia, StreamType = StreamType.Live, }; RecordDirectory = configManager.RecordInfo.RecordDirectory; return(true); } catch (Exception ex) { Log.Logger.Error($"【get record param exception】:{ex}"); return(false); } }
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; })); }
private async void ShareAsync() { if (_isProcessingShareOperation) { ShareToggleItem.IsChecked = !ShareToggleItem.IsChecked; return; } if (!_isProcessingShareOperation) { _isProcessingShareOperation = true; } try { MeetingResult <IList <VideoDeviceModel> > videoDeviceResult = _meetingService.GetVideoDevices(); MeetingResult <IList <string> > micResult = _meetingService.GetMicrophones(); ConfigManager configManager = _localDataManager.GetSettingConfigData(); IEnumerable <string> docCameras; if (!_deviceNameAccessor.TryGetName(DeviceName.Camera, (devName) => { return(devName.Option == "second"); }, out docCameras) || !videoDeviceResult.Result.Any(vdm => vdm.DeviceName == docCameras.FirstOrDefault())) { ShareToggleItem.IsChecked = false; MessageQueueManager.Instance.AddError("课件摄像头未配置!"); return; } if (configManager.DocVideoInfo?.DisplayWidth == 0 || configManager.DocVideoInfo?.DisplayHeight == 0 || configManager.DocVideoInfo?.VideoBitRate == 0) { ShareToggleItem.IsChecked = false; MessageQueueManager.Instance.AddError("课件采集参数未设置!"); return; } IEnumerable <string> docMics; if (!_deviceNameAccessor.TryGetName(DeviceName.Microphone, (devName) => { return(devName.Option == "second"); }, out docMics) || !micResult.Result.Any(mic => mic == docMics.FirstOrDefault())) { ShareToggleItem.IsChecked = false; MessageQueueManager.Instance.AddError("课件麦克风未配置!"); return; } if (!_windowManager.Participant.IsSpeaking) { ShareToggleItem.IsChecked = false; MessageQueueManager.Instance.AddError("发言状态才可以进行课件分享!"); return; } if (ShareToggleItem.IsChecked) { MeetingResult <int> publishDocCameraResult = await _windowManager.Publish(MeetingSdk.NetAgent.Models.MediaType.VideoDoc, docCameras.FirstOrDefault()); MeetingResult <int> publishDocMicResult = await _windowManager.Publish(MeetingSdk.NetAgent.Models.MediaType.AudioDoc, docMics.FirstOrDefault()); if (publishDocCameraResult.StatusCode != 0 || publishDocMicResult.StatusCode != 0) { ShareToggleItem.IsChecked = false; MessageQueueManager.Instance.AddError("打开课件失败!"); return; } AppCache.AddOrUpdate(CacheKey.DocVideoResourceId, publishDocCameraResult.Result); AppCache.AddOrUpdate(CacheKey.DocAudioResourceId, publishDocMicResult.Result); AppCache.AddOrUpdate(CacheKey.IsDocOpen, true); } else { object docCameraResourceIdObj = AppCache.TryGet(CacheKey.DocVideoResourceId); int docCameraResourceId; if (docCameraResourceIdObj == null || !int.TryParse(docCameraResourceIdObj.ToString(), out docCameraResourceId)) { return; } object docAudioResourceIdObj = AppCache.TryGet(CacheKey.DocAudioResourceId); int docAudioResourceId; if (docAudioResourceIdObj == null || !int.TryParse(docAudioResourceIdObj.ToString(), out docAudioResourceId)) { return; } MeetingResult stopShareCameraResult = await _windowManager.Unpublish(MeetingSdk.NetAgent.Models.MediaType.VideoDoc, docCameraResourceId); MeetingResult stopShareMicResult = await _windowManager.Unpublish(MeetingSdk.NetAgent.Models.MediaType.AudioDoc, docAudioResourceId); if (stopShareCameraResult.StatusCode != 0 || stopShareMicResult.StatusCode != 0) { ShareToggleItem.IsChecked = true; MessageQueueManager.Instance.AddError("关闭课件失败!"); return; } //CheckClassModeAsync(ModeDisplayerType.InteractionMode); AppCache.AddOrUpdate(CacheKey.IsDocOpen, false); } CheckClassMode(); } catch (Exception) { } finally { _isProcessingShareOperation = false; } }
public bool IsVideoAudioSettingsValid(Window sourceWindow) { string errorMsg = string.Empty; MeetingResult <IList <VideoDeviceModel> > videoDeviceResult = _meetingSdkAgent.GetVideoDevices(); MeetingResult <IList <string> > micResult = _meetingSdkAgent.GetMicrophones(); MeetingResult <IList <string> > speakerResult = _meetingSdkAgent.GetLoudSpeakers(); ConfigManager configManager = _localDataManager.GetSettingConfigData(); if (configManager == null) { errorMsg = "参数配置有误!"; MessageQueueManager.Instance.AddInfo(errorMsg); SettingNavView settingNavView = new SettingNavView(); settingNavView.Show(); sourceWindow?.Close(); return(false); } IDeviceNameAccessor deviceNameAccessor = DependencyResolver.Current.GetService <IDeviceNameAccessor>(); IEnumerable <string> cameraDeviceName; if (videoDeviceResult.Result.Count == 0 || string.IsNullOrEmpty(configManager.MainVideoInfo?.VideoDevice) || !deviceNameAccessor.TryGetName(DeviceName.Camera, new Func <DeviceName, bool>(d => { return(d.Option == "first"); }), out cameraDeviceName) || !videoDeviceResult.Result.Any(vdm => vdm.DeviceName == cameraDeviceName.FirstOrDefault())) { errorMsg = "人像采集未设置!"; MessageQueueManager.Instance.AddInfo(errorMsg); VideoSettingView videoSettingView = new VideoSettingView(); videoSettingView.Show(); sourceWindow?.Close(); return(false); } if (configManager.MainVideoInfo?.DisplayWidth == 0 || configManager.MainVideoInfo?.DisplayHeight == 0 || configManager.MainVideoInfo?.VideoBitRate == 0) { errorMsg = "人像采集参数未设置!"; MessageQueueManager.Instance.AddInfo(errorMsg); VideoSettingView videoSettingView = new VideoSettingView(); videoSettingView.Show(); sourceWindow?.Close(); return(false); } IEnumerable <string> micDeviceName; if (micResult.Result.Count == 0 || string.IsNullOrEmpty(configManager.AudioInfo?.AudioSammpleDevice) || !deviceNameAccessor.TryGetName(DeviceName.Microphone, new Func <DeviceName, bool>(d => { return(d.Option == "first"); }), out micDeviceName) || !micResult.Result.Any(mic => mic == micDeviceName.FirstOrDefault())) { errorMsg = "人声音源未设置!"; MessageQueueManager.Instance.AddInfo(errorMsg); AudioSettingView audioSettingView = new AudioSettingView(); audioSettingView.Show(); sourceWindow?.Close(); return(false); } if (configManager.AudioInfo?.SampleRate == 0 || configManager.AudioInfo?.AAC == 0) { errorMsg = "人声音源参数未设置!"; MessageQueueManager.Instance.AddInfo(errorMsg); AudioSettingView audioSettingView = new AudioSettingView(); audioSettingView.Show(); sourceWindow?.Close(); return(false); } string audioOutputDeviceName; if (speakerResult.Result.Count == 0 || string.IsNullOrEmpty(configManager.AudioInfo?.AudioOutPutDevice) || !deviceNameAccessor.TryGetSingleName(DeviceName.Speaker, out audioOutputDeviceName) || !speakerResult.Result.Any(speaker => speaker == audioOutputDeviceName)) { errorMsg = "放音设备未设置!"; MessageQueueManager.Instance.AddInfo(errorMsg); AudioSettingView audioSettingView = new AudioSettingView(); audioSettingView.Show(); sourceWindow?.Close(); return(false); } return(true); }
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); } }