function preparePeerConnection(
    keygenAlgorithm = null, peerConnectionConstraints = null) {
  if (gPeerConnection !== null)
    throw failTest('Creating peer connection, but we already have one.');

  if (keygenAlgorithm === null) {
    gPeerConnection = createPeerConnection_(null, peerConnectionConstraints);
    returnToTest('ok-peerconnection-created');
  } else {
    RTCPeerConnection.generateCertificate(keygenAlgorithm).then(
        function(certificate) {
          preparePeerConnectionWithCertificate(certificate,
              peerConnectionConstraints);
        },
        function() {
          failTest('Certificate generation failed. keygenAlgorithm: ' +
              JSON.stringify(keygenAlgorithm));
        });
  }
}
/**
 * Creates a peer connection. Must be called before most other public functions
 * in this file. Alternatively, see |preparePeerConnectionWithCertificate|.
 * @param {Object} keygenAlgorithm Unless null, this is an |AlgorithmIdentifier|
 * to be used as parameter to |RTCPeerConnection.generateCertificate|. The
 * resulting certificate will be used by the peer connection. If null, a default
 * certificate is generated by the |RTCPeerConnection| instead.
 * @param {string} peerConnectionConstraints Unless null, this adds peer
 * connection constraints when creating new RTCPeerConnection.
 */
Creates a peer connection. Must be called before most other public functions
in this file.
Creates a peer connection . Must be called before most other public functions in this file .
function preparePeerConnection(
    keygenAlgorithm = null, peerConnectionConstraints = null) {
  if (gPeerConnection !== null)
    throw failTest('Creating peer connection, but we already have one.');
  if (keygenAlgorithm === null) {
    gPeerConnection = createPeerConnection_(null, peerConnectionConstraints);
    returnToTest('ok-peerconnection-created');
  } else {
    RTCPeerConnection.generateCertificate(keygenAlgorithm).then(
        function(certificate) {
          preparePeerConnectionWithCertificate(certificate,
              peerConnectionConstraints);
        },
        function() {
          failTest('Certificate generation failed. keygenAlgorithm: ' +
              JSON.stringify(keygenAlgorithm));
        });
  }
}
function preparePeerConnection ( keygenAlgorithm = null , peerConnectionConstraints = null ) { if ( gPeerConnection !== null ) throw failTest ( 'Creating peer connection, but we already have one.' ) ; if ( keygenAlgorithm === null ) { gPeerConnection = createPeerConnection_ ( null , peerConnectionConstraints ) ; returnToTest ( 'ok-peerconnection-created' ) ; } else { RTCPeerConnection . generateCertificate ( keygenAlgorithm ) . then ( function ( certificate ) { preparePeerConnectionWithCertificate ( certificate , peerConnectionConstraints ) ; } , function ( ) { failTest ( 'Certificate generation failed. keygenAlgorithm: ' + JSON . stringify ( keygenAlgorithm ) ) ; } ) ; } }
Creates a peer connection.
Creates a peer connection .