How to use the react-native-webrtc.RTCPeerConnection function in react-native-webrtc

To help you get started, we’ve selected a few react-native-webrtc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atyenoria / react-native-webrtc-janus-gateway / src / janus.mobile.js View on Github external
Janus.debug("streamsDone:", stream);
          config.myStream = stream;
          var pc_config = {"iceServers": iceServers};
          //~ var pc_constraints = {'mandatory': {'MozDontOfferDataChannel':true}};
          var pc_constraints = {
              "optional": [{"DtlsSrtpKeyAgreement": true}]
          };
          if(ipv6Support === true) {
              // FIXME This is only supported in Chrome right now
              // For support in Firefox track this: https://bugzilla.mozilla.org/show_bug.cgi?id=797262
              pc_constraints.optional.push({"googIPv6":true});
          }
          Janus.log("Creating PeerConnection");
          console.log("Creating PeerConnection");
          Janus.debug(pc_constraints);
          config.pc = new RTCPeerConnection(pc_config, pc_constraints);
          Janus.debug(config.pc);
          console.log(config.pc);
  
          if(config.pc.getStats) {    // FIXME
              config.volume.value = 0;
              config.bitrate.value = "0 kbits/sec";
          }
          Janus.log("Preparing local SDP and gathering candidates (trickle=" + config.trickle + ")");
          console.log("Preparing local SDP and gathering candidates (trickle=" + config.trickle + ")");
  
          config.pc.onicecandidate = function(event) {
              // console.log("config.pc.onicecandidate")
              // if (event.candidate == null ||
              //         (webrtcDetectedBrowser === 'edge' && event.candidate.candidate.indexOf('endOfCandidates') > 0)) {
              //     Janus.log("End of candidates.");
              //     config.iceDone = true;
github 0mkara / RNAWebRTCApp / src / webrtcMiddleware.js View on Github external
const webrtcMiddleware = (function() {
    let socketId = null;
    const configuration = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
    const connection = {'optional': [{'DtlsSrtpKeyAgreement': true}, {'RtpDataChannels': true }]};
    const peerconn = new RTCPeerConnection(configuration, connection);
    // const sdpConstraints = {'mandatory': { 'OfferToReceiveAudio': false, 'OfferToReceiveVideo': false }};
    const offerOpts = { offertoreceiveaudio: false, offertoreceivevideo: false }

    peerconn.onnegotiationneeded = function(event) {
      console.log('onnegotiationneeded');
    };
    peerconn.oniceconnectionstatechange = function(event) {
        console.log('oniceconnectionstatechange');
    };
    peerconn.onsignalingstatechange = function() {
        console.log('onsignalingstatechange');
    };
    peerconn.onaddstream = function() {
        console.log('onaddstream');
    };
    peerconn.onremovestream = function() {
github WorldViews / JanusMobile / app / lib / janus.js View on Github external
//~ var pc_constraints = {'mandatory': {'MozDontOfferDataChannel':true}};
        var pc_constraints = {
            "optional": [{ "DtlsSrtpKeyAgreement": true }]
        };
        if (ipv6Support === true) {
            // FIXME This is only supported in Chrome right now
            // For support in Firefox track this: https://bugzilla.mozilla.org/show_bug.cgi?id=797262
            pc_constraints.optional.push({ "googIPv6": true });
        }
        if (adapter.browserDetails.browser === "edge") {
            // This is Edge, enable BUNDLE explicitly
            pc_config.bundlePolicy = "max-bundle";
        }
        Janus.log("Creating PeerConnection");
        Janus.debug(pc_constraints);
        config.pc = new RTCPeerConnection(pc_config, pc_constraints);
        Janus.debug(config.pc);
        if (config.pc.getStats) {	// FIXME
            config.volume.value = 0;
            config.bitrate.value = "0 kbits/sec";
        }
        Janus.log("Preparing local SDP and gathering candidates (trickle=" + config.trickle + ")");
        config.pc.oniceconnectionstatechange = function (e) {
            if (config.pc)
                pluginHandle.iceState(config.pc.iceConnectionState);
        };
        config.pc.onicecandidate = function (event) {
            if (event.candidate == null ||
                (adapter.browserDetails.browser === 'edge' && event.candidate.candidate.indexOf('endOfCandidates') > 0)) {
                Janus.log("End of candidates.");
                config.iceDone = true;
                if (config.trickle === true) {
github colinwitkamp / react-native-webrtc-sample / App.js View on Github external
async setupWebRTC() {
    const self = this
    const peer = new WebRTCLib.RTCPeerConnection(DEFAULT_ICE)
    peer.oniceconnectionstatechange = this.on_ICE_Connection_State_Change
    peer.onaddstream = this.on_Add_Stream
    peer.onicecandidate = this.on_ICE_Candiate

    console.info('localStream:', this.localStream)
    peer.addStream(this.localStream)
    this.peer = peer
  }
github DimitrisTzimikas / RCTWebRTCDemo2 / src / App.js View on Github external
const createPC = (socketId, isOffer) => {
  /**
   * Create the Peer Connection
   */
  const peer = new RTCPeerConnection(configuration);
  
  log('Peer', peer);
  
  pcPeers = {
    ...pcPeers,
    [socketId]: peer,
  };
  
  /**
   * On Negotiation Needed
   */
  peer.onnegotiationneeded = () => {
    //console.log('onnegotiationneeded');
    if (isOffer) {
      let callback = desc => {
github signalwire / signalwire-node / packages / common / src / util / webrtc / index.native.ts View on Github external
const _RTCPeerConnection = (config: RTCPeerConnectionConfig) => {
  const _config = objEmpty(config) ? null : config
  logger.info('_RTCPeerConnection', _config)
  return new RTCPeerConnection(_config)
}