@wazo/sdk 0.38.17 → 0.38.19

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 (46) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/web-rtc-client.test.js +30 -2
  3. package/esm/checker/Checker.js +30 -2
  4. package/esm/checker/checks/index.js +30 -2
  5. package/esm/checker/checks/webrtc-transport.js +30 -2
  6. package/esm/checker/checks/webrtc.js +30 -2
  7. package/esm/domain/Phone/WebRTCPhone.js +7 -1
  8. package/esm/index.js +37 -2
  9. package/esm/simple/Auth.js +37 -2
  10. package/esm/simple/Configuration.js +37 -2
  11. package/esm/simple/Phone.js +37 -2
  12. package/esm/simple/index.js +37 -2
  13. package/esm/simple/room/LocalParticipant.js +37 -2
  14. package/esm/simple/room/Participant.js +37 -2
  15. package/esm/simple/room/RemoteParticipant.js +37 -2
  16. package/esm/simple/room/Room.js +37 -2
  17. package/esm/simple/room/SipRoom.js +37 -2
  18. package/esm/simple/room/Stream.js +37 -2
  19. package/esm/simple/room/__tests__/Participant.test.js +37 -2
  20. package/esm/simple/room/__tests__/RemoteParticipant.test.js +37 -2
  21. package/esm/simple/utils.js +37 -2
  22. package/esm/web-rtc-client.js +30 -2
  23. package/lib/__tests__/web-rtc-client.test.js +30 -2
  24. package/lib/checker/Checker.js +30 -2
  25. package/lib/checker/checks/index.js +30 -2
  26. package/lib/checker/checks/webrtc-transport.js +30 -2
  27. package/lib/checker/checks/webrtc.js +30 -2
  28. package/lib/domain/Phone/WebRTCPhone.js +7 -0
  29. package/lib/index.js +37 -2
  30. package/lib/simple/Auth.js +37 -2
  31. package/lib/simple/Configuration.js +37 -2
  32. package/lib/simple/Phone.js +37 -2
  33. package/lib/simple/index.js +37 -2
  34. package/lib/simple/room/LocalParticipant.js +37 -2
  35. package/lib/simple/room/Participant.js +37 -2
  36. package/lib/simple/room/RemoteParticipant.js +37 -2
  37. package/lib/simple/room/Room.js +37 -2
  38. package/lib/simple/room/SipRoom.js +37 -2
  39. package/lib/simple/room/Stream.js +37 -2
  40. package/lib/simple/room/__tests__/Participant.test.js +37 -2
  41. package/lib/simple/room/__tests__/RemoteParticipant.test.js +37 -2
  42. package/lib/simple/utils.js +37 -2
  43. package/lib/web-rtc-client.js +30 -2
  44. package/package.json +1 -1
  45. package/src/domain/Phone/WebRTCPhone.js +6 -0
  46. package/src/web-rtc-client.js +30 -2
@@ -7032,6 +7032,7 @@ const MESSAGE = 'message';
7032
7032
  const ACCEPTED = 'accepted';
7033
7033
  const REJECTED = 'rejected';
7034
7034
  const ON_TRACK$1 = 'onTrack';
7035
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7035
7036
  const ON_REINVITE$1 = 'reinvite';
7036
7037
  const ON_ERROR = 'onError';
7037
7038
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7115,6 +7116,7 @@ class WebRTCClient extends Emitter {
7115
7116
 
7116
7117
 
7117
7118
 
7119
+
7118
7120
 
7119
7121
 
7120
7122
  static isAPrivateIp(ip ) {
@@ -7183,6 +7185,7 @@ class WebRTCClient extends Emitter {
7183
7185
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7184
7186
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7185
7187
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7188
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7186
7189
  }
7187
7190
 
7188
7191
  configureMedia(media ) {
@@ -7470,6 +7473,11 @@ class WebRTCClient extends Emitter {
7470
7473
  }
7471
7474
  this._onAccepted(session, response.session, true);
7472
7475
  },
7476
+ onProgress: (payload) => {
7477
+ if (payload.message.statusCode === 183) {
7478
+ this._onEarlyProgress(payload.session);
7479
+ }
7480
+ },
7473
7481
  onReject: (response ) => {
7474
7482
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7475
7483
  this._stopSendingStats(session);
@@ -8862,6 +8870,17 @@ class WebRTCClient extends Emitter {
8862
8870
  };
8863
8871
  }
8864
8872
 
8873
+ _onEarlyProgress(session ) {
8874
+ this._setupMedias(session);
8875
+
8876
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8877
+ this.updateRemoteStream(sessionId);
8878
+
8879
+ logger$8.info('Early media progress progress received', { sessionId });
8880
+
8881
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8882
+ }
8883
+
8865
8884
  _onAccepted(session , sessionDialog , withEvent = true) {
8866
8885
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8867
8886
 
@@ -8913,15 +8932,24 @@ class WebRTCClient extends Emitter {
8913
8932
 
8914
8933
  _setupMedias(session , newStream ) {
8915
8934
  // Safari hack, because you cannot call .play() from a non user action
8916
- const sessionId = this.getSipSessionId(session);
8935
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8917
8936
  const isConference = this.isConference(sessionId);
8918
8937
 
8938
+ if (sessionId in this.audioElements) {
8939
+ logger$8.info('html element already exists for session', { sessionId });
8940
+ return;
8941
+ }
8942
+
8919
8943
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8920
8944
  this.createAudioElementFor(sessionId);
8921
8945
  }
8922
8946
 
8923
8947
  const audioElement = this.audioElements[sessionId];
8924
- const stream = newStream || this.getRemoteStream(sessionId);
8948
+ const sipSession = this.sipSessions[session.callId];
8949
+ const removeStream = this.getRemoteStream(sessionId);
8950
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8951
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8952
+ const stream = newStream || removeStream || earlyStream;
8925
8953
 
8926
8954
  if (!this._isWeb() || !stream) {
8927
8955
  return;
@@ -9253,6 +9281,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9253
9281
  const ON_CHAT = 'phone/ON_CHAT';
9254
9282
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9255
9283
  const ON_DISCONNECTED = 'onDisconnected';
9284
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9256
9285
 
9257
9286
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9258
9287
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9294,6 +9323,7 @@ const events = [
9294
9323
  ON_SIGNAL,
9295
9324
  ON_NETWORK_STATS,
9296
9325
  ON_DISCONNECTED,
9326
+ ON_EARLY_MEDIA,
9297
9327
  ];
9298
9328
 
9299
9329
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10723,6 +10753,10 @@ class WebRTCPhone extends Emitter {
10723
10753
  logger$7.info('WebRTC disconnected');
10724
10754
  this.eventEmitter.emit(ON_DISCONNECTED);
10725
10755
  });
10756
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10757
+ logger$7.info('WebRTC early media');
10758
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10759
+ });
10726
10760
 
10727
10761
  this.client.on(this.client.REGISTERED, () => {
10728
10762
  logger$7.info('WebRTC registered', {
@@ -11006,6 +11040,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11006
11040
  ON_CHAT: ON_CHAT,
11007
11041
  ON_SIGNAL: ON_SIGNAL,
11008
11042
  ON_DISCONNECTED: ON_DISCONNECTED,
11043
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11009
11044
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11010
11045
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11011
11046
  events: events,
@@ -5619,6 +5619,7 @@ const MESSAGE = 'message';
5619
5619
  const ACCEPTED = 'accepted';
5620
5620
  const REJECTED = 'rejected';
5621
5621
  const ON_TRACK = 'onTrack';
5622
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5622
5623
  const ON_REINVITE = 'reinvite';
5623
5624
  const ON_ERROR = 'onError';
5624
5625
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5702,6 +5703,7 @@ class WebRTCClient extends Emitter {
5702
5703
 
5703
5704
 
5704
5705
 
5706
+
5705
5707
 
5706
5708
 
5707
5709
  static isAPrivateIp(ip ) {
@@ -5770,6 +5772,7 @@ class WebRTCClient extends Emitter {
5770
5772
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5771
5773
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5772
5774
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5775
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5773
5776
  }
5774
5777
 
5775
5778
  configureMedia(media ) {
@@ -6057,6 +6060,11 @@ class WebRTCClient extends Emitter {
6057
6060
  }
6058
6061
  this._onAccepted(session, response.session, true);
6059
6062
  },
6063
+ onProgress: (payload) => {
6064
+ if (payload.message.statusCode === 183) {
6065
+ this._onEarlyProgress(payload.session);
6066
+ }
6067
+ },
6060
6068
  onReject: (response ) => {
6061
6069
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6062
6070
  this._stopSendingStats(session);
@@ -7449,6 +7457,17 @@ class WebRTCClient extends Emitter {
7449
7457
  };
7450
7458
  }
7451
7459
 
7460
+ _onEarlyProgress(session ) {
7461
+ this._setupMedias(session);
7462
+
7463
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7464
+ this.updateRemoteStream(sessionId);
7465
+
7466
+ logger.info('Early media progress progress received', { sessionId });
7467
+
7468
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7469
+ }
7470
+
7452
7471
  _onAccepted(session , sessionDialog , withEvent = true) {
7453
7472
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7454
7473
 
@@ -7500,15 +7519,24 @@ class WebRTCClient extends Emitter {
7500
7519
 
7501
7520
  _setupMedias(session , newStream ) {
7502
7521
  // Safari hack, because you cannot call .play() from a non user action
7503
- const sessionId = this.getSipSessionId(session);
7522
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7504
7523
  const isConference = this.isConference(sessionId);
7505
7524
 
7525
+ if (sessionId in this.audioElements) {
7526
+ logger.info('html element already exists for session', { sessionId });
7527
+ return;
7528
+ }
7529
+
7506
7530
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7507
7531
  this.createAudioElementFor(sessionId);
7508
7532
  }
7509
7533
 
7510
7534
  const audioElement = this.audioElements[sessionId];
7511
- const stream = newStream || this.getRemoteStream(sessionId);
7535
+ const sipSession = this.sipSessions[session.callId];
7536
+ const removeStream = this.getRemoteStream(sessionId);
7537
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7538
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7539
+ const stream = newStream || removeStream || earlyStream;
7512
7540
 
7513
7541
  if (!this._isWeb() || !stream) {
7514
7542
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.38.17",
3
+ "version": "0.38.19",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
@@ -54,6 +54,7 @@ export const ON_NETWORK_STATS = 'onNetworkStats';
54
54
  export const ON_CHAT = 'phone/ON_CHAT';
55
55
  export const ON_SIGNAL = 'phone/ON_SIGNAL';
56
56
  export const ON_DISCONNECTED = 'onDisconnected';
57
+ export const ON_EARLY_MEDIA = 'onEarlyMedia';
57
58
 
58
59
  export const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
59
60
  export const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -95,6 +96,7 @@ export const events = [
95
96
  ON_SIGNAL,
96
97
  ON_NETWORK_STATS,
97
98
  ON_DISCONNECTED,
99
+ ON_EARLY_MEDIA,
98
100
  ];
99
101
 
100
102
  const logger = IssueReporter.loggerFor('webrtc-phone');
@@ -1526,6 +1528,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
1526
1528
  logger.info('WebRTC disconnected');
1527
1529
  this.eventEmitter.emit(ON_DISCONNECTED);
1528
1530
  });
1531
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
1532
+ logger.info('WebRTC early media');
1533
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
1534
+ });
1529
1535
 
1530
1536
  this.client.on(this.client.REGISTERED, () => {
1531
1537
  logger.info('WebRTC registered', {
@@ -65,6 +65,7 @@ const MESSAGE = 'message';
65
65
  const ACCEPTED = 'accepted';
66
66
  const REJECTED = 'rejected';
67
67
  const ON_TRACK = 'onTrack';
68
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
68
69
  const ON_REINVITE = 'reinvite';
69
70
  const ON_ERROR = 'onError';
70
71
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -148,6 +149,7 @@ export default class WebRTCClient extends Emitter {
148
149
  ON_ERROR: string;
149
150
  ON_SCREEN_SHARING_REINVITE: string;
150
151
  ON_NETWORK_STATS: string;
152
+ ON_EARLY_MEDIA: string;
151
153
  ON_DISCONNECTED: string;
152
154
 
153
155
  static isAPrivateIp(ip: string): boolean {
@@ -216,6 +218,7 @@ export default class WebRTCClient extends Emitter {
216
218
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
217
219
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
218
220
  this.ON_DISCONNECTED = ON_DISCONNECTED;
221
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
219
222
  }
220
223
 
221
224
  configureMedia(media: MediaConfig) {
@@ -503,6 +506,11 @@ export default class WebRTCClient extends Emitter {
503
506
  }
504
507
  this._onAccepted(session, response.session, true);
505
508
  },
509
+ onProgress: (payload) => {
510
+ if (payload.message.statusCode === 183) {
511
+ this._onEarlyProgress(payload.session);
512
+ }
513
+ },
506
514
  onReject: (response: IncomingResponse) => {
507
515
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
508
516
  this._stopSendingStats(session);
@@ -1895,6 +1903,17 @@ export default class WebRTCClient extends Emitter {
1895
1903
  };
1896
1904
  }
1897
1905
 
1906
+ _onEarlyProgress(session: SessionDialog) {
1907
+ this._setupMedias(session);
1908
+
1909
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
1910
+ this.updateRemoteStream(sessionId);
1911
+
1912
+ logger.info('Early media progress progress received', { sessionId });
1913
+
1914
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
1915
+ }
1916
+
1898
1917
  _onAccepted(session: Session, sessionDialog?: SessionDialog, withEvent: boolean = true) {
1899
1918
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
1900
1919
 
@@ -1946,15 +1965,24 @@ export default class WebRTCClient extends Emitter {
1946
1965
 
1947
1966
  _setupMedias(session: Session, newStream: ?MediaStream) {
1948
1967
  // Safari hack, because you cannot call .play() from a non user action
1949
- const sessionId = this.getSipSessionId(session);
1968
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
1950
1969
  const isConference = this.isConference(sessionId);
1951
1970
 
1971
+ if (sessionId in this.audioElements) {
1972
+ logger.info('html element already exists for session', { sessionId });
1973
+ return;
1974
+ }
1975
+
1952
1976
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
1953
1977
  this.createAudioElementFor(sessionId);
1954
1978
  }
1955
1979
 
1956
1980
  const audioElement = this.audioElements[sessionId];
1957
- const stream = newStream || this.getRemoteStream(sessionId);
1981
+ const sipSession = this.sipSessions[session.callId];
1982
+ const removeStream = this.getRemoteStream(sessionId);
1983
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
1984
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
1985
+ const stream = newStream || removeStream || earlyStream;
1958
1986
 
1959
1987
  if (!this._isWeb() || !stream) {
1960
1988
  return;