Ejemplo n.º 1
0
        public PeerConnection CreatePeerConnection(PeerConnectionObserver observer, PeerConnectionConfig config)
        {
            if (observer is null)
            {
                throw new ArgumentNullException(nameof(observer));
            }
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var interopIceServers = config.IceServers.Select(s => new PeerConnectionFactoryInterop.IceServerConfig
            {
                Username           = s.Username,
                Password           = s.Password,
                CommaSeperatedUrls = string.Join(';', s.Urls)
            }).ToArray();

            return(new PeerConnection(PeerConnectionFactoryInterop.CreatePeerConnection(
                                          Handle,
                                          interopIceServers,
                                          interopIceServers.Count(),
                                          observer.Native),
                                      observer,
                                      SignallingThread));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="unmanagedPointer"></param>
        /// <param name="observer">Keep ref only, does not own observer</param>
        internal PeerConnection(IntPtr unmanagedPointer, PeerConnectionObserver observer, RtcThread signallingThread)
        {
            _handle           = new PeerConnectionSafeHandle(unmanagedPointer);
            _signallingThread = signallingThread
                                ?? throw new ArgumentNullException(nameof(signallingThread));
            Observer = observer;
            Id       = Guid.NewGuid();

            if (Debugger.IsAttached)
            {
                var index = Interlocked.Increment(ref _debugIdPtr);
                if (index < _debugIds.Count)
                {
                    Id = _debugIds[index];
                }
            }
        }