private async void StartSpeak(SpeakModel obj)
        {
            if (_firstTimeToSpeak)
            {
                Monitor.Enter(_syncRoot);
                if (_firstTimeToSpeak)
                {
                    _firstTimeToSpeak = false;
                }
                Monitor.Exit(_syncRoot);
                return;
            }

            ThrowIfPublishVerify();

            Participant.IsSpeaking = true;

            Console.WriteLine($"_autoPublish:{_autoPublish}");

            if (_autoPublish)
            {
                IEnumerable <string> micDeviceName;
                if (!_deviceNameAccessor.TryGetName(DeviceName.Microphone, new Func <DeviceName, bool>(d => { return(d.Option == "first"); }), out micDeviceName))
                {
                    throw new Exception("麦克风未设置!");
                }
                await Async.Create(() => Publish(MediaType.Microphone, micDeviceName.FirstOrDefault())).TryRun("发布Microphone失败。");

                IEnumerable <string> cameraDeviceName;
                if (!_deviceNameAccessor.TryGetName(DeviceName.Camera, new Func <DeviceName, bool>(d => { return(d.Option == "first"); }), out cameraDeviceName))
                {
                    throw new Exception("人像摄像头未设置!");
                }
                await Async.Create(() => Publish(MediaType.Camera, cameraDeviceName.FirstOrDefault())).TryRun("发布Camera失败。");
            }
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public string IsVideoAudioSettingsValid()
        {
            MeetingResult <IList <VideoDeviceModel> > videoDeviceResult = _meetingSdkAgent.GetVideoDevices();

            MeetingResult <IList <string> > micResult = _meetingSdkAgent.GetMicrophones();

            MeetingResult <IList <string> > speakerResult = _meetingSdkAgent.GetLoudSpeakers();

            IDeviceNameAccessor deviceNameAccessor = IoC.Get <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()))
            {
                return(Messages.WarningNoCamera);
            }

            if (_configManager.MainVideoInfo?.DisplayWidth == 0 || _configManager.MainVideoInfo?.DisplayHeight == 0 || _configManager.MainVideoInfo?.VideoBitRate == 0)
            {
                return(Messages.WarningWrongVideoParams);
            }

            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()))
            {
                return(Messages.WarningNoMicrophone);
            }

            if (_configManager.AudioInfo?.SampleRate == 0 || _configManager.AudioInfo?.AAC == 0)
            {
                return(Messages.WarningWrongMicParams);
            }

            string audioOutputDeviceName;

            if (speakerResult.Result.Count == 0 || string.IsNullOrEmpty(_configManager.AudioInfo?.AudioOutPutDevice) || !deviceNameAccessor.TryGetSingleName(DeviceName.Speaker, out audioOutputDeviceName) || !speakerResult.Result.Any(speaker => speaker == audioOutputDeviceName))
            {
                return(Messages.WarningNoSpeaker);
            }

            if (string.IsNullOrEmpty(_configManager.RecordInfo.RecordDirectory))
            {
                return(Messages.WarningRecordDirectoryNotSet);
            }

            if (!Directory.Exists(_configManager.RecordInfo.RecordDirectory))
            {
                return(Messages.WarningRecordDirectoryNotExist);
            }

            return("");
        }