@signalwire/js 1.3.0-dev.1 → 1.4.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.
Files changed (69) hide show
  1. package/README.md +4 -2
  2. package/dist/esm/common/src/BaseSession.d.ts +8 -13
  3. package/dist/esm/common/src/BaseSession.js +33 -46
  4. package/dist/esm/common/src/BrowserSession.d.ts +20 -57
  5. package/dist/esm/common/src/BrowserSession.js +91 -359
  6. package/dist/esm/common/src/messages/Verto.d.ts +1 -10
  7. package/dist/esm/common/src/messages/Verto.js +1 -16
  8. package/dist/esm/common/src/messages/verto/Login.d.ts +1 -13
  9. package/dist/esm/common/src/messages/verto/Login.js +2 -5
  10. package/dist/esm/common/src/services/BroadcastHandler.js +3 -2
  11. package/dist/esm/common/src/services/Connection.d.ts +2 -2
  12. package/dist/esm/common/src/services/Handler.d.ts +8 -9
  13. package/dist/esm/common/src/services/Handler.js +38 -41
  14. package/dist/esm/common/src/util/constants/index.d.ts +0 -1
  15. package/dist/esm/common/src/util/constants/index.js +0 -1
  16. package/dist/esm/common/src/util/helpers.d.ts +10 -3
  17. package/dist/esm/common/src/util/helpers.js +11 -6
  18. package/dist/esm/common/src/util/interfaces.d.ts +56 -21
  19. package/dist/esm/common/src/util/interfaces.js +1 -0
  20. package/dist/esm/common/src/util/logger.js +1 -4
  21. package/dist/esm/common/src/util/webrtc/index.d.ts +2 -7
  22. package/dist/esm/common/src/util/webrtc/index.js +2 -63
  23. package/dist/esm/common/src/webrtc/BaseCall.d.ts +79 -0
  24. package/dist/esm/common/src/webrtc/BaseCall.js +711 -0
  25. package/dist/esm/common/src/webrtc/Call.d.ts +5 -5
  26. package/dist/esm/common/src/webrtc/Call.js +15 -34
  27. package/dist/esm/common/src/webrtc/CantinaAuth.d.ts +14 -9
  28. package/dist/esm/common/src/webrtc/CantinaAuth.js +18 -24
  29. package/dist/esm/common/src/webrtc/LayoutHandler.d.ts +3 -0
  30. package/dist/esm/common/src/webrtc/LayoutHandler.js +36 -0
  31. package/dist/esm/common/src/webrtc/Peer.d.ts +23 -0
  32. package/dist/esm/common/src/webrtc/Peer.js +169 -0
  33. package/dist/esm/common/src/webrtc/VertoHandler.d.ts +11 -2
  34. package/dist/esm/common/src/webrtc/VertoHandler.js +187 -147
  35. package/dist/esm/common/src/webrtc/constants.d.ts +12 -27
  36. package/dist/esm/common/src/webrtc/constants.js +11 -33
  37. package/dist/esm/common/src/webrtc/helpers.d.ts +25 -19
  38. package/dist/esm/common/src/webrtc/helpers.js +190 -162
  39. package/dist/esm/common/src/webrtc/interfaces.d.ts +52 -209
  40. package/dist/esm/common/src/webrtc/interfaces.js +1 -0
  41. package/dist/esm/js/index.d.ts +1 -3
  42. package/dist/esm/js/index.js +2 -2
  43. package/dist/esm/js/src/SignalWire.d.ts +2 -0
  44. package/dist/esm/js/src/SignalWire.js +13 -0
  45. package/dist/esm/js/src/Verto.d.ts +2 -8
  46. package/dist/esm/js/src/Verto.js +14 -50
  47. package/dist/index.min.js +2 -6
  48. package/dist/index.min.js.LICENSE.txt +5 -0
  49. package/package.json +24 -19
  50. package/dist/esm/common/src/webrtc/ChatChannelHandler.d.ts +0 -5
  51. package/dist/esm/common/src/webrtc/ChatChannelHandler.js +0 -22
  52. package/dist/esm/common/src/webrtc/Conference.d.ts +0 -15
  53. package/dist/esm/common/src/webrtc/Conference.js +0 -68
  54. package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.d.ts +0 -5
  55. package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.js +0 -77
  56. package/dist/esm/common/src/webrtc/InfoChannelHandler.d.ts +0 -7
  57. package/dist/esm/common/src/webrtc/InfoChannelHandler.js +0 -85
  58. package/dist/esm/common/src/webrtc/LaChannelHandler.d.ts +0 -5
  59. package/dist/esm/common/src/webrtc/LaChannelHandler.js +0 -58
  60. package/dist/esm/common/src/webrtc/ModChannelHandler.d.ts +0 -71
  61. package/dist/esm/common/src/webrtc/ModChannelHandler.js +0 -267
  62. package/dist/esm/common/src/webrtc/RTCPeer.d.ts +0 -51
  63. package/dist/esm/common/src/webrtc/RTCPeer.js +0 -556
  64. package/dist/esm/common/src/webrtc/WebRTCCall.d.ts +0 -182
  65. package/dist/esm/common/src/webrtc/WebRTCCall.js +0 -784
  66. package/dist/esm/common/src/webrtc/deviceHelpers.d.ts +0 -18
  67. package/dist/esm/common/src/webrtc/deviceHelpers.js +0 -113
  68. package/dist/esm/common/src/webrtc/sdpHelpers.d.ts +0 -3
  69. package/dist/esm/common/src/webrtc/sdpHelpers.js +0 -56
