public async Task Initialize(ConductorConfig config) { if (config == null) { throw new ArgumentException("Config cannon be null"); } this.coreDispatcher = config.CoreDispatcher ?? throw new ArgumentException( "Core dispatcher cannot be null"); if (config.Signaller != null) { this.signaller = new WebRtcSignaller(config.Signaller); this.signaller.ReceivedIceCandidate += this.signaller_ReceivedIceCandidate; this.signaller.ReceivedAnswer += this.signaller_ReceivedAnswer; this.signaller.ReceivedOffer += this.signaller_ReceivedOffer; } this.localVideo = config.LocalVideo; this.remoteVideo = config.RemoteVideo; var allowed = await this.requestAccessForMediaCapture(); if (!allowed) { throw new UnauthorizedAccessException("Can't access media"); } await Task.Run(() => { var configuration = new WebRtcLibConfiguration(); var queue = EventQueueMaker.Bind(this.coreDispatcher); configuration.Queue = queue; configuration.AudioCaptureFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("AudioCaptureProcessingQueue"); configuration.AudioRenderFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("AudioRenderProcessingQueue"); configuration.VideoFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("VideoFrameProcessingQueue"); WebRtcLib.Setup(configuration); }); }
/// <summary> /// Asynchronously initialize the object. /// </summary> /// <param name="config"></param> /// <returns></returns> public async Task Initialize(Config config) { if (config == null) { throw new ArgumentException("Config cannot be null"); } // required elements this.Dispatcher = config.CoreDispatcher ?? throw new ArgumentException( "Core Dispatcher cannot be null." ); this.Signaller = config.Signaller ?? throw new ArgumentException( "Signaller cannot be null." ); this.Signaller.MessageHandlers["Register"] += this.ReceivedRegistration; this.Signaller.MessageHandlers["Offer"] += this.ReceivedOffer; this.Signaller.MessageHandlers["Answer"] += this.ReceivedAnswer; this.Signaller.MessageHandlers["IceCandidate"] += this.ReceivedIceCandidate; this.Signaller.MessageHandlers["Shutdown"] += this.ReceivedShutdown; this.LocalVideo = config.LocalVideo; this.RemoteVideo = config.RemoteVideo; if (!await this.RequestAccessForMediaCapture()) { throw new UnauthorizedAccessException("Can't access media."); } await Task.Run(() => { var configuration = new WebRtcLibConfiguration(); var queue = EventQueueMaker.Bind(this.Dispatcher); configuration.Queue = queue; configuration.AudioCaptureFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("AudioCaptureProcessingQueue"); configuration.AudioRenderFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("AudioRenderProcessingQueue"); configuration.VideoFrameProcessingQueue = EventQueue.GetOrCreateThreadQueueByName("VideoFrameProcessingQueue"); WebRtcLib.Setup(configuration); }); }