How to use webrtc-adapter - 10 common examples

To help you get started, we’ve selected a few webrtc-adapter 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 collab-project / videojs-record / test / test-helpers.js View on Github external
applyScreenWorkaround() {
        // use polyfill in Firefox for now, see:
        // https://blog.mozilla.org/webrtc/getdisplaymedia-now-available-in-adapter-js/
        if (adapter.browserDetails.browser === 'firefox') {
            adapter.browserShim.shimGetDisplayMedia(window, 'screen');
        }
    },
github webcom-components / reach / src / definitions / Browser.js View on Github external
* @property {number} [minVersion] - current browser's minimum supported version
 * @property {boolean} compatible - is current browser supported ?
 */
const browser = Object.assign({
  compatible: !/\s/.test(adapter.browserDetails.browser)
    && (!adapter.browserDetails.minVersion
      || adapter.browserDetails.version >= adapter.browserDetails.minVersion)
}, adapter.browserDetails);

const version = `Reach v${SDK_VERSION} | Schema ${SCHEMA_VERSION} | Webcom v${Webcom.SDK_VERSION}`; // eslint-disable-line no-undef
let message = '';
if (browser.version === null) {
  message = 'Unsupported browser: browser must support WebRTC Peer-to-peer connections to use Reach';
} else if (browser.minVersion && browser.minVersion > browser.version) {
  message = `Unsupported browser: browser is outdated, update to latest version (${browser.minVersion}+)`;
} else if (!adapter.browserShim) {
  message = 'No shim for your browser. There might a problem with your package.';
}

// Log browser status & SDKs versions on load
let args = [`${version} ${message}`];
if (/^(chrome|firefox)$/.test(browser.browser)) {
  args = [
    `%c ${version} %c ${message}`,
    `background: ${browser.compatible ? 'blue' : 'red'}; color: #fff; font-weight: bold`,
    `color: ${browser.compatible ? 'inherit' : 'red'}`
  ];
}

console.log(...args); // eslint-disable-line no-console

export default browser;
github webcom-components / reach / src / definitions / Browser.js View on Github external
import adapter from 'webrtc-adapter';
import Webcom from 'webcom/webcom';

/**
 * The current browser's infos
 * @typedef {Object} Browser
 * @property {string} name - current browser's name
 * @property {number} [version] - current browser's version
 * @property {number} [minVersion] - current browser's minimum supported version
 * @property {boolean} compatible - is current browser supported ?
 */
const browser = Object.assign({
  compatible: !/\s/.test(adapter.browserDetails.browser)
    && (!adapter.browserDetails.minVersion
      || adapter.browserDetails.version >= adapter.browserDetails.minVersion)
}, adapter.browserDetails);

const version = `Reach v${SDK_VERSION} | Schema ${SCHEMA_VERSION} | Webcom v${Webcom.SDK_VERSION}`; // eslint-disable-line no-undef
let message = '';
if (browser.version === null) {
  message = 'Unsupported browser: browser must support WebRTC Peer-to-peer connections to use Reach';
} else if (browser.minVersion && browser.minVersion > browser.version) {
  message = `Unsupported browser: browser is outdated, update to latest version (${browser.minVersion}+)`;
} else if (!adapter.browserShim) {
  message = 'No shim for your browser. There might a problem with your package.';
}

// Log browser status & SDKs versions on load
let args = [`${version} ${message}`];
if (/^(chrome|firefox)$/.test(browser.browser)) {
github flashphoner / flashphoner_client / src / webrtc-media-provider.js View on Github external
connection.setRemoteDescription(rtcSdp).then(function () {
                    //use in edge for ice
                    if (adapter.browserDetails.browser == "edge") {
                        // var sdpArray = sdp.split("\n");
                        // var i;
                        // for (i = 0; i < sdpArray.length; i++) {
                        //     if (sdpArray[i].indexOf("m=video") == 0) {
                        //         break;
                        //     }
                        //     if (sdpArray[i].indexOf("a=candidate:1 1") == 0 || sdpArray[i].indexOf("a=candidate:2 1") == 0) {
                        //         var rtcIceCandidate = new RTCIceCandidate({
                        //             candidate: sdpArray[i],
                        //             sdpMid: "audio",
                        //             sdpMLineIndex: 0
                        //         });
                        //         connection.addIceCandidate(rtcIceCandidate);
                        //     }
                        // }
                        // var video = false;
github sjkummer / janus-gateway-js / src / webrtc / media-devices-shim.js View on Github external
MediaDevicesShim.getSharedScreen = function(constraints) {
  if (window.location.protocol !== 'https:') {
    return Promise.reject(new Error('Screen sharing only works on HTTPS, try the https:// version of this page'));
  }

  if ('chrome' == webrtc.browserDetails.browser) {
    return this._getSharedScreenChrome(constraints);
  } else if ('firefox' == webrtc.browserDetails.browser) {
    return this._getSharedScreenFirefox(constraints);
  }
};
github otalk / getScreenMedia / getscreenmedia.js View on Github external
module.exports = function (constraints, cb) {
    var hasConstraints = arguments.length === 2;
    var callback = hasConstraints ? cb : constraints;
    var error;

    if ('getDisplayMedia' in window.navigator.mediaDevices) { // prefer spec getDisplayMedia
        window.navigator.mediaDevices.getDisplayMedia(constraints)
        .then(function (stream) {
            callback(null, stream);
        }).catch(function (err) {
            callback(err);
        });
    } else if (adapter.browserDetails.browser === 'chrome') {
        if (sessionStorage.getScreenMediaJSExtensionId) {
            // check that the extension is installed by looking for a
            // sessionStorage variable that contains the extension id
            // this has to be set after installation unless the content
            // script does that
            chrome.runtime.sendMessage(sessionStorage.getScreenMediaJSExtensionId,
                {type:'getScreen', id: 1}, null,
                function (data) {
                    if (!data || data.sourceId === '') { // user canceled
                        var error = new Error('NavigatorUserMediaError');
                        error.name = 'NotAllowedError';
                        callback(error);
                    } else {
                        constraints = (hasConstraints && constraints) || {audio: false, video: {
                            mandatory: {
                                chromeMediaSource: 'desktop',
github sjkummer / janus-gateway-js / src / webrtc / media-devices-shim.js View on Github external
MediaDevicesShim._getSharedScreenChrome = function(constraints) {
  var chromever = webrtc.browserDetails.version;
  var maxver = 33;
  if (window.navigator.userAgent.match('Linux')) {
    maxver = 35;
  }	// "known" crash in chrome 34 and 35 on linux
  if (chromever >= 26 && chromever <= maxver) {
    // Chrome 26->33 requires some awkward chrome://flags manipulation
    constraints = Helpers.extend({}, constraints, {
      video: {
        mandatory: {
          googLeakyBucket: true,
          maxWidth: window.screen.width,
          maxHeight: window.screen.height,
          maxFrameRate: 3,
          chromeMediaSource: 'screen'
        }
      }
github freedomjs / freedom / providers / core / core.rtcpeerconnection.js View on Github external
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }

  this.events = [
github freedomjs / freedom / providers / core / core.rtcpeerconnection.js View on Github external
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }
github freedomjs / freedom / providers / core / core.rtcpeerconnection.js View on Github external
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }

webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

BSD-3-Clause
Latest version published 8 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages