void SetupFactory() { Logger.Debug("PeerChannel", "CreateFactory"); if (factory == null) { Logger.Debug("PeerChannel", "factory not found, create it."); var factoryConf = new WebRtcFactoryConfiguration { EnableAudioBufferEvents = false }; if (mediaOption.AudioUpstreamEnabled) { Logger.Debug("PeerChannel", $"audio upstream setting found, set device id: {mediaOption.MicrophoneDevice.Id}"); factoryConf.AudioCaptureDeviceId = mediaOption.MicrophoneDevice.Id; //factoryConf.AudioRenderingEnabled = true; } else { //factoryConf.AudioRenderingEnabled = false; } if (mediaOption.AudioDownstreamEnabled) { Logger.Debug("PeerChannel", $"audio downstream setting found, set device id: {mediaOption.SpeakerDevice.Id}"); factoryConf.AudioRenderDeviceId = mediaOption.SpeakerDevice.Id; //factoryConf.AudioCapturingEnabled = true; } else { //factoryConf.AudioCapturingEnabled = false; } if (mediaOption.VideoUpstreamEnabled && mediaOption.VideoCaptureCapability.DeviceId.Equals(Device.Screen.DeviceId)) { Logger.Debug("PeerChannel", "screen-share setting found, set device id"); factoryConf.CustomVideoFactory = screen.CreateCapturerFactory(); } else { factoryConf.CustomVideoFactory = null; } factory = new WebRtcFactory(factoryConf); /* * factory.OnAudioPostCaptureInitialize += Factory_OnAudioPostCaptureInit; * factory.OnAudioPostCaptureRuntimeSetting += Factory_OnAudioPostCaptureRuntimeSetting; * factory.OnAudioPostCapture += Factory_OnAudioPostCaptureBuffer; * * factory.OnAudioPreRenderInitialize += Factory_OnAudioPreRenderInit; * factory.OnAudioPreRenderRuntimeSetting += Factory_OnAudioPreRenderRuntimeSetting; * factory.OnAudioPreRender += Factory_OnAudioPreRenderBuffer; */ } }
private RTCConfiguration ConfigureRtc() { var factoryConfig = new WebRtcFactoryConfiguration(); _factory = new WebRtcFactory(factoryConfig); var config = new RTCConfiguration() { Factory = _factory, BundlePolicy = RTCBundlePolicy.Balanced, IceTransportPolicy = RTCIceTransportPolicy.All, IceServers = _iceServers }; return(config); }