You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TraceablePeerConnection.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /* global $ */
  2. var RTC = require('../RTC/RTC');
  3. var logger = require("jitsi-meet-logger").getLogger(__filename);
  4. var RTCBrowserType = require("../RTC/RTCBrowserType.js");
  5. var XMPPEvents = require("../../service/xmpp/XMPPEvents");
  6. var transform = require('sdp-transform');
  7. function TraceablePeerConnection(ice_config, constraints, session) {
  8. var self = this;
  9. this.session = session;
  10. this.replaceSSRCs = {
  11. "audio": [],
  12. "video": []
  13. };
  14. this.recvOnlySSRCs = {};
  15. var RTCPeerConnectionType = null;
  16. if (RTCBrowserType.isFirefox()) {
  17. RTCPeerConnectionType = mozRTCPeerConnection;
  18. } else if (RTCBrowserType.isTemasysPluginUsed()) {
  19. RTCPeerConnectionType = RTCPeerConnection;
  20. } else {
  21. RTCPeerConnectionType = webkitRTCPeerConnection;
  22. }
  23. this.peerconnection = new RTCPeerConnectionType(ice_config, constraints);
  24. this.updateLog = [];
  25. this.stats = {};
  26. this.statsinterval = null;
  27. this.maxstats = 0; // limit to 300 values, i.e. 5 minutes; set to 0 to disable
  28. var Interop = require('sdp-interop').Interop;
  29. this.interop = new Interop();
  30. var Simulcast = require('sdp-simulcast');
  31. this.simulcast = new Simulcast({numOfLayers: 3,
  32. explodeRemoteSimulcast: false});
  33. this.eventEmitter = this.session.room.eventEmitter;
  34. // override as desired
  35. this.trace = function (what, info) {
  36. /*logger.warn('WTRACE', what, info);
  37. if (info && RTCBrowserType.isIExplorer()) {
  38. if (info.length > 1024) {
  39. logger.warn('WTRACE', what, info.substr(1024));
  40. }
  41. if (info.length > 2048) {
  42. logger.warn('WTRACE', what, info.substr(2048));
  43. }
  44. }*/
  45. self.updateLog.push({
  46. time: new Date(),
  47. type: what,
  48. value: info || ""
  49. });
  50. };
  51. this.onicecandidate = null;
  52. this.peerconnection.onicecandidate = function (event) {
  53. // FIXME: this causes stack overflow with Temasys Plugin
  54. if (!RTCBrowserType.isTemasysPluginUsed())
  55. self.trace('onicecandidate', JSON.stringify(event.candidate, null, ' '));
  56. if (self.onicecandidate !== null) {
  57. self.onicecandidate(event);
  58. }
  59. };
  60. this.onaddstream = null;
  61. this.peerconnection.onaddstream = function (event) {
  62. self.trace('onaddstream', event.stream.id);
  63. if (self.onaddstream !== null) {
  64. self.onaddstream(event);
  65. }
  66. };
  67. this.onremovestream = null;
  68. this.peerconnection.onremovestream = function (event) {
  69. self.trace('onremovestream', event.stream.id);
  70. if (self.onremovestream !== null) {
  71. self.onremovestream(event);
  72. }
  73. };
  74. this.onsignalingstatechange = null;
  75. this.peerconnection.onsignalingstatechange = function (event) {
  76. self.trace('onsignalingstatechange', self.signalingState);
  77. if (self.onsignalingstatechange !== null) {
  78. self.onsignalingstatechange(event);
  79. }
  80. };
  81. this.oniceconnectionstatechange = null;
  82. this.peerconnection.oniceconnectionstatechange = function (event) {
  83. self.trace('oniceconnectionstatechange', self.iceConnectionState);
  84. if (self.oniceconnectionstatechange !== null) {
  85. self.oniceconnectionstatechange(event);
  86. }
  87. };
  88. this.onnegotiationneeded = null;
  89. this.peerconnection.onnegotiationneeded = function (event) {
  90. self.trace('onnegotiationneeded');
  91. if (self.onnegotiationneeded !== null) {
  92. self.onnegotiationneeded(event);
  93. }
  94. };
  95. self.ondatachannel = null;
  96. this.peerconnection.ondatachannel = function (event) {
  97. self.trace('ondatachannel', event);
  98. if (self.ondatachannel !== null) {
  99. self.ondatachannel(event);
  100. }
  101. };
  102. // XXX: do all non-firefox browsers which we support also support this?
  103. if (!RTCBrowserType.isFirefox() && this.maxstats) {
  104. this.statsinterval = window.setInterval(function() {
  105. self.peerconnection.getStats(function(stats) {
  106. var results = stats.result();
  107. var now = new Date();
  108. for (var i = 0; i < results.length; ++i) {
  109. results[i].names().forEach(function (name) {
  110. var id = results[i].id + '-' + name;
  111. if (!self.stats[id]) {
  112. self.stats[id] = {
  113. startTime: now,
  114. endTime: now,
  115. values: [],
  116. times: []
  117. };
  118. }
  119. self.stats[id].values.push(results[i].stat(name));
  120. self.stats[id].times.push(now.getTime());
  121. if (self.stats[id].values.length > self.maxstats) {
  122. self.stats[id].values.shift();
  123. self.stats[id].times.shift();
  124. }
  125. self.stats[id].endTime = now;
  126. });
  127. }
  128. });
  129. }, 1000);
  130. }
  131. }
  132. /**
  133. * Returns a string representation of a SessionDescription object.
  134. */
  135. var dumpSDP = function(description) {
  136. if (typeof description === 'undefined' || description == null) {
  137. return '';
  138. }
  139. return 'type: ' + description.type + '\r\n' + description.sdp;
  140. };
  141. /**
  142. * Injects receive only SSRC in the sdp if there are not other SSRCs.
  143. * @param desc the SDP that will be modified.
  144. * @returns the modified SDP.
  145. */
  146. TraceablePeerConnection.prototype.ssrcReplacement = function (desc) {
  147. if (typeof desc !== 'object' || desc === null ||
  148. typeof desc.sdp !== 'string') {
  149. console.warn('An empty description was passed as an argument.');
  150. return desc;
  151. }
  152. var RandomUtil = require('../util/RandomUtil');
  153. var session = transform.parse(desc.sdp);
  154. if (!Array.isArray(session.media))
  155. {
  156. return;
  157. }
  158. var modded = false;
  159. session.media.forEach(function (bLine) {
  160. if(!this.replaceSSRCs[bLine.type])
  161. return;
  162. modded = true;
  163. var SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
  164. //FIXME: The code expects that we have only SIM group or we
  165. // don't have any groups and we have only one SSRC per
  166. // stream. If we add another groups (FID, etc) this code
  167. // must be changed.
  168. while(SSRCs &&
  169. SSRCs.length){
  170. var ssrcOperation = SSRCs[0];
  171. switch(ssrcOperation.type) {
  172. case "mute":
  173. //FIXME: If we want to support multiple streams we have to add
  174. // recv-only ssrcs for the
  175. // muted streams on every change until the stream is unmuted
  176. // or removed. Otherwise the recv-only streams won't be included
  177. // in the SDP
  178. if(!bLine.ssrcs)
  179. bLine.ssrcs = [];
  180. var groups = ssrcOperation.ssrc.groups;
  181. var ssrc = null;
  182. if(groups && groups.length) {
  183. ssrc = groups[0].primarySSRC;
  184. } else if(ssrcOperation.ssrc.ssrcs &&
  185. ssrcOperation.ssrc.ssrcs.length) {
  186. ssrc = ssrcOperation.ssrc.ssrcs[0];
  187. } else {
  188. logger.error("SSRC replacement error!");
  189. break;
  190. }
  191. bLine.ssrcs.push({
  192. id: ssrc,
  193. attribute: 'cname',
  194. value: ['recvonly-', ssrc].join('')
  195. })
  196. break;
  197. case "unmute":
  198. if(!ssrcOperation.ssrc || !ssrcOperation.ssrc.ssrcs ||
  199. !ssrcOperation.ssrc.ssrcs.length)
  200. break;
  201. var ssrcMap = {};
  202. var ssrcLastIdx = ssrcOperation.ssrc.ssrcs.length - 1;
  203. for(var i = 0; i < bLine.ssrcs.length; i++) {
  204. var ssrc = bLine.ssrcs[i];
  205. if (ssrc.attribute !== 'msid' &&
  206. ssrc.value !== ssrcOperation.msid) {
  207. continue;
  208. }
  209. ssrcMap[ssrc.id] =
  210. ssrcOperation.ssrc.ssrcs[ssrcLastIdx];
  211. ssrcLastIdx--;
  212. if(ssrcLastIdx < 0)
  213. break;
  214. }
  215. var groups = ssrcOperation.ssrc.groups;
  216. if (typeof bLine.ssrcGroups !== 'undefined' &&
  217. Array.isArray(bLine.ssrcGroups) && groups &&
  218. groups.length) {
  219. bLine.ssrcGroups.forEach(function (group) {
  220. if(!group.ssrcs)
  221. return;
  222. var currentSSRCs = group.ssrcs.split(" ");
  223. var newGroup = null;
  224. for(var i = 0; i < groups.length; i++) {
  225. newGroup = groups[i].group;
  226. var newSSRCs = newGroup.ssrcs.split(" ");
  227. if(newGroup.semantics !== group.semantics)
  228. continue;
  229. var wrongGroup = false;
  230. for(var j = 0; j < currentSSRCs.length; j++) {
  231. if(newGroup.ssrcs.indexOf(
  232. ssrcMap[currentSSRCs[j]]) === -1){
  233. wrongGroup = true;
  234. break;
  235. }
  236. }
  237. if(!wrongGroup) {
  238. for(j = 0; j < newSSRCs.length; j++) {
  239. ssrcMap[currentSSRCs[j]] = newSSRCs[j];
  240. }
  241. break;
  242. }
  243. }
  244. group.ssrcs = newGroup.ssrcs;
  245. });
  246. }
  247. bLine.ssrcs.forEach(function (ssrc) {
  248. if(ssrcMap[ssrc.id]) {
  249. ssrc.id = ssrcMap[ssrc.id];
  250. }
  251. });
  252. break;
  253. default:
  254. break;
  255. }
  256. SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
  257. }
  258. if (!Array.isArray(bLine.ssrcs) || bLine.ssrcs.length === 0)
  259. {
  260. var ssrc = this.recvOnlySSRCs[bLine.type]
  261. = this.recvOnlySSRCs[bLine.type] ||
  262. RandomUtil.randomInt(1, 0xffffffff);
  263. bLine.ssrcs = [{
  264. id: ssrc,
  265. attribute: 'cname',
  266. value: ['recvonly-', ssrc].join('')
  267. }];
  268. }
  269. }.bind(this));
  270. return (!modded) ? desc : new RTCSessionDescription({
  271. type: desc.type,
  272. sdp: transform.write(session),
  273. });
  274. };
  275. /**
  276. * Returns map with keys msid and values ssrc.
  277. * @param desc the SDP that will be modified.
  278. */
  279. function extractSSRCMap(desc) {
  280. if (typeof desc !== 'object' || desc === null ||
  281. typeof desc.sdp !== 'string') {
  282. console.warn('An empty description was passed as an argument.');
  283. return desc;
  284. }
  285. var ssrcList = {};
  286. var ssrcGroups = {};
  287. var session = transform.parse(desc.sdp);
  288. if (!Array.isArray(session.media))
  289. {
  290. return;
  291. }
  292. session.media.forEach(function (bLine) {
  293. if (!Array.isArray(bLine.ssrcs))
  294. {
  295. return;
  296. }
  297. if (typeof bLine.ssrcGroups !== 'undefined' &&
  298. Array.isArray(bLine.ssrcGroups)) {
  299. bLine.ssrcGroups.forEach(function (group) {
  300. if (typeof group.semantics !== 'undefined' &&
  301. typeof group.ssrcs !== 'undefined') {
  302. var primarySSRC = Number(group.ssrcs.split(' ')[0]);
  303. ssrcGroups[primarySSRC] = ssrcGroups[primarySSRC] || [];
  304. ssrcGroups[primarySSRC].push(group);
  305. }
  306. });
  307. }
  308. bLine.ssrcs.forEach(function (ssrc) {
  309. if(ssrc.attribute !== 'msid')
  310. return;
  311. ssrcList[ssrc.value] = ssrcList[ssrc.value] ||
  312. {groups: [], ssrcs: []};
  313. ssrcList[ssrc.value].ssrcs.push(ssrc.id);
  314. if(ssrcGroups[ssrc.id]){
  315. ssrcGroups[ssrc.id].forEach(function (group) {
  316. ssrcList[ssrc.value].groups.push(
  317. {primarySSRC: ssrc.id, group: group});
  318. });
  319. }
  320. });
  321. });
  322. return ssrcList;
  323. }
  324. /**
  325. * Takes a SessionDescription object and returns a "normalized" version.
  326. * Currently it only takes care of ordering the a=ssrc lines.
  327. */
  328. var normalizePlanB = function(desc) {
  329. if (typeof desc !== 'object' || desc === null ||
  330. typeof desc.sdp !== 'string') {
  331. logger.warn('An empty description was passed as an argument.');
  332. return desc;
  333. }
  334. var transform = require('sdp-transform');
  335. var session = transform.parse(desc.sdp);
  336. if (typeof session !== 'undefined' &&
  337. typeof session.media !== 'undefined' && Array.isArray(session.media)) {
  338. session.media.forEach(function (mLine) {
  339. // Chrome appears to be picky about the order in which a=ssrc lines
  340. // are listed in an m-line when rtx is enabled (and thus there are
  341. // a=ssrc-group lines with FID semantics). Specifically if we have
  342. // "a=ssrc-group:FID S1 S2" and the "a=ssrc:S2" lines appear before
  343. // the "a=ssrc:S1" lines, SRD fails.
  344. // So, put SSRC which appear as the first SSRC in an FID ssrc-group
  345. // first.
  346. var firstSsrcs = [];
  347. var newSsrcLines = [];
  348. if (typeof mLine.ssrcGroups !== 'undefined' &&
  349. Array.isArray(mLine.ssrcGroups)) {
  350. mLine.ssrcGroups.forEach(function (group) {
  351. if (typeof group.semantics !== 'undefined' &&
  352. group.semantics === 'FID') {
  353. if (typeof group.ssrcs !== 'undefined') {
  354. firstSsrcs.push(Number(group.ssrcs.split(' ')[0]));
  355. }
  356. }
  357. });
  358. }
  359. if (typeof mLine.ssrcs !== 'undefined' && Array.isArray(mLine.ssrcs)) {
  360. var i;
  361. for (i = 0; i<mLine.ssrcs.length; i++){
  362. if (typeof mLine.ssrcs[i] === 'object'
  363. && typeof mLine.ssrcs[i].id !== 'undefined'
  364. && !$.inArray(mLine.ssrcs[i].id, firstSsrcs)) {
  365. newSsrcLines.push(mLine.ssrcs[i]);
  366. delete mLine.ssrcs[i];
  367. }
  368. }
  369. for (i = 0; i<mLine.ssrcs.length; i++){
  370. if (typeof mLine.ssrcs[i] !== 'undefined') {
  371. newSsrcLines.push(mLine.ssrcs[i]);
  372. }
  373. }
  374. mLine.ssrcs = newSsrcLines;
  375. }
  376. });
  377. }
  378. var resStr = transform.write(session);
  379. return new RTCSessionDescription({
  380. type: desc.type,
  381. sdp: resStr
  382. });
  383. };
  384. var getters = {
  385. signalingState: function () {
  386. return this.peerconnection.signalingState;
  387. },
  388. iceConnectionState: function () {
  389. return this.peerconnection.iceConnectionState;
  390. },
  391. localDescription: function() {
  392. var desc = this.peerconnection.localDescription;
  393. this.trace('getLocalDescription::preTransform', dumpSDP(desc));
  394. // if we're running on FF, transform to Plan B first.
  395. if (RTCBrowserType.usesUnifiedPlan()) {
  396. desc = this.interop.toPlanB(desc);
  397. this.trace('getLocalDescription::postTransform (Plan B)',
  398. dumpSDP(desc));
  399. }
  400. return desc;
  401. },
  402. remoteDescription: function() {
  403. var desc = this.peerconnection.remoteDescription;
  404. this.trace('getRemoteDescription::preTransform', dumpSDP(desc));
  405. // if we're running on FF, transform to Plan B first.
  406. if (RTCBrowserType.usesUnifiedPlan()) {
  407. desc = this.interop.toPlanB(desc);
  408. this.trace('getRemoteDescription::postTransform (Plan B)', dumpSDP(desc));
  409. }
  410. return desc;
  411. }
  412. };
  413. Object.keys(getters).forEach(function (prop) {
  414. Object.defineProperty(
  415. TraceablePeerConnection.prototype,
  416. prop, {
  417. get: getters[prop]
  418. }
  419. );
  420. });
  421. TraceablePeerConnection.prototype.addStream = function (stream, ssrcInfo) {
  422. this.trace('addStream', stream.id);
  423. try
  424. {
  425. this.peerconnection.addStream(stream);
  426. if(ssrcInfo && this.replaceSSRCs[ssrcInfo.mtype])
  427. this.replaceSSRCs[ssrcInfo.mtype].push(ssrcInfo);
  428. }
  429. catch (e)
  430. {
  431. logger.error(e);
  432. }
  433. };
  434. TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams,
  435. ssrcInfo) {
  436. this.trace('removeStream', stream.id);
  437. if(stopStreams) {
  438. RTC.stopMediaStream(stream);
  439. }
  440. try {
  441. // FF doesn't support this yet.
  442. if (this.peerconnection.removeStream) {
  443. this.peerconnection.removeStream(stream);
  444. if(ssrcInfo && this.replaceSSRCs[ssrcInfo.mtype])
  445. this.replaceSSRCs[ssrcInfo.mtype].push(ssrcInfo);
  446. }
  447. } catch (e) {
  448. logger.error(e);
  449. }
  450. };
  451. TraceablePeerConnection.prototype.createDataChannel = function (label, opts) {
  452. this.trace('createDataChannel', label, opts);
  453. return this.peerconnection.createDataChannel(label, opts);
  454. };
  455. TraceablePeerConnection.prototype.setLocalDescription
  456. = function (description, successCallback, failureCallback) {
  457. this.trace('setLocalDescription::preTransform', dumpSDP(description));
  458. // if we're running on FF, transform to Plan A first.
  459. if (RTCBrowserType.usesUnifiedPlan()) {
  460. description = this.interop.toUnifiedPlan(description);
  461. this.trace('setLocalDescription::postTransform (Plan A)',
  462. dumpSDP(description));
  463. }
  464. var self = this;
  465. this.peerconnection.setLocalDescription(description,
  466. function () {
  467. self.trace('setLocalDescriptionOnSuccess');
  468. successCallback();
  469. },
  470. function (err) {
  471. self.trace('setLocalDescriptionOnFailure', err);
  472. self.eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
  473. err, self.peerconnection);
  474. failureCallback(err);
  475. }
  476. );
  477. };
  478. TraceablePeerConnection.prototype.setRemoteDescription
  479. = function (description, successCallback, failureCallback) {
  480. this.trace('setRemoteDescription::preTransform', dumpSDP(description));
  481. // TODO the focus should squeze or explode the remote simulcast
  482. description = this.simulcast.mungeRemoteDescription(description);
  483. this.trace('setRemoteDescription::postTransform (simulcast)', dumpSDP(description));
  484. // if we're running on FF, transform to Plan A first.
  485. if (RTCBrowserType.usesUnifiedPlan()) {
  486. description = this.interop.toUnifiedPlan(description);
  487. this.trace('setRemoteDescription::postTransform (Plan A)', dumpSDP(description));
  488. }
  489. if (RTCBrowserType.usesPlanB()) {
  490. description = normalizePlanB(description);
  491. }
  492. var self = this;
  493. this.peerconnection.setRemoteDescription(description,
  494. function () {
  495. self.trace('setRemoteDescriptionOnSuccess');
  496. successCallback();
  497. },
  498. function (err) {
  499. self.trace('setRemoteDescriptionOnFailure', err);
  500. self.eventEmitter.emit(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
  501. err, self.peerconnection);
  502. failureCallback(err);
  503. }
  504. );
  505. /*
  506. if (this.statsinterval === null && this.maxstats > 0) {
  507. // start gathering stats
  508. }
  509. */
  510. };
  511. TraceablePeerConnection.prototype.close = function () {
  512. this.trace('stop');
  513. if (this.statsinterval !== null) {
  514. window.clearInterval(this.statsinterval);
  515. this.statsinterval = null;
  516. }
  517. this.peerconnection.close();
  518. };
  519. TraceablePeerConnection.prototype.createAnswer
  520. = function (successCallback, failureCallback, constraints) {
  521. var self = this;
  522. this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
  523. this.peerconnection.createAnswer(
  524. function (answer) {
  525. self.trace('createAnswerOnSuccess::preTransform', dumpSDP(answer));
  526. // if we're running on FF, transform to Plan A first.
  527. if (RTCBrowserType.usesUnifiedPlan()) {
  528. answer = self.interop.toPlanB(answer);
  529. self.trace('createAnswerOnSuccess::postTransform (Plan B)',
  530. dumpSDP(answer));
  531. }
  532. if (!self.session.room.options.disableSimulcast
  533. && self.simulcast.isSupported()) {
  534. answer = self.simulcast.mungeLocalDescription(answer);
  535. self.trace('createAnswerOnSuccess::postTransform (simulcast)',
  536. dumpSDP(answer));
  537. }
  538. if (!RTCBrowserType.isFirefox())
  539. {
  540. answer = self.ssrcReplacement(answer);
  541. self.trace('createAnswerOnSuccess::mungeLocalVideoSSRC',
  542. dumpSDP(answer));
  543. }
  544. self.eventEmitter.emit(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  545. extractSSRCMap(answer));
  546. successCallback(answer);
  547. },
  548. function(err) {
  549. self.trace('createAnswerOnFailure', err);
  550. self.eventEmitter.emit(XMPPEvents.CREATE_ANSWER_FAILED, err,
  551. self.peerconnection);
  552. failureCallback(err);
  553. },
  554. constraints
  555. );
  556. };
  557. TraceablePeerConnection.prototype.addIceCandidate
  558. = function (candidate, successCallback, failureCallback) {
  559. //var self = this;
  560. this.trace('addIceCandidate', JSON.stringify(candidate, null, ' '));
  561. this.peerconnection.addIceCandidate(candidate);
  562. /* maybe later
  563. this.peerconnection.addIceCandidate(candidate,
  564. function () {
  565. self.trace('addIceCandidateOnSuccess');
  566. successCallback();
  567. },
  568. function (err) {
  569. self.trace('addIceCandidateOnFailure', err);
  570. failureCallback(err);
  571. }
  572. );
  573. */
  574. };
  575. TraceablePeerConnection.prototype.getStats = function(callback, errback) {
  576. // TODO: Is this the correct way to handle Opera, Temasys?
  577. if (RTCBrowserType.isFirefox() || RTCBrowserType.isTemasysPluginUsed()) {
  578. // ignore for now...
  579. if(!errback)
  580. errback = function () {};
  581. this.peerconnection.getStats(null, callback, errback);
  582. } else {
  583. this.peerconnection.getStats(callback);
  584. }
  585. };
  586. module.exports = TraceablePeerConnection;