public PeerConnectionAdapter( PeerConnectionFactory peerConnectionFactory, VideoRouter videoRouter, IRoom room, IRemoteDevice device, IReadOnlyList <string> stunUrls) { if (peerConnectionFactory is null) { throw new ArgumentNullException(nameof(peerConnectionFactory)); } if (stunUrls is null) { throw new ArgumentNullException(nameof(stunUrls)); } Room = room ?? throw new ArgumentNullException(nameof(room)); Device = device ?? throw new ArgumentNullException(nameof(device)); _videoRouter = videoRouter ?? throw new ArgumentNullException(nameof(videoRouter)); var iceServerInfo = new PeerConnectionConfig.IceServerInfo(); foreach (var url in stunUrls) { iceServerInfo.Urls.Add(url); } var config = new PeerConnectionConfig(); config.IceServers.Add(iceServerInfo); _peerConnectionObserverImpl = new PeerConnectionObserver(); _peerConnectionObserverImpl.IceCandidateAdded += IceCandidateAdded; _peerConnectionObserverImpl.RenegotiationNeeded += RenegotationNeeded; _peerConnectionImpl = peerConnectionFactory.CreatePeerConnection(_peerConnectionObserverImpl, config); }
public void Initialize() { if (Interlocked.CompareExchange(ref _initialised, 1, 0) == 0) { _peerConnectionFactory.Initialize(); _signallingThread = new RtcThreadAdapter(_peerConnectionFactory.SignallingThread); _videoRouter = new VideoRouter(_signallingThread, _peerConnectionFactory); } else { throw new InvalidOperationException("Already initialised"); } }