File: source/template/header.js

  1. (function(globals) {
  2.  
  3. 'use strict';
  4.  
  5. /* jshint ignore:start */
  6. // Object.keys() polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
  7. !function(){Object.keys||(Object.keys=function(){var t=Object.prototype.hasOwnProperty,r=!{toString:null}.propertyIsEnumerable("toString"),e=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=e.length;return function(n){if("object"!=typeof n&&"function"!=typeof n||null===n)throw new TypeError("Object.keys called on non-object");var c=[];for(var l in n)t.call(n,l)&&c.push(l);if(r)for(var p=0;o>p;p++)t.call(n,e[p])&&c.push(e[p]);return c}}())}();
  8. // Date.getISOString() polyfill - https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
  9. !function(){function t(t){return 10>t?"0"+t:t}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+t(this.getUTCMonth()+1)+"-"+t(this.getUTCDate())+"T"+t(this.getUTCHours())+":"+t(this.getUTCMinutes())+":"+t(this.getUTCSeconds())+"."+(this.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}}();
  10. // Date.now() polyfill
  11. !function(){"function"!=typeof Date.now&&(Date.now=function(){return(new Date).getTime()})}();
  12. // addEventListener() polyfill - https://gist.github.com/eirikbacker/2864711
  13. !function(e,t){function n(e){var n=t[e];t[e]=function(e){return o(n(e))}}function a(t,n,a){return(a=this).attachEvent("on"+t,function(t){var t=t||e.event;t.preventDefault=t.preventDefault||function(){t.returnValue=!1},t.stopPropagation=t.stopPropagation||function(){t.cancelBubble=!0},n.call(a,t)})}function o(e,t){if(t=e.length)for(;t--;)e[t].addEventListener=a;else e.addEventListener=a;return e}e.addEventListener||(o([t,e]),"Element"in e?e.Element.prototype.addEventListener=a:(t.attachEvent("onreadystatechange",function(){o(t.all)}),n("getElementsByTagName"),n("getElementById"),n("createElement"),o(t.all)))}(window,document);
  14. // performance.now() polyfill - https://gist.github.com/paulirish/5438650
  15. !function(){if("performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var a=Date.now();performance.timing&&performance.timing.navigationStart&&(a=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-a}}}();
  16. // BlobBuilder polyfill
  17. window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
  18. // Array.prototype.forEach polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
  19. if(!Array.prototype.forEach){Array.prototype.forEach=function(callback){var T,k;if(this==null){throw new TypeError('this is null or not defined');} var O=Object(this);var len=O.length>>>0;if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');} if(arguments.length>1){T=arguments[1];} k=0;while(k<len){var kValue;if(k in O){kValue=O[k];callback.call(T,kValue,k,O);} k++;}};}
  20. /* jshint ignore:end */
  21.  
  22. /**
  23. * Global function that clones an object.
  24. */
  25. var clone = function (obj) {
  26. if (obj === null || typeof obj !== 'object') {
  27. return obj;
  28. }
  29.  
  30. var copy = function (data) {
  31. var copy = data.constructor();
  32. for (var attr in data) {
  33. if (data.hasOwnProperty(attr)) {
  34. copy[attr] = data[attr];
  35. }
  36. }
  37. return copy;
  38. };
  39.  
  40. if (typeof obj === 'object' && !Array.isArray(obj)) {
  41. try {
  42. return JSON.parse( JSON.stringify(obj) );
  43. } catch (err) {
  44. return copy(obj);
  45. }
  46. }
  47.  
  48. return copy(obj);
  49. };
  50.  
  51. /**
  52. * <h2>Prerequisites on using Skylink</h2>
  53. * Before using any Skylink functionalities, you will need to authenticate your App Key using
  54. * the <a href="#method_init">`init()` method</a>.
  55. *
  56. * To manage or create App Keys, you may access the [Temasys Console here](https://console.temasys.io).
  57. *
  58. * To view the list of supported browsers, visit [the list here](
  59. * https://github.com/Temasys/SkylinkJS#supported-browsers).
  60. *
  61. * Here are some articles to help you get started:
  62. * - [How to setup a simple video call](https://temasys.io/temasys-rtc-getting-started-web-sdk/)
  63. * - [How to setup screensharing](https://temasys.io/webrtc-screensharing-temasys-web-sdk/)
  64. * - [How to create a chatroom like feature](https://temasys.io/building-a-simple-peer-to-peer-webrtc-chat/)
  65. *
  66. * Here are some demos you may use to aid your development:
  67. * - Getaroom.io [[Demo](https://getaroom.io) / [Source code](https://github.com/Temasys/getaroom)]
  68. * - Creating a component [[Link](https://github.com/Temasys/skylink-call-button)]
  69. *
  70. * You may see the example below in the <a href="#">Constructor tab</a> to have a general idea how event subscription
  71. * and the ordering of <a href="#method_init"><code>init()</code></a> and
  72. * <a href="#method_joinRoom"><code>joinRoom()</code></a> methods should be called.
  73. *
  74. * If you have any issues, you may find answers to your questions in the FAQ section on [our support portal](
  75. * http://support.temasys.io), asks questions, request features or raise bug tickets as well.
  76. *
  77. * If you would like to contribute to our Temasys Web SDK codebase, see [the contributing README](
  78. * https://github.com/Temasys/SkylinkJS/blob/master/CONTRIBUTING.md).
  79. *
  80. * [See License (Apache 2.0)](https://github.com/Temasys/SkylinkJS/blob/master/LICENSE)
  81. *
  82. * @class Skylink
  83. * @constructor
  84. * @example
  85. * // Here's a simple example on how you can start using Skylink.
  86. * var skylinkDemo = new Skylink();
  87. *
  88. * // Subscribe all events first as a general guideline
  89. * skylinkDemo.on("incomingStream", function (peerId, stream, peerInfo, isSelf) {
  90. * if (isSelf) {
  91. * attachMediaStream(document.getElementById("selfVideo"), stream);
  92. * } else {
  93. * var peerVideo = document.createElement("video");
  94. * peerVideo.id = peerId;
  95. * peerVideo.autoplay = "autoplay";
  96. * document.getElementById("peersVideo").appendChild(peerVideo);
  97. * attachMediaStream(peerVideo, stream);
  98. * }
  99. * });
  100. *
  101. * skylinkDemo.on("peerLeft", function (peerId, peerInfo, isSelf) {
  102. * if (!isSelf) {
  103. * var peerVideo = document.getElementById(peerId);
  104. * // do a check if peerVideo exists first
  105. * if (peerVideo) {
  106. * document.getElementById("peersVideo").removeChild(peerVideo);
  107. * } else {
  108. * console.error("Peer video for " + peerId + " is not found.");
  109. * }
  110. * }
  111. * });
  112. *
  113. * // init() should always be called first before other methods other than event methods like on() or off().
  114. * skylinkDemo.init("YOUR_APP_KEY_HERE", function (error, success) {
  115. * if (success) {
  116. * skylinkDemo.joinRoom("my_room", {
  117. * userData: "My Username",
  118. * audio: true,
  119. * video: true
  120. * });
  121. * }
  122. * });
  123. * @for Skylink
  124. * @since 0.5.0
  125. */
  126. function Skylink() {
  127. /**
  128. * Stores the list of Peer Datachannel connections.
  129. * @attribute _dataChannels
  130. * @param {JSON} #peerId The list of Datachannels associated with Peer ID.
  131. * @param {RTCDataChannel} #peerId.#channelLabel The Datachannel connection.
  132. * The property name <code>"main"</code> is reserved for messaging Datachannel type.
  133. * @type JSON
  134. * @private
  135. * @for Skylink
  136. * @since 0.2.0
  137. */
  138. this._dataChannels = {};
  139.  
  140. /**
  141. * Stores the list of data transfers from / to Peers.
  142. * @attribute _dataTransfers
  143. * @param {JSON} #transferId The data transfer session.
  144. * @type JSON
  145. * @private
  146. * @for Skylink
  147. * @since 0.6.16
  148. */
  149. this._dataTransfers = {};
  150.  
  151. /**
  152. * Stores the list of sending data streaming sessions to Peers.
  153. * @attribute _dataStreams
  154. * @param {JSON} #streamId The data stream session.
  155. * @type JSON
  156. * @private
  157. * @for Skylink
  158. * @since 0.6.18
  159. */
  160. this._dataStreams = {};
  161.  
  162. /**
  163. * Stores the list of buffered ICE candidates that is received before
  164. * remote session description is received and set.
  165. * @attribute _peerCandidatesQueue
  166. * @param {Array} <#peerId> The list of the Peer connection buffered ICE candidates received.
  167. * @param {RTCIceCandidate} <#peerId>.<#index> The Peer connection buffered ICE candidate received.
  168. * @type JSON
  169. * @private
  170. * @for Skylink
  171. * @since 0.5.1
  172. */
  173. this._peerCandidatesQueue = {};
  174.  
  175. /**
  176. * Stores the list of ICE candidates received before signaling end.
  177. * @attribute _peerEndOfCandidatesCounter
  178. * @type JSON
  179. * @private
  180. * @for Skylink
  181. * @since 0.6.16
  182. */
  183. this._peerEndOfCandidatesCounter = {};
  184.  
  185. /**
  186. * Stores the list of Peer connection ICE candidates.
  187. * @attribute _gatheredCandidates
  188. * @param {JSON} <#peerId> The list of the Peer connection ICE candidates.
  189. * @param {JSON} <#peerId>.sending The list of the Peer connection ICE candidates sent.
  190. * @param {JSON} <#peerId>.receiving The list of the Peer connection ICE candidates received.
  191. * @type JSON
  192. * @private
  193. * @for Skylink
  194. * @since 0.6.14
  195. */
  196. this._gatheredCandidates = {};
  197.  
  198. /**
  199. * Stores the global number of Peer connection retries that would increase the wait-for-response timeout
  200. * for the Peer connection health timer.
  201. * @attribute _retryCounters
  202. * @type JSON
  203. * @private
  204. * @for Skylink
  205. * @since 0.5.10
  206. */
  207. this._retryCounters = {};
  208.  
  209. /**
  210. * Stores the list of the Peer connections.
  211. * @attribute _peerConnections
  212. * @param {RTCPeerConnection} <#peerId> The Peer connection.
  213. * @type JSON
  214. * @private
  215. * @for Skylink
  216. * @since 0.1.0
  217. */
  218. this._peerConnections = {};
  219.  
  220. /**
  221. * Stores the list of the Peer connections stats.
  222. * @attribute _peerStats
  223. * @param {JSON} <#peerId> The Peer connection stats.
  224. * @type JSON
  225. * @private
  226. * @for Skylink
  227. * @since 0.6.16
  228. */
  229. this._peerStats = {};
  230.  
  231. /**
  232. * Stores the list of the Peer connections stats.
  233. * @attribute _peerBandwidth
  234. * @param {JSON} <#peerId> The Peer connection stats.
  235. * @type JSON
  236. * @private
  237. * @for Skylink
  238. * @since 0.6.16
  239. */
  240. this._peerBandwidth = {};
  241.  
  242. /**
  243. * Stores the list of the Peer custom configs.
  244. * @attribute _peerCustomConfigs
  245. * @type JSON
  246. * @private
  247. * @for Skylink
  248. * @since 0.6.18
  249. */
  250. this._peerCustomConfigs = {};
  251.  
  252. /**
  253. * Stores the list of Peers session information.
  254. * @attribute _peerInformations
  255. * @param {JSON} <#peerId> The Peer session information.
  256. * @param {JSON|String} <#peerId>.userData The Peer custom data.
  257. * @param {JSON} <#peerId>.settings The Peer streaming information.
  258. * @param {JSON} <#peerId>.mediaStatus The Peer streaming muted status.
  259. * @param {JSON} <#peerId>.agent The Peer agent information.
  260. * @type JSON
  261. * @private
  262. * @for Skylink
  263. * @since 0.3.0
  264. */
  265. this._peerInformations = {};
  266.  
  267. /**
  268. * Stores the Signaling user credentials from the API response required for connecting to the Signaling server.
  269. * @attribute _user
  270. * @param {String} uid The API result "username".
  271. * @param {String} token The API result "userCred".
  272. * @param {String} timeStamp The API result "timeStamp".
  273. * @param {String} sid The Signaling server receive user Peer ID.
  274. * @type JSON
  275. * @private
  276. * @for Skylink
  277. * @since 0.5.6
  278. */
  279. this._user = null;
  280.  
  281. /**
  282. * Stores the User custom data.
  283. * By default, if no custom user data is set, it is an empty string <code>""</code>.
  284. * @attribute _userData
  285. * @type JSON|String
  286. * @default ""
  287. * @private
  288. * @for Skylink
  289. * @since 0.5.6
  290. */
  291. this._userData = '';
  292.  
  293. /**
  294. * Stores the User connection priority weight.
  295. * If Peer has a higher connection weight, it will do the offer from its Peer connection first.
  296. * @attribute _peerPriorityWeight
  297. * @type Number
  298. * @private
  299. * @for Skylink
  300. * @since 0.5.0
  301. */
  302. this._peerPriorityWeight = 0;
  303.  
  304. /**
  305. * Stores the flag that indicates if "autoIntroduce" is enabled.
  306. * If enabled, the Peers connecting the same Room will receive each others "enter" message ping.
  307. * @attribute _autoIntroduce
  308. * @type Boolean
  309. * @default true
  310. * @private
  311. * @for Skylink
  312. * @since 0.6.1
  313. */
  314. this._autoIntroduce = true;
  315.  
  316. /**
  317. * Stores the flag that indicates if "isPrivileged" is enabled.
  318. * If enabled, the User has Privileged features which has the ability to retrieve the list of
  319. * Peers in the same App space with <code>getPeers()</code> method
  320. * and introduce Peers to each other with <code>introducePeer</code> method.
  321. * @attribute isPrivileged
  322. * @type Boolean
  323. * @default false
  324. * @private
  325. * @for Skylink
  326. * @since 0.6.1
  327. */
  328. this._isPrivileged = false;
  329.  
  330. /**
  331. * Stores the list of Peers retrieved from the Signaling from <code>getPeers()</code> method.
  332. * @attribute _peerList
  333. * @type JSON
  334. * @private
  335. * @for Skylink
  336. * @since 0.6.1
  337. */
  338. this._peerList = null;
  339.  
  340. /**
  341. * Stores the current Room name that User is connected to.
  342. * @attribute _selectedRoom
  343. * @type String
  344. * @private
  345. * @for Skylink
  346. * @since 0.3.0
  347. */
  348. this._selectedRoom = null;
  349.  
  350. /**
  351. * Stores the flag that indicates if Room is locked.
  352. * @attribute _roomLocked
  353. * @type Boolean
  354. * @private
  355. * @for Skylink
  356. * @since 0.5.2
  357. */
  358. this._roomLocked = false;
  359.  
  360. /**
  361. * Stores the flag that indicates if User is connected to the Room.
  362. * @attribute _inRoom
  363. * @type Boolean
  364. * @private
  365. * @for Skylink
  366. * @since 0.4.0
  367. */
  368. this._inRoom = false;
  369.  
  370. /**
  371. * Stores the list of <code>on()</code> event handlers.
  372. * @attribute _EVENTS
  373. * @param {Array} <#event> The list of event handlers associated with the event.
  374. * @param {Function} <#event>.<#index> The event handler function.
  375. * @type JSON
  376. * @private
  377. * @for Skylink
  378. * @since 0.5.2
  379. */
  380. this._EVENTS = {};
  381.  
  382. /**
  383. * Stores the list of <code>once()</code> event handlers.
  384. * These events are only triggered once.
  385. * @attribute _onceEvents
  386. * @param {Array} <#event> The list of event handlers associated with the event.
  387. * @param {Array} <#event>.<#index> The array of event handler function and its condition function.
  388. * @type JSON
  389. * @private
  390. * @for Skylink
  391. * @since 0.5.4
  392. */
  393. this._onceEvents = {};
  394.  
  395. /**
  396. * Stores the timestamps data used for throttling.
  397. * @attribute _timestamp
  398. * @type JSON
  399. * @private
  400. * @for Skylink
  401. * @since 0.5.8
  402. */
  403. this._timestamp = {
  404. socketMessage: null,
  405. shareScreen: null,
  406. refreshConnection: null,
  407. getUserMedia: null,
  408. lastRestart: null
  409. };
  410.  
  411. /**
  412. * Stores the current socket connection information.
  413. * @attribute _socketSession
  414. * @type JSON
  415. * @private
  416. * @for Skylink
  417. * @since 0.6.13
  418. */
  419. this._socketSession = {};
  420.  
  421. /**
  422. * Stores the queued socket messages.
  423. * This is to prevent too many sent over less than a second interval that might cause dropped messages
  424. * or jams to the Signaling connection.
  425. * @attribute _socketMessageQueue
  426. * @type Array
  427. * @private
  428. * @for Skylink
  429. * @since 0.5.8
  430. */
  431. this._socketMessageQueue = [];
  432.  
  433. /**
  434. * Stores the <code>setTimeout</code> to sent queued socket messages.
  435. * @attribute _socketMessageTimeout
  436. * @type Object
  437. * @private
  438. * @for Skylink
  439. * @since 0.5.8
  440. */
  441. this._socketMessageTimeout = null;
  442.  
  443. /**
  444. * Stores the list of socket ports to use to connect to the Signaling.
  445. * These ports are defined by default which is commonly used currently by the Signaling.
  446. * Should re-evaluate this sometime.
  447. * @attribute _socketPorts
  448. * @param {Array} http: The list of HTTP socket ports.
  449. * @param {Array} https: The list of HTTPS socket ports.
  450. * @type JSON
  451. * @private
  452. * @for Skylink
  453. * @since 0.5.8
  454. */
  455. this._socketPorts = {
  456. 'http:': [80, 3000],
  457. 'https:': [443, 3443]
  458. };
  459.  
  460. /**
  461. * Stores the flag that indicates if socket connection to the Signaling has opened.
  462. * @attribute _channelOpen
  463. * @type Boolean
  464. * @private
  465. * @for Skylink
  466. * @since 0.5.2
  467. */
  468. this._channelOpen = false;
  469.  
  470. /**
  471. * Stores the Signaling server url.
  472. * @attribute _signalingServer
  473. * @type String
  474. * @private
  475. * @for Skylink
  476. * @since 0.5.2
  477. */
  478. this._signalingServer = null;
  479.  
  480. /**
  481. * Stores the Signaling server protocol.
  482. * @attribute _signalingServerProtocol
  483. * @type String
  484. * @private
  485. * @for Skylink
  486. * @since 0.5.4
  487. */
  488. this._signalingServerProtocol = window.location.protocol;
  489.  
  490. /**
  491. * Stores the Signaling server port.
  492. * @attribute _signalingServerPort
  493. * @type Number
  494. * @private
  495. * @for Skylink
  496. * @since 0.5.4
  497. */
  498. this._signalingServerPort = null;
  499.  
  500. /**
  501. * Stores the Signaling socket connection object.
  502. * @attribute _socket
  503. * @type io
  504. * @private
  505. * @for Skylink
  506. * @since 0.1.0
  507. */
  508. this._socket = null;
  509.  
  510. /**
  511. * Stores the flag that indicates if XDomainRequest is used for IE 8/9.
  512. * @attribute _socketUseXDR
  513. * @type Boolean
  514. * @private
  515. * @for Skylink
  516. * @since 0.5.4
  517. */
  518. this._socketUseXDR = false;
  519.  
  520. /**
  521. * Stores the value if ICE restart is supported.
  522. * @attribute _enableIceRestart
  523. * @type String
  524. * @private
  525. * @for Skylink
  526. * @since 0.6.16
  527. */
  528. this._enableIceRestart = false;
  529.  
  530. /**
  531. * Stores the flag if MCU environment is enabled.
  532. * @attribute _hasMCU
  533. * @type Boolean
  534. * @private
  535. * @for Skylink
  536. * @since 0.5.4
  537. */
  538. this._hasMCU = false;
  539.  
  540. /**
  541. * Stores the construct API REST path to obtain Room credentials.
  542. * @attribute _path
  543. * @type String
  544. * @private
  545. * @for Skylink
  546. * @since 0.1.0
  547. */
  548. this._path = null;
  549.  
  550. /**
  551. * Stores the current <code>init()</code> readyState.
  552. * @attribute _readyState
  553. * @type Number
  554. * @private
  555. * @for Skylink
  556. * @since 0.1.0
  557. */
  558. this._readyState = null;
  559.  
  560. /**
  561. * Stores the "cid" used for <code>joinRoom()</code>.
  562. * @attribute _key
  563. * @type String
  564. * @private
  565. * @for Skylink
  566. * @since 0.1.0
  567. */
  568. this._key = null;
  569.  
  570. /**
  571. * Stores the "apiOwner" used for <code>joinRoom()</code>.
  572. * @attribute _appKeyOwner
  573. * @type String
  574. * @private
  575. * @for Skylink
  576. * @since 0.5.2
  577. */
  578. this._appKeyOwner = null;
  579.  
  580. /**
  581. * Stores the Room credentials information for <code>joinRoom()</code>.
  582. * @attribute _room
  583. * @param {String} id The "rid" for <code>joinRoom()</code>.
  584. * @param {String} token The "roomCred" for <code>joinRoom()</code>.
  585. * @param {String} startDateTime The "start" for <code>joinRoom()</code>.
  586. * @param {String} duration The "len" for <code>joinRoom()</code>.
  587. * @param {String} connection The RTCPeerConnection constraints and configuration. This is not used in the SDK
  588. * except for the "mediaConstraints" property that sets the default <code>getUserMedia()</code> settings.
  589. * @type JSON
  590. * @private
  591. * @for Skylink
  592. * @since 0.5.2
  593. */
  594. this._room = null;
  595.  
  596. /**
  597. * Stores the list of Peer messages timestamp.
  598. * @attribute _peerMessagesStamps
  599. * @type JSON
  600. * @private
  601. * @for Skylink
  602. * @since 0.6.15
  603. */
  604. this._peerMessagesStamps = {};
  605.  
  606. /**
  607. * Stores the Streams.
  608. * @attribute _streams
  609. * @type JSON
  610. * @private
  611. * @for Skylink
  612. * @since 0.6.15
  613. */
  614. this._streams = {
  615. userMedia: null,
  616. screenshare: null
  617. };
  618.  
  619. /**
  620. * Stores the default camera Stream settings.
  621. * @attribute _streamsDefaultSettings
  622. * @type JSON
  623. * @private
  624. * @for Skylink
  625. * @since 0.6.15
  626. */
  627. this._streamsDefaultSettings = {
  628. userMedia: {
  629. audio: {
  630. stereo: false
  631. },
  632. video: {
  633. resolution: {
  634. width: 640,
  635. height: 480
  636. },
  637. frameRate: 50
  638. }
  639. },
  640. screenshare: {
  641. video: true
  642. }
  643. };
  644.  
  645. /**
  646. * Stores all the Stream required muted settings.
  647. * @attribute _streamsMutedSettings
  648. * @type JSON
  649. * @private
  650. * @for Skylink
  651. * @since 0.6.15
  652. */
  653. this._streamsMutedSettings = {
  654. audioMuted: false,
  655. videoMuted: false
  656. };
  657.  
  658. /**
  659. * Stores all the Stream sending maximum bandwidth settings.
  660. * @attribute _streamsBandwidthSettings
  661. * @type JSON
  662. * @private
  663. * @for Skylink
  664. * @since 0.6.15
  665. */
  666. this._streamsBandwidthSettings = {
  667. googleX: {},
  668. bAS: {}
  669. };
  670.  
  671. /**
  672. * Stores all the Stream stopped callbacks.
  673. * @attribute _streamsStoppedCbs
  674. * @type JSON
  675. * @private
  676. * @for Skylink
  677. * @since 0.6.15
  678. */
  679. this._streamsStoppedCbs = {};
  680.  
  681. /**
  682. * Stores all the Stream sessions.
  683. * Defined as <code>false</code> when Stream has already ended.
  684. * @attribute _streamsSession
  685. * @type JSON
  686. * @private
  687. * @for Skylink
  688. * @since 0.6.15
  689. */
  690. this._streamsSession = {};
  691.  
  692. /**
  693. * Stores the session description settings.
  694. * @attribute _sdpSettings
  695. * @type JSON
  696. * @private
  697. * @for Skylink
  698. * @since 0.6.16
  699. */
  700. this._sdpSettings = {
  701. connection: {
  702. audio: true,
  703. video: true,
  704. data: true
  705. },
  706. direction: {
  707. audio: { send: true, receive: true },
  708. video: { send: true, receive: true }
  709. }
  710. };
  711.  
  712. /**
  713. * Stores the publish only settings.
  714. * @attribute _publishOnly
  715. * @type Boolean
  716. * @private
  717. * @for Skylink
  718. * @since 0.6.16
  719. */
  720. this._publishOnly = false;
  721.  
  722. /**
  723. * Stores the parent ID.
  724. * @attribute _parentId
  725. * @type String
  726. * @private
  727. * @for Skylink
  728. * @since 0.6.18
  729. */
  730. this._parentId = null;
  731.  
  732. /**
  733. * Stores the list of recordings.
  734. * @attribute _recordings
  735. * @type JSON
  736. * @private
  737. * @beta
  738. * @for Skylink
  739. * @since 0.6.16
  740. */
  741. this._recordings = {};
  742.  
  743. /**
  744. * Stores the list of RTMP Sessions.
  745. * @attribute _rtmpSessions
  746. * @type JSON
  747. * @private
  748. * @beta
  749. * @for Skylink
  750. * @since 0.6.36
  751. */
  752. this._rtmpSessions = {};
  753.  
  754. /**
  755. * Stores the current active recording session ID.
  756. * There can only be 1 recording session at a time in a Room
  757. * @attribute _currentRecordingId
  758. * @type JSON
  759. * @private
  760. * @beta
  761. * @for Skylink
  762. * @since 0.6.16
  763. */
  764. this._currentRecordingId = false;
  765.  
  766. /**
  767. * Stores the recording session timeout to ensure 4 seconds has been recorded.
  768. * @attribute _recordingStartInterval
  769. * @type JSON
  770. * @private
  771. * @beta
  772. * @for Skylink
  773. * @since 0.6.16
  774. */
  775. this._recordingStartInterval = null;
  776.  
  777. /**
  778. * Stores the currently supported codecs.
  779. * @attribute _currentCodecSupport
  780. * @type JSON
  781. * @private
  782. * @for Skylink
  783. * @since 0.6.18
  784. */
  785. this._currentCodecSupport = null;
  786.  
  787. /**
  788. * Stores the session description orders and info.
  789. * @attribute _sdpSessions
  790. * @type JSON
  791. * @private
  792. * @for Skylink
  793. * @since 0.6.18
  794. */
  795. this._sdpSessions = {};
  796.  
  797. /**
  798. * Stores the flag if voice activity detection should be enabled.
  799. * @attribute _voiceActivityDetection
  800. * @type Boolean
  801. * @default true
  802. * @private
  803. * @for Skylink
  804. * @since 0.6.18
  805. */
  806. this._voiceActivityDetection = true;
  807.  
  808. /**
  809. * Stores the datachannel binary data chunk type.
  810. * @attribute _binaryChunkType
  811. * @type JSON
  812. * @private
  813. * @for Skylink
  814. * @since 0.6.18
  815. */
  816. this._binaryChunkType = this.DATA_TRANSFER_DATA_TYPE.ARRAY_BUFFER;
  817.  
  818. /**
  819. * Stores the RTCPeerConnection configuration.
  820. * @attribute _peerConnectionConfig
  821. * @type JSON
  822. * @private
  823. * @for Skylink
  824. * @since 0.6.18
  825. */
  826. this._peerConnectionConfig = {};
  827.  
  828. /**
  829. * Stores the auto bandwidth settings.
  830. * @attribute _bandwidthAdjuster
  831. * @type JSON
  832. * @private
  833. * @for Skylink
  834. * @since 0.6.18
  835. */
  836. this._bandwidthAdjuster = null;
  837.  
  838. /**
  839. * Stores the Peer connection status.
  840. * @attribute _peerConnStatus
  841. * @type JSON
  842. * @private
  843. * @for Skylink
  844. * @since 0.6.19
  845. */
  846. this._peerConnStatus = {};
  847.  
  848. /**
  849. * Stores the flag to temporarily halt joinRoom() from processing.
  850. * @attribute _joinRoomManager
  851. * @type Boolean
  852. * @private
  853. * @for Skylink
  854. * @since 0.6.19
  855. */
  856. this._joinRoomManager = {
  857. timestamp: 0,
  858. socketsFn: []
  859. };
  860.  
  861. /**
  862. * Stores the `init()` configuration.
  863. * @attribute _initOptions
  864. * @type JSON
  865. * @private
  866. * @for Skylink
  867. * @since 0.6.27
  868. */
  869. this._initOptions = {};
  870.  
  871. /**
  872. * Stores the unique random number used for generating the "client_id".
  873. * @attribute _statIdRandom
  874. * @type Number
  875. * @private
  876. * @for Skylink
  877. * @since 0.6.31
  878. */
  879. this._statIdRandom = Date.now() + Math.floor(Math.random() * 100000000);
  880.  
  881. /**
  882. * A mapping of transceiverIds and peer IDs (only when new MCU is in effect)
  883. * @attribute _transceiverIdPeerIdMap
  884. * @type Object
  885. * @private
  886. * @for Skylink
  887. * @since 0.6.31
  888. */
  889. this._transceiverIdPeerIdMap = {};
  890.  
  891. /**
  892. * (Extra) Tracks requested by the Peer/MCU in welcome/restart message. Used to create transceivers before createOffer.
  893. * @attribute _transceiverIdPeerIdMap
  894. * @type Object
  895. * @private
  896. * @for Skylink
  897. * @since 0.6.31
  898. */
  899. this._currentRequestedTracks = { audio: 0, video: 0 };
  900.  
  901. /**
  902. * Originally negotiated DTLS role of this peer.
  903. * @attribute _originalDTLSRole
  904. * @type String
  905. * @private
  906. * @for Skylink
  907. * @since 1.0.0
  908. */
  909. this._originalDTLSRole = null;
  910. }