@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
@@ -7030,6 +7030,7 @@ const MESSAGE = 'message';
7030
7030
  const ACCEPTED = 'accepted';
7031
7031
  const REJECTED = 'rejected';
7032
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7033
7034
  const ON_REINVITE$1 = 'reinvite';
7034
7035
  const ON_ERROR = 'onError';
7035
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7113,6 +7114,7 @@ class WebRTCClient extends Emitter {
7113
7114
 
7114
7115
 
7115
7116
 
7117
+
7116
7118
 
7117
7119
 
7118
7120
  static isAPrivateIp(ip ) {
@@ -7181,6 +7183,7 @@ class WebRTCClient extends Emitter {
7181
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7182
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7183
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7184
7187
  }
7185
7188
 
7186
7189
  configureMedia(media ) {
@@ -7468,6 +7471,11 @@ class WebRTCClient extends Emitter {
7468
7471
  }
7469
7472
  this._onAccepted(session, response.session, true);
7470
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7471
7479
  onReject: (response ) => {
7472
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7473
7481
  this._stopSendingStats(session);
@@ -8860,6 +8868,17 @@ class WebRTCClient extends Emitter {
8860
8868
  };
8861
8869
  }
8862
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8863
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8864
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8865
8884
 
@@ -8911,15 +8930,24 @@ class WebRTCClient extends Emitter {
8911
8930
 
8912
8931
  _setupMedias(session , newStream ) {
8913
8932
  // Safari hack, because you cannot call .play() from a non user action
8914
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8915
8934
  const isConference = this.isConference(sessionId);
8916
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8917
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8918
8942
  this.createAudioElementFor(sessionId);
8919
8943
  }
8920
8944
 
8921
8945
  const audioElement = this.audioElements[sessionId];
8922
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8949
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8950
+ const stream = newStream || removeStream || earlyStream;
8923
8951
 
8924
8952
  if (!this._isWeb() || !stream) {
8925
8953
  return;
@@ -9251,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9279
  const ON_CHAT = 'phone/ON_CHAT';
9252
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9283
 
9255
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9321,7 @@ const events = [
9292
9321
  ON_SIGNAL,
9293
9322
  ON_NETWORK_STATS,
9294
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9295
9325
  ];
9296
9326
 
9297
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10721
10751
  logger$7.info('WebRTC disconnected');
10722
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10724
10758
 
10725
10759
  this.client.on(this.client.REGISTERED, () => {
10726
10760
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11038
  ON_CHAT: ON_CHAT,
11005
11039
  ON_SIGNAL: ON_SIGNAL,
11006
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11044
  events: events,
@@ -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,
@@ -7030,6 +7030,7 @@ const MESSAGE = 'message';
7030
7030
  const ACCEPTED = 'accepted';
7031
7031
  const REJECTED = 'rejected';
7032
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7033
7034
  const ON_REINVITE$1 = 'reinvite';
7034
7035
  const ON_ERROR = 'onError';
7035
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7113,6 +7114,7 @@ class WebRTCClient extends Emitter {
7113
7114
 
7114
7115
 
7115
7116
 
7117
+
7116
7118
 
7117
7119
 
7118
7120
  static isAPrivateIp(ip ) {
@@ -7181,6 +7183,7 @@ class WebRTCClient extends Emitter {
7181
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7182
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7183
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7184
7187
  }
7185
7188
 
7186
7189
  configureMedia(media ) {
@@ -7468,6 +7471,11 @@ class WebRTCClient extends Emitter {
7468
7471
  }
7469
7472
  this._onAccepted(session, response.session, true);
7470
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7471
7479
  onReject: (response ) => {
7472
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7473
7481
  this._stopSendingStats(session);
@@ -8860,6 +8868,17 @@ class WebRTCClient extends Emitter {
8860
8868
  };
8861
8869
  }
8862
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8863
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8864
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8865
8884
 
@@ -8911,15 +8930,24 @@ class WebRTCClient extends Emitter {
8911
8930
 
8912
8931
  _setupMedias(session , newStream ) {
8913
8932
  // Safari hack, because you cannot call .play() from a non user action
8914
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8915
8934
  const isConference = this.isConference(sessionId);
8916
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8917
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8918
8942
  this.createAudioElementFor(sessionId);
8919
8943
  }
8920
8944
 
8921
8945
  const audioElement = this.audioElements[sessionId];
8922
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8949
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8950
+ const stream = newStream || removeStream || earlyStream;
8923
8951
 
8924
8952
  if (!this._isWeb() || !stream) {
8925
8953
  return;
@@ -9251,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9279
  const ON_CHAT = 'phone/ON_CHAT';
9252
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9283
 
9255
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9321,7 @@ const events = [
9292
9321
  ON_SIGNAL,
9293
9322
  ON_NETWORK_STATS,
9294
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9295
9325
  ];
9296
9326
 
9297
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10721
10751
  logger$7.info('WebRTC disconnected');
10722
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10724
10758
 
10725
10759
  this.client.on(this.client.REGISTERED, () => {
10726
10760
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11038
  ON_CHAT: ON_CHAT,
11005
11039
  ON_SIGNAL: ON_SIGNAL,
11006
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11044
  events: events,
@@ -7030,6 +7030,7 @@ const MESSAGE = 'message';
7030
7030
  const ACCEPTED = 'accepted';
7031
7031
  const REJECTED = 'rejected';
7032
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7033
7034
  const ON_REINVITE$1 = 'reinvite';
7034
7035
  const ON_ERROR = 'onError';
7035
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7113,6 +7114,7 @@ class WebRTCClient extends Emitter {
7113
7114
 
7114
7115
 
7115
7116
 
7117
+
7116
7118
 
7117
7119
 
7118
7120
  static isAPrivateIp(ip ) {
@@ -7181,6 +7183,7 @@ class WebRTCClient extends Emitter {
7181
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7182
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7183
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7184
7187
  }
7185
7188
 
7186
7189
  configureMedia(media ) {
@@ -7468,6 +7471,11 @@ class WebRTCClient extends Emitter {
7468
7471
  }
7469
7472
  this._onAccepted(session, response.session, true);
7470
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7471
7479
  onReject: (response ) => {
7472
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7473
7481
  this._stopSendingStats(session);
@@ -8860,6 +8868,17 @@ class WebRTCClient extends Emitter {
8860
8868
  };
8861
8869
  }
8862
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8863
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8864
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8865
8884
 
@@ -8911,15 +8930,24 @@ class WebRTCClient extends Emitter {
8911
8930
 
8912
8931
  _setupMedias(session , newStream ) {
8913
8932
  // Safari hack, because you cannot call .play() from a non user action
8914
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8915
8934
  const isConference = this.isConference(sessionId);
8916
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8917
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8918
8942
  this.createAudioElementFor(sessionId);
8919
8943
  }
8920
8944
 
8921
8945
  const audioElement = this.audioElements[sessionId];
8922
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8949
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8950
+ const stream = newStream || removeStream || earlyStream;
8923
8951
 
8924
8952
  if (!this._isWeb() || !stream) {
8925
8953
  return;
@@ -9251,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9279
  const ON_CHAT = 'phone/ON_CHAT';
9252
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9283
 
9255
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9321,7 @@ const events = [
9292
9321
  ON_SIGNAL,
9293
9322
  ON_NETWORK_STATS,
9294
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9295
9325
  ];
9296
9326
 
9297
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10721
10751
  logger$7.info('WebRTC disconnected');
10722
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10724
10758
 
10725
10759
  this.client.on(this.client.REGISTERED, () => {
10726
10760
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11038
  ON_CHAT: ON_CHAT,
11005
11039
  ON_SIGNAL: ON_SIGNAL,
11006
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11044
  events: events,
@@ -7030,6 +7030,7 @@ const MESSAGE = 'message';
7030
7030
  const ACCEPTED = 'accepted';
7031
7031
  const REJECTED = 'rejected';
7032
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7033
7034
  const ON_REINVITE$1 = 'reinvite';
7034
7035
  const ON_ERROR = 'onError';
7035
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7113,6 +7114,7 @@ class WebRTCClient extends Emitter {
7113
7114
 
7114
7115
 
7115
7116
 
7117
+
7116
7118
 
7117
7119
 
7118
7120
  static isAPrivateIp(ip ) {
@@ -7181,6 +7183,7 @@ class WebRTCClient extends Emitter {
7181
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7182
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7183
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7184
7187
  }
7185
7188
 
7186
7189
  configureMedia(media ) {
@@ -7468,6 +7471,11 @@ class WebRTCClient extends Emitter {
7468
7471
  }
7469
7472
  this._onAccepted(session, response.session, true);
7470
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7471
7479
  onReject: (response ) => {
7472
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7473
7481
  this._stopSendingStats(session);
@@ -8860,6 +8868,17 @@ class WebRTCClient extends Emitter {
8860
8868
  };
8861
8869
  }
8862
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8863
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8864
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8865
8884
 
@@ -8911,15 +8930,24 @@ class WebRTCClient extends Emitter {
8911
8930
 
8912
8931
  _setupMedias(session , newStream ) {
8913
8932
  // Safari hack, because you cannot call .play() from a non user action
8914
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8915
8934
  const isConference = this.isConference(sessionId);
8916
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8917
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8918
8942
  this.createAudioElementFor(sessionId);
8919
8943
  }
8920
8944
 
8921
8945
  const audioElement = this.audioElements[sessionId];
8922
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8949
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8950
+ const stream = newStream || removeStream || earlyStream;
8923
8951
 
8924
8952
  if (!this._isWeb() || !stream) {
8925
8953
  return;
@@ -9251,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9279
  const ON_CHAT = 'phone/ON_CHAT';
9252
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9283
 
9255
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9321,7 @@ const events = [
9292
9321
  ON_SIGNAL,
9293
9322
  ON_NETWORK_STATS,
9294
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9295
9325
  ];
9296
9326
 
9297
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10721
10751
  logger$7.info('WebRTC disconnected');
10722
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10724
10758
 
10725
10759
  this.client.on(this.client.REGISTERED, () => {
10726
10760
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11038
  ON_CHAT: ON_CHAT,
11005
11039
  ON_SIGNAL: ON_SIGNAL,
11006
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11044
  events: events,
@@ -7030,6 +7030,7 @@ const MESSAGE = 'message';
7030
7030
  const ACCEPTED = 'accepted';
7031
7031
  const REJECTED = 'rejected';
7032
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7033
7034
  const ON_REINVITE$1 = 'reinvite';
7034
7035
  const ON_ERROR = 'onError';
7035
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7113,6 +7114,7 @@ class WebRTCClient extends Emitter {
7113
7114
 
7114
7115
 
7115
7116
 
7117
+
7116
7118
 
7117
7119
 
7118
7120
  static isAPrivateIp(ip ) {
@@ -7181,6 +7183,7 @@ class WebRTCClient extends Emitter {
7181
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7182
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7183
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7184
7187
  }
7185
7188
 
7186
7189
  configureMedia(media ) {
@@ -7468,6 +7471,11 @@ class WebRTCClient extends Emitter {
7468
7471
  }
7469
7472
  this._onAccepted(session, response.session, true);
7470
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7471
7479
  onReject: (response ) => {
7472
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7473
7481
  this._stopSendingStats(session);
@@ -8860,6 +8868,17 @@ class WebRTCClient extends Emitter {
8860
8868
  };
8861
8869
  }
8862
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8863
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8864
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8865
8884
 
@@ -8911,15 +8930,24 @@ class WebRTCClient extends Emitter {
8911
8930
 
8912
8931
  _setupMedias(session , newStream ) {
8913
8932
  // Safari hack, because you cannot call .play() from a non user action
8914
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8915
8934
  const isConference = this.isConference(sessionId);
8916
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8917
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8918
8942
  this.createAudioElementFor(sessionId);
8919
8943
  }
8920
8944
 
8921
8945
  const audioElement = this.audioElements[sessionId];
8922
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8949
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8950
+ const stream = newStream || removeStream || earlyStream;
8923
8951
 
8924
8952
  if (!this._isWeb() || !stream) {
8925
8953
  return;
@@ -9251,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9279
  const ON_CHAT = 'phone/ON_CHAT';
9252
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9283
 
9255
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9321,7 @@ const events = [
9292
9321
  ON_SIGNAL,
9293
9322
  ON_NETWORK_STATS,
9294
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9295
9325
  ];
9296
9326
 
9297
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10721
10751
  logger$7.info('WebRTC disconnected');
10722
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10724
10758
 
10725
10759
  this.client.on(this.client.REGISTERED, () => {
10726
10760
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11038
  ON_CHAT: ON_CHAT,
11005
11039
  ON_SIGNAL: ON_SIGNAL,
11006
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11044
  events: events,