@wazo/sdk 0.38.17 → 0.38.18

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 +28 -2
  3. package/esm/checker/Checker.js +28 -2
  4. package/esm/checker/checks/index.js +28 -2
  5. package/esm/checker/checks/webrtc-transport.js +28 -2
  6. package/esm/checker/checks/webrtc.js +28 -2
  7. package/esm/domain/Phone/WebRTCPhone.js +7 -1
  8. package/esm/index.js +35 -2
  9. package/esm/simple/Auth.js +35 -2
  10. package/esm/simple/Configuration.js +35 -2
  11. package/esm/simple/Phone.js +35 -2
  12. package/esm/simple/index.js +35 -2
  13. package/esm/simple/room/LocalParticipant.js +35 -2
  14. package/esm/simple/room/Participant.js +35 -2
  15. package/esm/simple/room/RemoteParticipant.js +35 -2
  16. package/esm/simple/room/Room.js +35 -2
  17. package/esm/simple/room/SipRoom.js +35 -2
  18. package/esm/simple/room/Stream.js +35 -2
  19. package/esm/simple/room/__tests__/Participant.test.js +35 -2
  20. package/esm/simple/room/__tests__/RemoteParticipant.test.js +35 -2
  21. package/esm/simple/utils.js +35 -2
  22. package/esm/web-rtc-client.js +28 -2
  23. package/lib/__tests__/web-rtc-client.test.js +28 -2
  24. package/lib/checker/Checker.js +28 -2
  25. package/lib/checker/checks/index.js +28 -2
  26. package/lib/checker/checks/webrtc-transport.js +28 -2
  27. package/lib/checker/checks/webrtc.js +28 -2
  28. package/lib/domain/Phone/WebRTCPhone.js +7 -0
  29. package/lib/index.js +35 -2
  30. package/lib/simple/Auth.js +35 -2
  31. package/lib/simple/Configuration.js +35 -2
  32. package/lib/simple/Phone.js +35 -2
  33. package/lib/simple/index.js +35 -2
  34. package/lib/simple/room/LocalParticipant.js +35 -2
  35. package/lib/simple/room/Participant.js +35 -2
  36. package/lib/simple/room/RemoteParticipant.js +35 -2
  37. package/lib/simple/room/Room.js +35 -2
  38. package/lib/simple/room/SipRoom.js +35 -2
  39. package/lib/simple/room/Stream.js +35 -2
  40. package/lib/simple/room/__tests__/Participant.test.js +35 -2
  41. package/lib/simple/room/__tests__/RemoteParticipant.test.js +35 -2
  42. package/lib/simple/utils.js +35 -2
  43. package/lib/web-rtc-client.js +28 -2
  44. package/package.json +1 -1
  45. package/src/domain/Phone/WebRTCPhone.js +6 -0
  46. package/src/web-rtc-client.js +28 -2
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,
@@ -7020,6 +7020,7 @@ const MESSAGE = 'message';
7020
7020
  const ACCEPTED = 'accepted';
7021
7021
  const REJECTED = 'rejected';
7022
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7023
7024
  const ON_REINVITE$1 = 'reinvite';
7024
7025
  const ON_ERROR = 'onError';
7025
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7103,6 +7104,7 @@ class WebRTCClient extends Emitter {
7103
7104
 
7104
7105
 
7105
7106
 
7107
+
7106
7108
 
7107
7109
 
7108
7110
  static isAPrivateIp(ip ) {
@@ -7171,6 +7173,7 @@ class WebRTCClient extends Emitter {
7171
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7172
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7173
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7174
7177
  }
7175
7178
 
7176
7179
  configureMedia(media ) {
@@ -7458,6 +7461,11 @@ class WebRTCClient extends Emitter {
7458
7461
  }
7459
7462
  this._onAccepted(session, response.session, true);
7460
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7461
7469
  onReject: (response ) => {
7462
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7463
7471
  this._stopSendingStats(session);
@@ -8850,6 +8858,17 @@ class WebRTCClient extends Emitter {
8850
8858
  };
8851
8859
  }
8852
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8853
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8854
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8855
8874
 
@@ -8901,15 +8920,22 @@ class WebRTCClient extends Emitter {
8901
8920
 
8902
8921
  _setupMedias(session , newStream ) {
8903
8922
  // Safari hack, because you cannot call .play() from a non user action
8904
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8905
8924
  const isConference = this.isConference(sessionId);
8906
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8907
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8908
8932
  this.createAudioElementFor(sessionId);
8909
8933
  }
8910
8934
 
8911
8935
  const audioElement = this.audioElements[sessionId];
8912
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8913
8939
 
8914
8940
  if (!this._isWeb() || !stream) {
8915
8941
  return;
@@ -9241,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9267
  const ON_CHAT = 'phone/ON_CHAT';
9242
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9271
 
9245
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9309,7 @@ const events = [
9282
9309
  ON_SIGNAL,
9283
9310
  ON_NETWORK_STATS,
9284
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9285
9313
  ];
9286
9314
 
9287
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10711
10739
  logger$7.info('WebRTC disconnected');
10712
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10714
10746
 
10715
10747
  this.client.on(this.client.REGISTERED, () => {
10716
10748
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11026
  ON_CHAT: ON_CHAT,
10995
11027
  ON_SIGNAL: ON_SIGNAL,
10996
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11032
  events: events,