Esempio n. 1
0
        private void CreatePeerConnectionInternal()
        {
            if (_factory == null || _isError)
            {
                _logger.Error(TAG, "Peerconnection factory is not created");
                return;
            }

            _logger.Debug(TAG, "Create peer connection.");
            _queuedRemoteCandidates = new List <IceCandidate>();

            var rtcConfig = new RTCConfiguration(_parameters.IceServers);

            // TCP candidates are only useful when connecting to a server that supports
            // ICE-TCP.
            rtcConfig.TcpCandidatePolicy       = TcpCandidatePolicy.Disabled;
            rtcConfig.BundlePolicy             = BundlePolicy.MaxBundle;
            rtcConfig.RtcpMuxPolicy            = RtcpMuxPolicy.Require;
            rtcConfig.ContinualGatheringPolicy = ContinualGatheringPolicy.Continually;
            // Use ECDSA encryption.
            rtcConfig.KeyType = EncryptionKeyType.Ecdsa;
            // Enable DTLS for normal calls and disable for loopback calls.
            rtcConfig.EnableDtlsSrtp = _parameters.Loopback;
            rtcConfig.SdpSemantics   = SdpSemantics.UnifiedPlan;

            _peerConnection = _factory.CreatePeerConnection(rtcConfig, _peerConnectionListener);

            var mediaStreamLabels = new[] { "ARDAMS" };

            if (IsVideoCallEnabled)
            {
                _peerConnection.AddTrack(CreateVideoTrack(), mediaStreamLabels);

                // We can add the renderers right away because we don't need to wait for an
                // answer to get the remote track.
                _remoteVideoTrack           = GetRemoteVideoTrack();
                _remoteVideoTrack.IsEnabled = _renderVideo;
                _remoteVideoTrack.AddRenderer(_remoteRenderer);
            }

            _peerConnection.AddTrack(CreateAudioTrack(), mediaStreamLabels);

            if (IsVideoCallEnabled)
            {
                FindVideoSender();
            }

            if (_parameters.AecDump)
            {
                var result = _factory.StartAecDump(_parameters.AecDumpFile, -1);
                if (!result)
                {
                    _logger.Error(TAG, "Can not open aecdump file");
                }
            }

            _logger.Debug(TAG, "Peer connection created.");
        }
Esempio n. 2
0
 public IPeerConnection CreatePeerConnection(RTCConfiguration configuration,
                                             IPeerConnectionListener peerConnectionListener)
 {
     return(_factory.CreatePeerConnection(configuration, peerConnectionListener));
 }