private void CloseInternal()
        {
            if (_factory != null && _parameters.AecDump)
            {
                _factory.StopAecDump();
            }

            _logger.Debug(TAG, "Closing peer connection.");
            if (_rtcEventLog != null)
            {
                // RtcEventLog should stop before the peer connection is disposed.
                _rtcEventLog.Stop();
                _rtcEventLog = null;
            }

            _logger.Debug(TAG, "Closing audio source.");
            if (_audioSource != null)
            {
                _audioSource.Dispose();
                _audioSource = null;
            }

            _logger.Debug(TAG, "Stopping capturer.");
            if (_videoCapturer != null)
            {
                _videoCapturer.StopCapture();
                _videoCapturer.Dispose();
                _videoCapturerStopped = true;
                _videoCapturer        = null;
            }

            _logger.Debug(TAG, "Closing video source.");
            if (_videoSource != null)
            {
                _videoSource.Dispose();
                _videoSource = null;
            }

            _localRenderer  = null;
            _remoteRenderer = null;
            _logger.Debug(TAG, "Closing peer connection factory.");
            if (_factory != null)
            {
                _factory.Dispose();
                _factory = null;
            }

            _logger.Debug(TAG, "Closing peer connection done.");
            _peerConnectionEvents.OnPeerConnectionClosed();
            PeerConnectionFactory.StopInternalTracingCapture();
            PeerConnectionFactory.ShutdownInternalTracer();

            _executor.Release();
        }
        private void MaybeCreateAndStartRtcEventLog()
        {
            if (_peerConnection == null)
            {
                return;
            }
            if (!_parameters.EnableRtcEventLog)
            {
                _logger.Debug(TAG, "RtcEventLog is disabled.");
                return;
            }

            var file = Path.Combine(_parameters.RtcEventLogDirectory, CreateRtcEventLogOutputFile());

            _rtcEventLog = new RTCEventLog(_peerConnection, file, _logger);
            _rtcEventLog.Start();
        }