public VideoLiveAndRecordProvider(ILoggerFacade logger, IAudioDeviceManager audioDeviceManager, int defaultMicrophoneID)
 {
     _logger             = logger;
     _aacEncoder         = new AacEncoder();
     _videoEncoder       = new H264VideoEncoder();
     _audioDeviceManager = audioDeviceManager;
     _useAudioDevice     = _audioDeviceManager.GetAudioDeviceById(defaultMicrophoneID);
     if (_useAudioDevice == null)
     {
         _useAudioDevice = _audioDeviceManager.GetAudioDevices().First();
     }
     _aacEncoder.SetAudioDataSource(_useAudioDevice);
     _videoRecord        = new Record.Record(_videoEncoder, _aacEncoder);
     _videoLiveBroadcast = new LiveBroadcast.LiveBroadcast(_videoEncoder, _aacEncoder);
     _videoLiveBroadcast.OnNetworkInterruption          += _videoLiveBroadcast_OnNetworkInterruption;
     _videoLiveBroadcast.OnNetworkReconnectionFailed    += _videoLiveBroadcast_OnNetworkReconnectionFailed;
     _videoLiveBroadcast.OnNetworkReconnectionSucceeded += _videoLiveBroadcast_OnNetworkReconnectionSucceeded;
 }
        public void Initialize()
        {
            ResolutionInfoList = new List <ResolutionInfo> {
                new ResolutionInfo {
                    ID = 1, DisplayName = "1280*720", Width = 1280, Height = 720
                },
                new ResolutionInfo {
                    ID = 2, DisplayName = "960*540", Width = 960, Height = 540
                },
                new ResolutionInfo {
                    ID = 3, DisplayName = "640*360", Width = 640, Height = 360
                },
                new ResolutionInfo {
                    ID = 4, DisplayName = "480*270", Width = 480, Height = 270
                },
            };
            RateInfoList = new List <RateInfo>
            {
                new RateInfo {
                    ID = 2, DisplayName = "1000kbps", Value = 1000
                },
                new RateInfo {
                    ID = 3, DisplayName = "1500kbps", Value = 1500
                },
                new RateInfo {
                    ID = 4, DisplayName = "2000kbps", Value = 2000
                },
                new RateInfo {
                    ID = 5, DisplayName = "2500kbps", Value = 2500
                },
                new RateInfo {
                    ID = 6, DisplayName = "3000kbps", Value = 3000
                },
                new RateInfo {
                    ID = 7, DisplayName = "4000kbps", Value = 4000
                },
                new RateInfo {
                    ID = 8, DisplayName = "5000kbps", Value = 5000
                },
                new RateInfo {
                    ID = 9, DisplayName = "8000kbps", Value = 8000
                }
            };
            FrameRateInfoList = new List <FrameRateInfo>
            {
                new FrameRateInfo()
                {
                    ID = 1, DisplayName = "20FPS", Value = 20
                },
                new FrameRateInfo()
                {
                    ID = 2, DisplayName = "25FPS", Value = 25
                },
                new FrameRateInfo()
                {
                    ID = 3, DisplayName = "30FPS", Value = 30
                }
            };
            if (WaveOut.DeviceCount > 0)
            {
                SpeakerList = new List <SpeakerInfo>();
                for (var deviceId = -1; deviceId < WaveOut.DeviceCount; deviceId++)
                {
                    var capabilities = WaveOut.GetCapabilities(deviceId);
                    SpeakerList.Add(new SpeakerInfo {
                        ID = deviceId, Name = capabilities.ProductName
                    });                                                                                  //$"Device {deviceId} ({capabilities.ProductName})");
                }
                SelectedSpeaker = SpeakerList.First();
            }
            VideoDeviceList = _cameraDeviceService.GetVideoDevices();


            VideoDeviceAliasList = _videoDeviceAliasService.GetDeviceAliasList();
            if (VideoDeviceAliasList != null)
            {
                //TODO 对已移除的设备的备注名称需要做移除处理
                foreach (var item in VideoDeviceList)
                {
                    if (!VideoDeviceAliasList.Any(d => d.DeviceName == item.Name || d.DeviceNoteName == item.Name))
                    {
                        VideoDeviceAliasList.Add(new VideoDeviceAlias
                        {
                            DeviceName     = item.Name,
                            DeviceNoteName = item.Name
                        });
                    }
                }
            }

            SelectedVideoDevice = VideoDeviceList.FirstOrDefault();


            AduioDeviceList        = _audioDeviceManager.GetAudioDevices();
            DebugAduioDevice       = AduioDeviceList.First();
            SelectedAudioDevice    = AduioDeviceList.FirstOrDefault(item => item.ID == _config.UseMicrophoneID);
            SelectedResolutionInfo = ResolutionInfoList.FirstOrDefault(item => item.ID == _config.UseResolutionInfo.ID);
            SelectedFrameRateInfo  = FrameRateInfoList.FirstOrDefault(item => item.ID == _config.UseFrameRateInfo.ID);
            SelectedRateInfo       = RateInfoList.FirstOrDefault(item => item.ID == _config.UseRateInfo.ID);
            RecFileSavePath        = _config.RecFileSavePath;
            RecordingStatusChangesAccordingToLiveBroadcastStatus = _config.RecordingStatusChangesAccordingToLiveBroadcastStatus;
            UploadCompletedAutoDeleteLocalFile = _config.UploadCompletedAutoDeleteLocalFile;
            AutoUpload      = _config.IsAutoUpload;
            Duration        = _config.AutoDelayDuration;
            SaveBtnIsEnable = true;
        }