@telegenta/webclient 3.2.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/telegenta.js CHANGED
@@ -219,15 +219,15 @@ function createUUID() {
219
219
  d += performance.now(); //use high-precision timer if available
220
220
  }
221
221
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
222
- let r = (d + Math.random() * 16) % 16 | 0;
222
+ let r = ((d + Math.random() * 16) % 16) | 0;
223
223
  d = Math.floor(d / 16);
224
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
224
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
225
225
  });
226
226
  }
227
227
 
228
228
  // Compare properties of two objects. Comparison check if all properties in obj1 exists and has same values in obj2
229
229
  function compareObjects(obj1, obj2) {
230
- if ((!obj1) || (!obj2)) {
230
+ if (!obj1 || !obj2) {
231
231
  return false;
232
232
  }
233
233
 
@@ -241,7 +241,7 @@ function compareObjects(obj1, obj2) {
241
241
  return false;
242
242
  }
243
243
 
244
- return (obj1[k] === obj2[k]);
244
+ return obj1[k] === obj2[k];
245
245
  });
246
246
  }
247
247
 
@@ -257,13 +257,13 @@ function createDurationString(milliSeconds) {
257
257
  }
258
258
  // Hour
259
259
  if (seconds / 3600 >= 1) {
260
- s = s + Math.floor(seconds / 3600) % 24 + 'h ';
260
+ s = s + (Math.floor(seconds / 3600) % 24) + 'h ';
261
261
  }
262
262
 
263
263
  // Seconds
264
264
  if (seconds >= 0) {
265
- s = s + ("00" + Math.floor(seconds / 60) % 60).slice(-2) + ':';
266
- s = s + ("00" + (seconds % 60)).slice(-2);
265
+ s = s + ('00' + (Math.floor(seconds / 60) % 60)).slice(-2) + ':';
266
+ s = s + ('00' + (seconds % 60)).slice(-2);
267
267
  } else {
268
268
  s = '00:00';
269
269
  }
@@ -273,23 +273,23 @@ function createDurationString(milliSeconds) {
273
273
 
274
274
  // Browser checks
275
275
  function browserIsOpera() {
276
- return ((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) !== -1)
276
+ return (navigator.userAgent.indexOf('Opera') || navigator.userAgent.indexOf('OPR')) !== -1;
277
277
  }
278
278
 
279
279
  function browserIsChrome() {
280
- return (navigator.userAgent.indexOf("Chrome") !== -1)
280
+ return navigator.userAgent.indexOf('Chrome') !== -1;
281
281
  }
282
282
 
283
283
  function browserIsFirefox() {
284
- return (navigator.userAgent.indexOf("Firefox") !== -1)
284
+ return navigator.userAgent.indexOf('Firefox') !== -1;
285
285
  }
286
286
 
287
287
  function browserIsSafari() {
288
- return (navigator.userAgent.indexOf("Safari") !== -1)
288
+ return navigator.userAgent.indexOf('Safari') !== -1;
289
289
  }
290
290
 
291
291
  function browserIsEdge() {
292
- return (navigator.userAgent.indexOf("Edge") !== -1)
292
+ return navigator.userAgent.indexOf('Edge') !== -1;
293
293
  }
294
294
 
295
295
  // SIP header names are RFC 3261 tokens
@@ -329,6 +329,14 @@ function buildCustomHeaders(setHeader) {
329
329
  });
330
330
  }
331
331
 
332
+ // Rewrite Opus stereo=1 to stereo=0 on every a=fmtp line.
333
+ // Firefox always offers stereo=1 and Media Switches then opens a 2-channel leg, on which
334
+ // the recording carries the same mix on both channels.
335
+ // The result is recordings contain identical audio on both channels, affecting transcription diarization.
336
+ function withoutOpusStereo(sdp) {
337
+ return sdp.replace(/^a=fmtp:.*$/gm, (line) => line.replace(/stereo=1/g, 'stereo=0'));
338
+ }
339
+
332
340
  // Request timeout after 10 sec
333
341
  const REQUEST_TIMEOUT = 10000;
334
342
 
@@ -1541,7 +1549,7 @@ function camelcaseKeys(input, options) {
1541
1549
  // 'use strict';
1542
1550
 
1543
1551
  const options = {
1544
- wssServer: 'wss://api.telegenta.com/sip/',
1552
+ wssServer: 'wss://webrtc.telegenta.com/',
1545
1553
  eventServer: 'wss://esvc.telegenta.com/',
1546
1554
  provisionToken: null,
1547
1555
  authorizationUsername: null,
@@ -1753,10 +1761,7 @@ class Phone extends EventEmitter {
1753
1761
  return false;
1754
1762
  }
1755
1763
  const sinkId = deviceId || '';
1756
- await Promise.all([
1757
- this._remoteAudioElement.setSinkId(sinkId),
1758
- this._toneAudioElement.setSinkId(sinkId),
1759
- ]);
1764
+ await Promise.all([this._remoteAudioElement.setSinkId(sinkId), this._toneAudioElement.setSinkId(sinkId)]);
1760
1765
  return true;
1761
1766
  }
1762
1767
 
@@ -2752,6 +2757,13 @@ class Session extends EventEmitter {
2752
2757
  // Hookup events
2753
2758
  const self = this;
2754
2759
 
2760
+ // make sure to remove stereo=1 from the SDP
2761
+ this._webRTCSession.on('sdp', function (e) {
2762
+ if (e.originator === 'local') {
2763
+ e.sdp = withoutOpusStereo(e.sdp);
2764
+ }
2765
+ });
2766
+
2755
2767
  // ICE CANDIDATES
2756
2768
  this._webRTCSession.on('icecandidate', function (event) {
2757
2769
  const c = event.candidate;
@@ -3881,4 +3893,4 @@ class Session extends EventEmitter {
3881
3893
  }
3882
3894
  }
3883
3895
 
3884
- export { EventClient, EventServiceNotConnected, InvalidMediaDevice, InvalidOptions, InvalidParameter, LOGLVL, LogHandler, MediaNotPrepared, NoActiveSession, NotAllowed, NotReady, Phone, Request, Requestor, Session, UnableToConnect, browserIsChrome, browserIsEdge, browserIsFirefox, browserIsOpera, browserIsSafari, buildCustomHeaders, compareObjects, createDurationString, createUUID };
3896
+ export { EventClient, EventServiceNotConnected, InvalidMediaDevice, InvalidOptions, InvalidParameter, LOGLVL, LogHandler, MediaNotPrepared, NoActiveSession, NotAllowed, NotReady, Phone, Request, Requestor, Session, UnableToConnect, browserIsChrome, browserIsEdge, browserIsFirefox, browserIsOpera, browserIsSafari, buildCustomHeaders, compareObjects, createDurationString, createUUID, withoutOpusStereo };