Advertisement
Fapka

SU Adapter

Jun 7th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*! adapterjs - v0.15.0 - 2017-09-05 */
  2. var AdapterJS = AdapterJS || {};
  3. AdapterJS.options = AdapterJS.options || {},
  4. AdapterJS.options.getAllCams = !!AdapterJS.options.getAllCams,
  5. AdapterJS.options.hidePluginInstallPrompt = !!AdapterJS.options.hidePluginInstallPrompt,
  6. AdapterJS.options.forceSafariPlugin = !!AdapterJS.options.forceSafariPlugin,
  7. AdapterJS.VERSION = "0.15.0",
  8. AdapterJS.onwebrtcready = AdapterJS.onwebrtcready || function(isUsingPlugin) {}
  9. ,
  10. AdapterJS._onwebrtcreadies = [],
  11. AdapterJS.webRTCReady = function(baseCallback) {
  12.     if ("function" != typeof baseCallback)
  13.         throw new Error("Callback provided is not a function");
  14.     var callback = function() {
  15.         "function" == typeof window.require && "function" == typeof AdapterJS._defineMediaSourcePolyfill && AdapterJS._defineMediaSourcePolyfill(),
  16.         baseCallback(null !== AdapterJS.WebRTCPlugin.plugin)
  17.     };
  18.     !0 === AdapterJS.onwebrtcreadyDone ? callback() : AdapterJS._onwebrtcreadies.push(callback)
  19. }
  20. ,
  21. AdapterJS.WebRTCPlugin = AdapterJS.WebRTCPlugin || {},
  22. AdapterJS.WebRTCPlugin.pluginInfo = AdapterJS.WebRTCPlugin.pluginInfo || {
  23.     prefix: "Tem",
  24.     plugName: "TemWebRTCPlugin",
  25.     pluginId: "plugin0",
  26.     type: "application/x-temwebrtcplugin",
  27.     onload: "__TemWebRTCReady0",
  28.     portalLink: "https://skylink.io/plugin/",
  29.     downloadLink: null,
  30.     companyName: "Temasys",
  31.     downloadLinks: {
  32.         mac: "https://bit.ly/webrtcpluginpkg",
  33.         win: "https://bit.ly/webrtcpluginmsi"
  34.     }
  35. },
  36. void 0 !== AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks && null !== AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks && (navigator.platform.match(/^Mac/i) ? AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks.mac : navigator.platform.match(/^Win/i) && (AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks.win)),
  37. AdapterJS.WebRTCPlugin.TAGS = {
  38.     NONE: "none",
  39.     AUDIO: "audio",
  40.     VIDEO: "video"
  41. },
  42. AdapterJS.WebRTCPlugin.pageId = Math.random().toString(36).slice(2),
  43. AdapterJS.WebRTCPlugin.plugin = null,
  44. AdapterJS.WebRTCPlugin.setLogLevel = null,
  45. AdapterJS.WebRTCPlugin.defineWebRTCInterface = null,
  46. AdapterJS.WebRTCPlugin.isPluginInstalled = null,
  47. AdapterJS.WebRTCPlugin.pluginInjectionInterval = null,
  48. AdapterJS.WebRTCPlugin.injectPlugin = null,
  49. AdapterJS.WebRTCPlugin.PLUGIN_STATES = {
  50.     NONE: 0,
  51.     INITIALIZING: 1,
  52.     INJECTING: 2,
  53.     INJECTED: 3,
  54.     READY: 4
  55. },
  56. AdapterJS.WebRTCPlugin.pluginState = AdapterJS.WebRTCPlugin.PLUGIN_STATES.NONE,
  57. AdapterJS.onwebrtcreadyDone = !1,
  58. AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS = {
  59.     NONE: "NONE",
  60.     ERROR: "ERROR",
  61.     WARNING: "WARNING",
  62.     INFO: "INFO",
  63.     VERBOSE: "VERBOSE",
  64.     SENSITIVE: "SENSITIVE"
  65. },
  66. AdapterJS.WebRTCPlugin.WaitForPluginReady = null,
  67. AdapterJS.WebRTCPlugin.callWhenPluginReady = null,
  68. __TemWebRTCReady0 = function() {
  69.     "interactive" === document.readyState || "complete" === document.readyState ? (AdapterJS.WebRTCPlugin.pluginState = AdapterJS.WebRTCPlugin.PLUGIN_STATES.READY,
  70.     AdapterJS.maybeThroughWebRTCReady()) : setTimeout(__TemWebRTCReady0, 100)
  71. }
  72. ,
  73. AdapterJS.maybeThroughWebRTCReady = function() {
  74.     AdapterJS.onwebrtcreadyDone || (AdapterJS.onwebrtcreadyDone = !0,
  75.     AdapterJS._onwebrtcreadies.length ? AdapterJS._onwebrtcreadies.forEach(function(callback) {
  76.         "function" == typeof callback && callback(null !== AdapterJS.WebRTCPlugin.plugin)
  77.     }) : "function" == typeof AdapterJS.onwebrtcready && AdapterJS.onwebrtcready(null !== AdapterJS.WebRTCPlugin.plugin))
  78. }
  79. ,
  80. AdapterJS.TEXT = {
  81.     PLUGIN: {
  82.         REQUIRE_INSTALLATION: "This website requires you to install a WebRTC-enabling plugin to work on this browser.",
  83.         NOT_SUPPORTED: "Your browser does not support WebRTC.",
  84.         BUTTON: "Install Now"
  85.     },
  86.     REFRESH: {
  87.         REQUIRE_REFRESH: "Please refresh page",
  88.         BUTTON: "Refresh Page"
  89.     }
  90. },
  91. AdapterJS._iceConnectionStates = {
  92.     starting: "starting",
  93.     checking: "checking",
  94.     connected: "connected",
  95.     completed: "connected",
  96.     done: "completed",
  97.     disconnected: "disconnected",
  98.     failed: "failed",
  99.     closed: "closed"
  100. },
  101. AdapterJS._iceConnectionFiredStates = [],
  102. AdapterJS.isDefined = null,
  103. AdapterJS.parseWebrtcDetectedBrowser = function() {
  104.     var hasMatch = null;
  105.     if (window.opr && opr.addons || window.opera || navigator.userAgent.indexOf(" OPR/") >= 0)
  106.         hasMatch = navigator.userAgent.match(/OPR\/(\d+)/i) || [],
  107.         webrtcDetectedBrowser = "opera",
  108.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  109.         webrtcMinimumVersion = 26,
  110.         webrtcDetectedType = "webkit",
  111.         webrtcDetectedDCSupport = "SCTP";
  112.     else if (navigator.userAgent.match(/Bowser\/[0-9.]*/g)) {
  113.         hasMatch = navigator.userAgent.match(/Bowser\/[0-9.]*/g) || [];
  114.         var chromiumVersion = parseInt((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./i) || [])[2] || "0", 10);
  115.         webrtcDetectedBrowser = "bowser",
  116.         webrtcDetectedVersion = parseFloat((hasMatch[0] || "0/0").split("/")[1], 10),
  117.         webrtcMinimumVersion = 0,
  118.         webrtcDetectedType = "webkit",
  119.         webrtcDetectedDCSupport = chromiumVersion > 30 ? "SCTP" : "RTP"
  120.     } else if (navigator.userAgent.indexOf("OPiOS") > 0)
  121.         hasMatch = navigator.userAgent.match(/OPiOS\/([0-9]+)\./),
  122.         webrtcDetectedBrowser = "opera",
  123.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  124.         webrtcMinimumVersion = 0,
  125.         webrtcDetectedType = null,
  126.         webrtcDetectedDCSupport = null;
  127.     else if (navigator.userAgent.indexOf("CriOS") > 0)
  128.         hasMatch = navigator.userAgent.match(/CriOS\/([0-9]+)\./) || [],
  129.         webrtcDetectedBrowser = "chrome",
  130.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  131.         webrtcMinimumVersion = 0,
  132.         webrtcDetectedType = null,
  133.         webrtcDetectedDCSupport = null;
  134.     else if (navigator.userAgent.indexOf("FxiOS") > 0)
  135.         hasMatch = navigator.userAgent.match(/FxiOS\/([0-9]+)\./) || [],
  136.         webrtcDetectedBrowser = "firefox",
  137.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  138.         webrtcMinimumVersion = 0,
  139.         webrtcDetectedType = null,
  140.         webrtcDetectedDCSupport = null;
  141.     else if (document.documentMode)
  142.         hasMatch = /\brv[ :]+(\d+)/g.exec(navigator.userAgent) || [],
  143.         webrtcDetectedBrowser = "IE",
  144.         webrtcDetectedVersion = parseInt(hasMatch[1], 10),
  145.         webrtcMinimumVersion = 9,
  146.         webrtcDetectedType = "plugin",
  147.         webrtcDetectedDCSupport = "SCTP",
  148.         webrtcDetectedVersion || (hasMatch = /\bMSIE[ :]+(\d+)/g.exec(navigator.userAgent) || [],
  149.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10));
  150.     else if (window.StyleMedia || navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))
  151.         hasMatch = navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) || [],
  152.         webrtcDetectedBrowser = "edge",
  153.         webrtcDetectedVersion = parseFloat((hasMatch[0] || "0/0").split("/")[1], 10),
  154.         webrtcMinimumVersion = 13.10547,
  155.         webrtcDetectedType = "ms",
  156.         webrtcDetectedDCSupport = null;
  157.     else if ("undefined" != typeof InstallTrigger || navigator.userAgent.indexOf("irefox") > 0)
  158.         hasMatch = navigator.userAgent.match(/Firefox\/([0-9]+)\./) || [],
  159.         webrtcDetectedBrowser = "firefox",
  160.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  161.         webrtcMinimumVersion = 33,
  162.         webrtcDetectedType = "moz",
  163.         webrtcDetectedDCSupport = "SCTP";
  164.     else if (window.chrome && window.chrome.webstore || navigator.userAgent.indexOf("Chrom") > 0)
  165.         hasMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./i) || [],
  166.         webrtcDetectedBrowser = "chrome",
  167.         webrtcDetectedVersion = parseInt(hasMatch[2] || "0", 10),
  168.         webrtcMinimumVersion = 38,
  169.         webrtcDetectedType = "webkit",
  170.         webrtcDetectedDCSupport = webrtcDetectedVersion > 30 ? "SCTP" : "RTP";
  171.     else if (/constructor/i.test(window.HTMLElement) || function(p) {
  172.         return "[object SafariRemoteNotification]" === p.toString()
  173.     }(!window.safari || safari.pushNotification) || navigator.userAgent.match(/AppleWebKit\/(\d+)\./) || navigator.userAgent.match(/Version\/(\d+).(\d+)/)) {
  174.         hasMatch = navigator.userAgent.match(/version\/(\d+)/i) || [],
  175.         AppleWebKitBuild = navigator.userAgent.match(/AppleWebKit\/(\d+)/i) || [];
  176.         var isMobile = navigator.userAgent.match(/(iPhone|iPad)/gi)
  177.           , hasNativeImpl = AppleWebKitBuild.length >= 1 && AppleWebKitBuild[1] >= 604;
  178.         webrtcDetectedBrowser = "safari",
  179.         webrtcDetectedVersion = parseInt(hasMatch[1] || "0", 10),
  180.         webrtcMinimumVersion = 7,
  181.         webrtcDetectedType = isMobile ? hasNativeImpl ? "AppleWebKit" : null : hasNativeImpl && !AdapterJS.options.forceSafariPlugin ? "AppleWebKit" : "plugin",
  182.         webrtcDetectedDCSupport = "SCTP"
  183.     }
  184.     AdapterJS.webrtcDetectedBrowser = window.webrtcDetectedBrowser = webrtcDetectedBrowser,
  185.     AdapterJS.webrtcDetectedVersion = window.webrtcDetectedVersion = webrtcDetectedVersion,
  186.     AdapterJS.webrtcMinimumVersion = window.webrtcMinimumVersion = webrtcMinimumVersion,
  187.     AdapterJS.webrtcDetectedType = window.webrtcDetectedType = webrtcDetectedType,
  188.     AdapterJS.webrtcDetectedDCSupport = window.webrtcDetectedDCSupport = webrtcDetectedDCSupport
  189. }
  190. ,
  191. AdapterJS.addEvent = function(elem, evnt, func) {
  192.     elem.addEventListener ? elem.addEventListener(evnt, func, !1) : elem.attachEvent ? elem.attachEvent("on" + evnt, func) : elem[evnt] = func
  193. }
  194. ,
  195. AdapterJS.renderNotificationBar = function(message, buttonText, buttonCallback) {
  196.     if ("interactive" === document.readyState || "complete" === document.readyState) {
  197.         var w = window
  198.           , i = document.createElement("iframe");
  199.         i.name = "adapterjs-alert",
  200.         i.style.position = "fixed",
  201.         i.style.top = "-41px",
  202.         i.style.left = 0,
  203.         i.style.right = 0,
  204.         i.style.width = "100%",
  205.         i.style.height = "40px",
  206.         i.style.backgroundColor = "#ffffe1",
  207.         i.style.border = "none",
  208.         i.style.borderBottom = "1px solid #888888",
  209.         i.style.zIndex = "9999999",
  210.         "string" == typeof i.style.webkitTransition ? i.style.webkitTransition = "all .5s ease-out" : "string" == typeof i.style.transition && (i.style.transition = "all .5s ease-out"),
  211.         document.body.appendChild(i);
  212.         var c = i.contentWindow ? i.contentWindow : i.contentDocument.document ? i.contentDocument.document : i.contentDocument;
  213.         c.document.open(),
  214.         c.document.write('<span style="display: inline-block; font-family: Helvetica, Arial,sans-serif; font-size: .9rem; padding: 4px; vertical-align: middle; cursor: default;">' + message + "</span>"),
  215.         buttonText && "function" == typeof buttonCallback ? (c.document.write('<button id="okay">' + buttonText + '</button><button id="cancel">Cancel</button>'),
  216.         c.document.close(),
  217.         AdapterJS.addEvent(c.document.getElementById("okay"), "click", function(e) {
  218.             e.preventDefault();
  219.             try {
  220.                 e.cancelBubble = !0
  221.             } catch (error) {}
  222.             buttonCallback(e)
  223.         }),
  224.         AdapterJS.addEvent(c.document.getElementById("cancel"), "click", function(e) {
  225.             w.document.body.removeChild(i)
  226.         })) : c.document.close(),
  227.         setTimeout(function() {
  228.             "string" == typeof i.style.webkitTransform ? i.style.webkitTransform = "translateY(40px)" : "string" == typeof i.style.transform ? i.style.transform = "translateY(40px)" : i.style.top = "0px"
  229.         }, 300)
  230.     }
  231. }
  232. ,
  233. webrtcDetectedType = null,
  234. checkMediaDataChannelSettings = function(peerBrowserAgent, peerBrowserVersion, callback, constraints) {
  235.     if ("function" == typeof callback) {
  236.         var beOfferer = !0
  237.           , isLocalFirefox = "firefox" === AdapterJS.webrtcDetectedBrowser
  238.           , isLocalFirefoxInterop = "moz" === AdapterJS.webrtcDetectedType && AdapterJS.webrtcDetectedVersion > 30
  239.           , isPeerFirefox = "firefox" === peerBrowserAgent;
  240.         if (isLocalFirefox && isPeerFirefox || isLocalFirefoxInterop)
  241.             try {
  242.                 delete constraints.mandatory.MozDontOfferDataChannel
  243.             } catch (error) {}
  244.         else
  245.             isLocalFirefox && !isPeerFirefox && (constraints.mandatory.MozDontOfferDataChannel = !0);
  246.         if (!isLocalFirefox)
  247.             for (var prop in constraints.mandatory)
  248.                 constraints.mandatory.hasOwnProperty(prop) && -1 !== prop.indexOf("Moz") && delete constraints.mandatory[prop];
  249.         !isLocalFirefox || isPeerFirefox || isLocalFirefoxInterop || (beOfferer = !1),
  250.         callback(beOfferer, constraints)
  251.     }
  252. }
  253. ,
  254. checkIceConnectionState = function(peerId, iceConnectionState, callback) {
  255.     "function" == typeof callback && (peerId = peerId || "peer",
  256.     AdapterJS._iceConnectionFiredStates[peerId] && iceConnectionState !== AdapterJS._iceConnectionStates.disconnected && iceConnectionState !== AdapterJS._iceConnectionStates.failed && iceConnectionState !== AdapterJS._iceConnectionStates.closed || (AdapterJS._iceConnectionFiredStates[peerId] = []),
  257.     iceConnectionState = AdapterJS._iceConnectionStates[iceConnectionState],
  258.     AdapterJS._iceConnectionFiredStates[peerId].indexOf(iceConnectionState) < 0 && (AdapterJS._iceConnectionFiredStates[peerId].push(iceConnectionState),
  259.     iceConnectionState === AdapterJS._iceConnectionStates.connected && setTimeout(function() {
  260.         AdapterJS._iceConnectionFiredStates[peerId].push(AdapterJS._iceConnectionStates.done),
  261.         callback(AdapterJS._iceConnectionStates.done)
  262.     }, 1e3),
  263.     callback(iceConnectionState)))
  264. }
  265. ,
  266. createIceServer = null,
  267. createIceServers = null,
  268. MediaStream = "function" == typeof MediaStream ? MediaStream : null,
  269. RTCPeerConnection = "function" == typeof RTCPeerConnection ? RTCPeerConnection : null,
  270. RTCSessionDescription = "function" == typeof RTCSessionDescription ? RTCSessionDescription : null,
  271. RTCIceCandidate = "function" == typeof RTCIceCandidate ? RTCIceCandidate : null,
  272. getUserMedia = null,
  273. attachMediaStream = null,
  274. reattachMediaStream = null,
  275. webrtcDetectedBrowser = null,
  276. webrtcDetectedVersion = null,
  277. webrtcMinimumVersion = null,
  278. webrtcDetectedDCSupport = null,
  279. requestUserMedia = null,
  280. AdapterJS.parseWebrtcDetectedBrowser(),
  281. ["webkit", "moz", "ms", "AppleWebKit"].indexOf(AdapterJS.webrtcDetectedType) > -1 ? (navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) && window.RTCPeerConnection && (window.msRTCPeerConnection = window.RTCPeerConnection),
  282. function(f) {
  283.     if ("object" == typeof exports && "undefined" != typeof module)
  284.         module.exports = f();
  285.     else if ("function" == typeof define && define.amd)
  286.         define([], f);
  287.     else {
  288.         var g;
  289.         g = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this,
  290.         g.adapter = f()
  291.     }
  292. }(function() {
  293.     return function e(t, n, r) {
  294.         function s(o, u) {
  295.             if (!n[o]) {
  296.                 if (!t[o]) {
  297.                     var a = "function" == typeof require && require;
  298.                     if (!u && a)
  299.                         return a(o, !0);
  300.                     if (i)
  301.                         return i(o, !0);
  302.                     var f = new Error("Cannot find module '" + o + "'");
  303.                     throw f.code = "MODULE_NOT_FOUND",
  304.                     f
  305.                 }
  306.                 var l = n[o] = {
  307.                     exports: {}
  308.                 };
  309.                 t[o][0].call(l.exports, function(e) {
  310.                     var n = t[o][1][e];
  311.                     return s(n || e)
  312.                 }, l, l.exports, e, t, n, r)
  313.             }
  314.             return n[o].exports
  315.         }
  316.         for (var i = "function" == typeof require && require, o = 0; o < r.length; o++)
  317.             s(r[o]);
  318.         return s
  319.     }({
  320.         1: [function(requirecopy, module, exports) {
  321.             "use strict";
  322.             function writeMediaSection(transceiver, caps, type, stream) {
  323.                 var sdp = SDPUtils.writeRtpDescription(transceiver.kind, caps);
  324.                 if (sdp += SDPUtils.writeIceParameters(transceiver.iceGatherer.getLocalParameters()),
  325.                 sdp += SDPUtils.writeDtlsParameters(transceiver.dtlsTransport.getLocalParameters(), "offer" === type ? "actpass" : "active"),
  326.                 sdp += "a=mid:" + transceiver.mid + "\r\n",
  327.                 transceiver.direction ? sdp += "a=" + transceiver.direction + "\r\n" : transceiver.rtpSender && transceiver.rtpReceiver ? sdp += "a=sendrecv\r\n" : transceiver.rtpSender ? sdp += "a=sendonly\r\n" : transceiver.rtpReceiver ? sdp += "a=recvonly\r\n" : sdp += "a=inactive\r\n",
  328.                 transceiver.rtpSender) {
  329.                     var msid = "msid:" + stream.id + " " + transceiver.rtpSender.track.id + "\r\n";
  330.                     sdp += "a=" + msid,
  331.                     sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].ssrc + " " + msid,
  332.                     transceiver.sendEncodingParameters[0].rtx && (sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].rtx.ssrc + " " + msid,
  333.                     sdp += "a=ssrc-group:FID " + transceiver.sendEncodingParameters[0].ssrc + " " + transceiver.sendEncodingParameters[0].rtx.ssrc + "\r\n")
  334.                 }
  335.                 return sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].ssrc + " cname:" + SDPUtils.localCName + "\r\n",
  336.                 transceiver.rtpSender && transceiver.sendEncodingParameters[0].rtx && (sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].rtx.ssrc + " cname:" + SDPUtils.localCName + "\r\n"),
  337.                 sdp
  338.             }
  339.             function filterIceServers(iceServers, edgeVersion) {
  340.                 var hasTurn = !1;
  341.                 return iceServers = JSON.parse(JSON.stringify(iceServers)),
  342.                 iceServers.filter(function(server) {
  343.                     if (server && (server.urls || server.url)) {
  344.                         var urls = server.urls || server.url;
  345.                         server.url && server.urls;
  346.                         var isString = "string" == typeof urls;
  347.                         return isString && (urls = [urls]),
  348.                         urls = urls.filter(function(url) {
  349.                             return 0 !== url.indexOf("turn:") || -1 === url.indexOf("transport=udp") || -1 !== url.indexOf("turn:[") || hasTurn ? 0 === url.indexOf("stun:") && edgeVersion >= 14393 && -1 === url.indexOf("?transport=udp") : (hasTurn = !0,
  350.                             !0)
  351.                         }),
  352.                         delete server.url,
  353.                         server.urls = isString ? urls[0] : urls,
  354.                         !!urls.length
  355.                     }
  356.                     return !1
  357.                 })
  358.             }
  359.             function getCommonCapabilities(localCapabilities, remoteCapabilities) {
  360.                 var commonCapabilities = {
  361.                     codecs: [],
  362.                     headerExtensions: [],
  363.                     fecMechanisms: []
  364.                 }
  365.                   , findCodecByPayloadType = function(pt, codecs) {
  366.                     pt = parseInt(pt, 10);
  367.                     for (var i = 0; i < codecs.length; i++)
  368.                         if (codecs[i].payloadType === pt || codecs[i].preferredPayloadType === pt)
  369.                             return codecs[i]
  370.                 }
  371.                   , rtxCapabilityMatches = function(lRtx, rRtx, lCodecs, rCodecs) {
  372.                     var lCodec = findCodecByPayloadType(lRtx.parameters.apt, lCodecs)
  373.                       , rCodec = findCodecByPayloadType(rRtx.parameters.apt, rCodecs);
  374.                     return lCodec && rCodec && lCodec.name.toLowerCase() === rCodec.name.toLowerCase()
  375.                 };
  376.                 return localCapabilities.codecs.forEach(function(lCodec) {
  377.                     for (var i = 0; i < remoteCapabilities.codecs.length; i++) {
  378.                         var rCodec = remoteCapabilities.codecs[i];
  379.                         if (lCodec.name.toLowerCase() === rCodec.name.toLowerCase() && lCodec.clockRate === rCodec.clockRate) {
  380.                             if ("rtx" === lCodec.name.toLowerCase() && lCodec.parameters && rCodec.parameters.apt && !rtxCapabilityMatches(lCodec, rCodec, localCapabilities.codecs, remoteCapabilities.codecs))
  381.                                 continue;
  382.                             rCodec = JSON.parse(JSON.stringify(rCodec)),
  383.                             rCodec.numChannels = Math.min(lCodec.numChannels, rCodec.numChannels),
  384.                             commonCapabilities.codecs.push(rCodec),
  385.                             rCodec.rtcpFeedback = rCodec.rtcpFeedback.filter(function(fb) {
  386.                                 for (var j = 0; j < lCodec.rtcpFeedback.length; j++)
  387.                                     if (lCodec.rtcpFeedback[j].type === fb.type && lCodec.rtcpFeedback[j].parameter === fb.parameter)
  388.                                         return !0;
  389.                                 return !1
  390.                             });
  391.                             break
  392.                         }
  393.                     }
  394.                 }),
  395.                 localCapabilities.headerExtensions.forEach(function(lHeaderExtension) {
  396.                     for (var i = 0; i < remoteCapabilities.headerExtensions.length; i++) {
  397.                         var rHeaderExtension = remoteCapabilities.headerExtensions[i];
  398.                         if (lHeaderExtension.uri === rHeaderExtension.uri) {
  399.                             commonCapabilities.headerExtensions.push(rHeaderExtension);
  400.                             break
  401.                         }
  402.                     }
  403.                 }),
  404.                 commonCapabilities
  405.             }
  406.             function isActionAllowedInSignalingState(action, type, signalingState) {
  407.                 return -1 !== {
  408.                     offer: {
  409.                         setLocalDescription: ["stable", "have-local-offer"],
  410.                         setRemoteDescription: ["stable", "have-remote-offer"]
  411.                     },
  412.                     answer: {
  413.                         setLocalDescription: ["have-remote-offer", "have-local-pranswer"],
  414.                         setRemoteDescription: ["have-local-offer", "have-remote-pranswer"]
  415.                     }
  416.                 }[type][action].indexOf(signalingState)
  417.             }
  418.             function maybeAddCandidate(iceTransport, candidate) {
  419.                 iceTransport.getRemoteCandidates().find(function(remoteCandidate) {
  420.                     return candidate.foundation === remoteCandidate.foundation && candidate.ip === remoteCandidate.ip && candidate.port === remoteCandidate.port && candidate.priority === remoteCandidate.priority && candidate.protocol === remoteCandidate.protocol && candidate.type === remoteCandidate.type
  421.                 }) || iceTransport.addRemoteCandidate(candidate)
  422.             }
  423.             var SDPUtils = requirecopy("sdp");
  424.             module.exports = function(window, edgeVersion) {
  425.                 var RTCPeerConnection = function(config) {
  426.                     var self = this
  427.                       , _eventTarget = document.createDocumentFragment();
  428.                     if (["addEventListener", "removeEventListener", "dispatchEvent"].forEach(function(method) {
  429.                         self[method] = _eventTarget[method].bind(_eventTarget)
  430.                     }),
  431.                     this.onicecandidate = null,
  432.                     this.onaddstream = null,
  433.                     this.ontrack = null,
  434.                     this.onremovestream = null,
  435.                     this.onsignalingstatechange = null,
  436.                     this.oniceconnectionstatechange = null,
  437.                     this.onicegatheringstatechange = null,
  438.                     this.onnegotiationneeded = null,
  439.                     this.ondatachannel = null,
  440.                     this.canTrickleIceCandidates = null,
  441.                     this.needNegotiation = !1,
  442.                     this.localStreams = [],
  443.                     this.remoteStreams = [],
  444.                     this.localDescription = null,
  445.                     this.remoteDescription = null,
  446.                     this.signalingState = "stable",
  447.                     this.iceConnectionState = "new",
  448.                     this.iceGatheringState = "new",
  449.                     config = JSON.parse(JSON.stringify(config || {})),
  450.                     this.usingBundle = "max-bundle" === config.bundlePolicy,
  451.                     "negotiate" === config.rtcpMuxPolicy) {
  452.                         var e = new Error("rtcpMuxPolicy 'negotiate' is not supported");
  453.                         throw e.name = "NotSupportedError",
  454.                         e
  455.                     }
  456.                     switch (config.rtcpMuxPolicy || (config.rtcpMuxPolicy = "require"),
  457.                     config.iceTransportPolicy) {
  458.                     case "all":
  459.                     case "relay":
  460.                         break;
  461.                     default:
  462.                         config.iceTransportPolicy = "all"
  463.                     }
  464.                     switch (config.bundlePolicy) {
  465.                     case "balanced":
  466.                     case "max-compat":
  467.                     case "max-bundle":
  468.                         break;
  469.                     default:
  470.                         config.bundlePolicy = "balanced"
  471.                     }
  472.                     if (config.iceServers = filterIceServers(config.iceServers || [], edgeVersion),
  473.                     this._iceGatherers = [],
  474.                     config.iceCandidatePoolSize)
  475.                         for (var i = config.iceCandidatePoolSize; i > 0; i--)
  476.                             this._iceGatherers = new window.RTCIceGatherer({
  477.                                 iceServers: config.iceServers,
  478.                                 gatherPolicy: config.iceTransportPolicy
  479.                             });
  480.                     else
  481.                         config.iceCandidatePoolSize = 0;
  482.                     this._config = config,
  483.                     this.transceivers = [],
  484.                     this._sdpSessionId = SDPUtils.generateSessionId(),
  485.                     this._sdpSessionVersion = 0
  486.                 };
  487.                 return RTCPeerConnection.prototype._emitGatheringStateChange = function() {
  488.                     var event = new Event("icegatheringstatechange");
  489.                     this.dispatchEvent(event),
  490.                     null !== this.onicegatheringstatechange && this.onicegatheringstatechange(event)
  491.                 }
  492.                 ,
  493.                 RTCPeerConnection.prototype.getConfiguration = function() {
  494.                     return this._config
  495.                 }
  496.                 ,
  497.                 RTCPeerConnection.prototype.getLocalStreams = function() {
  498.                     return this.localStreams
  499.                 }
  500.                 ,
  501.                 RTCPeerConnection.prototype.getRemoteStreams = function() {
  502.                     return this.remoteStreams
  503.                 }
  504.                 ,
  505.                 RTCPeerConnection.prototype._createTransceiver = function(kind) {
  506.                     var hasBundleTransport = this.transceivers.length > 0
  507.                       , transceiver = {
  508.                         track: null,
  509.                         iceGatherer: null,
  510.                         iceTransport: null,
  511.                         dtlsTransport: null,
  512.                         localCapabilities: null,
  513.                         remoteCapabilities: null,
  514.                         rtpSender: null,
  515.                         rtpReceiver: null,
  516.                         kind: kind,
  517.                         mid: null,
  518.                         sendEncodingParameters: null,
  519.                         recvEncodingParameters: null,
  520.                         stream: null,
  521.                         wantReceive: !0
  522.                     };
  523.                     if (this.usingBundle && hasBundleTransport)
  524.                         transceiver.iceTransport = this.transceivers[0].iceTransport,
  525.                         transceiver.dtlsTransport = this.transceivers[0].dtlsTransport;
  526.                     else {
  527.                         var transports = this._createIceAndDtlsTransports();
  528.                         transceiver.iceTransport = transports.iceTransport,
  529.                         transceiver.dtlsTransport = transports.dtlsTransport
  530.                     }
  531.                     return this.transceivers.push(transceiver),
  532.                     transceiver
  533.                 }
  534.                 ,
  535.                 RTCPeerConnection.prototype.addTrack = function(track, stream) {
  536.                     for (var transceiver, i = 0; i < this.transceivers.length; i++)
  537.                         this.transceivers[i].track || this.transceivers[i].kind !== track.kind || (transceiver = this.transceivers[i]);
  538.                     return transceiver || (transceiver = this._createTransceiver(track.kind)),
  539.                     this._maybeFireNegotiationNeeded(),
  540.                     -1 === this.localStreams.indexOf(stream) && this.localStreams.push(stream),
  541.                     transceiver.track = track,
  542.                     transceiver.stream = stream,
  543.                     transceiver.rtpSender = new window.RTCRtpSender(track,transceiver.dtlsTransport),
  544.                     transceiver.rtpSender
  545.                 }
  546.                 ,
  547.                 RTCPeerConnection.prototype.addStream = function(stream) {
  548.                     var self = this;
  549.                     if (edgeVersion >= 15025)
  550.                         stream.getTracks().forEach(function(track) {
  551.                             self.addTrack(track, stream)
  552.                         });
  553.                     else {
  554.                         var clonedStream = stream.clone();
  555.                         stream.getTracks().forEach(function(track, idx) {
  556.                             var clonedTrack = clonedStream.getTracks()[idx];
  557.                             track.addEventListener("enabled", function(event) {
  558.                                 clonedTrack.enabled = event.enabled
  559.                             })
  560.                         }),
  561.                         clonedStream.getTracks().forEach(function(track) {
  562.                             self.addTrack(track, clonedStream)
  563.                         })
  564.                     }
  565.                 }
  566.                 ,
  567.                 RTCPeerConnection.prototype.removeStream = function(stream) {
  568.                     var idx = this.localStreams.indexOf(stream);
  569.                     idx > -1 && (this.localStreams.splice(idx, 1),
  570.                     this._maybeFireNegotiationNeeded())
  571.                 }
  572.                 ,
  573.                 RTCPeerConnection.prototype.getSenders = function() {
  574.                     return this.transceivers.filter(function(transceiver) {
  575.                         return !!transceiver.rtpSender
  576.                     }).map(function(transceiver) {
  577.                         return transceiver.rtpSender
  578.                     })
  579.                 }
  580.                 ,
  581.                 RTCPeerConnection.prototype.getReceivers = function() {
  582.                     return this.transceivers.filter(function(transceiver) {
  583.                         return !!transceiver.rtpReceiver
  584.                     }).map(function(transceiver) {
  585.                         return transceiver.rtpReceiver
  586.                     })
  587.                 }
  588.                 ,
  589.                 RTCPeerConnection.prototype._createIceGatherer = function(sdpMLineIndex, usingBundle) {
  590.                     var self = this;
  591.                     if (usingBundle && sdpMLineIndex > 0)
  592.                         return this.transceivers[0].iceGatherer;
  593.                     if (this._iceGatherers.length)
  594.                         return this._iceGatherers.shift();
  595.                     var iceGatherer = new window.RTCIceGatherer({
  596.                         iceServers: this._config.iceServers,
  597.                         gatherPolicy: this._config.iceTransportPolicy
  598.                     });
  599.                     return Object.defineProperty(iceGatherer, "state", {
  600.                         value: "new",
  601.                         writable: !0
  602.                     }),
  603.                     this.transceivers[sdpMLineIndex].candidates = [],
  604.                     this.transceivers[sdpMLineIndex].bufferCandidates = function(event) {
  605.                         var end = !event.candidate || 0 === Object.keys(event.candidate).length;
  606.                         iceGatherer.state = end ? "completed" : "gathering",
  607.                         null !== self.transceivers[sdpMLineIndex].candidates && self.transceivers[sdpMLineIndex].candidates.push(event.candidate)
  608.                     }
  609.                     ,
  610.                     iceGatherer.addEventListener("localcandidate", this.transceivers[sdpMLineIndex].bufferCandidates),
  611.                     iceGatherer
  612.                 }
  613.                 ,
  614.                 RTCPeerConnection.prototype._gather = function(mid, sdpMLineIndex) {
  615.                     var self = this
  616.                       , iceGatherer = this.transceivers[sdpMLineIndex].iceGatherer;
  617.                     if (!iceGatherer.onlocalcandidate) {
  618.                         var candidates = this.transceivers[sdpMLineIndex].candidates;
  619.                         this.transceivers[sdpMLineIndex].candidates = null,
  620.                         iceGatherer.removeEventListener("localcandidate", this.transceivers[sdpMLineIndex].bufferCandidates),
  621.                         iceGatherer.onlocalcandidate = function(evt) {
  622.                             if (!(self.usingBundle && sdpMLineIndex > 0)) {
  623.                                 var event = new Event("icecandidate");
  624.                                 event.candidate = {
  625.                                     sdpMid: mid,
  626.                                     sdpMLineIndex: sdpMLineIndex
  627.                                 };
  628.                                 var cand = evt.candidate
  629.                                   , end = !cand || 0 === Object.keys(cand).length;
  630.                                 end ? "new" !== iceGatherer.state && "gathering" !== iceGatherer.state || (iceGatherer.state = "completed") : ("new" === iceGatherer.state && (iceGatherer.state = "gathering"),
  631.                                 cand.component = 1,
  632.                                 event.candidate.candidate = SDPUtils.writeCandidate(cand));
  633.                                 var sections = SDPUtils.splitSections(self.localDescription.sdp);
  634.                                 sections[event.candidate.sdpMLineIndex + 1] += end ? "a=end-of-candidates\r\n" : "a=" + event.candidate.candidate + "\r\n",
  635.                                 self.localDescription.sdp = sections.join("");
  636.                                 var complete = self.transceivers.every(function(transceiver) {
  637.                                     return transceiver.iceGatherer && "completed" === transceiver.iceGatherer.state
  638.                                 });
  639.                                 "gathering" !== self.iceGatheringState && (self.iceGatheringState = "gathering",
  640.                                 self._emitGatheringStateChange()),
  641.                                 end || (self.dispatchEvent(event),
  642.                                 null !== self.onicecandidate && self.onicecandidate(event)),
  643.                                 complete && (self.dispatchEvent(new Event("icecandidate")),
  644.                                 null !== self.onicecandidate && self.onicecandidate(new Event("icecandidate")),
  645.                                 self.iceGatheringState = "complete",
  646.                                 self._emitGatheringStateChange())
  647.                             }
  648.                         }
  649.                         ,
  650.                         window.setTimeout(function() {
  651.                             candidates.forEach(function(candidate) {
  652.                                 var e = new Event("RTCIceGatherEvent");
  653.                                 e.candidate = candidate,
  654.                                 iceGatherer.onlocalcandidate(e)
  655.                             })
  656.                         }, 0)
  657.                     }
  658.                 }
  659.                 ,
  660.                 RTCPeerConnection.prototype._createIceAndDtlsTransports = function() {
  661.                     var self = this
  662.                       , iceTransport = new window.RTCIceTransport(null);
  663.                     iceTransport.onicestatechange = function() {
  664.                         self._updateConnectionState()
  665.                     }
  666.                     ;
  667.                     var dtlsTransport = new window.RTCDtlsTransport(iceTransport);
  668.                     return dtlsTransport.ondtlsstatechange = function() {
  669.                         self._updateConnectionState()
  670.                     }
  671.                     ,
  672.                     dtlsTransport.onerror = function() {
  673.                         Object.defineProperty(dtlsTransport, "state", {
  674.                             value: "failed",
  675.                             writable: !0
  676.                         }),
  677.                         self._updateConnectionState()
  678.                     }
  679.                     ,
  680.                     {
  681.                         iceTransport: iceTransport,
  682.                         dtlsTransport: dtlsTransport
  683.                     }
  684.                 }
  685.                 ,
  686.                 RTCPeerConnection.prototype._disposeIceAndDtlsTransports = function(sdpMLineIndex) {
  687.                     var iceGatherer = this.transceivers[sdpMLineIndex].iceGatherer;
  688.                     iceGatherer && (delete iceGatherer.onlocalcandidate,
  689.                     delete this.transceivers[sdpMLineIndex].iceGatherer);
  690.                     var iceTransport = this.transceivers[sdpMLineIndex].iceTransport;
  691.                     iceTransport && (delete iceTransport.onicestatechange,
  692.                     delete this.transceivers[sdpMLineIndex].iceTransport);
  693.                     var dtlsTransport = this.transceivers[sdpMLineIndex].dtlsTransport;
  694.                     dtlsTransport && (delete dtlsTransport.ondtlsstatechange,
  695.                     delete dtlsTransport.onerror,
  696.                     delete this.transceivers[sdpMLineIndex].dtlsTransport)
  697.                 }
  698.                 ,
  699.                 RTCPeerConnection.prototype._transceive = function(transceiver, send, recv) {
  700.                     var params = getCommonCapabilities(transceiver.localCapabilities, transceiver.remoteCapabilities);
  701.                     send && transceiver.rtpSender && (params.encodings = transceiver.sendEncodingParameters,
  702.                     params.rtcp = {
  703.                         cname: SDPUtils.localCName,
  704.                         compound: transceiver.rtcpParameters.compound
  705.                     },
  706.                     transceiver.recvEncodingParameters.length && (params.rtcp.ssrc = transceiver.recvEncodingParameters[0].ssrc),
  707.                     transceiver.rtpSender.send(params)),
  708.                     recv && transceiver.rtpReceiver && ("video" === transceiver.kind && transceiver.recvEncodingParameters && edgeVersion < 15019 && transceiver.recvEncodingParameters.forEach(function(p) {
  709.                         delete p.rtx
  710.                     }),
  711.                     params.encodings = transceiver.recvEncodingParameters,
  712.                     params.rtcp = {
  713.                         cname: transceiver.rtcpParameters.cname,
  714.                         compound: transceiver.rtcpParameters.compound
  715.                     },
  716.                     transceiver.sendEncodingParameters.length && (params.rtcp.ssrc = transceiver.sendEncodingParameters[0].ssrc),
  717.                     transceiver.rtpReceiver.receive(params))
  718.                 }
  719.                 ,
  720.                 RTCPeerConnection.prototype.setLocalDescription = function(description) {
  721.                     var self = this
  722.                       , args = arguments;
  723.                     if (!isActionAllowedInSignalingState("setLocalDescription", description.type, this.signalingState))
  724.                         return new Promise(function(resolve, reject) {
  725.                             var e = new Error("Can not set remote " + description.type + " in state " + self.signalingState);
  726.                             e.name = "InvalidStateError",
  727.                             args.length > 2 && "function" == typeof args[2] && args[2].apply(null, [e]),
  728.                             reject(e)
  729.                         }
  730.                         );
  731.                     var sections, sessionpart;
  732.                     if ("offer" === description.type)
  733.                         sections = SDPUtils.splitSections(description.sdp),
  734.                         sessionpart = sections.shift(),
  735.                         sections.forEach(function(mediaSection, sdpMLineIndex) {
  736.                             var caps = SDPUtils.parseRtpParameters(mediaSection);
  737.                             self.transceivers[sdpMLineIndex].localCapabilities = caps
  738.                         }),
  739.                         this.transceivers.forEach(function(transceiver, sdpMLineIndex) {
  740.                             self._gather(transceiver.mid, sdpMLineIndex)
  741.                         });
  742.                     else if ("answer" === description.type) {
  743.                         sections = SDPUtils.splitSections(self.remoteDescription.sdp),
  744.                         sessionpart = sections.shift();
  745.                         var isIceLite = SDPUtils.matchPrefix(sessionpart, "a=ice-lite").length > 0;
  746.                         sections.forEach(function(mediaSection, sdpMLineIndex) {
  747.                             var transceiver = self.transceivers[sdpMLineIndex]
  748.                               , iceGatherer = transceiver.iceGatherer
  749.                               , iceTransport = transceiver.iceTransport
  750.                               , dtlsTransport = transceiver.dtlsTransport
  751.                               , localCapabilities = transceiver.localCapabilities
  752.                               , remoteCapabilities = transceiver.remoteCapabilities;
  753.                             if (!SDPUtils.isRejected(mediaSection) && !transceiver.isDatachannel) {
  754.                                 var remoteIceParameters = SDPUtils.getIceParameters(mediaSection, sessionpart)
  755.                                   , remoteDtlsParameters = SDPUtils.getDtlsParameters(mediaSection, sessionpart);
  756.                                 isIceLite && (remoteDtlsParameters.role = "server"),
  757.                                 self.usingBundle && 0 !== sdpMLineIndex || (self._gather(transceiver.mid, sdpMLineIndex),
  758.                                 "new" === iceTransport.state && iceTransport.start(iceGatherer, remoteIceParameters, isIceLite ? "controlling" : "controlled"),
  759.                                 "new" === dtlsTransport.state && dtlsTransport.start(remoteDtlsParameters));
  760.                                 var params = getCommonCapabilities(localCapabilities, remoteCapabilities);
  761.                                 self._transceive(transceiver, params.codecs.length > 0, !1)
  762.                             }
  763.                         })
  764.                     }
  765.                     switch (this.localDescription = {
  766.                         type: description.type,
  767.                         sdp: description.sdp
  768.                     },
  769.                     description.type) {
  770.                     case "offer":
  771.                         this._updateSignalingState("have-local-offer");
  772.                         break;
  773.                     case "answer":
  774.                         this._updateSignalingState("stable");
  775.                         break;
  776.                     default:
  777.                         throw new TypeError('unsupported type "' + description.type + '"')
  778.                     }
  779.                     var cb = arguments.length > 1 && "function" == typeof arguments[1] && arguments[1];
  780.                     return new Promise(function(resolve) {
  781.                         cb && cb.apply(null),
  782.                         resolve()
  783.                     }
  784.                     )
  785.                 }
  786.                 ,
  787.                 RTCPeerConnection.prototype.setRemoteDescription = function(description) {
  788.                     var self = this
  789.                       , args = arguments;
  790.                     if (!isActionAllowedInSignalingState("setRemoteDescription", description.type, this.signalingState))
  791.                         return new Promise(function(resolve, reject) {
  792.                             var e = new Error("Can not set remote " + description.type + " in state " + self.signalingState);
  793.                             e.name = "InvalidStateError",
  794.                             args.length > 2 && "function" == typeof args[2] && args[2].apply(null, [e]),
  795.                             reject(e)
  796.                         }
  797.                         );
  798.                     var streams = {};
  799.                     this.remoteStreams.forEach(function(stream) {
  800.                         streams[stream.id] = stream
  801.                     });
  802.                     var receiverList = []
  803.                       , sections = SDPUtils.splitSections(description.sdp)
  804.                       , sessionpart = sections.shift()
  805.                       , isIceLite = SDPUtils.matchPrefix(sessionpart, "a=ice-lite").length > 0
  806.                       , usingBundle = SDPUtils.matchPrefix(sessionpart, "a=group:BUNDLE ").length > 0;
  807.                     this.usingBundle = usingBundle;
  808.                     var iceOptions = SDPUtils.matchPrefix(sessionpart, "a=ice-options:")[0];
  809.                     switch (this.canTrickleIceCandidates = !!iceOptions && iceOptions.substr(14).split(" ").indexOf("trickle") >= 0,
  810.                     sections.forEach(function(mediaSection, sdpMLineIndex) {
  811.                         var lines = SDPUtils.splitLines(mediaSection)
  812.                           , kind = SDPUtils.getKind(mediaSection)
  813.                           , rejected = SDPUtils.isRejected(mediaSection)
  814.                           , protocol = lines[0].substr(2).split(" ")[2]
  815.                           , direction = SDPUtils.getDirection(mediaSection, sessionpart)
  816.                           , remoteMsid = SDPUtils.parseMsid(mediaSection)
  817.                           , mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier();
  818.                         if ("application" === kind && "DTLS/SCTP" === protocol)
  819.                             return void (self.transceivers[sdpMLineIndex] = {
  820.                                 mid: mid,
  821.                                 isDatachannel: !0
  822.                             });
  823.                         var transceiver, iceGatherer, iceTransport, dtlsTransport, rtpReceiver, sendEncodingParameters, recvEncodingParameters, localCapabilities, track, remoteIceParameters, remoteDtlsParameters, remoteCapabilities = SDPUtils.parseRtpParameters(mediaSection);
  824.                         rejected || (remoteIceParameters = SDPUtils.getIceParameters(mediaSection, sessionpart),
  825.                         remoteDtlsParameters = SDPUtils.getDtlsParameters(mediaSection, sessionpart),
  826.                         remoteDtlsParameters.role = "client"),
  827.                         recvEncodingParameters = SDPUtils.parseRtpEncodingParameters(mediaSection);
  828.                         var rtcpParameters = SDPUtils.parseRtcpParameters(mediaSection)
  829.                           , isComplete = SDPUtils.matchPrefix(mediaSection, "a=end-of-candidates", sessionpart).length > 0
  830.                           , cands = SDPUtils.matchPrefix(mediaSection, "a=candidate:").map(function(cand) {
  831.                             return SDPUtils.parseCandidate(cand)
  832.                         }).filter(function(cand) {
  833.                             return 1 === cand.component
  834.                         });
  835.                         if (("offer" === description.type || "answer" === description.type) && !rejected && usingBundle && sdpMLineIndex > 0 && self.transceivers[sdpMLineIndex] && (self._disposeIceAndDtlsTransports(sdpMLineIndex),
  836.                         self.transceivers[sdpMLineIndex].iceGatherer = self.transceivers[0].iceGatherer,
  837.                         self.transceivers[sdpMLineIndex].iceTransport = self.transceivers[0].iceTransport,
  838.                         self.transceivers[sdpMLineIndex].dtlsTransport = self.transceivers[0].dtlsTransport,
  839.                         self.transceivers[sdpMLineIndex].rtpSender && self.transceivers[sdpMLineIndex].rtpSender.setTransport(self.transceivers[0].dtlsTransport),
  840.                         self.transceivers[sdpMLineIndex].rtpReceiver && self.transceivers[sdpMLineIndex].rtpReceiver.setTransport(self.transceivers[0].dtlsTransport)),
  841.                         "offer" !== description.type || rejected)
  842.                             "answer" !== description.type || rejected || (transceiver = self.transceivers[sdpMLineIndex],
  843.                             iceGatherer = transceiver.iceGatherer,
  844.                             iceTransport = transceiver.iceTransport,
  845.                             dtlsTransport = transceiver.dtlsTransport,
  846.                             rtpReceiver = transceiver.rtpReceiver,
  847.                             sendEncodingParameters = transceiver.sendEncodingParameters,
  848.                             localCapabilities = transceiver.localCapabilities,
  849.                             self.transceivers[sdpMLineIndex].recvEncodingParameters = recvEncodingParameters,
  850.                             self.transceivers[sdpMLineIndex].remoteCapabilities = remoteCapabilities,
  851.                             self.transceivers[sdpMLineIndex].rtcpParameters = rtcpParameters,
  852.                             cands.length && (!isIceLite && !isComplete || usingBundle && 0 !== sdpMLineIndex || "new" !== iceTransport.state ? cands.forEach(function(candidate) {
  853.                                 maybeAddCandidate(transceiver.iceTransport, candidate)
  854.                             }) : iceTransport.setRemoteCandidates(cands)),
  855.                             usingBundle && 0 !== sdpMLineIndex || ("new" === iceTransport.state && iceTransport.start(iceGatherer, remoteIceParameters, "controlling"),
  856.                             "new" === dtlsTransport.state && dtlsTransport.start(remoteDtlsParameters)),
  857.                             self._transceive(transceiver, "sendrecv" === direction || "recvonly" === direction, "sendrecv" === direction || "sendonly" === direction),
  858.                             !rtpReceiver || "sendrecv" !== direction && "sendonly" !== direction ? delete transceiver.rtpReceiver : (track = rtpReceiver.track,
  859.                             remoteMsid ? (streams[remoteMsid.stream] || (streams[remoteMsid.stream] = new window.MediaStream),
  860.                             streams[remoteMsid.stream].addTrack(track),
  861.                             receiverList.push([track, rtpReceiver, streams[remoteMsid.stream]])) : (streams.default || (streams.default = new window.MediaStream),
  862.                             streams.default.addTrack(track),
  863.                             receiverList.push([track, rtpReceiver, streams.default]))));
  864.                         else {
  865.                             if (transceiver = self.transceivers[sdpMLineIndex] || self._createTransceiver(kind),
  866.                             transceiver.mid = mid,
  867.                             transceiver.iceGatherer || (transceiver.iceGatherer = self._createIceGatherer(sdpMLineIndex, usingBundle)),
  868.                             cands.length && (!isComplete || usingBundle && 0 !== sdpMLineIndex || "new" !== transceiver.iceTransport.state ? cands.forEach(function(candidate) {
  869.                                 maybeAddCandidate(transceiver.iceTransport, candidate)
  870.                             }) : transceiver.iceTransport.setRemoteCandidates(cands)),
  871.                             localCapabilities = window.RTCRtpReceiver.getCapabilities(kind),
  872.                             edgeVersion < 15019 && (localCapabilities.codecs = localCapabilities.codecs.filter(function(codec) {
  873.                                 return "rtx" !== codec.name
  874.                             })),
  875.                             sendEncodingParameters = [{
  876.                                 ssrc: 1001 * (2 * sdpMLineIndex + 2)
  877.                             }],
  878.                             "sendrecv" === direction || "sendonly" === direction) {
  879.                                 var isNewTrack = !transceiver.rtpReceiver;
  880.                                 if (rtpReceiver = transceiver.rtpReceiver || new window.RTCRtpReceiver(transceiver.dtlsTransport,kind),
  881.                                 isNewTrack) {
  882.                                     var stream;
  883.                                     track = rtpReceiver.track,
  884.                                     remoteMsid ? (streams[remoteMsid.stream] || (streams[remoteMsid.stream] = new window.MediaStream,
  885.                                     Object.defineProperty(streams[remoteMsid.stream], "id", {
  886.                                         get: function() {
  887.                                             return remoteMsid.stream
  888.                                         }
  889.                                     })),
  890.                                     Object.defineProperty(track, "id", {
  891.                                         get: function() {
  892.                                             return remoteMsid.track
  893.                                         }
  894.                                     }),
  895.                                     stream = streams[remoteMsid.stream]) : (streams.default || (streams.default = new window.MediaStream),
  896.                                     stream = streams.default),
  897.                                     stream.addTrack(track),
  898.                                     receiverList.push([track, rtpReceiver, stream])
  899.                                 }
  900.                             }
  901.                             transceiver.localCapabilities = localCapabilities,
  902.                             transceiver.remoteCapabilities = remoteCapabilities,
  903.                             transceiver.rtpReceiver = rtpReceiver,
  904.                             transceiver.rtcpParameters = rtcpParameters,
  905.                             transceiver.sendEncodingParameters = sendEncodingParameters,
  906.                             transceiver.recvEncodingParameters = recvEncodingParameters,
  907.                             self._transceive(self.transceivers[sdpMLineIndex], !1, "sendrecv" === direction || "sendonly" === direction)
  908.                         }
  909.                     }),
  910.                     this.remoteDescription = {
  911.                         type: description.type,
  912.                         sdp: description.sdp
  913.                     },
  914.                     description.type) {
  915.                     case "offer":
  916.                         this._updateSignalingState("have-remote-offer");
  917.                         break;
  918.                     case "answer":
  919.                         this._updateSignalingState("stable");
  920.                         break;
  921.                     default:
  922.                         throw new TypeError('unsupported type "' + description.type + '"')
  923.                     }
  924.                     return Object.keys(streams).forEach(function(sid) {
  925.                         var stream = streams[sid];
  926.                         if (stream.getTracks().length) {
  927.                             if (-1 === self.remoteStreams.indexOf(stream)) {
  928.                                 self.remoteStreams.push(stream);
  929.                                 var event = new Event("addstream");
  930.                                 event.stream = stream,
  931.                                 window.setTimeout(function() {
  932.                                     self.dispatchEvent(event),
  933.                                     null !== self.onaddstream && self.onaddstream(event)
  934.                                 })
  935.                             }
  936.                             receiverList.forEach(function(item) {
  937.                                 var track = item[0]
  938.                                   , receiver = item[1];
  939.                                 if (stream.id === item[2].id) {
  940.                                     var trackEvent = new Event("track");
  941.                                     trackEvent.track = track,
  942.                                     trackEvent.receiver = receiver,
  943.                                     trackEvent.transceiver = {
  944.                                         receiver: receiver
  945.                                     },
  946.                                     trackEvent.streams = [stream],
  947.                                     window.setTimeout(function() {
  948.                                         self.dispatchEvent(trackEvent),
  949.                                         null !== self.ontrack && self.ontrack(trackEvent)
  950.                                     })
  951.                                 }
  952.                             })
  953.                         }
  954.                     }),
  955.                     window.setTimeout(function() {
  956.                         self && self.transceivers && self.transceivers.forEach(function(transceiver) {
  957.                             transceiver.iceTransport && "new" === transceiver.iceTransport.state && transceiver.iceTransport.getRemoteCandidates().length > 0 && transceiver.iceTransport.addRemoteCandidate({})
  958.                         })
  959.                     }, 4e3),
  960.                     new Promise(function(resolve) {
  961.                         args.length > 1 && "function" == typeof args[1] && args[1].apply(null),
  962.                         resolve()
  963.                     }
  964.                     )
  965.                 }
  966.                 ,
  967.                 RTCPeerConnection.prototype.close = function() {
  968.                     this.transceivers.forEach(function(transceiver) {
  969.                         transceiver.iceTransport && transceiver.iceTransport.stop(),
  970.                         transceiver.dtlsTransport && transceiver.dtlsTransport.stop(),
  971.                         transceiver.rtpSender && transceiver.rtpSender.stop(),
  972.                         transceiver.rtpReceiver && transceiver.rtpReceiver.stop()
  973.                     }),
  974.                     this._updateSignalingState("closed")
  975.                 }
  976.                 ,
  977.                 RTCPeerConnection.prototype._updateSignalingState = function(newState) {
  978.                     this.signalingState = newState;
  979.                     var event = new Event("signalingstatechange");
  980.                     this.dispatchEvent(event),
  981.                     null !== this.onsignalingstatechange && this.onsignalingstatechange(event)
  982.                 }
  983.                 ,
  984.                 RTCPeerConnection.prototype._maybeFireNegotiationNeeded = function() {
  985.                     var self = this;
  986.                     "stable" === this.signalingState && !0 !== this.needNegotiation && (this.needNegotiation = !0,
  987.                     window.setTimeout(function() {
  988.                         if (!1 !== self.needNegotiation) {
  989.                             self.needNegotiation = !1;
  990.                             var event = new Event("negotiationneeded");
  991.                             self.dispatchEvent(event),
  992.                             null !== self.onnegotiationneeded && self.onnegotiationneeded(event)
  993.                         }
  994.                     }, 0))
  995.                 }
  996.                 ,
  997.                 RTCPeerConnection.prototype._updateConnectionState = function() {
  998.                     var newState, self = this, states = {
  999.                         new: 0,
  1000.                         closed: 0,
  1001.                         connecting: 0,
  1002.                         checking: 0,
  1003.                         connected: 0,
  1004.                         completed: 0,
  1005.                         disconnected: 0,
  1006.                         failed: 0
  1007.                     };
  1008.                     if (this.transceivers.forEach(function(transceiver) {
  1009.                         states[transceiver.iceTransport.state]++,
  1010.                         states[transceiver.dtlsTransport.state]++
  1011.                     }),
  1012.                     states.connected += states.completed,
  1013.                     newState = "new",
  1014.                     states.failed > 0 ? newState = "failed" : states.connecting > 0 || states.checking > 0 ? newState = "connecting" : states.disconnected > 0 ? newState = "disconnected" : states.new > 0 ? newState = "new" : (states.connected > 0 || states.completed > 0) && (newState = "connected"),
  1015.                     newState !== self.iceConnectionState) {
  1016.                         self.iceConnectionState = newState;
  1017.                         var event = new Event("iceconnectionstatechange");
  1018.                         this.dispatchEvent(event),
  1019.                         null !== this.oniceconnectionstatechange && this.oniceconnectionstatechange(event)
  1020.                     }
  1021.                 }
  1022.                 ,
  1023.                 RTCPeerConnection.prototype.createOffer = function() {
  1024.                     var offerOptions, self = this, args = arguments;
  1025.                     1 === arguments.length && "function" != typeof arguments[0] ? offerOptions = arguments[0] : 3 === arguments.length && (offerOptions = arguments[2]);
  1026.                     var numAudioTracks = this.transceivers.filter(function(t) {
  1027.                         return "audio" === t.kind
  1028.                     }).length
  1029.                       , numVideoTracks = this.transceivers.filter(function(t) {
  1030.                         return "video" === t.kind
  1031.                     }).length;
  1032.                     if (offerOptions) {
  1033.                         if (offerOptions.mandatory || offerOptions.optional)
  1034.                             throw new TypeError("Legacy mandatory/optional constraints not supported.");
  1035.                         void 0 !== offerOptions.offerToReceiveAudio && (numAudioTracks = !0 === offerOptions.offerToReceiveAudio ? 1 : !1 === offerOptions.offerToReceiveAudio ? 0 : offerOptions.offerToReceiveAudio),
  1036.                         void 0 !== offerOptions.offerToReceiveVideo && (numVideoTracks = !0 === offerOptions.offerToReceiveVideo ? 1 : !1 === offerOptions.offerToReceiveVideo ? 0 : offerOptions.offerToReceiveVideo)
  1037.                     }
  1038.                     for (this.transceivers.forEach(function(transceiver) {
  1039.                         "audio" === transceiver.kind ? --numAudioTracks < 0 && (transceiver.wantReceive = !1) : "video" === transceiver.kind && --numVideoTracks < 0 && (transceiver.wantReceive = !1)
  1040.                     }); numAudioTracks > 0 || numVideoTracks > 0; )
  1041.                         numAudioTracks > 0 && (this._createTransceiver("audio"),
  1042.                         numAudioTracks--),
  1043.                         numVideoTracks > 0 && (this._createTransceiver("video"),
  1044.                         numVideoTracks--);
  1045.                     var sdp = SDPUtils.writeSessionBoilerplate(this._sdpSessionId, this._sdpSessionVersion++);
  1046.                     this.transceivers.forEach(function(transceiver, sdpMLineIndex) {
  1047.                         var track = transceiver.track
  1048.                           , kind = transceiver.kind
  1049.                           , mid = SDPUtils.generateIdentifier();
  1050.                         transceiver.mid = mid,
  1051.                         transceiver.iceGatherer || (transceiver.iceGatherer = self._createIceGatherer(sdpMLineIndex, self.usingBundle));
  1052.                         var localCapabilities = window.RTCRtpSender.getCapabilities(kind);
  1053.                         edgeVersion < 15019 && (localCapabilities.codecs = localCapabilities.codecs.filter(function(codec) {
  1054.                             return "rtx" !== codec.name
  1055.                         })),
  1056.                         localCapabilities.codecs.forEach(function(codec) {
  1057.                             "H264" === codec.name && void 0 === codec.parameters["level-asymmetry-allowed"] && (codec.parameters["level-asymmetry-allowed"] = "1")
  1058.                         });
  1059.                         var sendEncodingParameters = [{
  1060.                             ssrc: 1001 * (2 * sdpMLineIndex + 1)
  1061.                         }];
  1062.                         track && edgeVersion >= 15019 && "video" === kind && (sendEncodingParameters[0].rtx = {
  1063.                             ssrc: 1001 * (2 * sdpMLineIndex + 1) + 1
  1064.                         }),
  1065.                         transceiver.wantReceive && (transceiver.rtpReceiver = new window.RTCRtpReceiver(transceiver.dtlsTransport,kind)),
  1066.                         transceiver.localCapabilities = localCapabilities,
  1067.                         transceiver.sendEncodingParameters = sendEncodingParameters
  1068.                     }),
  1069.                     "max-compat" !== this._config.bundlePolicy && (sdp += "a=group:BUNDLE " + this.transceivers.map(function(t) {
  1070.                         return t.mid
  1071.                     }).join(" ") + "\r\n"),
  1072.                     sdp += "a=ice-options:trickle\r\n",
  1073.                     this.transceivers.forEach(function(transceiver, sdpMLineIndex) {
  1074.                         sdp += writeMediaSection(transceiver, transceiver.localCapabilities, "offer", transceiver.stream),
  1075.                         sdp += "a=rtcp-rsize\r\n",
  1076.                         !transceiver.iceGatherer || "new" === self.iceGatheringState || 0 !== sdpMLineIndex && self.usingBundle || (transceiver.iceGatherer.getLocalCandidates().forEach(function(cand) {
  1077.                             cand.component = 1,
  1078.                             sdp += "a=" + SDPUtils.writeCandidate(cand) + "\r\n"
  1079.                         }),
  1080.                         "completed" === transceiver.iceGatherer.state && (sdp += "a=end-of-candidates\r\n"))
  1081.                     });
  1082.                     var desc = new window.RTCSessionDescription({
  1083.                         type: "offer",
  1084.                         sdp: sdp
  1085.                     });
  1086.                     return new Promise(function(resolve) {
  1087.                         if (args.length > 0 && "function" == typeof args[0])
  1088.                             return args[0].apply(null, [desc]),
  1089.                             void resolve();
  1090.                         resolve(desc)
  1091.                     }
  1092.                     )
  1093.                 }
  1094.                 ,
  1095.                 RTCPeerConnection.prototype.createAnswer = function() {
  1096.                     var args = arguments
  1097.                       , sdp = SDPUtils.writeSessionBoilerplate(this._sdpSessionId, this._sdpSessionVersion++);
  1098.                     this.usingBundle && (sdp += "a=group:BUNDLE " + this.transceivers.map(function(t) {
  1099.                         return t.mid
  1100.                     }).join(" ") + "\r\n");
  1101.                     var mediaSectionsInOffer = SDPUtils.splitSections(this.remoteDescription.sdp).length - 1;
  1102.                     this.transceivers.forEach(function(transceiver, sdpMLineIndex) {
  1103.                         if (!(sdpMLineIndex + 1 > mediaSectionsInOffer)) {
  1104.                             if (transceiver.isDatachannel)
  1105.                                 return void (sdp += "m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:" + transceiver.mid + "\r\n");
  1106.                             if (transceiver.stream) {
  1107.                                 var localTrack;
  1108.                                 "audio" === transceiver.kind ? localTrack = transceiver.stream.getAudioTracks()[0] : "video" === transceiver.kind && (localTrack = transceiver.stream.getVideoTracks()[0]),
  1109.                                 localTrack && edgeVersion >= 15019 && "video" === transceiver.kind && (transceiver.sendEncodingParameters[0].rtx = {
  1110.                                     ssrc: 1001 * (2 * sdpMLineIndex + 2) + 1
  1111.                                 })
  1112.                             }
  1113.                             var commonCapabilities = getCommonCapabilities(transceiver.localCapabilities, transceiver.remoteCapabilities);
  1114.                             !commonCapabilities.codecs.filter(function(c) {
  1115.                                 return "rtx" === c.name.toLowerCase()
  1116.                             }).length && transceiver.sendEncodingParameters[0].rtx && delete transceiver.sendEncodingParameters[0].rtx,
  1117.                             sdp += writeMediaSection(transceiver, commonCapabilities, "answer", transceiver.stream),
  1118.                             transceiver.rtcpParameters && transceiver.rtcpParameters.reducedSize && (sdp += "a=rtcp-rsize\r\n")
  1119.                         }
  1120.                     });
  1121.                     var desc = new window.RTCSessionDescription({
  1122.                         type: "answer",
  1123.                         sdp: sdp
  1124.                     });
  1125.                     return new Promise(function(resolve) {
  1126.                         if (args.length > 0 && "function" == typeof args[0])
  1127.                             return args[0].apply(null, [desc]),
  1128.                             void resolve();
  1129.                         resolve(desc)
  1130.                     }
  1131.                     )
  1132.                 }
  1133.                 ,
  1134.                 RTCPeerConnection.prototype.addIceCandidate = function(candidate) {
  1135.                     var err, sections;
  1136.                     if (candidate && "" !== candidate.candidate) {
  1137.                         if (!candidate.sdpMLineIndex && !candidate.sdpMid)
  1138.                             throw new TypeError("sdpMLineIndex or sdpMid required");
  1139.                         if (this.remoteDescription) {
  1140.                             var sdpMLineIndex = candidate.sdpMLineIndex;
  1141.                             if (candidate.sdpMid)
  1142.                                 for (var i = 0; i < this.transceivers.length; i++)
  1143.                                     if (this.transceivers[i].mid === candidate.sdpMid) {
  1144.                                         sdpMLineIndex = i;
  1145.                                         break
  1146.                                     }
  1147.                             var transceiver = this.transceivers[sdpMLineIndex];
  1148.                             if (transceiver) {
  1149.                                 if (transceiver.isDatachannel)
  1150.                                     return Promise.resolve();
  1151.                                 var cand = Object.keys(candidate.candidate).length > 0 ? SDPUtils.parseCandidate(candidate.candidate) : {};
  1152.                                 if ("tcp" === cand.protocol && (0 === cand.port || 9 === cand.port))
  1153.                                     return Promise.resolve();
  1154.                                 if (cand.component && 1 !== cand.component)
  1155.                                     return Promise.resolve();
  1156.                                 (0 === sdpMLineIndex || sdpMLineIndex > 0 && transceiver.iceTransport !== this.transceivers[0].iceTransport) && transceiver.iceTransport.addRemoteCandidate(cand);
  1157.                                 var candidateString = candidate.candidate.trim();
  1158.                                 0 === candidateString.indexOf("a=") && (candidateString = candidateString.substr(2)),
  1159.                                 sections = SDPUtils.splitSections(this.remoteDescription.sdp),
  1160.                                 sections[sdpMLineIndex + 1] += "a=" + (cand.type ? candidateString : "end-of-candidates") + "\r\n",
  1161.                                 this.remoteDescription.sdp = sections.join("")
  1162.                             } else
  1163.                                 err = new Error("Can not add ICE candidate"),
  1164.                                 err.name = "OperationError"
  1165.                         } else
  1166.                             err = new Error("Can not add ICE candidate without a remote description"),
  1167.                             err.name = "InvalidStateError"
  1168.                     } else
  1169.                         for (var j = 0; j < this.transceivers.length && (this.transceivers[j].isDatachannel || (this.transceivers[j].iceTransport.addRemoteCandidate({}),
  1170.                         sections = SDPUtils.splitSections(this.remoteDescription.sdp),
  1171.                         sections[j + 1] += "a=end-of-candidates\r\n",
  1172.                         this.remoteDescription.sdp = sections.join(""),
  1173.                         !this.usingBundle)); j++)
  1174.                             ;
  1175.                     var args = arguments;
  1176.                     return new Promise(function(resolve, reject) {
  1177.                         err ? (args.length > 2 && "function" == typeof args[2] && args[2].apply(null, [err]),
  1178.                         reject(err)) : (args.length > 1 && "function" == typeof args[1] && args[1].apply(null),
  1179.                         resolve())
  1180.                     }
  1181.                     )
  1182.                 }
  1183.                 ,
  1184.                 RTCPeerConnection.prototype.getStats = function() {
  1185.                     var promises = [];
  1186.                     this.transceivers.forEach(function(transceiver) {
  1187.                         ["rtpSender", "rtpReceiver", "iceGatherer", "iceTransport", "dtlsTransport"].forEach(function(method) {
  1188.                             transceiver[method] && promises.push(transceiver[method].getStats())
  1189.                         })
  1190.                     });
  1191.                     var cb = arguments.length > 1 && "function" == typeof arguments[1] && arguments[1]
  1192.                       , fixStatsType = function(stat) {
  1193.                         return {
  1194.                             inboundrtp: "inbound-rtp",
  1195.                             outboundrtp: "outbound-rtp",
  1196.                             candidatepair: "candidate-pair",
  1197.                             localcandidate: "local-candidate",
  1198.                             remotecandidate: "remote-candidate"
  1199.                         }[stat.type] || stat.type
  1200.                     };
  1201.                     return new Promise(function(resolve) {
  1202.                         var results = new Map;
  1203.                         Promise.all(promises).then(function(res) {
  1204.                             res.forEach(function(result) {
  1205.                                 Object.keys(result).forEach(function(id) {
  1206.                                     result[id].type = fixStatsType(result[id]),
  1207.                                     results.set(id, result[id])
  1208.                                 })
  1209.                             }),
  1210.                             cb && cb.apply(null, results),
  1211.                             resolve(results)
  1212.                         })
  1213.                     }
  1214.                     )
  1215.                 }
  1216.                 ,
  1217.                 RTCPeerConnection
  1218.             }
  1219.         }
  1220.         , {
  1221.             sdp: 2
  1222.         }],
  1223.         2: [function(requirecopy, module, exports) {
  1224.             "use strict";
  1225.             var SDPUtils = {};
  1226.             SDPUtils.generateIdentifier = function() {
  1227.                 return Math.random().toString(36).substr(2, 10)
  1228.             }
  1229.             ,
  1230.             SDPUtils.localCName = SDPUtils.generateIdentifier(),
  1231.             SDPUtils.splitLines = function(blob) {
  1232.                 return blob.trim().split("\n").map(function(line) {
  1233.                     return line.trim()
  1234.                 })
  1235.             }
  1236.             ,
  1237.             SDPUtils.splitSections = function(blob) {
  1238.                 return blob.split("\nm=").map(function(part, index) {
  1239.                     return (index > 0 ? "m=" + part : part).trim() + "\r\n"
  1240.                 })
  1241.             }
  1242.             ,
  1243.             SDPUtils.matchPrefix = function(blob, prefix) {
  1244.                 return SDPUtils.splitLines(blob).filter(function(line) {
  1245.                     return 0 === line.indexOf(prefix)
  1246.                 })
  1247.             }
  1248.             ,
  1249.             SDPUtils.parseCandidate = function(line) {
  1250.                 var parts;
  1251.                 parts = 0 === line.indexOf("a=candidate:") ? line.substring(12).split(" ") : line.substring(10).split(" ");
  1252.                 for (var candidate = {
  1253.                     foundation: parts[0],
  1254.                     component: parseInt(parts[1], 10),
  1255.                     protocol: parts[2].toLowerCase(),
  1256.                     priority: parseInt(parts[3], 10),
  1257.                     ip: parts[4],
  1258.                     port: parseInt(parts[5], 10),
  1259.                     type: parts[7]
  1260.                 }, i = 8; i < parts.length; i += 2)
  1261.                     switch (parts[i]) {
  1262.                     case "raddr":
  1263.                         candidate.relatedAddress = parts[i + 1];
  1264.                         break;
  1265.                     case "rport":
  1266.                         candidate.relatedPort = parseInt(parts[i + 1], 10);
  1267.                         break;
  1268.                     case "tcptype":
  1269.                         candidate.tcpType = parts[i + 1];
  1270.                         break;
  1271.                     case "ufrag":
  1272.                         candidate.ufrag = parts[i + 1],
  1273.                         candidate.usernameFragment = parts[i + 1];
  1274.                         break;
  1275.                     default:
  1276.                         candidate[parts[i]] = parts[i + 1]
  1277.                     }
  1278.                 return candidate
  1279.             }
  1280.             ,
  1281.             SDPUtils.writeCandidate = function(candidate) {
  1282.                 var sdp = [];
  1283.                 sdp.push(candidate.foundation),
  1284.                 sdp.push(candidate.component),
  1285.                 sdp.push(candidate.protocol.toUpperCase()),
  1286.                 sdp.push(candidate.priority),
  1287.                 sdp.push(candidate.ip),
  1288.                 sdp.push(candidate.port);
  1289.                 var type = candidate.type;
  1290.                 return sdp.push("typ"),
  1291.                 sdp.push(type),
  1292.                 "host" !== type && candidate.relatedAddress && candidate.relatedPort && (sdp.push("raddr"),
  1293.                 sdp.push(candidate.relatedAddress),
  1294.                 sdp.push("rport"),
  1295.                 sdp.push(candidate.relatedPort)),
  1296.                 candidate.tcpType && "tcp" === candidate.protocol.toLowerCase() && (sdp.push("tcptype"),
  1297.                 sdp.push(candidate.tcpType)),
  1298.                 candidate.ufrag && (sdp.push("ufrag"),
  1299.                 sdp.push(candidate.ufrag)),
  1300.                 "candidate:" + sdp.join(" ")
  1301.             }
  1302.             ,
  1303.             SDPUtils.parseIceOptions = function(line) {
  1304.                 return line.substr(14).split(" ")
  1305.             }
  1306.             ,
  1307.             SDPUtils.parseRtpMap = function(line) {
  1308.                 var parts = line.substr(9).split(" ")
  1309.                   , parsed = {
  1310.                     payloadType: parseInt(parts.shift(), 10)
  1311.                 };
  1312.                 return parts = parts[0].split("/"),
  1313.                 parsed.name = parts[0],
  1314.                 parsed.clockRate = parseInt(parts[1], 10),
  1315.                 parsed.numChannels = 3 === parts.length ? parseInt(parts[2], 10) : 1,
  1316.                 parsed
  1317.             }
  1318.             ,
  1319.             SDPUtils.writeRtpMap = function(codec) {
  1320.                 var pt = codec.payloadType;
  1321.                 return void 0 !== codec.preferredPayloadType && (pt = codec.preferredPayloadType),
  1322.                 "a=rtpmap:" + pt + " " + codec.name + "/" + codec.clockRate + (1 !== codec.numChannels ? "/" + codec.numChannels : "") + "\r\n"
  1323.             }
  1324.             ,
  1325.             SDPUtils.parseExtmap = function(line) {
  1326.                 var parts = line.substr(9).split(" ");
  1327.                 return {
  1328.                     id: parseInt(parts[0], 10),
  1329.                     direction: parts[0].indexOf("/") > 0 ? parts[0].split("/")[1] : "sendrecv",
  1330.                     uri: parts[1]
  1331.                 }
  1332.             }
  1333.             ,
  1334.             SDPUtils.writeExtmap = function(headerExtension) {
  1335.                 return "a=extmap:" + (headerExtension.id || headerExtension.preferredId) + (headerExtension.direction && "sendrecv" !== headerExtension.direction ? "/" + headerExtension.direction : "") + " " + headerExtension.uri + "\r\n"
  1336.             }
  1337.             ,
  1338.             SDPUtils.parseFmtp = function(line) {
  1339.                 for (var kv, parsed = {}, parts = line.substr(line.indexOf(" ") + 1).split(";"), j = 0; j < parts.length; j++)
  1340.                     kv = parts[j].trim().split("="),
  1341.                     parsed[kv[0].trim()] = kv[1];
  1342.                 return parsed
  1343.             }
  1344.             ,
  1345.             SDPUtils.writeFmtp = function(codec) {
  1346.                 var line = ""
  1347.                   , pt = codec.payloadType;
  1348.                 if (void 0 !== codec.preferredPayloadType && (pt = codec.preferredPayloadType),
  1349.                 codec.parameters && Object.keys(codec.parameters).length) {
  1350.                     var params = [];
  1351.                     Object.keys(codec.parameters).forEach(function(param) {
  1352.                         params.push(param + "=" + codec.parameters[param])
  1353.                     }),
  1354.                     line += "a=fmtp:" + pt + " " + params.join(";") + "\r\n"
  1355.                 }
  1356.                 return line
  1357.             }
  1358.             ,
  1359.             SDPUtils.parseRtcpFb = function(line) {
  1360.                 var parts = line.substr(line.indexOf(" ") + 1).split(" ");
  1361.                 return {
  1362.                     type: parts.shift(),
  1363.                     parameter: parts.join(" ")
  1364.                 }
  1365.             }
  1366.             ,
  1367.             SDPUtils.writeRtcpFb = function(codec) {
  1368.                 var lines = ""
  1369.                   , pt = codec.payloadType;
  1370.                 return void 0 !== codec.preferredPayloadType && (pt = codec.preferredPayloadType),
  1371.                 codec.rtcpFeedback && codec.rtcpFeedback.length && codec.rtcpFeedback.forEach(function(fb) {
  1372.                     lines += "a=rtcp-fb:" + pt + " " + fb.type + (fb.parameter && fb.parameter.length ? " " + fb.parameter : "") + "\r\n"
  1373.                 }),
  1374.                 lines
  1375.             }
  1376.             ,
  1377.             SDPUtils.parseSsrcMedia = function(line) {
  1378.                 var sp = line.indexOf(" ")
  1379.                   , parts = {
  1380.                     ssrc: parseInt(line.substr(7, sp - 7), 10)
  1381.                 }
  1382.                   , colon = line.indexOf(":", sp);
  1383.                 return colon > -1 ? (parts.attribute = line.substr(sp + 1, colon - sp - 1),
  1384.                 parts.value = line.substr(colon + 1)) : parts.attribute = line.substr(sp + 1),
  1385.                 parts
  1386.             }
  1387.             ,
  1388.             SDPUtils.getMid = function(mediaSection) {
  1389.                 var mid = SDPUtils.matchPrefix(mediaSection, "a=mid:")[0];
  1390.                 if (mid)
  1391.                     return mid.substr(6)
  1392.             }
  1393.             ,
  1394.             SDPUtils.parseFingerprint = function(line) {
  1395.                 var parts = line.substr(14).split(" ");
  1396.                 return {
  1397.                     algorithm: parts[0].toLowerCase(),
  1398.                     value: parts[1]
  1399.                 }
  1400.             }
  1401.             ,
  1402.             SDPUtils.getDtlsParameters = function(mediaSection, sessionpart) {
  1403.                 return {
  1404.                     role: "auto",
  1405.                     fingerprints: SDPUtils.matchPrefix(mediaSection + sessionpart, "a=fingerprint:").map(SDPUtils.parseFingerprint)
  1406.                 }
  1407.             }
  1408.             ,
  1409.             SDPUtils.writeDtlsParameters = function(params, setupType) {
  1410.                 var sdp = "a=setup:" + setupType + "\r\n";
  1411.                 return params.fingerprints.forEach(function(fp) {
  1412.                     sdp += "a=fingerprint:" + fp.algorithm + " " + fp.value + "\r\n"
  1413.                 }),
  1414.                 sdp
  1415.             }
  1416.             ,
  1417.             SDPUtils.getIceParameters = function(mediaSection, sessionpart) {
  1418.                 var lines = SDPUtils.splitLines(mediaSection);
  1419.                 return lines = lines.concat(SDPUtils.splitLines(sessionpart)),
  1420.                 {
  1421.                     usernameFragment: lines.filter(function(line) {
  1422.                         return 0 === line.indexOf("a=ice-ufrag:")
  1423.                     })[0].substr(12),
  1424.                     password: lines.filter(function(line) {
  1425.                         return 0 === line.indexOf("a=ice-pwd:")
  1426.                     })[0].substr(10)
  1427.                 }
  1428.             }
  1429.             ,
  1430.             SDPUtils.writeIceParameters = function(params) {
  1431.                 return "a=ice-ufrag:" + params.usernameFragment + "\r\na=ice-pwd:" + params.password + "\r\n"
  1432.             }
  1433.             ,
  1434.             SDPUtils.parseRtpParameters = function(mediaSection) {
  1435.                 for (var description = {
  1436.                     codecs: [],
  1437.                     headerExtensions: [],
  1438.                     fecMechanisms: [],
  1439.                     rtcp: []
  1440.                 }, lines = SDPUtils.splitLines(mediaSection), mline = lines[0].split(" "), i = 3; i < mline.length; i++) {
  1441.                     var pt = mline[i]
  1442.                       , rtpmapline = SDPUtils.matchPrefix(mediaSection, "a=rtpmap:" + pt + " ")[0];
  1443.                     if (rtpmapline) {
  1444.                         var codec = SDPUtils.parseRtpMap(rtpmapline)
  1445.                           , fmtps = SDPUtils.matchPrefix(mediaSection, "a=fmtp:" + pt + " ");
  1446.                         switch (codec.parameters = fmtps.length ? SDPUtils.parseFmtp(fmtps[0]) : {},
  1447.                         codec.rtcpFeedback = SDPUtils.matchPrefix(mediaSection, "a=rtcp-fb:" + pt + " ").map(SDPUtils.parseRtcpFb),
  1448.                         description.codecs.push(codec),
  1449.                         codec.name.toUpperCase()) {
  1450.                         case "RED":
  1451.                         case "ULPFEC":
  1452.                             description.fecMechanisms.push(codec.name.toUpperCase())
  1453.                         }
  1454.                     }
  1455.                 }
  1456.                 return SDPUtils.matchPrefix(mediaSection, "a=extmap:").forEach(function(line) {
  1457.                     description.headerExtensions.push(SDPUtils.parseExtmap(line))
  1458.                 }),
  1459.                 description
  1460.             }
  1461.             ,
  1462.             SDPUtils.writeRtpDescription = function(kind, caps) {
  1463.                 var sdp = "";
  1464.                 sdp += "m=" + kind + " ",
  1465.                 sdp += caps.codecs.length > 0 ? "9" : "0",
  1466.                 sdp += " UDP/TLS/RTP/SAVPF ",
  1467.                 sdp += caps.codecs.map(function(codec) {
  1468.                     return void 0 !== codec.preferredPayloadType ? codec.preferredPayloadType : codec.payloadType
  1469.                 }).join(" ") + "\r\n",
  1470.                 sdp += "c=IN IP4 0.0.0.0\r\n",
  1471.                 sdp += "a=rtcp:9 IN IP4 0.0.0.0\r\n",
  1472.                 caps.codecs.forEach(function(codec) {
  1473.                     sdp += SDPUtils.writeRtpMap(codec),
  1474.                     sdp += SDPUtils.writeFmtp(codec),
  1475.                     sdp += SDPUtils.writeRtcpFb(codec)
  1476.                 });
  1477.                 var maxptime = 0;
  1478.                 return caps.codecs.forEach(function(codec) {
  1479.                     codec.maxptime > maxptime && (maxptime = codec.maxptime)
  1480.                 }),
  1481.                 maxptime > 0 && (sdp += "a=maxptime:" + maxptime + "\r\n"),
  1482.                 sdp += "a=rtcp-mux\r\n",
  1483.                 caps.headerExtensions.forEach(function(extension) {
  1484.                     sdp += SDPUtils.writeExtmap(extension)
  1485.                 }),
  1486.                 sdp
  1487.             }
  1488.             ,
  1489.             SDPUtils.parseRtpEncodingParameters = function(mediaSection) {
  1490.                 var secondarySsrc, encodingParameters = [], description = SDPUtils.parseRtpParameters(mediaSection), hasRed = -1 !== description.fecMechanisms.indexOf("RED"), hasUlpfec = -1 !== description.fecMechanisms.indexOf("ULPFEC"), ssrcs = SDPUtils.matchPrefix(mediaSection, "a=ssrc:").map(function(line) {
  1491.                     return SDPUtils.parseSsrcMedia(line)
  1492.                 }).filter(function(parts) {
  1493.                     return "cname" === parts.attribute
  1494.                 }), primarySsrc = ssrcs.length > 0 && ssrcs[0].ssrc, flows = SDPUtils.matchPrefix(mediaSection, "a=ssrc-group:FID").map(function(line) {
  1495.                     var parts = line.split(" ");
  1496.                     return parts.shift(),
  1497.                     parts.map(function(part) {
  1498.                         return parseInt(part, 10)
  1499.                     })
  1500.                 });
  1501.                 flows.length > 0 && flows[0].length > 1 && flows[0][0] === primarySsrc && (secondarySsrc = flows[0][1]),
  1502.                 description.codecs.forEach(function(codec) {
  1503.                     if ("RTX" === codec.name.toUpperCase() && codec.parameters.apt) {
  1504.                         var encParam = {
  1505.                             ssrc: primarySsrc,
  1506.                             codecPayloadType: parseInt(codec.parameters.apt, 10),
  1507.                             rtx: {
  1508.                                 ssrc: secondarySsrc
  1509.                             }
  1510.                         };
  1511.                         encodingParameters.push(encParam),
  1512.                         hasRed && (encParam = JSON.parse(JSON.stringify(encParam)),
  1513.                         encParam.fec = {
  1514.                             ssrc: secondarySsrc,
  1515.                             mechanism: hasUlpfec ? "red+ulpfec" : "red"
  1516.                         },
  1517.                         encodingParameters.push(encParam))
  1518.                     }
  1519.                 }),
  1520.                 0 === encodingParameters.length && primarySsrc && encodingParameters.push({
  1521.                     ssrc: primarySsrc
  1522.                 });
  1523.                 var bandwidth = SDPUtils.matchPrefix(mediaSection, "b=");
  1524.                 return bandwidth.length && (bandwidth = 0 === bandwidth[0].indexOf("b=TIAS:") ? parseInt(bandwidth[0].substr(7), 10) : 0 === bandwidth[0].indexOf("b=AS:") ? 1e3 * parseInt(bandwidth[0].substr(5), 10) * .95 - 16e3 : void 0,
  1525.                 encodingParameters.forEach(function(params) {
  1526.                     params.maxBitrate = bandwidth
  1527.                 })),
  1528.                 encodingParameters
  1529.             }
  1530.             ,
  1531.             SDPUtils.parseRtcpParameters = function(mediaSection) {
  1532.                 var rtcpParameters = {}
  1533.                   , remoteSsrc = SDPUtils.matchPrefix(mediaSection, "a=ssrc:").map(function(line) {
  1534.                     return SDPUtils.parseSsrcMedia(line)
  1535.                 }).filter(function(obj) {
  1536.                     return "cname" === obj.attribute
  1537.                 })[0];
  1538.                 remoteSsrc && (rtcpParameters.cname = remoteSsrc.value,
  1539.                 rtcpParameters.ssrc = remoteSsrc.ssrc);
  1540.                 var rsize = SDPUtils.matchPrefix(mediaSection, "a=rtcp-rsize");
  1541.                 rtcpParameters.reducedSize = rsize.length > 0,
  1542.                 rtcpParameters.compound = 0 === rsize.length;
  1543.                 var mux = SDPUtils.matchPrefix(mediaSection, "a=rtcp-mux");
  1544.                 return rtcpParameters.mux = mux.length > 0,
  1545.                 rtcpParameters
  1546.             }
  1547.             ,
  1548.             SDPUtils.parseMsid = function(mediaSection) {
  1549.                 var parts, spec = SDPUtils.matchPrefix(mediaSection, "a=msid:");
  1550.                 if (1 === spec.length)
  1551.                     return parts = spec[0].substr(7).split(" "),
  1552.                     {
  1553.                         stream: parts[0],
  1554.                         track: parts[1]
  1555.                     };
  1556.                 var planB = SDPUtils.matchPrefix(mediaSection, "a=ssrc:").map(function(line) {
  1557.                     return SDPUtils.parseSsrcMedia(line)
  1558.                 }).filter(function(parts) {
  1559.                     return "msid" === parts.attribute
  1560.                 });
  1561.                 return planB.length > 0 ? (parts = planB[0].value.split(" "),
  1562.                 {
  1563.                     stream: parts[0],
  1564.                     track: parts[1]
  1565.                 }) : void 0
  1566.             }
  1567.             ,
  1568.             SDPUtils.generateSessionId = function() {
  1569.                 return Math.random().toString().substr(2, 21)
  1570.             }
  1571.             ,
  1572.             SDPUtils.writeSessionBoilerplate = function(sessId, sessVer) {
  1573.                 var version = void 0 !== sessVer ? sessVer : 2;
  1574.                 return "v=0\r\no=thisisadapterortc " + (sessId || SDPUtils.generateSessionId()) + " " + version + " IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"
  1575.             }
  1576.             ,
  1577.             SDPUtils.writeMediaSection = function(transceiver, caps, type, stream) {
  1578.                 var sdp = SDPUtils.writeRtpDescription(transceiver.kind, caps);
  1579.                 if (sdp += SDPUtils.writeIceParameters(transceiver.iceGatherer.getLocalParameters()),
  1580.                 sdp += SDPUtils.writeDtlsParameters(transceiver.dtlsTransport.getLocalParameters(), "offer" === type ? "actpass" : "active"),
  1581.                 sdp += "a=mid:" + transceiver.mid + "\r\n",
  1582.                 transceiver.direction ? sdp += "a=" + transceiver.direction + "\r\n" : transceiver.rtpSender && transceiver.rtpReceiver ? sdp += "a=sendrecv\r\n" : transceiver.rtpSender ? sdp += "a=sendonly\r\n" : transceiver.rtpReceiver ? sdp += "a=recvonly\r\n" : sdp += "a=inactive\r\n",
  1583.                 transceiver.rtpSender) {
  1584.                     var msid = "msid:" + stream.id + " " + transceiver.rtpSender.track.id + "\r\n";
  1585.                     sdp += "a=" + msid,
  1586.                     sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].ssrc + " " + msid,
  1587.                     transceiver.sendEncodingParameters[0].rtx && (sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].rtx.ssrc + " " + msid,
  1588.                     sdp += "a=ssrc-group:FID " + transceiver.sendEncodingParameters[0].ssrc + " " + transceiver.sendEncodingParameters[0].rtx.ssrc + "\r\n")
  1589.                 }
  1590.                 return sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].ssrc + " cname:" + SDPUtils.localCName + "\r\n",
  1591.                 transceiver.rtpSender && transceiver.sendEncodingParameters[0].rtx && (sdp += "a=ssrc:" + transceiver.sendEncodingParameters[0].rtx.ssrc + " cname:" + SDPUtils.localCName + "\r\n"),
  1592.                 sdp
  1593.             }
  1594.             ,
  1595.             SDPUtils.getDirection = function(mediaSection, sessionpart) {
  1596.                 for (var lines = SDPUtils.splitLines(mediaSection), i = 0; i < lines.length; i++)
  1597.                     switch (lines[i]) {
  1598.                     case "a=sendrecv":
  1599.                     case "a=sendonly":
  1600.                     case "a=recvonly":
  1601.                     case "a=inactive":
  1602.                         return lines[i].substr(2)
  1603.                     }
  1604.                 return sessionpart ? SDPUtils.getDirection(sessionpart) : "sendrecv"
  1605.             }
  1606.             ,
  1607.             SDPUtils.getKind = function(mediaSection) {
  1608.                 return SDPUtils.splitLines(mediaSection)[0].split(" ")[0].substr(2)
  1609.             }
  1610.             ,
  1611.             SDPUtils.isRejected = function(mediaSection) {
  1612.                 return "0" === mediaSection.split(" ", 2)[1]
  1613.             }
  1614.             ,
  1615.             module.exports = SDPUtils
  1616.         }
  1617.         , {}],
  1618.         3: [function(requirecopy, module, exports) {
  1619.             (function(global) {
  1620.                 "use strict";
  1621.                 var adapterFactory = requirecopy("./adapter_factory.js");
  1622.                 module.exports = adapterFactory({
  1623.                     window: global.window
  1624.                 })
  1625.             }
  1626.             ).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {})
  1627.         }
  1628.         , {
  1629.             "./adapter_factory.js": 4
  1630.         }],
  1631.         4: [function(requirecopy, module, exports) {
  1632.             "use strict";
  1633.             module.exports = function(dependencies, opts) {
  1634.                 var window = dependencies && dependencies.window
  1635.                   , options = {
  1636.                     shimChrome: !0,
  1637.                     shimFirefox: !0,
  1638.                     shimEdge: !0,
  1639.                     shimSafari: !0
  1640.                 };
  1641.                 for (var key in opts)
  1642.                     hasOwnProperty.call(opts, key) && (options[key] = opts[key]);
  1643.                 var utils = requirecopy("./utils")
  1644.                   , logging = utils.log
  1645.                   , browserDetails = utils.detectBrowser(window)
  1646.                   , adapter = {
  1647.                     browserDetails: browserDetails,
  1648.                     extractVersion: utils.extractVersion,
  1649.                     disableLog: utils.disableLog,
  1650.                     disableWarnings: utils.disableWarnings
  1651.                 }
  1652.                   , chromeShim = requirecopy("./chrome/chrome_shim") || null
  1653.                   , edgeShim = requirecopy("./edge/edge_shim") || null
  1654.                   , firefoxShim = requirecopy("./firefox/firefox_shim") || null
  1655.                   , safariShim = requirecopy("./safari/safari_shim") || null
  1656.                   , commonShim = requirecopy("./common_shim") || null;
  1657.                 switch (browserDetails.browser) {
  1658.                 case "chrome":
  1659.                     if (!chromeShim || !chromeShim.shimPeerConnection || !options.shimChrome)
  1660.                         return logging("Chrome shim is not included in this adapter release."),
  1661.                         adapter;
  1662.                     logging("adapter.js shimming chrome."),
  1663.                     adapter.browserShim = chromeShim,
  1664.                     chromeShim.shimGetUserMedia(window),
  1665.                     chromeShim.shimMediaStream(window),
  1666.                     utils.shimCreateObjectURL(window),
  1667.                     chromeShim.shimSourceObject(window),
  1668.                     chromeShim.shimPeerConnection(window),
  1669.                     chromeShim.shimOnTrack(window),
  1670.                     chromeShim.shimAddTrackRemoveTrack(window),
  1671.                     chromeShim.shimGetSendersWithDtmf(window),
  1672.                     commonShim.shimRTCIceCandidate(window);
  1673.                     break;
  1674.                 case "firefox":
  1675.                     if (!firefoxShim || !firefoxShim.shimPeerConnection || !options.shimFirefox)
  1676.                         return logging("Firefox shim is not included in this adapter release."),
  1677.                         adapter;
  1678.                     logging("adapter.js shimming firefox."),
  1679.                     adapter.browserShim = firefoxShim,
  1680.                     firefoxShim.shimGetUserMedia(window),
  1681.                     utils.shimCreateObjectURL(window),
  1682.                     firefoxShim.shimSourceObject(window),
  1683.                     firefoxShim.shimPeerConnection(window),
  1684.                     firefoxShim.shimOnTrack(window),
  1685.                     commonShim.shimRTCIceCandidate(window);
  1686.                     break;
  1687.                 case "edge":
  1688.                     if (!edgeShim || !edgeShim.shimPeerConnection || !options.shimEdge)
  1689.                         return logging("MS edge shim is not included in this adapter release."),
  1690.                         adapter;
  1691.                     logging("adapter.js shimming edge."),
  1692.                     adapter.browserShim = edgeShim,
  1693.                     edgeShim.shimGetUserMedia(window),
  1694.                     utils.shimCreateObjectURL(window),
  1695.                     edgeShim.shimPeerConnection(window),
  1696.                     edgeShim.shimReplaceTrack(window);
  1697.                     break;
  1698.                 case "safari":
  1699.                     if (!safariShim || !options.shimSafari)
  1700.                         return logging("Safari shim is not included in this adapter release."),
  1701.                         adapter;
  1702.                     logging("adapter.js shimming safari."),
  1703.                     adapter.browserShim = safariShim,
  1704.                     utils.shimCreateObjectURL(window),
  1705.                     safariShim.shimRTCIceServerUrls(window),
  1706.                     safariShim.shimCallbacksAPI(window),
  1707.                     safariShim.shimLocalStreamsAPI(window),
  1708.                     safariShim.shimRemoteStreamsAPI(window),
  1709.                     safariShim.shimTrackEventTransceiver(window),
  1710.                     safariShim.shimGetUserMedia(window),
  1711.                     commonShim.shimRTCIceCandidate(window);
  1712.                     break;
  1713.                 default:
  1714.                     logging("Unsupported browser!")
  1715.                 }
  1716.                 return adapter
  1717.             }
  1718.         }
  1719.         , {
  1720.             "./chrome/chrome_shim": 5,
  1721.             "./common_shim": 7,
  1722.             "./edge/edge_shim": 8,
  1723.             "./firefox/firefox_shim": 10,
  1724.             "./safari/safari_shim": 12,
  1725.             "./utils": 13
  1726.         }],
  1727.         5: [function(requirecopy, module, exports) {
  1728.             "use strict";
  1729.             var utils = requirecopy("../utils.js")
  1730.               , logging = utils.log
  1731.               , chromeShim = {
  1732.                 shimMediaStream: function(window) {
  1733.                     window.MediaStream = window.MediaStream || window.webkitMediaStream
  1734.                 },
  1735.                 shimOnTrack: function(window) {
  1736.                     if ("object" == typeof window && window.RTCPeerConnection && !("ontrack"in window.RTCPeerConnection.prototype)) {
  1737.                         Object.defineProperty(window.RTCPeerConnection.prototype, "ontrack", {
  1738.                             get: function() {
  1739.                                 return this._ontrack
  1740.                             },
  1741.                             set: function(f) {
  1742.                                 this._ontrack && this.removeEventListener("track", this._ontrack),
  1743.                                 this.addEventListener("track", this._ontrack = f)
  1744.                             }
  1745.                         });
  1746.                         var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
  1747.                         window.RTCPeerConnection.prototype.setRemoteDescription = function() {
  1748.                             var pc = this;
  1749.                             return pc._ontrackpoly || (pc._ontrackpoly = function(e) {
  1750.                                 e.stream.addEventListener("addtrack", function(te) {
  1751.                                     var receiver;
  1752.                                     receiver = window.RTCPeerConnection.prototype.getReceivers ? pc.getReceivers().find(function(r) {
  1753.                                         return r.track && r.track.id === te.track.id
  1754.                                     }) : {
  1755.                                         track: te.track
  1756.                                     };
  1757.                                     var event = new Event("track");
  1758.                                     event.track = te.track,
  1759.                                     event.receiver = receiver,
  1760.                                     event.transceiver = {
  1761.                                         receiver: receiver
  1762.                                     },
  1763.                                     event.streams = [e.stream],
  1764.                                     pc.dispatchEvent(event)
  1765.                                 }),
  1766.                                 e.stream.getTracks().forEach(function(track) {
  1767.                                     var receiver;
  1768.                                     receiver = window.RTCPeerConnection.prototype.getReceivers ? pc.getReceivers().find(function(r) {
  1769.                                         return r.track && r.track.id === track.id
  1770.                                     }) : {
  1771.                                         track: track
  1772.                                     };
  1773.                                     var event = new Event("track");
  1774.                                     event.track = track,
  1775.                                     event.receiver = receiver,
  1776.                                     event.transceiver = {
  1777.                                         receiver: receiver
  1778.                                     },
  1779.                                     event.streams = [e.stream],
  1780.                                     pc.dispatchEvent(event)
  1781.                                 })
  1782.                             }
  1783.                             ,
  1784.                             pc.addEventListener("addstream", pc._ontrackpoly)),
  1785.                             origSetRemoteDescription.apply(pc, arguments)
  1786.                         }
  1787.                     }
  1788.                 },
  1789.                 shimGetSendersWithDtmf: function(window) {
  1790.                     if ("object" == typeof window && window.RTCPeerConnection && !("getSenders"in window.RTCPeerConnection.prototype) && "createDTMFSender"in window.RTCPeerConnection.prototype) {
  1791.                         var shimSenderWithDtmf = function(pc, track) {
  1792.                             return {
  1793.                                 track: track,
  1794.                                 get dtmf() {
  1795.                                     return void 0 === this._dtmf && ("audio" === track.kind ? this._dtmf = pc.createDTMFSender(track) : this._dtmf = null),
  1796.                                     this._dtmf
  1797.                                 },
  1798.                                 _pc: pc
  1799.                             }
  1800.                         };
  1801.                         if (!window.RTCPeerConnection.prototype.getSenders) {
  1802.                             window.RTCPeerConnection.prototype.getSenders = function() {
  1803.                                 return this._senders = this._senders || [],
  1804.                                 this._senders.slice()
  1805.                             }
  1806.                             ;
  1807.                             var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
  1808.                             window.RTCPeerConnection.prototype.addTrack = function(track, stream) {
  1809.                                 var pc = this
  1810.                                   , sender = origAddTrack.apply(pc, arguments);
  1811.                                 return sender || (sender = shimSenderWithDtmf(pc, track),
  1812.                                 pc._senders.push(sender)),
  1813.                                 sender
  1814.                             }
  1815.                             ;
  1816.                             var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
  1817.                             window.RTCPeerConnection.prototype.removeTrack = function(sender) {
  1818.                                 var pc = this;
  1819.                                 origRemoveTrack.apply(pc, arguments);
  1820.                                 var idx = pc._senders.indexOf(sender);
  1821.                                 -1 !== idx && pc._senders.splice(idx, 1)
  1822.                             }
  1823.                         }
  1824.                         var origAddStream = window.RTCPeerConnection.prototype.addStream;
  1825.                         window.RTCPeerConnection.prototype.addStream = function(stream) {
  1826.                             var pc = this;
  1827.                             pc._senders = pc._senders || [],
  1828.                             origAddStream.apply(pc, [stream]),
  1829.                             stream.getTracks().forEach(function(track) {
  1830.                                 pc._senders.push(shimSenderWithDtmf(pc, track))
  1831.                             })
  1832.                         }
  1833.                         ;
  1834.                         var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
  1835.                         window.RTCPeerConnection.prototype.removeStream = function(stream) {
  1836.                             var pc = this;
  1837.                             pc._senders = pc._senders || [],
  1838.                             origRemoveStream.apply(pc, [pc._streams[stream.id] || stream]),
  1839.                             stream.getTracks().forEach(function(track) {
  1840.                                 var sender = pc._senders.find(function(s) {
  1841.                                     return s.track === track
  1842.                                 });
  1843.                                 sender && pc._senders.splice(pc._senders.indexOf(sender), 1)
  1844.                             })
  1845.                         }
  1846.                     } else if ("object" == typeof window && window.RTCPeerConnection && "getSenders"in window.RTCPeerConnection.prototype && "createDTMFSender"in window.RTCPeerConnection.prototype && window.RTCRtpSender && !("dtmf"in window.RTCRtpSender.prototype)) {
  1847.                         var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
  1848.                         window.RTCPeerConnection.prototype.getSenders = function() {
  1849.                             var pc = this
  1850.                               , senders = origGetSenders.apply(pc, []);
  1851.                             return senders.forEach(function(sender) {
  1852.                                 sender._pc = pc
  1853.                             }),
  1854.                             senders
  1855.                         }
  1856.                         ,
  1857.                         Object.defineProperty(window.RTCRtpSender.prototype, "dtmf", {
  1858.                             get: function() {
  1859.                                 return void 0 === this._dtmf && ("audio" === this.track.kind ? this._dtmf = this._pc.createDTMFSender(this.track) : this._dtmf = null),
  1860.                                 this._dtmf
  1861.                             }
  1862.                         })
  1863.                     }
  1864.                 },
  1865.                 shimSourceObject: function(window) {
  1866.                     var URL = window && window.URL;
  1867.                     "object" == typeof window && (!window.HTMLMediaElement || "srcObject"in window.HTMLMediaElement.prototype || Object.defineProperty(window.HTMLMediaElement.prototype, "srcObject", {
  1868.                         get: function() {
  1869.                             return this._srcObject
  1870.                         },
  1871.                         set: function(stream) {
  1872.                             var self = this;
  1873.                             if (this._srcObject = stream,
  1874.                             this.src && URL.revokeObjectURL(this.src),
  1875.                             !stream)
  1876.                                 return void (this.src = "");
  1877.                             this.src = URL.createObjectURL(stream),
  1878.                             stream.addEventListener("addtrack", function() {
  1879.                                 self.src && URL.revokeObjectURL(self.src),
  1880.                                 self.src = URL.createObjectURL(stream)
  1881.                             }),
  1882.                             stream.addEventListener("removetrack", function() {
  1883.                                 self.src && URL.revokeObjectURL(self.src),
  1884.                                 self.src = URL.createObjectURL(stream)
  1885.                             })
  1886.                         }
  1887.                     }))
  1888.                 },
  1889.                 shimAddTrackRemoveTrack: function(window) {
  1890.                     function replaceInternalStreamId(pc, description) {
  1891.                         var sdp = description.sdp;
  1892.                         return Object.keys(pc._reverseStreams || []).forEach(function(internalId) {
  1893.                             var externalStream = pc._reverseStreams[internalId]
  1894.                               , internalStream = pc._streams[externalStream.id];
  1895.                             sdp = sdp.replace(new RegExp(internalStream.id,"g"), externalStream.id)
  1896.                         }),
  1897.                         new RTCSessionDescription({
  1898.                             type: description.type,
  1899.                             sdp: sdp
  1900.                         })
  1901.                     }
  1902.                     function replaceExternalStreamId(pc, description) {
  1903.                         var sdp = description.sdp;
  1904.                         return Object.keys(pc._reverseStreams || []).forEach(function(internalId) {
  1905.                             var externalStream = pc._reverseStreams[internalId]
  1906.                               , internalStream = pc._streams[externalStream.id];
  1907.                             sdp = sdp.replace(new RegExp(externalStream.id,"g"), internalStream.id)
  1908.                         }),
  1909.                         new RTCSessionDescription({
  1910.                             type: description.type,
  1911.                             sdp: sdp
  1912.                         })
  1913.                     }
  1914.                     if (!window.RTCPeerConnection.prototype.addTrack) {
  1915.                         var origGetLocalStreams = window.RTCPeerConnection.prototype.getLocalStreams;
  1916.                         window.RTCPeerConnection.prototype.getLocalStreams = function() {
  1917.                             var self = this
  1918.                               , nativeStreams = origGetLocalStreams.apply(this);
  1919.                             return self._reverseStreams = self._reverseStreams || {},
  1920.                             nativeStreams.map(function(stream) {
  1921.                                 return self._reverseStreams[stream.id]
  1922.                             })
  1923.                         }
  1924.                         ;
  1925.                         var origAddStream = window.RTCPeerConnection.prototype.addStream;
  1926.                         window.RTCPeerConnection.prototype.addStream = function(stream) {
  1927.                             var pc = this;
  1928.                             if (pc._streams = pc._streams || {},
  1929.                             pc._reverseStreams = pc._reverseStreams || {},
  1930.                             stream.getTracks().forEach(function(track) {
  1931.                                 if (pc.getSenders().find(function(s) {
  1932.                                     return s.track === track
  1933.                                 }))
  1934.                                     throw new DOMException("Track already exists.","InvalidAccessError")
  1935.                             }),
  1936.                             !pc._reverseStreams[stream.id]) {
  1937.                                 var newStream = new window.MediaStream(stream.getTracks());
  1938.                                 pc._streams[stream.id] = newStream,
  1939.                                 pc._reverseStreams[newStream.id] = stream,
  1940.                                 stream = newStream
  1941.                             }
  1942.                             origAddStream.apply(pc, [stream])
  1943.                         }
  1944.                         ;
  1945.                         var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
  1946.                         window.RTCPeerConnection.prototype.removeStream = function(stream) {
  1947.                             var pc = this;
  1948.                             pc._streams = pc._streams || {},
  1949.                             pc._reverseStreams = pc._reverseStreams || {},
  1950.                             origRemoveStream.apply(pc, [pc._streams[stream.id] || stream]),
  1951.                             delete pc._reverseStreams[pc._streams[stream.id] ? pc._streams[stream.id].id : stream.id],
  1952.                             delete pc._streams[stream.id]
  1953.                         }
  1954.                         ,
  1955.                         window.RTCPeerConnection.prototype.addTrack = function(track, stream) {
  1956.                             var pc = this;
  1957.                             if ("closed" === pc.signalingState)
  1958.                                 throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
  1959.                             var streams = [].slice.call(arguments, 1);
  1960.                             if (1 !== streams.length || !streams[0].getTracks().find(function(t) {
  1961.                                 return t === track
  1962.                             }))
  1963.                                 throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError");
  1964.                             if (pc.getSenders().find(function(s) {
  1965.                                 return s.track === track
  1966.                             }))
  1967.                                 throw new DOMException("Track already exists.","InvalidAccessError");
  1968.                             pc._streams = pc._streams || {},
  1969.                             pc._reverseStreams = pc._reverseStreams || {};
  1970.                             var oldStream = pc._streams[stream.id];
  1971.                             if (oldStream)
  1972.                                 oldStream.addTrack(track),
  1973.                                 Promise.resolve().then(function() {
  1974.                                     pc.dispatchEvent(new Event("negotiationneeded"))
  1975.                                 });
  1976.                             else {
  1977.                                 var newStream = new window.MediaStream([track]);
  1978.                                 pc._streams[stream.id] = newStream,
  1979.                                 pc._reverseStreams[newStream.id] = stream,
  1980.                                 pc.addStream(newStream)
  1981.                             }
  1982.                             return pc.getSenders().find(function(s) {
  1983.                                 return s.track === track
  1984.                             })
  1985.                         }
  1986.                         ,
  1987.                         ["createOffer", "createAnswer"].forEach(function(method) {
  1988.                             var nativeMethod = window.RTCPeerConnection.prototype[method];
  1989.                             window.RTCPeerConnection.prototype[method] = function() {
  1990.                                 var pc = this
  1991.                                   , args = arguments;
  1992.                                 return arguments.length && "function" == typeof arguments[0] ? nativeMethod.apply(pc, [function(description) {
  1993.                                     var desc = replaceInternalStreamId(pc, description);
  1994.                                     args[0].apply(null, [desc])
  1995.                                 }
  1996.                                 , function(err) {
  1997.                                     args[1] && args[1].apply(null, err)
  1998.                                 }
  1999.                                 , arguments[2]]) : nativeMethod.apply(pc, arguments).then(function(description) {
  2000.                                     return replaceInternalStreamId(pc, description)
  2001.                                 })
  2002.                             }
  2003.                         });
  2004.                         var origSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
  2005.                         window.RTCPeerConnection.prototype.setLocalDescription = function() {
  2006.                             var pc = this;
  2007.                             return arguments.length && arguments[0].type ? (arguments[0] = replaceExternalStreamId(pc, arguments[0]),
  2008.                             origSetLocalDescription.apply(pc, arguments)) : origSetLocalDescription.apply(pc, arguments)
  2009.                         }
  2010.                         ;
  2011.                         var origLocalDescription = Object.getOwnPropertyDescriptor(window.RTCPeerConnection.prototype, "localDescription");
  2012.                         Object.defineProperty(window.RTCPeerConnection.prototype, "localDescription", {
  2013.                             get: function() {
  2014.                                 var pc = this
  2015.                                   , description = origLocalDescription.get.apply(this);
  2016.                                 return "" === description.type ? description : replaceInternalStreamId(pc, description)
  2017.                             }
  2018.                         }),
  2019.                         window.RTCPeerConnection.prototype.removeTrack = function(sender) {
  2020.                             var pc = this;
  2021.                             if ("closed" === pc.signalingState)
  2022.                                 throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
  2023.                             if (!sender._pc)
  2024.                                 throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");
  2025.                             if (sender._pc !== pc)
  2026.                                 throw new DOMException("Sender was not created by this connection.","InvalidAccessError");
  2027.                             pc._streams = pc._streams || {};
  2028.                             var stream;
  2029.                             Object.keys(pc._streams).forEach(function(streamid) {
  2030.                                 pc._streams[streamid].getTracks().find(function(track) {
  2031.                                     return sender.track === track
  2032.                                 }) && (stream = pc._streams[streamid])
  2033.                             }),
  2034.                             stream && (1 === stream.getTracks().length ? pc.removeStream(stream) : stream.removeTrack(sender.track),
  2035.                             pc.dispatchEvent(new Event("negotiationneeded")))
  2036.                         }
  2037.                     }
  2038.                 },
  2039.                 shimPeerConnection: function(window) {
  2040.                     var browserDetails = utils.detectBrowser(window);
  2041.                     if (window.RTCPeerConnection) {
  2042.                         var OrigPeerConnection = window.RTCPeerConnection;
  2043.                         window.RTCPeerConnection = function(pcConfig, pcConstraints) {
  2044.                             if (pcConfig && pcConfig.iceServers) {
  2045.                                 for (var newIceServers = [], i = 0; i < pcConfig.iceServers.length; i++) {
  2046.                                     var server = pcConfig.iceServers[i];
  2047.                                     !server.hasOwnProperty("urls") && server.hasOwnProperty("url") ? (utils.deprecated("RTCIceServer.url", "RTCIceServer.urls"),
  2048.                                     server = JSON.parse(JSON.stringify(server)),
  2049.                                     server.urls = server.url,
  2050.                                     newIceServers.push(server)) : newIceServers.push(pcConfig.iceServers[i])
  2051.                                 }
  2052.                                 pcConfig.iceServers = newIceServers
  2053.                             }
  2054.                             return new OrigPeerConnection(pcConfig,pcConstraints)
  2055.                         }
  2056.                         ,
  2057.                         window.RTCPeerConnection.prototype = OrigPeerConnection.prototype,
  2058.                         Object.defineProperty(window.RTCPeerConnection, "generateCertificate", {
  2059.                             get: function() {
  2060.                                 return OrigPeerConnection.generateCertificate
  2061.                             }
  2062.                         })
  2063.                     } else
  2064.                         window.RTCPeerConnection = function(pcConfig, pcConstraints) {
  2065.                             return logging("PeerConnection"),
  2066.                             pcConfig && pcConfig.iceTransportPolicy && (pcConfig.iceTransports = pcConfig.iceTransportPolicy),
  2067.                             new window.webkitRTCPeerConnection(pcConfig,pcConstraints)
  2068.                         }
  2069.                         ,
  2070.                         window.RTCPeerConnection.prototype = window.webkitRTCPeerConnection.prototype,
  2071.                         window.webkitRTCPeerConnection.generateCertificate && Object.defineProperty(window.RTCPeerConnection, "generateCertificate", {
  2072.                             get: function() {
  2073.                                 return window.webkitRTCPeerConnection.generateCertificate
  2074.                             }
  2075.                         });
  2076.                     var origGetStats = window.RTCPeerConnection.prototype.getStats;
  2077.                     window.RTCPeerConnection.prototype.getStats = function(selector, successCallback, errorCallback) {
  2078.                         var self = this
  2079.                           , args = arguments;
  2080.                         if (arguments.length > 0 && "function" == typeof selector)
  2081.                             return origGetStats.apply(this, arguments);
  2082.                         if (0 === origGetStats.length && (0 === arguments.length || "function" != typeof arguments[0]))
  2083.                             return origGetStats.apply(this, []);
  2084.                         var fixChromeStats_ = function(response) {
  2085.                             var standardReport = {};
  2086.                             return response.result().forEach(function(report) {
  2087.                                 var standardStats = {
  2088.                                     id: report.id,
  2089.                                     timestamp: report.timestamp,
  2090.                                     type: {
  2091.                                         localcandidate: "local-candidate",
  2092.                                         remotecandidate: "remote-candidate"
  2093.                                     }[report.type] || report.type
  2094.                                 };
  2095.                                 report.names().forEach(function(name) {
  2096.                                     standardStats[name] = report.stat(name)
  2097.                                 }),
  2098.                                 standardReport[standardStats.id] = standardStats
  2099.                             }),
  2100.                             standardReport
  2101.                         }
  2102.                           , makeMapStats = function(stats) {
  2103.                             return new Map(Object.keys(stats).map(function(key) {
  2104.                                 return [key, stats[key]]
  2105.                             }))
  2106.                         };
  2107.                         if (arguments.length >= 2) {
  2108.                             var successCallbackWrapper_ = function(response) {
  2109.                                 args[1](makeMapStats(fixChromeStats_(response)))
  2110.                             };
  2111.                             return origGetStats.apply(this, [successCallbackWrapper_, arguments[0]])
  2112.                         }
  2113.                         return new Promise(function(resolve, reject) {
  2114.                             origGetStats.apply(self, [function(response) {
  2115.                                 resolve(makeMapStats(fixChromeStats_(response)))
  2116.                             }
  2117.                             , reject])
  2118.                         }
  2119.                         ).then(successCallback, errorCallback)
  2120.                     }
  2121.                     ,
  2122.                     browserDetails.version < 51 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(method) {
  2123.                         var nativeMethod = window.RTCPeerConnection.prototype[method];
  2124.                         window.RTCPeerConnection.prototype[method] = function() {
  2125.                             var args = arguments
  2126.                               , self = this
  2127.                               , promise = new Promise(function(resolve, reject) {
  2128.                                 nativeMethod.apply(self, [args[0], resolve, reject])
  2129.                             }
  2130.                             );
  2131.                             return args.length < 2 ? promise : promise.then(function() {
  2132.                                 args[1].apply(null, [])
  2133.                             }, function(err) {
  2134.                                 args.length >= 3 && args[2].apply(null, [err])
  2135.                             })
  2136.                         }
  2137.                     }),
  2138.                     browserDetails.version < 52 && ["createOffer", "createAnswer"].forEach(function(method) {
  2139.                         var nativeMethod = window.RTCPeerConnection.prototype[method];
  2140.                         window.RTCPeerConnection.prototype[method] = function() {
  2141.                             var self = this;
  2142.                             if (arguments.length < 1 || 1 === arguments.length && "object" == typeof arguments[0]) {
  2143.                                 var opts = 1 === arguments.length ? arguments[0] : void 0;
  2144.                                 return new Promise(function(resolve, reject) {
  2145.                                     nativeMethod.apply(self, [resolve, reject, opts])
  2146.                                 }
  2147.                                 )
  2148.                             }
  2149.                             return nativeMethod.apply(this, arguments)
  2150.                         }
  2151.                     }),
  2152.                     ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(method) {
  2153.                         var nativeMethod = window.RTCPeerConnection.prototype[method];
  2154.                         window.RTCPeerConnection.prototype[method] = function() {
  2155.                             return arguments[0] = new ("addIceCandidate" === method ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]),
  2156.                             nativeMethod.apply(this, arguments)
  2157.                         }
  2158.                     });
  2159.                     var nativeAddIceCandidate = window.RTCPeerConnection.prototype.addIceCandidate;
  2160.                     window.RTCPeerConnection.prototype.addIceCandidate = function() {
  2161.                         return arguments[0] ? nativeAddIceCandidate.apply(this, arguments) : (arguments[1] && arguments[1].apply(null),
  2162.                         Promise.resolve())
  2163.                     }
  2164.                 }
  2165.             };
  2166.             module.exports = {
  2167.                 shimMediaStream: chromeShim.shimMediaStream,
  2168.                 shimOnTrack: chromeShim.shimOnTrack,
  2169.                 shimAddTrackRemoveTrack: chromeShim.shimAddTrackRemoveTrack,
  2170.                 shimGetSendersWithDtmf: chromeShim.shimGetSendersWithDtmf,
  2171.                 shimSourceObject: chromeShim.shimSourceObject,
  2172.                 shimPeerConnection: chromeShim.shimPeerConnection,
  2173.                 shimGetUserMedia: requirecopy("./getusermedia")
  2174.             }
  2175.         }
  2176.         , {
  2177.             "../utils.js": 13,
  2178.             "./getusermedia": 6
  2179.         }],
  2180.         6: [function(requirecopy, module, exports) {
  2181.             "use strict";
  2182.             var utils = requirecopy("../utils.js")
  2183.               , logging = utils.log;
  2184.             module.exports = function(window) {
  2185.                 var browserDetails = utils.detectBrowser(window)
  2186.                   , navigator = window && window.navigator
  2187.                   , constraintsToChrome_ = function(c) {
  2188.                     if ("object" != typeof c || c.mandatory || c.optional)
  2189.                         return c;
  2190.                     var cc = {};
  2191.                     return Object.keys(c).forEach(function(key) {
  2192.                         if ("require" !== key && "advanced" !== key && "mediaSource" !== key) {
  2193.                             var r = "object" == typeof c[key] ? c[key] : {
  2194.                                 ideal: c[key]
  2195.                             };
  2196.                             void 0 !== r.exact && "number" == typeof r.exact && (r.min = r.max = r.exact);
  2197.                             var oldname_ = function(prefix, name) {
  2198.                                 return prefix ? prefix + name.charAt(0).toUpperCase() + name.slice(1) : "deviceId" === name ? "sourceId" : name
  2199.                             };
  2200.                             if (void 0 !== r.ideal) {
  2201.                                 cc.optional = cc.optional || [];
  2202.                                 var oc = {};
  2203.                                 "number" == typeof r.ideal ? (oc[oldname_("min", key)] = r.ideal,
  2204.                                 cc.optional.push(oc),
  2205.                                 oc = {},
  2206.                                 oc[oldname_("max", key)] = r.ideal,
  2207.                                 cc.optional.push(oc)) : (oc[oldname_("", key)] = r.ideal,
  2208.                                 cc.optional.push(oc))
  2209.                             }
  2210.                             void 0 !== r.exact && "number" != typeof r.exact ? (cc.mandatory = cc.mandatory || {},
  2211.                             cc.mandatory[oldname_("", key)] = r.exact) : ["min", "max"].forEach(function(mix) {
  2212.                                 void 0 !== r[mix] && (cc.mandatory = cc.mandatory || {},
  2213.                                 cc.mandatory[oldname_(mix, key)] = r[mix])
  2214.                             })
  2215.                         }
  2216.                     }),
  2217.                     c.advanced && (cc.optional = (cc.optional || []).concat(c.advanced)),
  2218.                     cc
  2219.                 }
  2220.                   , shimConstraints_ = function(constraints, func) {
  2221.                     if ((constraints = JSON.parse(JSON.stringify(constraints))) && "object" == typeof constraints.audio) {
  2222.                         var remap = function(obj, a, b) {
  2223.                             a in obj && !(b in obj) && (obj[b] = obj[a],
  2224.                             delete obj[a])
  2225.                         };
  2226.                         constraints = JSON.parse(JSON.stringify(constraints)),
  2227.                         remap(constraints.audio, "autoGainControl", "googAutoGainControl"),
  2228.                         remap(constraints.audio, "noiseSuppression", "googNoiseSuppression"),
  2229.                         constraints.audio = constraintsToChrome_(constraints.audio)
  2230.                     }
  2231.                     if (constraints && "object" == typeof constraints.video) {
  2232.                         var face = constraints.video.facingMode;
  2233.                         face = face && ("object" == typeof face ? face : {
  2234.                             ideal: face
  2235.                         });
  2236.                         var getSupportedFacingModeLies = browserDetails.version < 61;
  2237.                         if (face && ("user" === face.exact || "environment" === face.exact || "user" === face.ideal || "environment" === face.ideal) && (!navigator.mediaDevices.getSupportedConstraints || !navigator.mediaDevices.getSupportedConstraints().facingMode || getSupportedFacingModeLies)) {
  2238.                             delete constraints.video.facingMode;
  2239.                             var matches;
  2240.                             if ("environment" === face.exact || "environment" === face.ideal ? matches = ["back", "rear"] : "user" !== face.exact && "user" !== face.ideal || (matches = ["front"]),
  2241.                             matches)
  2242.                                 return navigator.mediaDevices.enumerateDevices().then(function(devices) {
  2243.                                     devices = devices.filter(function(d) {
  2244.                                         return "videoinput" === d.kind
  2245.                                     });
  2246.                                     var dev = devices.find(function(d) {
  2247.                                         return matches.some(function(match) {
  2248.                                             return -1 !== d.label.toLowerCase().indexOf(match)
  2249.                                         })
  2250.                                     });
  2251.                                     return !dev && devices.length && -1 !== matches.indexOf("back") && (dev = devices[devices.length - 1]),
  2252.                                     dev && (constraints.video.deviceId = face.exact ? {
  2253.                                         exact: dev.deviceId
  2254.                                     } : {
  2255.                                         ideal: dev.deviceId
  2256.                                     }),
  2257.                                     constraints.video = constraintsToChrome_(constraints.video),
  2258.                                     logging("chrome: " + JSON.stringify(constraints)),
  2259.                                     func(constraints)
  2260.                                 })
  2261.                         }
  2262.                         constraints.video = constraintsToChrome_(constraints.video)
  2263.                     }
  2264.                     return logging("chrome: " + JSON.stringify(constraints)),
  2265.                     func(constraints)
  2266.                 }
  2267.                   , shimError_ = function(e) {
  2268.                     return {
  2269.                         name: {
  2270.                             PermissionDeniedError: "NotAllowedError",
  2271.                             InvalidStateError: "NotReadableError",
  2272.                             DevicesNotFoundError: "NotFoundError",
  2273.                             ConstraintNotSatisfiedError: "OverconstrainedError",
  2274.                             TrackStartError: "NotReadableError",
  2275.                             MediaDeviceFailedDueToShutdown: "NotReadableError",
  2276.                             MediaDeviceKillSwitchOn: "NotReadableError"
  2277.                         }[e.name] || e.name,
  2278.                         message: e.message,
  2279.                         constraint: e.constraintName,
  2280.                         toString: function() {
  2281.                             return this.name + (this.message && ": ") + this.message
  2282.                         }
  2283.                     }
  2284.                 }
  2285.                   , getUserMedia_ = function(constraints, onSuccess, onError) {
  2286.                     shimConstraints_(constraints, function(c) {
  2287.                         navigator.webkitGetUserMedia(c, onSuccess, function(e) {
  2288.                             onError && onError(shimError_(e))
  2289.                         })
  2290.                     })
  2291.                 };
  2292.                 navigator.getUserMedia = getUserMedia_;
  2293.                 var getUserMediaPromise_ = function(constraints) {
  2294.                     return new Promise(function(resolve, reject) {
  2295.                         navigator.getUserMedia(constraints, resolve, reject)
  2296.                     }
  2297.                     )
  2298.                 };
  2299.                 if (navigator.mediaDevices || (navigator.mediaDevices = {
  2300.                     getUserMedia: getUserMediaPromise_,
  2301.                     enumerateDevices: function() {
  2302.                         return new Promise(function(resolve) {
  2303.                             var kinds = {
  2304.                                 audio: "audioinput",
  2305.                                 video: "videoinput"
  2306.                             };
  2307.                             return window.MediaStreamTrack.getSources(function(devices) {
  2308.                                 resolve(devices.map(function(device) {
  2309.                                     return {
  2310.                                         label: device.label,
  2311.                                         kind: kinds[device.kind],
  2312.                                         deviceId: device.id,
  2313.                                         groupId: ""
  2314.                                     }
  2315.                                 }))
  2316.                             })
  2317.                         }
  2318.                         )
  2319.                     },
  2320.                     getSupportedConstraints: function() {
  2321.                         return {
  2322.                             deviceId: !0,
  2323.                             echoCancellation: !0,
  2324.                             facingMode: !0,
  2325.                             frameRate: !0,
  2326.                             height: !0,
  2327.                             width: !0
  2328.                         }
  2329.                     }
  2330.                 }),
  2331.                 navigator.mediaDevices.getUserMedia) {
  2332.                     var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
  2333.                     navigator.mediaDevices.getUserMedia = function(cs) {
  2334.                         return shimConstraints_(cs, function(c) {
  2335.                             return origGetUserMedia(c).then(function(stream) {
  2336.                                 if (c.audio && !stream.getAudioTracks().length || c.video && !stream.getVideoTracks().length)
  2337.                                     throw stream.getTracks().forEach(function(track) {
  2338.                                         track.stop()
  2339.                                     }),
  2340.                                     new DOMException("","NotFoundError");
  2341.                                 return stream
  2342.                             }, function(e) {
  2343.                                 return Promise.reject(shimError_(e))
  2344.                             })
  2345.                         })
  2346.                     }
  2347.                 } else
  2348.                     navigator.mediaDevices.getUserMedia = function(constraints) {
  2349.                         return getUserMediaPromise_(constraints)
  2350.                     }
  2351.                     ;
  2352.                 void 0 === navigator.mediaDevices.addEventListener && (navigator.mediaDevices.addEventListener = function() {
  2353.                     logging("Dummy mediaDevices.addEventListener called.")
  2354.                 }
  2355.                 ),
  2356.                 void 0 === navigator.mediaDevices.removeEventListener && (navigator.mediaDevices.removeEventListener = function() {
  2357.                     logging("Dummy mediaDevices.removeEventListener called.")
  2358.                 }
  2359.                 )
  2360.             }
  2361.         }
  2362.         , {
  2363.             "../utils.js": 13
  2364.         }],
  2365.         7: [function(requirecopy, module, exports) {
  2366.             "use strict";
  2367.             function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {
  2368.                 if (window.RTCPeerConnection) {
  2369.                     var proto = window.RTCPeerConnection.prototype
  2370.                       , nativeAddEventListener = proto.addEventListener;
  2371.                     proto.addEventListener = function(nativeEventName, cb) {
  2372.                         if (nativeEventName !== eventNameToWrap)
  2373.                             return nativeAddEventListener.apply(this, arguments);
  2374.                         var wrappedCallback = function(e) {
  2375.                             cb(wrapper(e))
  2376.                         };
  2377.                         return this._eventMap = this._eventMap || {},
  2378.                         this._eventMap[cb] = wrappedCallback,
  2379.                         nativeAddEventListener.apply(this, [nativeEventName, wrappedCallback])
  2380.                     }
  2381.                     ;
  2382.                     var nativeRemoveEventListener = proto.removeEventListener;
  2383.                     proto.removeEventListener = function(nativeEventName, cb) {
  2384.                         if (nativeEventName !== eventNameToWrap || !this._eventMap || !this._eventMap[cb])
  2385.                             return nativeRemoveEventListener.apply(this, arguments);
  2386.                         var unwrappedCb = this._eventMap[cb];
  2387.                         return delete this._eventMap[cb],
  2388.                         nativeRemoveEventListener.apply(this, [nativeEventName, unwrappedCb])
  2389.                     }
  2390.                     ,
  2391.                     Object.defineProperty(proto, "on" + eventNameToWrap, {
  2392.                         get: function() {
  2393.                             return this["_on" + eventNameToWrap]
  2394.                         },
  2395.                         set: function(cb) {
  2396.                             this["_on" + eventNameToWrap] && (this.removeEventListener(eventNameToWrap, this["_on" + eventNameToWrap]),
  2397.                             delete this["_on" + eventNameToWrap]),
  2398.                             cb && this.addEventListener(eventNameToWrap, this["_on" + eventNameToWrap] = cb)
  2399.                         }
  2400.                     })
  2401.                 }
  2402.             }
  2403.             var SDPUtils = requirecopy("sdp");
  2404.             module.exports = {
  2405.                 shimRTCIceCandidate: function(window) {
  2406.                     if (!(window.RTCIceCandidate && "foundation"in window.RTCIceCandidate.prototype)) {
  2407.                         var NativeRTCIceCandidate = window.RTCIceCandidate;
  2408.                         window.RTCIceCandidate = function(args) {
  2409.                             "object" == typeof args && args.candidate && 0 === args.candidate.indexOf("a=") && (args = JSON.parse(JSON.stringify(args)),
  2410.                             args.candidate = args.candidate.substr(2));
  2411.                             var nativeCandidate = new NativeRTCIceCandidate(args)
  2412.                               , parsedCandidate = SDPUtils.parseCandidate(args.candidate)
  2413.                               , augmentedCandidate = Object.assign(nativeCandidate, parsedCandidate);
  2414.                             return augmentedCandidate.toJSON = function() {
  2415.                                 return {
  2416.                                     candidate: augmentedCandidate.candidate,
  2417.                                     sdpMid: augmentedCandidate.sdpMid,
  2418.                                     sdpMLineIndex: augmentedCandidate.sdpMLineIndex,
  2419.                                     usernameFragment: augmentedCandidate.usernameFragment
  2420.                                 }
  2421.                             }
  2422.                             ,
  2423.                             augmentedCandidate
  2424.                         }
  2425.                         ,
  2426.                         wrapPeerConnectionEvent(window, "icecandidate", function(e) {
  2427.                             return e.candidate && Object.defineProperty(e, "candidate", {
  2428.                                 value: new window.RTCIceCandidate(e.candidate),
  2429.                                 writable: "false"
  2430.                             }),
  2431.                             e
  2432.                         })
  2433.                     }
  2434.                 }
  2435.             }
  2436.         }
  2437.         , {
  2438.             sdp: 2
  2439.         }],
  2440.         8: [function(requirecopy, module, exports) {
  2441.             "use strict";
  2442.             var utils = requirecopy("../utils")
  2443.               , shimRTCPeerConnection = requirecopy("rtcpeerconnection-shim");
  2444.             module.exports = {
  2445.                 shimGetUserMedia: requirecopy("./getusermedia"),
  2446.                 shimPeerConnection: function(window) {
  2447.                     var browserDetails = utils.detectBrowser(window);
  2448.                     if (window.RTCIceGatherer && (window.RTCIceCandidate || (window.RTCIceCandidate = function(args) {
  2449.                         return args
  2450.                     }
  2451.                     ),
  2452.                     window.RTCSessionDescription || (window.RTCSessionDescription = function(args) {
  2453.                         return args
  2454.                     }
  2455.                     ),
  2456.                     browserDetails.version < 15025)) {
  2457.                         var origMSTEnabled = Object.getOwnPropertyDescriptor(window.MediaStreamTrack.prototype, "enabled");
  2458.                         Object.defineProperty(window.MediaStreamTrack.prototype, "enabled", {
  2459.                             set: function(value) {
  2460.                                 origMSTEnabled.set.call(this, value);
  2461.                                 var ev = new Event("enabled");
  2462.                                 ev.enabled = value,
  2463.                                 this.dispatchEvent(ev)
  2464.                             }
  2465.                         })
  2466.                     }
  2467.                     !window.RTCRtpSender || "dtmf"in window.RTCRtpSender.prototype || Object.defineProperty(window.RTCRtpSender.prototype, "dtmf", {
  2468.                         get: function() {
  2469.                             return void 0 === this._dtmf && ("audio" === this.track.kind ? this._dtmf = new window.RTCDtmfSender(this) : "video" === this.track.kind && (this._dtmf = null)),
  2470.                             this._dtmf
  2471.                         }
  2472.                     }),
  2473.                     window.RTCPeerConnection = shimRTCPeerConnection(window, browserDetails.version)
  2474.                 },
  2475.                 shimReplaceTrack: function(window) {
  2476.                     !window.RTCRtpSender || "replaceTrack"in window.RTCRtpSender.prototype || (window.RTCRtpSender.prototype.replaceTrack = window.RTCRtpSender.prototype.setTrack)
  2477.                 }
  2478.             }
  2479.         }
  2480.         , {
  2481.             "../utils": 13,
  2482.             "./getusermedia": 9,
  2483.             "rtcpeerconnection-shim": 1
  2484.         }],
  2485.         9: [function(requirecopy, module, exports) {
  2486.             "use strict";
  2487.             module.exports = function(window) {
  2488.                 var navigator = window && window.navigator
  2489.                   , shimError_ = function(e) {
  2490.                     return {
  2491.                         name: {
  2492.                             PermissionDeniedError: "NotAllowedError"
  2493.                         }[e.name] || e.name,
  2494.                         message: e.message,
  2495.                         constraint: e.constraint,
  2496.                         toString: function() {
  2497.                             return this.name
  2498.                         }
  2499.                     }
  2500.                 }
  2501.                   , origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
  2502.                 navigator.mediaDevices.getUserMedia = function(c) {
  2503.                     return origGetUserMedia(c).catch(function(e) {
  2504.                         return Promise.reject(shimError_(e))
  2505.                     })
  2506.                 }
  2507.             }
  2508.         }
  2509.         , {}],
  2510.         10: [function(requirecopy, module, exports) {
  2511.             "use strict";
  2512.             var utils = requirecopy("../utils")
  2513.               , firefoxShim = {
  2514.                 shimOnTrack: function(window) {
  2515.                     "object" != typeof window || !window.RTCPeerConnection || "ontrack"in window.RTCPeerConnection.prototype || Object.defineProperty(window.RTCPeerConnection.prototype, "ontrack", {
  2516.                         get: function() {
  2517.                             return this._ontrack
  2518.                         },
  2519.                         set: function(f) {
  2520.                             this._ontrack && (this.removeEventListener("track", this._ontrack),
  2521.                             this.removeEventListener("addstream", this._ontrackpoly)),
  2522.                             this.addEventListener("track", this._ontrack = f),
  2523.                             this.addEventListener("addstream", this._ontrackpoly = function(e) {
  2524.                                 e.stream.getTracks().forEach(function(track) {
  2525.                                     var event = new Event("track");
  2526.                                     event.track = track,
  2527.                                     event.receiver = {
  2528.                                         track: track
  2529.                                     },
  2530.                                     event.transceiver = {
  2531.                                         receiver: event.receiver
  2532.                                     },
  2533.                                     event.streams = [e.stream],
  2534.                                     this.dispatchEvent(event)
  2535.                                 }
  2536.                                 .bind(this))
  2537.                             }
  2538.                             .bind(this))
  2539.                         }
  2540.                     }),
  2541.                     "object" == typeof window && window.RTCPeerConnection && "receiver"in window.RTCTrackEvent.prototype && !("transceiver"in window.RTCTrackEvent.prototype) && Object.defineProperty(window.RTCTrackEvent.prototype, "transceiver", {
  2542.                         get: function() {
  2543.                             return {
  2544.                                 receiver: this.receiver
  2545.                             }
  2546.                         }
  2547.                     })
  2548.                 },
  2549.                 shimSourceObject: function(window) {
  2550.                     "object" == typeof window && (!window.HTMLMediaElement || "srcObject"in window.HTMLMediaElement.prototype || Object.defineProperty(window.HTMLMediaElement.prototype, "srcObject", {
  2551.                         get: function() {
  2552.                             return this.mozSrcObject
  2553.                         },
  2554.                         set: function(stream) {
  2555.                             this.mozSrcObject = stream
  2556.                         }
  2557.                     }))
  2558.                 },
  2559.                 shimPeerConnection: function(window) {
  2560.                     var browserDetails = utils.detectBrowser(window);
  2561.                     if ("object" == typeof window && (window.RTCPeerConnection || window.mozRTCPeerConnection)) {
  2562.                         window.RTCPeerConnection || (window.RTCPeerConnection = function(pcConfig, pcConstraints) {
  2563.                             if (browserDetails.version < 38 && pcConfig && pcConfig.iceServers) {
  2564.                                 for (var newIceServers = [], i = 0; i < pcConfig.iceServers.length; i++) {
  2565.                                     var server = pcConfig.iceServers[i];
  2566.                                     if (server.hasOwnProperty("urls"))
  2567.                                         for (var j = 0; j < server.urls.length; j++) {
  2568.                                             var newServer = {
  2569.                                                 url: server.urls[j]
  2570.                                             };
  2571.                                             0 === server.urls[j].indexOf("turn") && (newServer.username = server.username,
  2572.                                             newServer.credential = server.credential),
  2573.                                             newIceServers.push(newServer)
  2574.                                         }
  2575.                                     else
  2576.                                         newIceServers.push(pcConfig.iceServers[i])
  2577.                                 }
  2578.                                 pcConfig.iceServers = newIceServers
  2579.                             }
  2580.                             return new window.mozRTCPeerConnection(pcConfig,pcConstraints)
  2581.                         }
  2582.                         ,
  2583.                         window.RTCPeerConnection.prototype = window.mozRTCPeerConnection.prototype,
  2584.                         window.mozRTCPeerConnection.generateCertificate && Object.defineProperty(window.RTCPeerConnection, "generateCertificate", {
  2585.                             get: function() {
  2586.                                 return window.mozRTCPeerConnection.generateCertificate
  2587.                             }
  2588.                         }),
  2589.                         window.RTCSessionDescription = window.mozRTCSessionDescription,
  2590.                         window.RTCIceCandidate = window.mozRTCIceCandidate),
  2591.                         ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(method) {
  2592.                             var nativeMethod = window.RTCPeerConnection.prototype[method];
  2593.                             window.RTCPeerConnection.prototype[method] = function() {
  2594.                                 return arguments[0] = new ("addIceCandidate" === method ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]),
  2595.                                 nativeMethod.apply(this, arguments)
  2596.                             }
  2597.                         });
  2598.                         var nativeAddIceCandidate = window.RTCPeerConnection.prototype.addIceCandidate;
  2599.                         window.RTCPeerConnection.prototype.addIceCandidate = function() {
  2600.                             return arguments[0] ? nativeAddIceCandidate.apply(this, arguments) : (arguments[1] && arguments[1].apply(null),
  2601.                             Promise.resolve())
  2602.                         }
  2603.                         ;
  2604.                         var makeMapStats = function(stats) {
  2605.                             var map = new Map;
  2606.                             return Object.keys(stats).forEach(function(key) {
  2607.                                 map.set(key, stats[key]),
  2608.                                 map[key] = stats[key]
  2609.                             }),
  2610.                             map
  2611.                         }
  2612.                           , modernStatsTypes = {
  2613.                             inboundrtp: "inbound-rtp",
  2614.                             outboundrtp: "outbound-rtp",
  2615.                             candidatepair: "candidate-pair",
  2616.                             localcandidate: "local-candidate",
  2617.                             remotecandidate: "remote-candidate"
  2618.                         }
  2619.                           , nativeGetStats = window.RTCPeerConnection.prototype.getStats;
  2620.                         window.RTCPeerConnection.prototype.getStats = function(selector, onSucc, onErr) {
  2621.                             return nativeGetStats.apply(this, [selector || null]).then(function(stats) {
  2622.                                 if (browserDetails.version < 48 && (stats = makeMapStats(stats)),
  2623.                                 browserDetails.version < 53 && !onSucc)
  2624.                                     try {
  2625.                                         stats.forEach(function(stat) {
  2626.                                             stat.type = modernStatsTypes[stat.type] || stat.type
  2627.                                         })
  2628.                                     } catch (e) {
  2629.                                         if ("TypeError" !== e.name)
  2630.                                             throw e;
  2631.                                         stats.forEach(function(stat, i) {
  2632.                                             stats.set(i, Object.assign({}, stat, {
  2633.                                                 type: modernStatsTypes[stat.type] || stat.type
  2634.                                             }))
  2635.                                         })
  2636.                                     }
  2637.                                 return stats
  2638.                             }).then(onSucc, onErr)
  2639.                         }
  2640.                     }
  2641.                 }
  2642.             };
  2643.             module.exports = {
  2644.                 shimOnTrack: firefoxShim.shimOnTrack,
  2645.                 shimSourceObject: firefoxShim.shimSourceObject,
  2646.                 shimPeerConnection: firefoxShim.shimPeerConnection,
  2647.                 shimGetUserMedia: requirecopy("./getusermedia")
  2648.             }
  2649.         }
  2650.         , {
  2651.             "../utils": 13,
  2652.             "./getusermedia": 11
  2653.         }],
  2654.         11: [function(requirecopy, module, exports) {
  2655.             "use strict";
  2656.             var utils = requirecopy("../utils")
  2657.               , logging = utils.log;
  2658.             module.exports = function(window) {
  2659.                 var browserDetails = utils.detectBrowser(window)
  2660.                   , navigator = window && window.navigator
  2661.                   , MediaStreamTrack = window && window.MediaStreamTrack
  2662.                   , shimError_ = function(e) {
  2663.                     return {
  2664.                         name: {
  2665.                             InternalError: "NotReadableError",
  2666.                             NotSupportedError: "TypeError",
  2667.                             PermissionDeniedError: "NotAllowedError",
  2668.                             SecurityError: "NotAllowedError"
  2669.                         }[e.name] || e.name,
  2670.                         message: {
  2671.                             "The operation is insecure.": "The request is not allowed by the user agent or the platform in the current context."
  2672.                         }[e.message] || e.message,
  2673.                         constraint: e.constraint,
  2674.                         toString: function() {
  2675.                             return this.name + (this.message && ": ") + this.message
  2676.                         }
  2677.                     }
  2678.                 }
  2679.                   , getUserMedia_ = function(constraints, onSuccess, onError) {
  2680.                     var constraintsToFF37_ = function(c) {
  2681.                         if ("object" != typeof c || c.require)
  2682.                             return c;
  2683.                         var require = [];
  2684.                         return Object.keys(c).forEach(function(key) {
  2685.                             if ("require" !== key && "advanced" !== key && "mediaSource" !== key) {
  2686.                                 var r = c[key] = "object" == typeof c[key] ? c[key] : {
  2687.                                     ideal: c[key]
  2688.                                 };
  2689.                                 if (void 0 === r.min && void 0 === r.max && void 0 === r.exact || require.push(key),
  2690.                                 void 0 !== r.exact && ("number" == typeof r.exact ? r.min = r.max = r.exact : c[key] = r.exact,
  2691.                                 delete r.exact),
  2692.                                 void 0 !== r.ideal) {
  2693.                                     c.advanced = c.advanced || [];
  2694.                                     var oc = {};
  2695.                                     "number" == typeof r.ideal ? oc[key] = {
  2696.                                         min: r.ideal,
  2697.                                         max: r.ideal
  2698.                                     } : oc[key] = r.ideal,
  2699.                                     c.advanced.push(oc),
  2700.                                     delete r.ideal,
  2701.                                     Object.keys(r).length || delete c[key]
  2702.                                 }
  2703.                             }
  2704.                         }),
  2705.                         require.length && (c.require = require),
  2706.                         c
  2707.                     };
  2708.                     return constraints = JSON.parse(JSON.stringify(constraints)),
  2709.                     browserDetails.version < 38 && (logging("spec: " + JSON.stringify(constraints)),
  2710.                     constraints.audio && (constraints.audio = constraintsToFF37_(constraints.audio)),
  2711.                     constraints.video && (constraints.video = constraintsToFF37_(constraints.video)),
  2712.                     logging("ff37: " + JSON.stringify(constraints))),
  2713.                     navigator.mozGetUserMedia(constraints, onSuccess, function(e) {
  2714.                         onError(shimError_(e))
  2715.                     })
  2716.                 }
  2717.                   , getUserMediaPromise_ = function(constraints) {
  2718.                     return new Promise(function(resolve, reject) {
  2719.                         getUserMedia_(constraints, resolve, reject)
  2720.                     }
  2721.                     )
  2722.                 };
  2723.                 if (navigator.mediaDevices || (navigator.mediaDevices = {
  2724.                     getUserMedia: getUserMediaPromise_,
  2725.                     addEventListener: function() {},
  2726.                     removeEventListener: function() {}
  2727.                 }),
  2728.                 navigator.mediaDevices.enumerateDevices = navigator.mediaDevices.enumerateDevices || function() {
  2729.                     return new Promise(function(resolve) {
  2730.                         resolve([{
  2731.                             kind: "audioinput",
  2732.                             deviceId: "default",
  2733.                             label: "",
  2734.                             groupId: ""
  2735.                         }, {
  2736.                             kind: "videoinput",
  2737.                             deviceId: "default",
  2738.                             label: "",
  2739.                             groupId: ""
  2740.                         }])
  2741.                     }
  2742.                     )
  2743.                 }
  2744.                 ,
  2745.                 browserDetails.version < 41) {
  2746.                     var orgEnumerateDevices = navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);
  2747.                     navigator.mediaDevices.enumerateDevices = function() {
  2748.                         return orgEnumerateDevices().then(void 0, function(e) {
  2749.                             if ("NotFoundError" === e.name)
  2750.                                 return [];
  2751.                             throw e
  2752.                         })
  2753.                     }
  2754.                 }
  2755.                 if (browserDetails.version < 49) {
  2756.                     var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
  2757.                     navigator.mediaDevices.getUserMedia = function(c) {
  2758.                         return origGetUserMedia(c).then(function(stream) {
  2759.                             if (c.audio && !stream.getAudioTracks().length || c.video && !stream.getVideoTracks().length)
  2760.                                 throw stream.getTracks().forEach(function(track) {
  2761.                                     track.stop()
  2762.                                 }),
  2763.                                 new DOMException("The object can not be found here.","NotFoundError");
  2764.                             return stream
  2765.                         }, function(e) {
  2766.                             return Promise.reject(shimError_(e))
  2767.                         })
  2768.                     }
  2769.                 }
  2770.                 if (!(browserDetails.version > 55 && "autoGainControl"in navigator.mediaDevices.getSupportedConstraints())) {
  2771.                     var remap = function(obj, a, b) {
  2772.                         a in obj && !(b in obj) && (obj[b] = obj[a],
  2773.                         delete obj[a])
  2774.                     }
  2775.                       , nativeGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
  2776.                     if (navigator.mediaDevices.getUserMedia = function(c) {
  2777.                         return "object" == typeof c && "object" == typeof c.audio && (c = JSON.parse(JSON.stringify(c)),
  2778.                         remap(c.audio, "autoGainControl", "mozAutoGainControl"),
  2779.                         remap(c.audio, "noiseSuppression", "mozNoiseSuppression")),
  2780.                         nativeGetUserMedia(c)
  2781.                     }
  2782.                     ,
  2783.                     MediaStreamTrack && MediaStreamTrack.prototype.getSettings) {
  2784.                         var nativeGetSettings = MediaStreamTrack.prototype.getSettings;
  2785.                         MediaStreamTrack.prototype.getSettings = function() {
  2786.                             var obj = nativeGetSettings.apply(this, arguments);
  2787.                             return remap(obj, "mozAutoGainControl", "autoGainControl"),
  2788.                             remap(obj, "mozNoiseSuppression", "noiseSuppression"),
  2789.                             obj
  2790.                         }
  2791.                     }
  2792.                     if (MediaStreamTrack && MediaStreamTrack.prototype.applyConstraints) {
  2793.                         var nativeApplyConstraints = MediaStreamTrack.prototype.applyConstraints;
  2794.                         MediaStreamTrack.prototype.applyConstraints = function(c) {
  2795.                             return "audio" === this.kind && "object" == typeof c && (c = JSON.parse(JSON.stringify(c)),
  2796.                             remap(c, "autoGainControl", "mozAutoGainControl"),
  2797.                             remap(c, "noiseSuppression", "mozNoiseSuppression")),
  2798.                             nativeApplyConstraints.apply(this, [c])
  2799.                         }
  2800.                     }
  2801.                 }
  2802.                 navigator.getUserMedia = function(constraints, onSuccess, onError) {
  2803.                     if (browserDetails.version < 44)
  2804.                         return getUserMedia_(constraints, onSuccess, onError);
  2805.                     utils.deprecated("navigator.getUserMedia", "navigator.mediaDevices.getUserMedia"),
  2806.                     navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError)
  2807.                 }
  2808.             }
  2809.         }
  2810.         , {
  2811.             "../utils": 13
  2812.         }],
  2813.         12: [function(requirecopy, module, exports) {
  2814.             "use strict";
  2815.             var utils = requirecopy("../utils")
  2816.               , safariShim = {
  2817.                 shimLocalStreamsAPI: function(window) {
  2818.                     if ("object" == typeof window && window.RTCPeerConnection) {
  2819.                         if ("getLocalStreams"in window.RTCPeerConnection.prototype || (window.RTCPeerConnection.prototype.getLocalStreams = function() {
  2820.                             return this._localStreams || (this._localStreams = []),
  2821.                             this._localStreams
  2822.                         }
  2823.                         ),
  2824.                         "getStreamById"in window.RTCPeerConnection.prototype || (window.RTCPeerConnection.prototype.getStreamById = function(id) {
  2825.                             var result = null;
  2826.                             return this._localStreams && this._localStreams.forEach(function(stream) {
  2827.                                 stream.id === id && (result = stream)
  2828.                             }),
  2829.                             this._remoteStreams && this._remoteStreams.forEach(function(stream) {
  2830.                                 stream.id === id && (result = stream)
  2831.                             }),
  2832.                             result
  2833.                         }
  2834.                         ),
  2835.                         !("addStream"in window.RTCPeerConnection.prototype)) {
  2836.                             var _addTrack = window.RTCPeerConnection.prototype.addTrack;
  2837.                             window.RTCPeerConnection.prototype.addStream = function(stream) {
  2838.                                 this._localStreams || (this._localStreams = []),
  2839.                                 -1 === this._localStreams.indexOf(stream) && this._localStreams.push(stream);
  2840.                                 var self = this;
  2841.                                 stream.getTracks().forEach(function(track) {
  2842.                                     _addTrack.call(self, track, stream)
  2843.                                 })
  2844.                             }
  2845.                             ,
  2846.                             window.RTCPeerConnection.prototype.addTrack = function(track, stream) {
  2847.                                 stream && (this._localStreams ? -1 === this._localStreams.indexOf(stream) && this._localStreams.push(stream) : this._localStreams = [stream]),
  2848.                                 _addTrack.call(this, track, stream)
  2849.                             }
  2850.                         }
  2851.                         "removeStream"in window.RTCPeerConnection.prototype || (window.RTCPeerConnection.prototype.removeStream = function(stream) {
  2852.                             this._localStreams || (this._localStreams = []);
  2853.                             var index = this._localStreams.indexOf(stream);
  2854.                             if (-1 !== index) {
  2855.                                 this._localStreams.splice(index, 1);
  2856.                                 var self = this
  2857.                                   , tracks = stream.getTracks();
  2858.                                 this.getSenders().forEach(function(sender) {
  2859.                                     -1 !== tracks.indexOf(sender.track) && self.removeTrack(sender)
  2860.                                 })
  2861.                             }
  2862.                         }
  2863.                         )
  2864.                     }
  2865.                 },
  2866.                 shimRemoteStreamsAPI: function(window) {
  2867.                     "object" == typeof window && window.RTCPeerConnection && ("getRemoteStreams"in window.RTCPeerConnection.prototype || (window.RTCPeerConnection.prototype.getRemoteStreams = function() {
  2868.                         return this._remoteStreams ? this._remoteStreams : []
  2869.                     }
  2870.                     ),
  2871.                     "onaddstream"in window.RTCPeerConnection.prototype || Object.defineProperty(window.RTCPeerConnection.prototype, "onaddstream", {
  2872.                         get: function() {
  2873.                             return this._onaddstream
  2874.                         },
  2875.                         set: function(f) {
  2876.                             this._onaddstream && (this.removeEventListener("addstream", this._onaddstream),
  2877.                             this.removeEventListener("track", this._onaddstreampoly)),
  2878.                             this.addEventListener("addstream", this._onaddstream = f),
  2879.                             this.addEventListener("track", this._onaddstreampoly = function(e) {
  2880.                                 var stream = e.streams[0];
  2881.                                 if (this._remoteStreams || (this._remoteStreams = []),
  2882.                                 !(this._remoteStreams.indexOf(stream) >= 0)) {
  2883.                                     this._remoteStreams.push(stream);
  2884.                                     var event = new Event("addstream");
  2885.                                     event.stream = e.streams[0],
  2886.                                     this.dispatchEvent(event)
  2887.                                 }
  2888.                             }
  2889.                             .bind(this))
  2890.                         }
  2891.                     }))
  2892.                 },
  2893.                 shimCallbacksAPI: function(window) {
  2894.                     if ("object" == typeof window && window.RTCPeerConnection) {
  2895.                         var prototype = window.RTCPeerConnection.prototype
  2896.                           , createOffer = prototype.createOffer
  2897.                           , createAnswer = prototype.createAnswer
  2898.                           , setLocalDescription = prototype.setLocalDescription
  2899.                           , setRemoteDescription = prototype.setRemoteDescription
  2900.                           , addIceCandidate = prototype.addIceCandidate;
  2901.                         prototype.createOffer = function(successCallback, failureCallback) {
  2902.                             var options = arguments.length >= 2 ? arguments[2] : arguments[0]
  2903.                               , promise = createOffer.apply(this, [options]);
  2904.                             return failureCallback ? (promise.then(successCallback, failureCallback),
  2905.                             Promise.resolve()) : promise
  2906.                         }
  2907.                         ,
  2908.                         prototype.createAnswer = function(successCallback, failureCallback) {
  2909.                             var options = arguments.length >= 2 ? arguments[2] : arguments[0]
  2910.                               , promise = createAnswer.apply(this, [options]);
  2911.                             return failureCallback ? (promise.then(successCallback, failureCallback),
  2912.                             Promise.resolve()) : promise
  2913.                         }
  2914.                         ;
  2915.                         var withCallback = function(description, successCallback, failureCallback) {
  2916.                             var promise = setLocalDescription.apply(this, [description]);
  2917.                             return failureCallback ? (promise.then(successCallback, failureCallback),
  2918.                             Promise.resolve()) : promise
  2919.                         };
  2920.                         prototype.setLocalDescription = withCallback,
  2921.                         withCallback = function(description, successCallback, failureCallback) {
  2922.                             var promise = setRemoteDescription.apply(this, [description]);
  2923.                             return failureCallback ? (promise.then(successCallback, failureCallback),
  2924.                             Promise.resolve()) : promise
  2925.                         }
  2926.                         ,
  2927.                         prototype.setRemoteDescription = withCallback,
  2928.                         withCallback = function(candidate, successCallback, failureCallback) {
  2929.                             var promise = addIceCandidate.apply(this, [candidate]);
  2930.                             return failureCallback ? (promise.then(successCallback, failureCallback),
  2931.                             Promise.resolve()) : promise
  2932.                         }
  2933.                         ,
  2934.                         prototype.addIceCandidate = withCallback
  2935.                     }
  2936.                 },
  2937.                 shimGetUserMedia: function(window) {
  2938.                     var navigator = window && window.navigator;
  2939.                     navigator.getUserMedia || (navigator.webkitGetUserMedia ? navigator.getUserMedia = navigator.webkitGetUserMedia.bind(navigator) : navigator.mediaDevices && navigator.mediaDevices.getUserMedia && (navigator.getUserMedia = function(constraints, cb, errcb) {
  2940.                         navigator.mediaDevices.getUserMedia(constraints).then(cb, errcb)
  2941.                     }
  2942.                     .bind(navigator)))
  2943.                 },
  2944.                 shimRTCIceServerUrls: function(window) {
  2945.                     var OrigPeerConnection = window.RTCPeerConnection;
  2946.                     window.RTCPeerConnection = function(pcConfig, pcConstraints) {
  2947.                         if (pcConfig && pcConfig.iceServers) {
  2948.                             for (var newIceServers = [], i = 0; i < pcConfig.iceServers.length; i++) {
  2949.                                 var server = pcConfig.iceServers[i];
  2950.                                 !server.hasOwnProperty("urls") && server.hasOwnProperty("url") ? (utils.deprecated("RTCIceServer.url", "RTCIceServer.urls"),
  2951.                                 server = JSON.parse(JSON.stringify(server)),
  2952.                                 server.urls = server.url,
  2953.                                 delete server.url,
  2954.                                 newIceServers.push(server)) : newIceServers.push(pcConfig.iceServers[i])
  2955.                             }
  2956.                             pcConfig.iceServers = newIceServers
  2957.                         }
  2958.                         return new OrigPeerConnection(pcConfig,pcConstraints)
  2959.                     }
  2960.                     ,
  2961.                     window.RTCPeerConnection.prototype = OrigPeerConnection.prototype,
  2962.                     Object.defineProperty(window.RTCPeerConnection, "generateCertificate", {
  2963.                         get: function() {
  2964.                             return OrigPeerConnection.generateCertificate
  2965.                         }
  2966.                     })
  2967.                 },
  2968.                 shimTrackEventTransceiver: function(window) {
  2969.                     "object" == typeof window && window.RTCPeerConnection && "receiver"in window.RTCTrackEvent.prototype && !window.RTCTransceiver && Object.defineProperty(window.RTCTrackEvent.prototype, "transceiver", {
  2970.                         get: function() {
  2971.                             return {
  2972.                                 receiver: this.receiver
  2973.                             }
  2974.                         }
  2975.                     })
  2976.                 }
  2977.             };
  2978.             module.exports = {
  2979.                 shimCallbacksAPI: safariShim.shimCallbacksAPI,
  2980.                 shimLocalStreamsAPI: safariShim.shimLocalStreamsAPI,
  2981.                 shimRemoteStreamsAPI: safariShim.shimRemoteStreamsAPI,
  2982.                 shimGetUserMedia: safariShim.shimGetUserMedia,
  2983.                 shimRTCIceServerUrls: safariShim.shimRTCIceServerUrls,
  2984.                 shimTrackEventTransceiver: safariShim.shimTrackEventTransceiver
  2985.             }
  2986.         }
  2987.         , {
  2988.             "../utils": 13
  2989.         }],
  2990.         13: [function(requirecopy, module, exports) {
  2991.             "use strict";
  2992.             var logDisabled_ = !0
  2993.               , deprecationWarnings_ = !0
  2994.               , utils = {
  2995.                 disableLog: function(bool) {
  2996.                     return "boolean" != typeof bool ? new Error("Argument type: " + typeof bool + ". Please use a boolean.") : (logDisabled_ = bool,
  2997.                     bool ? "adapter.js logging disabled" : "adapter.js logging enabled")
  2998.                 },
  2999.                 disableWarnings: function(bool) {
  3000.                     return "boolean" != typeof bool ? new Error("Argument type: " + typeof bool + ". Please use a boolean.") : (deprecationWarnings_ = !bool,
  3001.                     "adapter.js deprecation warnings " + (bool ? "disabled" : "enabled"))
  3002.                 },
  3003.                 log: function() {
  3004.                     if ("object" == typeof window) {
  3005.                         if (logDisabled_)
  3006.                             return;
  3007.                         "undefined" != typeof console && console.log
  3008.                     }
  3009.                 },
  3010.                 deprecated: function(oldMethod, newMethod) {},
  3011.                 extractVersion: function(uastring, expr, pos) {
  3012.                     var match = uastring.match(expr);
  3013.                     return match && match.length >= pos && parseInt(match[pos], 10)
  3014.                 },
  3015.                 detectBrowser: function(window) {
  3016.                     var navigator = window && window.navigator
  3017.                       , result = {};
  3018.                     if (result.browser = null,
  3019.                     result.version = null,
  3020.                     void 0 === window || !window.navigator)
  3021.                         return result.browser = "Not a browser.",
  3022.                         result;
  3023.                     if (navigator.mozGetUserMedia)
  3024.                         result.browser = "firefox",
  3025.                         result.version = this.extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
  3026.                     else if (navigator.webkitGetUserMedia)
  3027.                         if (window.webkitRTCPeerConnection)
  3028.                             result.browser = "chrome",
  3029.                             result.version = this.extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
  3030.                         else {
  3031.                             if (!navigator.userAgent.match(/Version\/(\d+).(\d+)/))
  3032.                                 return result.browser = "Unsupported webkit-based browser with GUM support but no WebRTC support.",
  3033.                                 result;
  3034.                             result.browser = "safari",
  3035.                             result.version = this.extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1)
  3036.                         }
  3037.                     else if (navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))
  3038.                         result.browser = "edge",
  3039.                         result.version = this.extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2);
  3040.                     else {
  3041.                         if (!navigator.mediaDevices || !navigator.userAgent.match(/AppleWebKit\/(\d+)\./))
  3042.                             return result.browser = "Not a supported browser.",
  3043.                             result;
  3044.                         result.browser = "safari",
  3045.                         result.version = this.extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1)
  3046.                     }
  3047.                     return result
  3048.                 },
  3049.                 shimCreateObjectURL: function(window) {
  3050.                     var URL = window && window.URL;
  3051.                     if ("object" == typeof window && window.HTMLMediaElement && "srcObject"in window.HTMLMediaElement.prototype && URL.createObjectURL && URL.revokeObjectURL) {
  3052.                         var nativeCreateObjectURL = URL.createObjectURL.bind(URL)
  3053.                           , nativeRevokeObjectURL = URL.revokeObjectURL.bind(URL)
  3054.                           , streams = new Map
  3055.                           , newId = 0;
  3056.                         URL.createObjectURL = function(stream) {
  3057.                             if ("getTracks"in stream) {
  3058.                                 var url = "polyblob:" + ++newId;
  3059.                                 return streams.set(url, stream),
  3060.                                 utils.deprecated("URL.createObjectURL(stream)", "elem.srcObject = stream"),
  3061.                                 url
  3062.                             }
  3063.                             return nativeCreateObjectURL(stream)
  3064.                         }
  3065.                         ,
  3066.                         URL.revokeObjectURL = function(url) {
  3067.                             nativeRevokeObjectURL(url),
  3068.                             streams.delete(url)
  3069.                         }
  3070.                         ;
  3071.                         var dsc = Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype, "src");
  3072.                         Object.defineProperty(window.HTMLMediaElement.prototype, "src", {
  3073.                             get: function() {
  3074.                                 return dsc.get.apply(this)
  3075.                             },
  3076.                             set: function(url) {
  3077.                                 return this.srcObject = streams.get(url) || null,
  3078.                                 dsc.set.apply(this, [url])
  3079.                             }
  3080.                         });
  3081.                         var nativeSetAttribute = window.HTMLMediaElement.prototype.setAttribute;
  3082.                         window.HTMLMediaElement.prototype.setAttribute = function() {
  3083.                             return 2 === arguments.length && "src" === ("" + arguments[0]).toLowerCase() && (this.srcObject = streams.get(arguments[1]) || null),
  3084.                             nativeSetAttribute.apply(this, arguments)
  3085.                         }
  3086.                     }
  3087.                 }
  3088.             };
  3089.             module.exports = {
  3090.                 log: utils.log,
  3091.                 deprecated: utils.deprecated,
  3092.                 disableLog: utils.disableLog,
  3093.                 disableWarnings: utils.disableWarnings,
  3094.                 extractVersion: utils.extractVersion,
  3095.                 shimCreateObjectURL: utils.shimCreateObjectURL,
  3096.                 detectBrowser: utils.detectBrowser.bind(utils)
  3097.             }
  3098.         }
  3099.         , {}]
  3100.     }, {}, [3])(3)
  3101. }),
  3102. navigator.mozGetUserMedia ? (MediaStreamTrack.getSources = function(successCb) {
  3103.     setTimeout(function() {
  3104.         successCb([{
  3105.             kind: "audio",
  3106.             id: "default",
  3107.             label: "",
  3108.             facing: ""
  3109.         }, {
  3110.             kind: "video",
  3111.             id: "default",
  3112.             label: "",
  3113.             facing: ""
  3114.         }])
  3115.     }, 0)
  3116. }
  3117. ,
  3118. attachMediaStream = function(element, stream) {
  3119.     return element.srcObject = stream,
  3120.     element
  3121. }
  3122. ,
  3123. reattachMediaStream = function(to, from) {
  3124.     return to.srcObject = from.srcObject,
  3125.     to
  3126. }
  3127. ,
  3128. createIceServer = function(url, username, password) {
  3129.     var iceServer = null
  3130.       , urlParts = url.split(":");
  3131.     if (0 === urlParts[0].indexOf("stun"))
  3132.         iceServer = {
  3133.             urls: [url]
  3134.         };
  3135.     else if (0 === urlParts[0].indexOf("turn"))
  3136.         if (AdapterJS.webrtcDetectedVersion < 27) {
  3137.             var turnUrlParts = url.split("?");
  3138.             1 !== turnUrlParts.length && 0 !== turnUrlParts[1].indexOf("transport=udp") || (iceServer = {
  3139.                 urls: [turnUrlParts[0]],
  3140.                 credential: password,
  3141.                 username: username
  3142.             })
  3143.         } else
  3144.             iceServer = {
  3145.                 urls: [url],
  3146.                 credential: password,
  3147.                 username: username
  3148.             };
  3149.     return iceServer
  3150. }
  3151. ,
  3152. createIceServers = function(urls, username, password) {
  3153.     var iceServers = [];
  3154.     for (i = 0; i < urls.length; i++) {
  3155.         var iceServer = createIceServer(urls[i], username, password);
  3156.         null !== iceServer && iceServers.push(iceServer)
  3157.     }
  3158.     return iceServers
  3159. }
  3160. ) : navigator.webkitGetUserMedia ? (attachMediaStream = function(element, stream) {
  3161.     return AdapterJS.webrtcDetectedVersion >= 43 ? element.srcObject = stream : void 0 !== element.src && (element.src = URL.createObjectURL(stream)),
  3162.     element
  3163. }
  3164. ,
  3165. reattachMediaStream = function(to, from) {
  3166.     return AdapterJS.webrtcDetectedVersion >= 43 ? to.srcObject = from.srcObject : to.src = from.src,
  3167.     to
  3168. }
  3169. ,
  3170. createIceServer = function(url, username, password) {
  3171.     var iceServer = null
  3172.       , urlParts = url.split(":");
  3173.     return 0 === urlParts[0].indexOf("stun") ? iceServer = {
  3174.         url: url
  3175.     } : 0 === urlParts[0].indexOf("turn") && (iceServer = {
  3176.         url: url,
  3177.         credential: password,
  3178.         username: username
  3179.     }),
  3180.     iceServer
  3181. }
  3182. ,
  3183. createIceServers = function(urls, username, password) {
  3184.     var iceServers = [];
  3185.     if (AdapterJS.webrtcDetectedVersion >= 34)
  3186.         iceServers = {
  3187.             urls: urls,
  3188.             credential: password,
  3189.             username: username
  3190.         };
  3191.     else
  3192.         for (i = 0; i < urls.length; i++) {
  3193.             var iceServer = createIceServer(urls[i], username, password);
  3194.             null !== iceServer && iceServers.push(iceServer)
  3195.         }
  3196.     return iceServers
  3197. }
  3198. ) : "AppleWebKit" === AdapterJS.webrtcDetectedType ? (attachMediaStream = function(element, stream) {
  3199.     return element.srcObject = stream,
  3200.     element
  3201. }
  3202. ,
  3203. reattachMediaStream = function(to, from) {
  3204.     return to.srcObject = from.srcObject,
  3205.     to
  3206. }
  3207. ,
  3208. navigator.mediaDevices && navigator.mediaDevices.getUserMedia && (navigator.getUserMedia = getUserMedia = function(constraints, successCb, errorCb) {
  3209.     navigator.mediaDevices.getUserMedia(constraints).then(successCb).catch(errorCb)
  3210. }
  3211. )) : navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) && (attachMediaStream = function(element, stream) {
  3212.     return element.srcObject = stream,
  3213.     element
  3214. }
  3215. ,
  3216. reattachMediaStream = function(to, from) {
  3217.     return to.srcObject = from.srcObject,
  3218.     to
  3219. }
  3220. ),
  3221. attachMediaStream_base = attachMediaStream,
  3222. "opera" === AdapterJS.webrtcDetectedBrowser && (attachMediaStream_base = function(element, stream) {
  3223.     AdapterJS.webrtcDetectedVersion > 38 ? element.srcObject = stream : void 0 !== element.src && (element.src = URL.createObjectURL(stream))
  3224. }
  3225. ),
  3226. attachMediaStream = function(element, stream) {
  3227.     return "chrome" !== AdapterJS.webrtcDetectedBrowser && "opera" !== AdapterJS.webrtcDetectedBrowser || stream ? attachMediaStream_base(element, stream) : element.src = "",
  3228.     element
  3229. }
  3230. ,
  3231. reattachMediaStream_base = reattachMediaStream,
  3232. reattachMediaStream = function(to, from) {
  3233.     return reattachMediaStream_base(to, from),
  3234.     to
  3235. }
  3236. ,
  3237. window.attachMediaStream = attachMediaStream,
  3238. window.reattachMediaStream = reattachMediaStream,
  3239. window.getUserMedia = function(constraints, onSuccess, onFailure) {
  3240.     navigator.getUserMedia(constraints, onSuccess, onFailure)
  3241. }
  3242. ,
  3243. AdapterJS.attachMediaStream = attachMediaStream,
  3244. AdapterJS.reattachMediaStream = reattachMediaStream,
  3245. AdapterJS.getUserMedia = getUserMedia,
  3246. "undefined" == typeof Promise && (requestUserMedia = null),
  3247. AdapterJS.maybeThroughWebRTCReady()) : ("object" == typeof console && "function" == typeof console.log || (console = {} || console,
  3248. console.log = function(arg) {}
  3249. ,
  3250. console.info = function(arg) {}
  3251. ,
  3252. console.error = function(arg) {}
  3253. ,
  3254. console.dir = function(arg) {}
  3255. ,
  3256. console.exception = function(arg) {}
  3257. ,
  3258. console.trace = function(arg) {}
  3259. ,
  3260. console.warn = function(arg) {}
  3261. ,
  3262. console.count = function(arg) {}
  3263. ,
  3264. console.debug = function(arg) {}
  3265. ,
  3266. console.count = function(arg) {}
  3267. ,
  3268. console.time = function(arg) {}
  3269. ,
  3270. console.timeEnd = function(arg) {}
  3271. ,
  3272. console.group = function(arg) {}
  3273. ,
  3274. console.groupCollapsed = function(arg) {}
  3275. ,
  3276. console.groupEnd = function(arg) {}
  3277. ),
  3278. AdapterJS.WebRTCPlugin.WaitForPluginReady = function() {
  3279.     for (; AdapterJS.WebRTCPlugin.pluginState !== AdapterJS.WebRTCPlugin.PLUGIN_STATES.READY; )
  3280.         ;
  3281. }
  3282. ,
  3283. AdapterJS.WebRTCPlugin.callWhenPluginReady = function(callback) {
  3284.     if (AdapterJS.WebRTCPlugin.pluginState === AdapterJS.WebRTCPlugin.PLUGIN_STATES.READY)
  3285.         callback();
  3286.     else
  3287.         var checkPluginReadyState = setInterval(function() {
  3288.             AdapterJS.WebRTCPlugin.pluginState === AdapterJS.WebRTCPlugin.PLUGIN_STATES.READY && (clearInterval(checkPluginReadyState),
  3289.             callback())
  3290.         }, 100)
  3291. }
  3292. ,
  3293. AdapterJS.WebRTCPlugin.setLogLevel = function(logLevel) {
  3294.     AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
  3295.         AdapterJS.WebRTCPlugin.plugin.setLogLevel(logLevel)
  3296.     })
  3297. }
  3298. ,
  3299. AdapterJS.WebRTCPlugin.injectPlugin = function() {
  3300.     if (("interactive" === document.readyState || "complete" === document.readyState) && AdapterJS.WebRTCPlugin.pluginState === AdapterJS.WebRTCPlugin.PLUGIN_STATES.INITIALIZING) {
  3301.         if (AdapterJS.WebRTCPlugin.pluginState = AdapterJS.WebRTCPlugin.PLUGIN_STATES.INJECTING,
  3302.         "IE" === AdapterJS.webrtcDetectedBrowser && AdapterJS.webrtcDetectedVersion <= 10) {
  3303.             var frag = document.createDocumentFragment();
  3304.             for (AdapterJS.WebRTCPlugin.plugin = document.createElement("div"),
  3305.             AdapterJS.WebRTCPlugin.plugin.innerHTML = '<object id="' + AdapterJS.WebRTCPlugin.pluginInfo.pluginId + '" type="' + AdapterJS.WebRTCPlugin.pluginInfo.type + '" width="1" height="1"><param name="pluginId" value="' + AdapterJS.WebRTCPlugin.pluginInfo.pluginId + '" /> <param name="windowless" value="false" /> <param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> <param name="onload" value="' + AdapterJS.WebRTCPlugin.pluginInfo.onload + '" /><param name="tag" value="' + AdapterJS.WebRTCPlugin.TAGS.NONE + '" />' + (AdapterJS.options.getAllCams ? '<param name="forceGetAllCams" value="True" />' : "") + "</object>"; AdapterJS.WebRTCPlugin.plugin.firstChild; )
  3306.                 frag.appendChild(AdapterJS.WebRTCPlugin.plugin.firstChild);
  3307.             document.body.appendChild(frag),
  3308.             AdapterJS.WebRTCPlugin.plugin = document.getElementById(AdapterJS.WebRTCPlugin.pluginInfo.pluginId)
  3309.         } else
  3310.             AdapterJS.WebRTCPlugin.plugin = document.createElement("object"),
  3311.             AdapterJS.WebRTCPlugin.plugin.id = AdapterJS.WebRTCPlugin.pluginInfo.pluginId,
  3312.             "IE" === AdapterJS.webrtcDetectedBrowser ? (AdapterJS.WebRTCPlugin.plugin.width = "1px",
  3313.             AdapterJS.WebRTCPlugin.plugin.height = "1px") : (AdapterJS.WebRTCPlugin.plugin.width = "0px",
  3314.             AdapterJS.WebRTCPlugin.plugin.height = "0px"),
  3315.             AdapterJS.WebRTCPlugin.plugin.type = AdapterJS.WebRTCPlugin.pluginInfo.type,
  3316.             AdapterJS.WebRTCPlugin.plugin.innerHTML = '<param name="onload" value="' + AdapterJS.WebRTCPlugin.pluginInfo.onload + '"><param name="pluginId" value="' + AdapterJS.WebRTCPlugin.pluginInfo.pluginId + '"><param name="windowless" value="false" /> ' + (AdapterJS.options.getAllCams ? '<param name="forceGetAllCams" value="True" />' : "") + '<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '"><param name="tag" value="' + AdapterJS.WebRTCPlugin.TAGS.NONE + '" />',
  3317.             document.body.appendChild(AdapterJS.WebRTCPlugin.plugin);
  3318.         AdapterJS.WebRTCPlugin.pluginState = AdapterJS.WebRTCPlugin.PLUGIN_STATES.INJECTED
  3319.     }
  3320. }
  3321. ,
  3322. AdapterJS.WebRTCPlugin.isPluginInstalled = function(comName, plugName, plugType, installedCb, notInstalledCb) {
  3323.     if ("IE" !== AdapterJS.webrtcDetectedBrowser) {
  3324.         for (var pluginArray = navigator.mimeTypes, i = 0; i < pluginArray.length; i++)
  3325.             if (pluginArray[i].type.indexOf(plugType) >= 0)
  3326.                 return void installedCb();
  3327.         notInstalledCb()
  3328.     } else {
  3329.         try {
  3330.             new ActiveXObject(comName + "." + plugName)
  3331.         } catch (e) {
  3332.             return void notInstalledCb()
  3333.         }
  3334.         installedCb()
  3335.     }
  3336. }
  3337. ,
  3338. AdapterJS.WebRTCPlugin.defineWebRTCInterface = function() {
  3339.     if (AdapterJS.WebRTCPlugin.pluginState !== AdapterJS.WebRTCPlugin.PLUGIN_STATES.READY) {
  3340.         AdapterJS.WebRTCPlugin.pluginState = AdapterJS.WebRTCPlugin.PLUGIN_STATES.INITIALIZING,
  3341.         AdapterJS.isDefined = function(variable) {
  3342.             return null !== variable && void 0 !== variable
  3343.         }
  3344.         ,
  3345.         createIceServer = function(url, username, password) {
  3346.             var iceServer = null
  3347.               , urlParts = url.split(":");
  3348.             return 0 === urlParts[0].indexOf("stun") ? iceServer = {
  3349.                 url: url,
  3350.                 hasCredentials: !1
  3351.             } : 0 === urlParts[0].indexOf("turn") && (iceServer = {
  3352.                 url: url,
  3353.                 hasCredentials: !0,
  3354.                 credential: password,
  3355.                 username: username
  3356.             }),
  3357.             iceServer
  3358.         }
  3359.         ,
  3360.         createIceServers = function(urls, username, password) {
  3361.             for (var iceServers = [], i = 0; i < urls.length; ++i)
  3362.                 iceServers.push(createIceServer(urls[i], username, password));
  3363.             return iceServers
  3364.         }
  3365.         ,
  3366.         RTCSessionDescription = function(info) {
  3367.             return AdapterJS.WebRTCPlugin.WaitForPluginReady(),
  3368.             AdapterJS.WebRTCPlugin.plugin.ConstructSessionDescription(info.type, info.sdp)
  3369.         }
  3370.         ,
  3371.         MediaStream = function(mediaStreamOrTracks) {
  3372.             return AdapterJS.WebRTCPlugin.WaitForPluginReady(),
  3373.             AdapterJS.WebRTCPlugin.plugin.MediaStream(mediaStreamOrTracks)
  3374.         }
  3375.         ,
  3376.         RTCPeerConnection = function(servers, constraints) {
  3377.             if (void 0 !== servers && null !== servers && !Array.isArray(servers.iceServers))
  3378.                 throw new Error("Failed to construct 'RTCPeerConnection': Malformed RTCConfiguration");
  3379.             if (void 0 !== constraints && null !== constraints) {
  3380.                 var invalidConstraits = !1;
  3381.                 if (invalidConstraits |= "object" != typeof constraints,
  3382.                 invalidConstraits |= constraints.hasOwnProperty("mandatory") && void 0 !== constraints.mandatory && null !== constraints.mandatory && constraints.mandatory.constructor !== Object,
  3383.                 invalidConstraits |= constraints.hasOwnProperty("optional") && void 0 !== constraints.optional && null !== constraints.optional && !Array.isArray(constraints.optional))
  3384.                     throw new Error("Failed to construct 'RTCPeerConnection': Malformed constraints object")
  3385.             }
  3386.             AdapterJS.WebRTCPlugin.WaitForPluginReady();
  3387.             var iceServers = null;
  3388.             if (servers && Array.isArray(servers.iceServers)) {
  3389.                 iceServers = servers.iceServers;
  3390.                 for (var i = 0; i < iceServers.length; i++)
  3391.                     iceServers[i].urls && !iceServers[i].url && (iceServers[i].url = iceServers[i].urls),
  3392.                     iceServers[i].hasCredentials = AdapterJS.isDefined(iceServers[i].username) && AdapterJS.isDefined(iceServers[i].credential)
  3393.             }
  3394.             if (AdapterJS.WebRTCPlugin.plugin.PEER_CONNECTION_VERSION && AdapterJS.WebRTCPlugin.plugin.PEER_CONNECTION_VERSION > 1)
  3395.                 return iceServers && (servers.iceServers = iceServers),
  3396.                 AdapterJS.WebRTCPlugin.plugin.PeerConnection(servers);
  3397.             var mandatory = constraints && constraints.mandatory ? constraints.mandatory : null
  3398.               , optional = constraints && constraints.optional ? constraints.optional : null;
  3399.             return AdapterJS.WebRTCPlugin.plugin.PeerConnection(AdapterJS.WebRTCPlugin.pageId, iceServers, mandatory, optional)
  3400.         }
  3401.         ,
  3402.         MediaStreamTrack = function() {}
  3403.         ,
  3404.         MediaStreamTrack.getSources = function(callback) {
  3405.             AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
  3406.                 AdapterJS.WebRTCPlugin.plugin.GetSources(callback)
  3407.             })
  3408.         }
  3409.         ;
  3410.         var constraintsToPlugin = function(c) {
  3411.             if ("object" != typeof c || c.mandatory || c.optional)
  3412.                 return c;
  3413.             var cc = {};
  3414.             return Object.keys(c).forEach(function(key) {
  3415.                 if ("require" !== key && "advanced" !== key) {
  3416.                     if ("string" == typeof c[key])
  3417.                         return void (cc[key] = c[key]);
  3418.                     var r = "object" == typeof c[key] ? c[key] : {
  3419.                         ideal: c[key]
  3420.                     };
  3421.                     void 0 !== r.exact && "number" == typeof r.exact && (r.min = r.max = r.exact);
  3422.                     var oldname = function(prefix, name) {
  3423.                         return prefix ? prefix + name.charAt(0).toUpperCase() + name.slice(1) : "deviceId" === name ? "sourceId" : name
  3424.                     };
  3425.                     if ("sourceId" === oldname("", key) && void 0 !== r.exact && (r.ideal = r.exact,
  3426.                     r.exact = void 0),
  3427.                     void 0 !== r.ideal) {
  3428.                         cc.optional = cc.optional || [];
  3429.                         var oc = {};
  3430.                         "number" == typeof r.ideal ? (oc[oldname("min", key)] = r.ideal,
  3431.                         cc.optional.push(oc),
  3432.                         oc = {},
  3433.                         oc[oldname("max", key)] = r.ideal,
  3434.                         cc.optional.push(oc)) : (oc[oldname("", key)] = r.ideal,
  3435.                         cc.optional.push(oc))
  3436.                     }
  3437.                     void 0 !== r.exact && "number" != typeof r.exact ? (cc.mandatory = cc.mandatory || {},
  3438.                     cc.mandatory[oldname("", key)] = r.exact) : ["min", "max"].forEach(function(mix) {
  3439.                         void 0 !== r[mix] && (cc.mandatory = cc.mandatory || {},
  3440.                         cc.mandatory[oldname(mix, key)] = r[mix])
  3441.                     })
  3442.                 }
  3443.             }),
  3444.             c.advanced && (cc.optional = (cc.optional || []).concat(c.advanced)),
  3445.             cc
  3446.         };
  3447.         getUserMedia = function(constraints, successCallback, failureCallback) {
  3448.             var cc = {};
  3449.             cc.audio = !!constraints.audio && constraintsToPlugin(constraints.audio),
  3450.             cc.video = !!constraints.video && constraintsToPlugin(constraints.video),
  3451.             AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
  3452.                 AdapterJS.WebRTCPlugin.plugin.getUserMedia(cc, successCallback, failureCallback)
  3453.             })
  3454.         }
  3455.         ,
  3456.         window.navigator.getUserMedia = getUserMedia,
  3457.         "undefined" != typeof Promise && (requestUserMedia = function(constraints) {
  3458.             return new Promise(function(resolve, reject) {
  3459.                 try {
  3460.                     getUserMedia(constraints, resolve, reject)
  3461.                 } catch (error) {
  3462.                     reject(error)
  3463.                 }
  3464.             }
  3465.             )
  3466.         }
  3467.         ,
  3468.         navigator.mediaDevices = {
  3469.             getUserMedia: requestUserMedia,
  3470.             enumerateDevices: function() {
  3471.                 return new Promise(function(resolve) {
  3472.                     var kinds = {
  3473.                         audio: "audioinput",
  3474.                         video: "videoinput"
  3475.                     };
  3476.                     return MediaStreamTrack.getSources(function(devices) {
  3477.                         resolve(devices.map(function(device) {
  3478.                             return {
  3479.                                 label: device.label,
  3480.                                 kind: kinds[device.kind],
  3481.                                 id: device.id,
  3482.                                 deviceId: device.id,
  3483.                                 groupId: ""
  3484.                             }
  3485.                         }))
  3486.                     })
  3487.                 }
  3488.                 )
  3489.             }
  3490.         }),
  3491.         attachMediaStream = function(element, stream) {
  3492.             if (element && element.parentNode) {
  3493.                 var streamId;
  3494.                 null === stream ? streamId = "" : (void 0 !== stream.enableSoundTracks && stream.enableSoundTracks(!0),
  3495.                 streamId = stream.id);
  3496.                 var elementId = 0 === element.id.length ? Math.random().toString(36).slice(2) : element.id
  3497.                   , nodeName = element.nodeName.toLowerCase();
  3498.                 if ("object" !== nodeName) {
  3499.                     var tag;
  3500.                     switch (nodeName) {
  3501.                     case "audio":
  3502.                         tag = AdapterJS.WebRTCPlugin.TAGS.AUDIO;
  3503.                         break;
  3504.                     case "video":
  3505.                         tag = AdapterJS.WebRTCPlugin.TAGS.VIDEO;
  3506.                         break;
  3507.                     default:
  3508.                         tag = AdapterJS.WebRTCPlugin.TAGS.NONE
  3509.                     }
  3510.                     var frag = document.createDocumentFragment()
  3511.                       , temp = document.createElement("div")
  3512.                       , classHTML = "";
  3513.                     for (element.className ? classHTML = 'class="' + element.className + '" ' : element.attributes && element.attributes.class && (classHTML = 'class="' + element.attributes.class.value + '" '),
  3514.                     temp.innerHTML = '<object id="' + elementId + '" ' + classHTML + 'type="' + AdapterJS.WebRTCPlugin.pluginInfo.type + '"><param name="pluginId" value="' + elementId + '" /> <param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> <param name="windowless" value="true" /> <param name="streamId" value="' + streamId + '" /> <param name="tag" value="' + tag + '" /> </object>'; temp.firstChild; )
  3515.                         frag.appendChild(temp.firstChild);
  3516.                     var height = ""
  3517.                       , width = "";
  3518.                     element.clientWidth || element.clientHeight ? (width = element.clientWidth,
  3519.                     height = element.clientHeight) : (element.width || element.height) && (width = element.width,
  3520.                     height = element.height),
  3521.                     element.parentNode.insertBefore(frag, element),
  3522.                     frag = document.getElementById(elementId),
  3523.                     frag.width = width,
  3524.                     frag.height = height,
  3525.                     element.parentNode.removeChild(element)
  3526.                 } else {
  3527.                     for (var children = element.children, i = 0; i !== children.length; ++i)
  3528.                         if ("streamId" === children[i].name) {
  3529.                             children[i].value = streamId;
  3530.                             break
  3531.                         }
  3532.                     element.setStreamId(streamId)
  3533.                 }
  3534.                 var newElement = document.getElementById(elementId);
  3535.                 return AdapterJS.forwardEventHandlers(newElement, element, Object.getPrototypeOf(element)),
  3536.                 newElement
  3537.             }
  3538.         }
  3539.         ,
  3540.         reattachMediaStream = function(to, from) {
  3541.             for (var stream = null, children = from.children, i = 0; i !== children.length; ++i)
  3542.                 if ("streamId" === children[i].name) {
  3543.                     AdapterJS.WebRTCPlugin.WaitForPluginReady(),
  3544.                     stream = AdapterJS.WebRTCPlugin.plugin.getStreamWithId(AdapterJS.WebRTCPlugin.pageId, children[i].value);
  3545.                     break
  3546.                 }
  3547.             if (null !== stream)
  3548.                 return attachMediaStream(to, stream)
  3549.         }
  3550.         ,
  3551.         window.attachMediaStream = attachMediaStream,
  3552.         window.reattachMediaStream = reattachMediaStream,
  3553.         window.getUserMedia = getUserMedia,
  3554.         AdapterJS.attachMediaStream = attachMediaStream,
  3555.         AdapterJS.reattachMediaStream = reattachMediaStream,
  3556.         AdapterJS.getUserMedia = getUserMedia,
  3557.         AdapterJS.forwardEventHandlers = function(destElem, srcElem, prototype) {
  3558.             var properties = Object.getOwnPropertyNames(prototype);
  3559.             for (var prop in properties)
  3560.                 if (prop) {
  3561.                     var propName = properties[prop];
  3562.                     "function" == typeof propName.slice && "on" === propName.slice(0, 2) && "function" == typeof srcElem[propName] && AdapterJS.addEvent(destElem, propName.slice(2), srcElem[propName])
  3563.                 }
  3564.             var subPrototype = Object.getPrototypeOf(prototype);
  3565.             subPrototype && AdapterJS.forwardEventHandlers(destElem, srcElem, subPrototype)
  3566.         }
  3567.         ,
  3568.         RTCIceCandidate = function(candidate) {
  3569.             return candidate.sdpMid || (candidate.sdpMid = ""),
  3570.             AdapterJS.WebRTCPlugin.WaitForPluginReady(),
  3571.             AdapterJS.WebRTCPlugin.plugin.ConstructIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.candidate)
  3572.         }
  3573.         ,
  3574.         AdapterJS.addEvent(document, "readystatechange", AdapterJS.WebRTCPlugin.injectPlugin),
  3575.         AdapterJS.WebRTCPlugin.injectPlugin()
  3576.     }
  3577. }
  3578. ,
  3579. AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCb = AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCb || function() {
  3580.     AdapterJS.addEvent(document, "readystatechange", AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCbPriv),
  3581.     AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCbPriv()
  3582. }
  3583. ,
  3584. AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCbPriv = function() {
  3585.     if (!AdapterJS.options.hidePluginInstallPrompt) {
  3586.         var downloadLink = AdapterJS.WebRTCPlugin.pluginInfo.downloadLink;
  3587.         if (downloadLink) {
  3588.             var popupString;
  3589.             popupString = AdapterJS.WebRTCPlugin.pluginInfo.portalLink ? 'This website requires you to install the  <a href="' + AdapterJS.WebRTCPlugin.pluginInfo.portalLink + '" target="_blank">' + AdapterJS.WebRTCPlugin.pluginInfo.companyName + " WebRTC Plugin</a> to work on this browser." : AdapterJS.TEXT.PLUGIN.REQUIRE_INSTALLATION,
  3590.             AdapterJS.renderNotificationBar(popupString, AdapterJS.TEXT.PLUGIN.BUTTON, function() {
  3591.                 window.open(downloadLink, "_top");
  3592.                 var pluginInstallInterval = setInterval(function() {
  3593.                     "IE" !== AdapterJS.webrtcDetectedBrowser && navigator.plugins.refresh(!1),
  3594.                     AdapterJS.WebRTCPlugin.isPluginInstalled(AdapterJS.WebRTCPlugin.pluginInfo.prefix, AdapterJS.WebRTCPlugin.pluginInfo.plugName, AdapterJS.WebRTCPlugin.pluginInfo.type, function() {
  3595.                         clearInterval(pluginInstallInterval),
  3596.                         AdapterJS.WebRTCPlugin.defineWebRTCInterface()
  3597.                     }, function() {})
  3598.                 }, 500)
  3599.             })
  3600.         } else
  3601.             AdapterJS.renderNotificationBar(AdapterJS.TEXT.PLUGIN.NOT_SUPPORTED)
  3602.     }
  3603. }
  3604. ,
  3605. AdapterJS.WebRTCPlugin.isPluginInstalled(AdapterJS.WebRTCPlugin.pluginInfo.prefix, AdapterJS.WebRTCPlugin.pluginInfo.plugName, AdapterJS.WebRTCPlugin.pluginInfo.type, AdapterJS.WebRTCPlugin.defineWebRTCInterface, AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCb)),
  3606. "undefined" != typeof exports && (module.exports = AdapterJS);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement