UNPKG

trtc-sdk

Version:
1 lines 225 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=10)}([function(e,t,n){"use strict";var r={HOST_NAME:"qcloud.rtc.qq.com",WS_URL:"wss://qcloud.rtc.qq.com:8687",WEBRTC_CGI_URL:"https://qcloud.rtc.qq.com:8687/api/uploadlog",BK_HOST_NAME:"bk.rtc.qq.com",BK_WS_URL:"wss://bk.rtc.qq.com:8687",BK_WEBRTC_CGI_URL:"https://bk.rtc.qq.com:8687/api/uploadlog",BACKUP_WEBRTC_CGI_URL:"https://ilivelog.qcloud.com/",WEBRTC_STUN_SERVER:"",ConstraintsMode:0,ICE_BUILD_STATE:{SUC:0,SDP_FAILED:1,CANDIDATE_FAILED:2,H264_NOT_SUPPORT:3,GET_STUN_IP_FAILED:4},Version:"3.4.2",RTC_EVENT:{ON_PEER_SDP:"on_peer_sdp",ON_UPDATE_PEER_SDP:"on_update_peer_sdp",ON_PEER_CANDIDATE:"on_peer_candidate",ON_BIND_SESSION:"on_bind_session",ON_MEDIA_CHANGE:"on_media_change",ON_START_CHAT:"on_start_chat",ON_QUIT_CHAT:"on_quit_chat",ON_CREATE_ROOM:"on_create_room",ON_CREATE_PEER:"on_create_peer",ON_CLOSE_PEER:"on_close_peer",ON_QUALITY_REPORT:"on_quality_report",ON_GET_USER_MEDIA:"on_get_user_media",ON_GET_USER_MEDIA_OK:"on_get_user_media_ok",ON_GET_USER_MEDIA_FAILED:"on_get_user_media_failed",ON_GET_LOACL_SDP_FAILED:"on_get_local_sdp_failed",ON_SET_REMOTE_SDP_FAILED:"on_set_remote_sdp_failed",ON_GET_LOCAL_CANDIDATE_FAILED:"on_get_local_candidate_failed",ON_SET_REMOTE_CANDIDATE_FAILED:"on_set_remote_candidate_failed",ON_GET_SRC_PEER_CONNECTION_FAILED:"on_get_srctinyid_peerconnection_failed",ON_SET_REMOTE_CANDIDATE_SUC:"on_set_remote_candidate_suc",ON_SET_REMOTE_SDP_SUC:"on_set_remote_sdp_suc",ON_ICE_COMPLETE:"on_ice_complete",ON_ICE_BROKEN:"on_ice_broken",ON_START_WEBRTC_FAILED_WITHOUT_CALLBACK:"on_start_webrtc_failed_without_callback",ON_CREATE_PEERCONNECTION_FAILED:"on_create_peerconnection_failed",ON_END_REPORT:"on_end_report",ON_SPEAR_ROLE_CHANGE:"on_spear_role_change",ON_REBUILD_SESSION:"on_rebuild_session",ON_START_WEBRTC:"on_start_webrtc",ON_UPLOAD_WEB_LOG:"on_upload_web_log",INIT_END_REPORT:"init_end_report",ON_GET_MAX_TIMEMS:"on_get_max_timems",ON_NOT_SUPPORT_H264:"on_not_support_h264",ON_STUN_FAILED:"on_stun_failed",ON_STREAM_NOTIFY:"on_stream_notify",UPDATE_MUTE_STAT:"on_change_av_state"},KEY_TAG:{WEBSOCKET_TAG:"websocket_tag",SDP_TAG:"sdp_tag",CANDIDATE_TAG:"candidate_tag",USER_MEDIA_TAG:"user_media_tag",UPDATE_VIDEO_SSRC_TAG:"update_video_ssrc_tag",UPDATE_AUDIO_SSRC_TAG:"update_audio_ssrc_tag",UPDATE_LOCAL_MEDIA_STREAM_TAG:"update_local_media_stream_tag",UPDATE_SUB_VIDEO_TAG:"update_sub_video_tag",RTC_LOG_TAG:"rtc_log_tag",WEBSOCKET_BUILD_FAILED_TAG:"websocket_build_failed_tag",WEBSOCKET_REBUILD_TAG:"websocket_rebuild_tag",REPORT_TIME_OUT_TAG:"report_timeout"},MEDIA_CHANGE:{OPEN_VIDEO:1,CLOSE_VIDEO:2,OPEN_AUDIO:3,CLOSE_AUDIO:4},WS_MAX_RETRY_COUNT:3,WS_RETRY_DIST:3e3,WS_CMD:{SDP:2,CANDIDATE:4,MEDIA_CHANGE:13,START_CHAT:6,QUIT_CHAT:8,CLOSE_PEER:9,CLOSE_PEER_RES:10,ON_STAGE:12,WS_INIT_OK:19,WS_INIT_FAILED:80,CREATE_ROOM_RESULT:20,NOTIFY_CREATE_PEER_CONNECTION:16,NOTIFY_CREATE_PEER_CONNECTION_RES:17,NOTIFY_CLOSE_PEER_CONNECTION:18,NOTIFY_CHANGE_CONSTRAINTS:32,NOTIFY_SUB_VIDEO_STATE:48,NOTIFY_UPDATE_AUDIO_SSRC:50,NOTIFY_UPDATE_VIDEO_SSRC:52,NOTIFY_MAX_TIMEMS:770,NOTIFY_RECONNECT_DC:529,ACTIVE_USER_STAT_UPDATED:23,NOTIFY_RECONNECT_WS_RES:514},STREAM_TYPE:{NONE:0,AUDIO:1,MAIN:2,AID:7},STREAM_MISD:{MAIN:"5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",AID:"224d130c-7b5c-415b-aaa2-79c2eb5a6df2"},USER_DEFINED_EVENT:{WEBSOCKET_INIT:"websocket_init",WEBSOCKET_INIT_OK:"websocket_init_ok",RECEIVE_CREATE_PEER:"receive_create_pc",BEGIN_CREATE_PEER:"begin_create_pc",CREATE_PC_SUC:"create_pc_suc",CREATE_PC_FAILED:"create_pc_failed",BEGIN_START_WEBRTC:"begin_start_webrtc",GET_LOCAL_SDP_SUC:"get_local_sdp_suc",GET_LOCAL_SDP_FAILED:"get_local_sdp_failed",RECEIVE_REMOTE_SDP:"receive_remote_sdp",SET_REMOTE_SDP_SUC:"set_remote_sdp_suc",SET_REMOTE_SDP_FAILED:"set_remote_sdp_failed",GET_LOCAL_CANDIDATE_SUC:"get_local_candidate_suc",GET_LOCAL_STUN_IP_FAILED:"get_local_stun_ip_failed",RECEIVE_REMOTE_CANDIDATE:"receive_remote_candidate",SET_REMOTE_CANDIDATE_SUC:"set_remote_candidate_suc",SET_REMOTE_CANDIDATE_FAILED:"set_remote_candidate_failed",ON_ICE_STATE_CHANGE:"on_ice_state_change",ON_ICE_GATHERING_STATE_CHANGE:"on_ice_gathering_state_change",ON_WEBSOCKET_CLOSE_BY_NETWORK_BROKEN:"on_websocket_close_by_network_broken",NOTICE_PEERCONNECTION:"notice_pc",NOTIFY_NO_SIG_AFTER_PRECONNECTION:"notice_no_sig_after_preconnection"},OPTIONAL:{optional:[{DtlsSrtpKeyAgreement:!0}]},ERROR_CODE:{SUCC:0,PARAM_MISSING:10001,PARAM_INVALID:10016,NOT_SUPPORT:10002,INIT_WS_FAILED:10005,ENTER_ROOM_ERROR:10006,CREATE_PEERCONNECTION_FAILED:10007,GET_USERMEDIA_FAILED:10008,GET_LOCALSDP_FAILED:10009,GET_LOCAL_CANDIDATE_FAILED:10011,GET_ANSWER_SDP_FAILED:10013,ON_ICE_BROKEN:10014,ON_ICE_CLOSE:10015,INIT_SDK_FAILED:11e3,SET_REMOTE_SDP_FAILED:10012,NOT_FOUND:10031,NOT_INITED:10032,START_RTC_FAILED:10033,STOP_RTC_FAILED:10034,WS_CLOSE:10035,WS_ERROR:10036,UPDATE_VIDEO_SSRC_FAILED:10037,UPDATE_AUDIO_SSRC_FAILED:10038,NOT_FOUND_PEER:10039,CHOOSE_SPEARK_FAILED:10040,DTLS_CONNECTION_TIMEOUT:10041,WS_RECONNECT_FAILED:10042,TLS_VERIFY_ERROR:70236},ERROR_MSG:{SECURITY_ERROR:"由于浏览器安全限制,获取/枚举音视频设备接口必须在https域名或localhost下访问"},getConfiguration:function(){var e={iceServers:[],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};return r.WEBRTC_STUN_SERVER&&(e.iceServers=[{urls:r.WEBRTC_STUN_SERVER}]),e},setHostname:function(e){this.HOST_NAME=e,this.WS_URL="wss://"+e+":8687",this.WEBRTC_CGI_URL="https://"+e+":8687/api/uploadlog"},setBkHostname:function(e){this.BK_HOST_NAME=e,this.BK_WS_URL="wss://"+e+":8687",this.BK_WEBRTC_CGI_URL="https://"+e+":8687/api/uploadlog"}};e.exports=r},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t,n,r){return}function i(e){C=e}function o(e,t,n,r){try{if(!p.WEBRTC_CGI_URL)return void console.warn("CGI URL not ready!");var i=JSON.stringify({index:"webrtc",type:"websdk",localip:e.localip,relayip:e.relayip,signalip:e.signalip,tinyid:e.config&&e.config.tinyid,userId:e.config&&e.config.userId,appid:e.config&&e.config.sdkAppId,roomId:e.roomid||0,sdkappid:String(e.config&&e.config.sdkAppId),tag:r,version:p.Version,log:t});if(!m)return;l.post(h,i,{parseJson:!1}).catch(function(e){_<R?_++:(h=h===p.WEBRTC_CGI_URL?p.BACKUP_WEBRTC_CGI_URL:p.WEBRTC_CGI_URL,_=0)})}catch(e){_<R?(_++,console.error("upload log error : ",e)):(h=h===p.WEBRTC_CGI_URL?p.BACKUP_WEBRTC_CGI_URL:p.WEBRTC_CGI_URL,_=0)}}function a(e){v=e.log||!1,m=void 0===e.uploadLog||e.uploadLog,v?(console.log("-------------调试模式----------------"),f.recordLogs=!0):f.recordLogs=!1,m||console.log("-------------不上报----------------"),e.vconsole?s():!e.vconsole&&g&&(g.destroy(),g=null)}function s(){var e=document.createElement("script");e.src="//sqimg.qq.com/expert_qq/vConsole/vconsole.min.js",document.body.appendChild(e),e.onload=function(){window.vConsole=new VConsole}}function c(e){var t=[" domain:",p.HOST_NAME," sdkappid:",e.config.sdkAppId];console.log("%c %s","color:#00a4ff;font-family:Microsoft Yahei",t.join(" "))}function d(){console.log("%c %s","color:#00a4ff;font-family:Microsoft Yahei",p.WEBRTC_STUN_SERVER)}var u=n(4),p=n(0),l=n(5),f=n(18),f=new f;f.realTimeLoggingOn=!1;var v=!1,m=!0,g=null,_=0,R=5,h=p.BACKUP_WEBRTC_CGI_URL,C=null,S=new function(){var e="WEBRTC_API : ";this._uploadLogOpen=u.query("uploadlog")||!1,u.query("debug")&&s(),this.LOG_LEVEL={RTC_LOG_DEBUG:"RTC_LOG_DEBUG",RTC_LOG_INFO:"RTC_LOG_INFO",RTC_LOG_WARN:"RTC_LOG_WARN",RTC_LOG_ERROR:"RTC_LOG_ERROR"},this.error=function(t,n){f.log("[ERROR]"+t+(n?JSON.stringify(n):"")),v&&(n?console.error(e+t,n):console.error(e+t))},this.debug=function(t,n){v&&(f.log("[DEBUG]"+t+(n?JSON.stringify(n):"")),n?console.log(e+t,n):console.log(e+t))},this.info=function(t,n){f.log("[INFO]"+t+(n?JSON.stringify(n):"")),v&&(n?console.info(e+t,n):console.info(e+t))},this.warn=function(t,n){f.log("[WARN]"+t+(n?JSON.stringify(n):"")),v&&(n?console.warn(e+t,n):console.warn(e+t))}};!function(){try{var e=["Version:"+p.Version," ","感谢您选择腾讯视频云","我们为您准备了辅助开发的快捷访问地址,访问你在开发中定位问题:"," ","错误码:https://cloud.tencent.com/document/product/647/17016"," ","常见问题:https://cloud.tencent.com/document/product/647/17017"];console.log("%c %s","color:#00a4ff;font-family:Microsoft Yahei",e.join("\n"))}catch(e){}}(),e.exports={printEnvironmentInfo:c,printRelayInfo:d,uploadWebLog:o,debug:a,RTCLog:S,badjsReport:r,badjsInit:i,debugout:f}},function(e,t,n){"use strict";var r=n(6),i={TBS_MIN_VERSION:43600,h264Support:!1,checkTBSVersion:function(){for(var e=navigator.userAgent.split(" "),t=!1,n=0,r=0;r<e.length;r++){var i=e[r];if(-1!==i.indexOf("TBS")||-1!==i.indexOf("tbs")){t=!0;var o=i.split("/")[1];n=parseInt(o)||0}}return{isTBS:t,TBSversion:n,isTBSValid:n>=this.TBS_MIN_VERSION}},checkH264Support:function(e){var t=new RTCPeerConnection(null);t.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1}).then(function(n){e(-1===n.sdp.toLowerCase().indexOf("h264")?!1:!0),t.close()},function(t){e(!1)})},support:function(e,t){"function"==typeof e?this.doCheck({screenshare:!0},e):this.doCheck(e,t)},doCheck:function(e,t){var n=!1;["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].forEach(function(e){n||e in window&&(n=!0)});var i=this.checkTBSVersion();i.isTBS||(this.isFF()?n=!1:this.isSafari()&&-1===navigator.platform.indexOf("Mac")&&(n=!0));var o={support:n,isTBS:i.isTBS,isTBSValid:i.isTBSValid,TBSversion:i.TBSversion,isSafari:this.isSafari(),iOSVersion:this.iOSVersion(),screenshare:!1,isFF:this.isFF()};return this.checkH264Support(function(n){if(o.h264Support=n,n||(o.support=!1),!e.screenshare&&t)return delete o.screenshare,void t(o);if(e.screenshareApi||(e.screenshareApi="native"),e.screenshareApi&&"extension"!==e.screenshareApi&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia&&parseFloat(r.client.version)>=72&&"chrome"===r.client.type)return console.debug("[DetectRTC]: chrome 72 版本以后无需安装插件"),o.screenshare=!0,void t(o);var i=e.extensionId||null;ScreenChromeExtensionUtil.getChromeExtensionStatus(i,function(e){"installed-enabled"===e?ScreenChromeExtensionUtil.isChromeExtensionAvailable(function(e){e&&(o.screenshare=!0),t&&t(o)}):t&&t(o)})}),o},isTBS:function(){return this.checkTBSVersion().isTBS},isSafari:function(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("chrome/")},iOSVersion:function(){var e=navigator.userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/);return e&&[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]||0)]||!1},isFF:function(){return-1!==navigator.userAgent.toLowerCase().indexOf("firefox")},isChrome:function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},isUnifiedPlanDefault:function(){if("undefined"==typeof RTCRtpTransceiver)return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=new RTCPeerConnection,t=!1;try{e.addTransceiver("audio"),t=!0}catch(e){}return e.close(),t},detectMediaDevice:function(e){var t=!1,n=!1;try{navigator.mediaDevices.enumerateDevices().then(function(r){r.forEach(function(e){e&&"videoinput"===e.kind?n=!0:e&&"audioinput"===e.kind&&(t=!0)}),e&&e({hasAudio:t,hasVideo:n})}).catch(function(r){e&&e({hasAudio:t,hasVideo:n})})}catch(r){e&&e({hasAudio:t,hasVideo:n})}}};e.exports=i},function(e,t,n){"use strict";function r(e){var t=i(e),n=i("10.0.0.0"),r=i("10.255.255.255"),a=i("172.16.0.0"),s=i("172.31.255.255"),c=i("192.168.0.0"),d=i("192.168.255.255"),u=i("127.0.0.0"),p=i("127.255.255.255");return o(t,n,r)||o(t,a,s)||o(t,c,d)||o(t,u,p)}function i(e){var t=e.split(".");return 256*parseInt(t[0])*256*256+256*parseInt(t[1])*256+256*parseInt(t[2])+parseInt(t[3])}function o(e,t,n){return e>=t&&e<=n}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s={query:function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""},getHash:function(e){var t=window.location.hash.match(new RegExp("(#|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""},cloneObj:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){var t,n=e.constructor===Array?[]:{};if("object"===(void 0===e?"undefined":a(e))){if(window.JSON)t=JSON.stringify(e),n=JSON.parse(t);else for(var r in e)n[r]="object"===a(e[r])?cloneObj(e[r]):e[r];return n}}),takeSnapshot:function(e,t){var n=this;return function(t){var n=document.createElement("canvas");n.width=t.videoWidth||t.clientWidth,n.height=t.videoHeight||t.clientHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),e&&e(n.toDataURL("image/png"))}(n)},isInnerIPFn:r};HTMLVideoElement.prototype.takeSnapshot=s.takeSnapshot,e.exports=s},function(e,t,n){var r=n(17),i=new r;e.exports=i},function(e,t,n){"use strict";var r=window.document,i=window.navigator,o=i.userAgent.toLowerCase(),a=r.documentMode,s=window.chrome||!1,c={agent:o,isIE:/msie/.test(o),isIPhone:/iphone/.test(o),isElectron:/electron/.test(o),isGecko:o.indexOf("gecko")>0&&o.indexOf("like gecko")<0,isWebkit:o.indexOf("webkit")>0,isStrict:"CSS1Compat"===r.compatMode,supportSubTitle:function(){return"track"in r.createElement("track")},supportScope:function(){return"scoped"in r.createElement("style")},ieVersion:function(){try{return o.match(/msie ([\d.]+)/)[1]||0}catch(e){return a}},operaVersion:function(){try{if(window.opera)return o.match(/opera.([\d.]+)/)[1];if(o.indexOf("opr")>0)return o.match(/opr\/([\d.]+)/)[1]}catch(e){return 0}},versionFilter:function(){if(1===arguments.length&&"string"==typeof arguments[0]){var e=arguments[0];return start=e.indexOf("."),start>0&&(end=e.indexOf(".",start+1),-1!==end)?e.substr(0,end):e}return 1===arguments.length?arguments[0]:0}};try{c.type=c.isIE?"ie":window.opera||o.indexOf("opr")>0?"opera":o.indexOf("chrome")>0?"chrome":window.openDatabase?"safari":o.indexOf("firefox")>0?"firefox":"unknow",c.version="ie"===c.type?c.ieVersion():"firefox"===c.type?o.match(/firefox\/([\d.]+)/)[1]:"chrome"===c.type?o.match(/chrome\/([\d.]+)/)[1]:"opera"===c.type?c.operaVersion():"safari"===c.type?o.match(/version\/([\d.]+)/)[1]:"0",c.shell=function(){if(o.indexOf("maxthon")>0)return c.version=o.match(/maxthon\/([\d.]+)/)[1]||c.version,"maxthon";if(o.indexOf("qqbrowser")>0)return c.version=o.match(/qqbrowser\/([\d.]+)/)[1]||c.version,"qqbrowser";if(o.indexOf("se 2.x")>0)return"sougou";if(s&&"opera"!==c.type){var e=window.external,t=window.clientInformation,n=t.languages;if(e&&"LiebaoGetVersion"in e)return"liebao";if(o.indexOf("bidubrowser")>0)return c.version=o.match(/bidubrowser\/([\d.]+)/)[1]||o.match(/chrome\/([\d.]+)/)[1],"baidu";if(c.supportSubTitle()&&void 0===n){var r=Object.keys(s.webstore).length;window;return r>1?"360qucik":"360secure"}return"chrome"}return c.type},c.name=c.shell(),c.version=c.versionFilter(c.version)}catch(e){}e.exports={client:c}},function(e,t){var n=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,names:["value","direction","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+" %s"+(e.config?" %s":"")}},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach(function(e){n[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},function(e,t,n){var r=function(){},i=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],o=function(e){var t={};t.obj=e;var n,o;"undefined"!=typeof window?(window.console=window.console||{},o=window.console):o=console||{},o.debug||(o.debug=o.log);for(var a=i.length;a--;)n=i[a],o[n]?Function.prototype.bind?t[n]=Function.prototype.bind.call(o[n],o,"%s"):t[n]=Function.prototype.apply.call(o[n],o,"xyz",arguments):(o[n]=r,t[n]=r);if(Function.prototype.bind){var s="["+(t.obj&&t.obj.debugId?t.obj.debugId:"null")+"]";t.error=Function.prototype.bind.call(o.error,o,s+" * error: %s"),t.warn=Function.prototype.bind.call(o.warn,o,s+" ** warn: %s"),t.info=Function.prototype.bind.call(o.info,o,s+" *** info: %s"),o.debug?t.debug=Function.prototype.bind.call(o.debug,o):t.debug=Function.prototype.bind.call(o.log,o),t.log=Function.prototype.bind.call(o.log,o,s+" ***** log: %s"),t.group=Function.prototype.bind.call(o.log,o,s+" GROUP: %s"),t.groupCollapsed=Function.prototype.bind.call(o.log,o,s+" GROUP: %s")}return t}(),a=function(e,t){if(!e)throw t?"Assertion failed: '"+t+"'":"Assertion failed."},t=o;t.assert=a,e.exports=t,"undefined"!=typeof window&&(window.debug=o,window.assert=a)},function(e,t,n){"use strict";function r(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,c=r(e),d=1;d<arguments.length;d++){n=Object(arguments[d]);for(var u in n)o.call(n,u)&&(c[u]=n[u]);if(i){s=i(n);for(var p=0;p<s.length;p++)a.call(n,s[p])&&(c[s[p]]=n[s[p]])}}return c}},function(e,t,n){n(11),n(12),e.exports=n(13)},function(e,t,n){"use strict";(function(n){var r,i,o,a,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(n){if("object"===s(t)&&void 0!==e)e.exports=n();else{i=[],r=n,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}}(function(){return function(){function e(t,n,r){function i(s,c){if(!n[s]){if(!t[s]){var d="function"==typeof a&&a;if(!c&&d)return a(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){return i(t[s][1][e]||e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof a&&a,s=0;s<r.length;s++)i(r[s]);return i}return e}()({1:[function(e,t,n){},{}],2:[function(e,t,n){var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){var t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");for(var n={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},r.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)t=r[i].trim().split("="),n[t[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return n=n.concat(r.splitLines(t)),{usernameFragment:n.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e),i=n[0].split(" "),o=3;o<i.length;o++){var a=i[o],s=r.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(s){var c=r.parseRtpMap(s),d=r.matchPrefix(e,"a=fmtp:"+a+" ");switch(c.parameters=d.length?r.parseFmtp(d[0]):{},c.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(r.parseRtcpFb),t.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(r.rtx={ssrc:t}),n.push(r),o&&(r=JSON.parse(JSON.stringify(r)),r.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var u=r.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=u})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=r.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return t=n[0].substr(7).split(" "),{stream:t[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t,n){var i,o=void 0!==t?t:2;return i=e||r.generateSessionId(),"v=0\r\no="+(n||"thisisadapterortc")+" "+i+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var o=r.writeRtpDescription(e.kind,t);if(o+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),o},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e),n=t[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0],n=t.substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},r.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=r.splitLines(e),n=0;n<t.length;n++)if(t[n].length<2||"="!==t[n].charAt(1))return!1;return!0},"object"===(void 0===t?"undefined":s(t))&&(t.exports=r)},{}],3:[function(e,t,r){(function(n){var r=e("./adapter_factory.js");t.exports=r({window:n.window})}).call(this,void 0!==n?n:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./adapter_factory.js":4}],4:[function(e,t,n){var r=e("./utils");t.exports=function(t,n){var i=t&&t.window,o={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var a in n)hasOwnProperty.call(n,a)&&(o[a]=n[a]);var s=r.log,c=r.detectBrowser(i),d=e("./chrome/chrome_shim")||null,u=e("./edge/edge_shim")||null,p=e("./firefox/firefox_shim")||null,l=e("./safari/safari_shim")||null,f=e("./common_shim")||null,v={browserDetails:c,commonShim:f,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(c.browser){case"chrome":if(!d||!d.shimPeerConnection||!o.shimChrome)return s("Chrome shim is not included in this adapter release."),v;s("adapter.js shimming chrome."),v.browserShim=d,f.shimCreateObjectURL(i),d.shimGetUserMedia(i),d.shimMediaStream(i),d.shimSourceObject(i),d.shimPeerConnection(i),d.shimOnTrack(i),d.shimAddTrackRemoveTrack(i),d.shimGetSendersWithDtmf(i),d.shimSenderReceiverGetStats(i),d.fixNegotiationNeeded(i),f.shimRTCIceCandidate(i),f.shimMaxMessageSize(i),f.shimSendThrowTypeError(i);break;case"firefox":if(!p||!p.shimPeerConnection||!o.shimFirefox)return s("Firefox shim is not included in this adapter release."),v;s("adapter.js shimming firefox."),v.browserShim=p,f.shimCreateObjectURL(i),p.shimGetUserMedia(i),p.shimSourceObject(i),p.shimPeerConnection(i),p.shimOnTrack(i),p.shimRemoveStream(i),p.shimSenderGetStats(i),p.shimReceiverGetStats(i),p.shimRTCDataChannel(i),f.shimRTCIceCandidate(i),f.shimMaxMessageSize(i),f.shimSendThrowTypeError(i);break;case"edge":if(!u||!u.shimPeerConnection||!o.shimEdge)return s("MS edge shim is not included in this adapter release."),v;s("adapter.js shimming edge."),v.browserShim=u,f.shimCreateObjectURL(i),u.shimGetUserMedia(i),u.shimPeerConnection(i),u.shimReplaceTrack(i),u.shimGetDisplayMedia(i),f.shimMaxMessageSize(i),f.shimSendThrowTypeError(i);break;case"safari":if(!l||!o.shimSafari)return s("Safari shim is not included in this adapter release."),v;s("adapter.js shimming safari."),v.browserShim=l,f.shimCreateObjectURL(i),l.shimRTCIceServerUrls(i),l.shimCreateOfferLegacy(i),l.shimCallbacksAPI(i),l.shimLocalStreamsAPI(i),l.shimRemoteStreamsAPI(i),l.shimTrackEventTransceiver(i),l.shimGetUserMedia(i),f.shimRTCIceCandidate(i),f.shimMaxMessageSize(i),f.shimSendThrowTypeError(i);break;default:s("Unsupported browser!")}return v}},{"./chrome/chrome_shim":5,"./common_shim":7,"./edge/edge_shim":1,"./firefox/firefox_shim":8,"./safari/safari_shim":10,"./utils":11}],5:[function(e,t,n){function r(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(function(i){i.endsWith("Id")?r(e,e.get(t[i]),n):i.endsWith("Ids")&&t[i].forEach(function(t){r(e,e.get(t),n)})}))}function i(e,t,n){var i=n?"outbound-rtp":"inbound-rtp",o=new Map;if(null===t)return o;var a=[];return e.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)}),a.forEach(function(t){e.forEach(function(n){n.type===i&&n.trackId===t.id&&r(e,n,o)})}),o}var o=e("../utils.js"),a=o.log;t.exports={shimGetUserMedia:e("./getusermedia"),shimMediaStream:function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function(e){if("object"!==(void 0===e?"undefined":s(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)o.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return n._ontrackpoly||(n._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)}),t.stream.getTracks().forEach(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)})},n.addEventListener("addstream",n._ontrackpoly)),t.apply(n,arguments)}}},shimGetSendersWithDtmf:function(e){if("object"===(void 0===e?"undefined":s(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=this,o=n.apply(i,arguments);return o||(o=t(i,e),i._senders.push(o)),o};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;r.apply(t,arguments);var n=t._senders.indexOf(e);-1!==n&&t._senders.splice(n,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;n._senders=n._senders||[],i.apply(n,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._senders=t._senders||[],o.apply(t,[e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"===(void 0===e?"undefined":s(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(e,[]);return t.forEach(function(t){t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSenderReceiverGetStats:function(e){if("object"===(void 0===e?"undefined":s(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return i(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=r.apply(e,[]);return t.forEach(function(t){t._pc=e}),t}),o.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return i(t,e.track,!1)})}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var t=this;if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var n,r,i,o=arguments[0];return t.getSenders().forEach(function(e){e.track===o&&(n?i=!0:n=e)}),t.getReceivers().forEach(function(e){return e.track===o&&(r?i=!0:r=e),e.track===o}),i||n&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(t,arguments)}}}},shimSourceObject:function(e){var t=e&&e.URL;"object"===(void 0===e?"undefined":s(e))&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var n=this;if(this._srcObject=e,this.src&&t.revokeObjectURL(this.src),!e)return void(this.src="");this.src=t.createObjectURL(e),e.addEventListener("addtrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)}),e.addEventListener("removetrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)})}}))},shimAddTrackRemoveTrackWithNative:function(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var r=t.getSenders();n.apply(this,arguments);var i=t.getSenders().filter(function(e){return-1===r.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]}),i.apply(this,arguments)}},shimAddTrackRemoveTrack:function(e){function t(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}function n(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}if(e.RTCPeerConnection){var r=o.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return this.shimAddTrackRemoveTrackWithNative(e);var i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=i.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}a.apply(n,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},s.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var o=r._streams[n.id];if(o)o.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(n){var r=e.RTCPeerConnection.prototype[n];e.RTCPeerConnection.prototype[n]=function(){var e=this,n=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(e,[function(r){var i=t(e,r);n[0].apply(null,[i])},function(e){n[1]&&n[1].apply(null,e)},arguments[2]]):r.apply(e,arguments).then(function(n){return t(e,n)})}});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this;return arguments.length&&arguments[0].type?(arguments[0]=n(e,arguments[0]),c.apply(e,arguments)):c.apply(e,arguments)};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=this,n=d.get.apply(this);return""===n.type?n:t(e,n)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==t)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}}},shimPeerConnection:function(e){var t=o.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=function(t,n){return a("PeerConnection"),t&&t.iceTransportPolicy&&(t.iceTransports=t.iceTransportPolicy),new e.webkitRTCPeerConnection(t,n)},e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype,e.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.webkitRTCPeerConnection.generateCertificate}})),e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,t,r){var i=this,o=arguments;if(