@@ -1,11 +1,11 @@
1
- import WebRTCCall from './WebRTCCall';
1
+ import BaseCall from './BaseCall';
2
2
  import { CallOptions } from './interfaces';
3
- export default class Call extends WebRTCCall {
3
+ export default class Call extends BaseCall {
4
+ screenShare: Call;
4
5
  private _statsInterval;
5
- startScreenShare(opts?: CallOptions): Promise<WebRTCCall>;
6
+ hangup(params?: any, execute?: boolean): void;
7
+ startScreenShare(opts?: CallOptions): Promise<Call>;
6
8
  stopScreenShare(): void;
7
- addSecondSource(opts?: CallOptions): Promise<WebRTCCall>;
8
- removeSecondSource(): void;
9
9
  setAudioOutDevice(deviceId: string): Promise<boolean>;
10
10
  protected _finalize(): void;
11
11
  private _stats;
@@ -8,19 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import logger from '../util/logger';
11
- import WebRTCCall from './WebRTCCall';
11
+ import BaseCall from './BaseCall';
12
12
  import { getDisplayMedia, setMediaElementSinkId } from '../util/webrtc';
13
- import { Notification } from './constants';
14
- export default class Call extends WebRTCCall {
13
+ export default class Call extends BaseCall {
15
14
  constructor() {
16
15
  super(...arguments);
17
16
  this._statsInterval = null;
18
17
  }
18
+ hangup(params = {}, execute = true) {
19
+ if (this.screenShare instanceof Call) {
20
+ this.screenShare.hangup(params, execute);
21
+ }
22
+ super.hangup(params, execute);
23
+ }
19
24
  startScreenShare(opts) {
20
25
  return __awaiter(this, void 0, void 0, function* () {
21
- const { audio = false, video = true } = (opts || {});
22
- const displayStream = yield getDisplayMedia({ audio, video });
23
- displayStream.getVideoTracks().forEach(t => {
26
+ const displayStream = yield getDisplayMedia({ video: true });
27
+ displayStream.getTracks().forEach(t => {
24
28
  t.addEventListener('ended', () => {
25
29
  if (this.screenShare) {
26
30
  this.screenShare.hangup();
@@ -28,8 +32,7 @@ export default class Call extends WebRTCCall {
28
32
  });
29
33
  });
30
34
  const { remoteCallerName, remoteCallerNumber, callerName, callerNumber } = this.options;
31
- const options = Object.assign({ screenShare: true, recoverCall: false, skipLiveArray: true, skipNotifications: true, localStream: displayStream, destinationNumber: this.extension, remoteCallerName,
32
- remoteCallerNumber, callerName: `${callerName} (Screen)`, callerNumber: `${callerNumber} (Screen)` }, opts);
35
+ const options = Object.assign({ screenShare: true, localStream: displayStream, destinationNumber: `${this.extension}-screen`, remoteCallerName, remoteCallerNumber: `${remoteCallerNumber}-screen`, callerName: `${callerName} (Screen)`, callerNumber: `${callerNumber} (Screen)` }, opts);
33
36
  this.screenShare = new Call(this.session, options);
34
37
  this.screenShare.invite();
35
38
  return this.screenShare;
@@ -40,36 +43,14 @@ export default class Call extends WebRTCCall {
40
43
  this.screenShare.hangup();
41
44
  }
42
45
  }
43
- addSecondSource(opts) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const { remoteCallerName, remoteCallerNumber, callerName, callerNumber } = this.options;
46
- const options = Object.assign({ secondSource: true, recoverCall: false, skipLiveArray: true, skipNotifications: true, destinationNumber: this.extension, remoteCallerName,
47
- remoteCallerNumber, callerName: `${callerName} (Second Source)`, callerNumber: `${callerNumber} (Second Source)`, localStream: null }, opts);
48
- this.secondSource = new Call(this.session, options);
49
- this.secondSource.invite();
50
- return this.secondSource;
51
- });
52
- }
53
- removeSecondSource() {
54
- if (this.secondSource instanceof Call) {
55
- this.secondSource.hangup();
56
- }
57
- }
58
46
  setAudioOutDevice(deviceId) {
59
47
  return __awaiter(this, void 0, void 0, function* () {
60
48
  this.options.speakerId = deviceId;
61
- const { remoteElement, speakerId, experimental } = this.options;
62
- if (experimental === true) {
63
- try {
64
- yield this.audioElements[0].setSinkId(speakerId);
65
- this._dispatchNotification({ type: Notification.DeviceUpdated });
66
- }
67
- catch (error) {
68
- console.error('setAudioOutDevice error', this.audioElements, speakerId);
69
- }
70
- return;
49
+ const { remoteElement, speakerId } = this.options;
50
+ if (remoteElement && speakerId) {
51
+ return setMediaElementSinkId(remoteElement, speakerId);
71
52
  }
72
- return setMediaElementSinkId(remoteElement, speakerId);
53
+ return false;
73
54
  });
74
55
  }
75
56
  _finalize() {
@@ -1,17 +1,22 @@
1
- import { ICantinaUser } from './interfaces';
2
- declare type BootstrapResponse = {
3
- project_id: string;
4
- };
5
- declare type RefreshResponse = {
1
+ import { ICantinaAuthParams, ICantinaUser } from './interfaces';
2
+ type RefreshResponse = {
3
+ project: string;
6
4
  jwt_token: string;
7
5
  };
6
+ type CheckInviteTokenResponse = {
7
+ valid: boolean;
8
+ name: string;
9
+ config: object;
10
+ };
8
11
  declare class CantinaAuth {
12
+ private params;
9
13
  baseUrl: string;
10
14
  hostname: string;
15
+ constructor(params?: ICantinaAuthParams);
11
16
  private _fetch;
12
- bootstrap(hostname: string): Promise<BootstrapResponse>;
13
- login(username: string, project_id: string): Promise<ICantinaUser>;
14
- refresh(refreshToken?: any): Promise<RefreshResponse>;
15
- logout(): Promise<void>;
17
+ userLogin(username: string, password: string): Promise<ICantinaUser>;
18
+ guestLogin(name: string, email: string, token: string): Promise<ICantinaUser>;
19
+ refresh(): Promise<RefreshResponse>;
20
+ checkInviteToken(token: string): Promise<CheckInviteTokenResponse>;
16
21
  }
17
22
  export default CantinaAuth;
@@ -16,57 +16,51 @@ const FETCH_OPTIONS = {
16
16
  }
17
17
  };
18
18
  class CantinaAuth {
19
- constructor() {
20
- this.baseUrl = '';
19
+ constructor(params = {}) {
20
+ this.params = params;
21
+ this.baseUrl = 'https://cantina-backend.signalwire.com';
21
22
  this._fetch = (url, options) => {
22
23
  return fetch(url, options).then((response) => __awaiter(this, void 0, void 0, function* () {
24
+ const payload = yield response.json();
23
25
  if (response.status >= 200 && response.status < 300) {
24
- if (response.status === 204) {
25
- return response;
26
- }
27
- const payload = yield response.json();
28
26
  return payload;
29
27
  }
30
28
  else {
31
29
  const errorMessage = `HTTP Request failed with status ${response.status}`;
32
30
  const error = new Error(errorMessage);
33
- error.response = response;
31
+ error.payload = payload;
34
32
  return Promise.reject(error);
35
33
  }
36
34
  }));
37
35
  };
36
+ const { hostname = location.hostname } = params;
37
+ this.hostname = hostname;
38
38
  }
39
- bootstrap(hostname) {
39
+ userLogin(username, password) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
- const clear = encodeURIComponent(hostname);
42
- const url = `${this.baseUrl}/api/configuration?hostname=${clear}`;
43
- const response = yield this._fetch(url, Object.assign(Object.assign({}, FETCH_OPTIONS), { method: 'GET' }));
44
- logger.info('bootstrap response', response);
41
+ const response = yield this._fetch(`${this.baseUrl}/login/user`, Object.assign(Object.assign({}, FETCH_OPTIONS), { body: JSON.stringify({ username, password, hostname: this.hostname }) }));
42
+ logger.info('userLogin response', response);
45
43
  return response;
46
44
  });
47
45
  }
48
- login(username, project_id) {
46
+ guestLogin(name, email, token) {
49
47
  return __awaiter(this, void 0, void 0, function* () {
50
- const response = yield this._fetch(`${this.baseUrl}/api/login`, Object.assign(Object.assign({}, FETCH_OPTIONS), { body: JSON.stringify({ username, project_id }) }));
51
- logger.info('userLogin response', response);
48
+ const response = yield this._fetch(`${this.baseUrl}/login/guest`, Object.assign(Object.assign({}, FETCH_OPTIONS), { body: JSON.stringify({ name, email, token, hostname: this.hostname }) }));
49
+ logger.info('guestLogin response', response);
52
50
  return response;
53
51
  });
54
52
  }
55
- refresh(refreshToken = null) {
53
+ refresh() {
56
54
  return __awaiter(this, void 0, void 0, function* () {
57
- const options = Object.assign(Object.assign({}, FETCH_OPTIONS), { method: 'PUT' });
58
- if (refreshToken) {
59
- options.body = JSON.stringify({ refresh_token: refreshToken });
60
- }
61
- const response = yield this._fetch(`${this.baseUrl}/api/refresh`, options);
55
+ const response = yield this._fetch(`${this.baseUrl}/refresh`, Object.assign(Object.assign({}, FETCH_OPTIONS), { method: 'PUT', body: JSON.stringify({ hostname: this.hostname }) }));
62
56
  logger.info('refresh response', response);
63
57
  return response;
64
58
  });
65
59
  }
66
- logout() {
60
+ checkInviteToken(token) {
67
61
  return __awaiter(this, void 0, void 0, function* () {
68
- const response = yield this._fetch(`${this.baseUrl}/api/logout`, Object.assign(Object.assign({}, FETCH_OPTIONS), { method: 'PUT' }));
69
- logger.info('logout response', response);
62
+ const response = yield this._fetch(`${this.baseUrl}/check-token`, Object.assign(Object.assign({}, FETCH_OPTIONS), { body: JSON.stringify({ token, hostname: this.hostname }) }));
63
+ logger.info('checkInviteToken response', response);
70
64
  return response;
71
65
  });
72
66
  }
@@ -0,0 +1,3 @@
1
+ import BrowserSession from '../BrowserSession';
2
+ declare const MCULayoutEventHandler: (session: BrowserSession, eventData: any) => void;
3
+ export { MCULayoutEventHandler };
@@ -0,0 +1,36 @@
1
+ import { NOTIFICATION_TYPE, ConferenceAction } from './constants';
2
+ import { SwEvent } from '../util/constants';
3
+ import { trigger } from '../services/Handler';
4
+ import { safeParseJson } from '../util/helpers';
5
+ const MCULayoutEventHandler = (session, eventData) => {
6
+ const { contentType, canvasType, callID, canvasInfo = null, currentLayerIdx = -1 } = eventData;
7
+ if (canvasInfo && canvasType !== 'mcu-personal-canvas') {
8
+ delete canvasInfo.memberID;
9
+ }
10
+ const data = {
11
+ type: NOTIFICATION_TYPE.conferenceUpdate,
12
+ call: session.calls[callID],
13
+ canvasInfo: _clearCanvasInfo(canvasInfo),
14
+ currentLayerIdx
15
+ };
16
+ switch (contentType) {
17
+ case 'layer-info': {
18
+ const notification = Object.assign({ action: ConferenceAction.LayerInfo }, data);
19
+ trigger(SwEvent.Notification, notification, session.uuid);
20
+ break;
21
+ }
22
+ case 'layout-info': {
23
+ const notification = Object.assign({ action: ConferenceAction.LayoutInfo }, data);
24
+ trigger(SwEvent.Notification, notification, session.uuid);
25
+ break;
26
+ }
27
+ }
28
+ };
29
+ const _clearCanvasInfo = (canvasInfo) => {
30
+ const tmp = JSON.stringify(canvasInfo)
31
+ .replace(/memberID/g, 'participantId')
32
+ .replace(/ID"/g, 'Id"')
33
+ .replace(/POS"/g, 'Pos"');
34
+ return safeParseJson(tmp);
35
+ };
36
+ export { MCULayoutEventHandler };
@@ -0,0 +1,23 @@
1
+ import { PeerType } from './constants';
2
+ import { CallOptions } from './interfaces';
3
+ export default class Peer {
4
+ type: PeerType;
5
+ private options;
6
+ instance: RTCPeerConnection;
7
+ onSdpReadyTwice: Function;
8
+ private _constraints;
9
+ private _negotiating;
10
+ constructor(type: PeerType, options: CallOptions);
11
+ startNegotiation(): void;
12
+ private _init;
13
+ private _createOffer;
14
+ private _createAnswer;
15
+ private _setLocalDescription;
16
+ private _sdpReady;
17
+ private _retrieveLocalStream;
18
+ private _isOffer;
19
+ private _isAnswer;
20
+ private _config;
21
+ private _getSenderByKind;
22
+ applyMediaConstraints(kind: string, constraints: MediaTrackConstraints): Promise<void>;
23
+ }
@@ -0,0 +1,169 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import logger from '../util/logger';
11
+ import { getUserMedia, getMediaConstraints, sdpStereoHack, sdpBitrateHack } from './helpers';
12
+ import { SwEvent } from '../util/constants';
13
+ import { PeerType } from './constants';
14
+ import { attachMediaStream, muteMediaElement, sdpToJsonHack, RTCPeerConnection, streamIsValid } from '../util/webrtc';
15
+ import { isFunction } from '../util/helpers';
16
+ import { trigger } from '../services/Handler';
17
+ import { filterIceServers } from './helpers';
18
+ export default class Peer {
19
+ constructor(type, options) {
20
+ this.type = type;
21
+ this.options = options;
22
+ this.onSdpReadyTwice = null;
23
+ this._negotiating = false;
24
+ logger.info('New Peer with type:', this.type, 'Options:', this.options);
25
+ this._constraints = { offerToReceiveAudio: true, offerToReceiveVideo: true };
26
+ this._sdpReady = this._sdpReady.bind(this);
27
+ this._init();
28
+ }
29
+ startNegotiation() {
30
+ this._negotiating = true;
31
+ if (this._isOffer()) {
32
+ this._createOffer();
33
+ }
34
+ else {
35
+ this._createAnswer();
36
+ }
37
+ }
38
+ _init() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ this.instance = RTCPeerConnection(this._config());
41
+ this.instance.onsignalingstatechange = event => {
42
+ switch (this.instance.signalingState) {
43
+ case 'stable':
44
+ this._negotiating = false;
45
+ break;
46
+ case 'closed':
47
+ this.instance = null;
48
+ break;
49
+ default:
50
+ this._negotiating = true;
51
+ }
52
+ };
53
+ this.instance.onnegotiationneeded = event => {
54
+ if (this._negotiating) {
55
+ logger.debug('Skip twice onnegotiationneeded..');
56
+ return;
57
+ }
58
+ this.startNegotiation();
59
+ };
60
+ this.options.localStream = yield this._retrieveLocalStream()
61
+ .catch(error => {
62
+ trigger(SwEvent.MediaError, error, this.options.id);
63
+ return null;
64
+ });
65
+ const { localElement, localStream = null, screenShare = false } = this.options;
66
+ if (streamIsValid(localStream)) {
67
+ if (typeof this.instance.addTrack === 'function') {
68
+ localStream.getTracks().forEach(t => this.instance.addTrack(t, localStream));
69
+ }
70
+ else {
71
+ this.instance.addStream(localStream);
72
+ }
73
+ if (screenShare !== true) {
74
+ muteMediaElement(localElement);
75
+ attachMediaStream(localElement, localStream);
76
+ }
77
+ }
78
+ else if (localStream === null) {
79
+ this.startNegotiation();
80
+ }
81
+ });
82
+ }
83
+ _createOffer() {
84
+ if (!this._isOffer()) {
85
+ return;
86
+ }
87
+ this.instance.createOffer(this._constraints)
88
+ .then(this._setLocalDescription.bind(this))
89
+ .then(this._sdpReady)
90
+ .catch(error => logger.error('Peer _createOffer error:', error));
91
+ }
92
+ _createAnswer() {
93
+ if (!this._isAnswer()) {
94
+ return;
95
+ }
96
+ const { remoteSdp, useStereo } = this.options;
97
+ const sdp = useStereo ? sdpStereoHack(remoteSdp) : remoteSdp;
98
+ const sessionDescr = sdpToJsonHack({ sdp, type: PeerType.Offer });
99
+ this.instance.setRemoteDescription(sessionDescr)
100
+ .then(() => this.instance.createAnswer())
101
+ .then(this._setLocalDescription.bind(this))
102
+ .then(this._sdpReady)
103
+ .catch(error => logger.error('Peer _createAnswer error:', error));
104
+ }
105
+ _setLocalDescription(sessionDescription) {
106
+ const { useStereo, googleMaxBitrate, googleMinBitrate, googleStartBitrate } = this.options;
107
+ if (useStereo) {
108
+ sessionDescription.sdp = sdpStereoHack(sessionDescription.sdp);
109
+ }
110
+ if (googleMaxBitrate && googleMinBitrate && googleStartBitrate) {
111
+ sessionDescription.sdp = sdpBitrateHack(sessionDescription.sdp, googleMaxBitrate, googleMinBitrate, googleStartBitrate);
112
+ }
113
+ return this.instance.setLocalDescription(sessionDescription);
114
+ }
115
+ _sdpReady() {
116
+ if (isFunction(this.onSdpReadyTwice)) {
117
+ this.onSdpReadyTwice(this.instance.localDescription);
118
+ }
119
+ }
120
+ _retrieveLocalStream() {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ if (streamIsValid(this.options.localStream)) {
123
+ return this.options.localStream;
124
+ }
125
+ const constraints = yield getMediaConstraints(this.options);
126
+ return getUserMedia(constraints);
127
+ });
128
+ }
129
+ _isOffer() {
130
+ return this.type === PeerType.Offer;
131
+ }
132
+ _isAnswer() {
133
+ return this.type === PeerType.Answer;
134
+ }
135
+ _config() {
136
+ const { iceServers = [], iceTransportPolicy = 'all', disableUdpIceServers = false } = this.options;
137
+ const filteredIceServers = filterIceServers(iceServers, { disableUdpIceServers });
138
+ const config = {
139
+ iceTransportPolicy,
140
+ sdpSemantics: 'unified-plan',
141
+ bundlePolicy: 'max-compat',
142
+ iceServers: filteredIceServers,
143
+ };
144
+ logger.info('RTC config', config);
145
+ return config;
146
+ }
147
+ _getSenderByKind(kind) {
148
+ if (this.instance) {
149
+ return this.instance.getSenders().find(({ track }) => (track && track.kind === kind));
150
+ }
151
+ }
152
+ applyMediaConstraints(kind, constraints) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ try {
155
+ const sender = this._getSenderByKind(kind);
156
+ if (!sender || !sender.track) {
157
+ return logger.info('No sender to apply constraints', kind, constraints);
158
+ }
159
+ if (sender.track.readyState === 'live') {
160
+ logger.info(`Apply ${kind} constraints`, this.options.id, constraints);
161
+ yield sender.track.applyConstraints(constraints);
162
+ }
163
+ }
164
+ catch (error) {
165
+ logger.error('Error applying constraints', kind, constraints);
166
+ }
167
+ });
168
+ }
169
+ }
@@ -1,3 +1,12 @@
1
1
  import BrowserSession from '../BrowserSession';
2
- declare const _default: (session: BrowserSession, msg: any) => any;
3
- export default _default;
2
+ declare class VertoHandler {
3
+ session: BrowserSession;
4
+ nodeId: string;
5
+ constructor(session: BrowserSession);
6
+ private _ack;
7
+ handleMessage(msg: any): Promise<void>;
8
+ private _retrieveCallId;
9
+ private _handlePvtEvent;
10
+ private _handleSessionEvent;
11
+ }
12
+ export default VertoHandler;