@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
@@ -6689,6 +6689,7 @@ const MESSAGE = 'message';
6689
6689
  const ACCEPTED = 'accepted';
6690
6690
  const REJECTED = 'rejected';
6691
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6692
6693
  const ON_REINVITE$1 = 'reinvite';
6693
6694
  const ON_ERROR = 'onError';
6694
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6772,6 +6773,7 @@ class WebRTCClient extends Emitter {
6772
6773
 
6773
6774
 
6774
6775
 
6776
+
6775
6777
 
6776
6778
 
6777
6779
  static isAPrivateIp(ip ) {
@@ -6840,6 +6842,7 @@ class WebRTCClient extends Emitter {
6840
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6841
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6842
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6843
6846
  }
6844
6847
 
6845
6848
  configureMedia(media ) {
@@ -7127,6 +7130,11 @@ class WebRTCClient extends Emitter {
7127
7130
  }
7128
7131
  this._onAccepted(session, response.session, true);
7129
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7130
7138
  onReject: (response ) => {
7131
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7132
7140
  this._stopSendingStats(session);
@@ -8519,6 +8527,17 @@ class WebRTCClient extends Emitter {
8519
8527
  };
8520
8528
  }
8521
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8522
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8523
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8524
8543
 
@@ -8570,15 +8589,24 @@ class WebRTCClient extends Emitter {
8570
8589
 
8571
8590
  _setupMedias(session , newStream ) {
8572
8591
  // Safari hack, because you cannot call .play() from a non user action
8573
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8574
8593
  const isConference = this.isConference(sessionId);
8575
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8576
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8577
8601
  this.createAudioElementFor(sessionId);
8578
8602
  }
8579
8603
 
8580
8604
  const audioElement = this.audioElements[sessionId];
8581
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8608
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8609
+ const stream = newStream || removeStream || earlyStream;
8582
8610
 
8583
8611
  if (!this._isWeb() || !stream) {
8584
8612
  return;
@@ -8910,6 +8938,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8910
8938
  const ON_CHAT = 'phone/ON_CHAT';
8911
8939
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8912
8940
  const ON_DISCONNECTED = 'onDisconnected';
8941
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8913
8942
 
8914
8943
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8915
8944
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8951,6 +8980,7 @@ const events = [
8951
8980
  ON_SIGNAL,
8952
8981
  ON_NETWORK_STATS,
8953
8982
  ON_DISCONNECTED,
8983
+ ON_EARLY_MEDIA,
8954
8984
  ];
8955
8985
 
8956
8986
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10380,6 +10410,10 @@ class WebRTCPhone extends Emitter {
10380
10410
  logger$8.info('WebRTC disconnected');
10381
10411
  this.eventEmitter.emit(ON_DISCONNECTED);
10382
10412
  });
10413
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10414
+ logger$8.info('WebRTC early media');
10415
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10416
+ });
10383
10417
 
10384
10418
  this.client.on(this.client.REGISTERED, () => {
10385
10419
  logger$8.info('WebRTC registered', {
@@ -10663,6 +10697,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10663
10697
  ON_CHAT: ON_CHAT,
10664
10698
  ON_SIGNAL: ON_SIGNAL,
10665
10699
  ON_DISCONNECTED: ON_DISCONNECTED,
10700
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10666
10701
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10667
10702
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10668
10703
  events: events,
@@ -6689,6 +6689,7 @@ const MESSAGE = 'message';
6689
6689
  const ACCEPTED = 'accepted';
6690
6690
  const REJECTED = 'rejected';
6691
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6692
6693
  const ON_REINVITE$1 = 'reinvite';
6693
6694
  const ON_ERROR = 'onError';
6694
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6772,6 +6773,7 @@ class WebRTCClient extends Emitter {
6772
6773
 
6773
6774
 
6774
6775
 
6776
+
6775
6777
 
6776
6778
 
6777
6779
  static isAPrivateIp(ip ) {
@@ -6840,6 +6842,7 @@ class WebRTCClient extends Emitter {
6840
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6841
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6842
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6843
6846
  }
6844
6847
 
6845
6848
  configureMedia(media ) {
@@ -7127,6 +7130,11 @@ class WebRTCClient extends Emitter {
7127
7130
  }
7128
7131
  this._onAccepted(session, response.session, true);
7129
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7130
7138
  onReject: (response ) => {
7131
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7132
7140
  this._stopSendingStats(session);
@@ -8519,6 +8527,17 @@ class WebRTCClient extends Emitter {
8519
8527
  };
8520
8528
  }
8521
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8522
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8523
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8524
8543
 
@@ -8570,15 +8589,24 @@ class WebRTCClient extends Emitter {
8570
8589
 
8571
8590
  _setupMedias(session , newStream ) {
8572
8591
  // Safari hack, because you cannot call .play() from a non user action
8573
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8574
8593
  const isConference = this.isConference(sessionId);
8575
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8576
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8577
8601
  this.createAudioElementFor(sessionId);
8578
8602
  }
8579
8603
 
8580
8604
  const audioElement = this.audioElements[sessionId];
8581
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8608
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8609
+ const stream = newStream || removeStream || earlyStream;
8582
8610
 
8583
8611
  if (!this._isWeb() || !stream) {
8584
8612
  return;
@@ -8910,6 +8938,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8910
8938
  const ON_CHAT = 'phone/ON_CHAT';
8911
8939
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8912
8940
  const ON_DISCONNECTED = 'onDisconnected';
8941
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8913
8942
 
8914
8943
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8915
8944
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8951,6 +8980,7 @@ const events = [
8951
8980
  ON_SIGNAL,
8952
8981
  ON_NETWORK_STATS,
8953
8982
  ON_DISCONNECTED,
8983
+ ON_EARLY_MEDIA,
8954
8984
  ];
8955
8985
 
8956
8986
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10380,6 +10410,10 @@ class WebRTCPhone extends Emitter {
10380
10410
  logger$8.info('WebRTC disconnected');
10381
10411
  this.eventEmitter.emit(ON_DISCONNECTED);
10382
10412
  });
10413
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10414
+ logger$8.info('WebRTC early media');
10415
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10416
+ });
10383
10417
 
10384
10418
  this.client.on(this.client.REGISTERED, () => {
10385
10419
  logger$8.info('WebRTC registered', {
@@ -10663,6 +10697,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10663
10697
  ON_CHAT: ON_CHAT,
10664
10698
  ON_SIGNAL: ON_SIGNAL,
10665
10699
  ON_DISCONNECTED: ON_DISCONNECTED,
10700
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10666
10701
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10667
10702
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10668
10703
  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,24 @@ 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 earlyStream = sipSession && sipSession.sessionDescriptionHandler
8939
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8940
+ const stream = newStream || removeStream || earlyStream;
8913
8941
 
8914
8942
  if (!this._isWeb() || !stream) {
8915
8943
  return;
@@ -9241,6 +9269,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9269
  const ON_CHAT = 'phone/ON_CHAT';
9242
9270
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9271
  const ON_DISCONNECTED = 'onDisconnected';
9272
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9273
 
9245
9274
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9275
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9311,7 @@ const events = [
9282
9311
  ON_SIGNAL,
9283
9312
  ON_NETWORK_STATS,
9284
9313
  ON_DISCONNECTED,
9314
+ ON_EARLY_MEDIA,
9285
9315
  ];
9286
9316
 
9287
9317
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10741,10 @@ class WebRTCPhone extends Emitter {
10711
10741
  logger$7.info('WebRTC disconnected');
10712
10742
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10743
  });
10744
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10745
+ logger$7.info('WebRTC early media');
10746
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10747
+ });
10714
10748
 
10715
10749
  this.client.on(this.client.REGISTERED, () => {
10716
10750
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11028,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11028
  ON_CHAT: ON_CHAT,
10995
11029
  ON_SIGNAL: ON_SIGNAL,
10996
11030
  ON_DISCONNECTED: ON_DISCONNECTED,
11031
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11032
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11033
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11034
  events: events,
@@ -6689,6 +6689,7 @@ const MESSAGE = 'message';
6689
6689
  const ACCEPTED = 'accepted';
6690
6690
  const REJECTED = 'rejected';
6691
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6692
6693
  const ON_REINVITE$1 = 'reinvite';
6693
6694
  const ON_ERROR = 'onError';
6694
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6772,6 +6773,7 @@ class WebRTCClient extends Emitter {
6772
6773
 
6773
6774
 
6774
6775
 
6776
+
6775
6777
 
6776
6778
 
6777
6779
  static isAPrivateIp(ip ) {
@@ -6840,6 +6842,7 @@ class WebRTCClient extends Emitter {
6840
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6841
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6842
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6843
6846
  }
6844
6847
 
6845
6848
  configureMedia(media ) {
@@ -7127,6 +7130,11 @@ class WebRTCClient extends Emitter {
7127
7130
  }
7128
7131
  this._onAccepted(session, response.session, true);
7129
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7130
7138
  onReject: (response ) => {
7131
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7132
7140
  this._stopSendingStats(session);
@@ -8519,6 +8527,17 @@ class WebRTCClient extends Emitter {
8519
8527
  };
8520
8528
  }
8521
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8522
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8523
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8524
8543
 
@@ -8570,15 +8589,24 @@ class WebRTCClient extends Emitter {
8570
8589
 
8571
8590
  _setupMedias(session , newStream ) {
8572
8591
  // Safari hack, because you cannot call .play() from a non user action
8573
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8574
8593
  const isConference = this.isConference(sessionId);
8575
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8576
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8577
8601
  this.createAudioElementFor(sessionId);
8578
8602
  }
8579
8603
 
8580
8604
  const audioElement = this.audioElements[sessionId];
8581
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8608
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8609
+ const stream = newStream || removeStream || earlyStream;
8582
8610
 
8583
8611
  if (!this._isWeb() || !stream) {
8584
8612
  return;
@@ -8910,6 +8938,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8910
8938
  const ON_CHAT = 'phone/ON_CHAT';
8911
8939
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8912
8940
  const ON_DISCONNECTED = 'onDisconnected';
8941
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8913
8942
 
8914
8943
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8915
8944
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8951,6 +8980,7 @@ const events = [
8951
8980
  ON_SIGNAL,
8952
8981
  ON_NETWORK_STATS,
8953
8982
  ON_DISCONNECTED,
8983
+ ON_EARLY_MEDIA,
8954
8984
  ];
8955
8985
 
8956
8986
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10380,6 +10410,10 @@ class WebRTCPhone extends Emitter {
10380
10410
  logger$8.info('WebRTC disconnected');
10381
10411
  this.eventEmitter.emit(ON_DISCONNECTED);
10382
10412
  });
10413
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10414
+ logger$8.info('WebRTC early media');
10415
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10416
+ });
10383
10417
 
10384
10418
  this.client.on(this.client.REGISTERED, () => {
10385
10419
  logger$8.info('WebRTC registered', {
@@ -10663,6 +10697,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10663
10697
  ON_CHAT: ON_CHAT,
10664
10698
  ON_SIGNAL: ON_SIGNAL,
10665
10699
  ON_DISCONNECTED: ON_DISCONNECTED,
10700
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10666
10701
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10667
10702
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10668
10703
  events: events,
@@ -6689,6 +6689,7 @@ const MESSAGE = 'message';
6689
6689
  const ACCEPTED = 'accepted';
6690
6690
  const REJECTED = 'rejected';
6691
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6692
6693
  const ON_REINVITE$1 = 'reinvite';
6693
6694
  const ON_ERROR = 'onError';
6694
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6772,6 +6773,7 @@ class WebRTCClient extends Emitter {
6772
6773
 
6773
6774
 
6774
6775
 
6776
+
6775
6777
 
6776
6778
 
6777
6779
  static isAPrivateIp(ip ) {
@@ -6840,6 +6842,7 @@ class WebRTCClient extends Emitter {
6840
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6841
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6842
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6843
6846
  }
6844
6847
 
6845
6848
  configureMedia(media ) {
@@ -7127,6 +7130,11 @@ class WebRTCClient extends Emitter {
7127
7130
  }
7128
7131
  this._onAccepted(session, response.session, true);
7129
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7130
7138
  onReject: (response ) => {
7131
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7132
7140
  this._stopSendingStats(session);
@@ -8519,6 +8527,17 @@ class WebRTCClient extends Emitter {
8519
8527
  };
8520
8528
  }
8521
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8522
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8523
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8524
8543
 
@@ -8570,15 +8589,24 @@ class WebRTCClient extends Emitter {
8570
8589
 
8571
8590
  _setupMedias(session , newStream ) {
8572
8591
  // Safari hack, because you cannot call .play() from a non user action
8573
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8574
8593
  const isConference = this.isConference(sessionId);
8575
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8576
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8577
8601
  this.createAudioElementFor(sessionId);
8578
8602
  }
8579
8603
 
8580
8604
  const audioElement = this.audioElements[sessionId];
8581
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8608
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8609
+ const stream = newStream || removeStream || earlyStream;
8582
8610
 
8583
8611
  if (!this._isWeb() || !stream) {
8584
8612
  return;
@@ -8910,6 +8938,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8910
8938
  const ON_CHAT = 'phone/ON_CHAT';
8911
8939
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8912
8940
  const ON_DISCONNECTED = 'onDisconnected';
8941
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8913
8942
 
8914
8943
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8915
8944
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8951,6 +8980,7 @@ const events = [
8951
8980
  ON_SIGNAL,
8952
8981
  ON_NETWORK_STATS,
8953
8982
  ON_DISCONNECTED,
8983
+ ON_EARLY_MEDIA,
8954
8984
  ];
8955
8985
 
8956
8986
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10380,6 +10410,10 @@ class WebRTCPhone extends Emitter {
10380
10410
  logger$8.info('WebRTC disconnected');
10381
10411
  this.eventEmitter.emit(ON_DISCONNECTED);
10382
10412
  });
10413
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10414
+ logger$8.info('WebRTC early media');
10415
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10416
+ });
10383
10417
 
10384
10418
  this.client.on(this.client.REGISTERED, () => {
10385
10419
  logger$8.info('WebRTC registered', {
@@ -10663,6 +10697,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10663
10697
  ON_CHAT: ON_CHAT,
10664
10698
  ON_SIGNAL: ON_SIGNAL,
10665
10699
  ON_DISCONNECTED: ON_DISCONNECTED,
10700
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10666
10701
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10667
10702
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10668
10703
  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,24 @@ 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 earlyStream = sipSession && sipSession.sessionDescriptionHandler
8939
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8940
+ const stream = newStream || removeStream || earlyStream;
8913
8941
 
8914
8942
  if (!this._isWeb() || !stream) {
8915
8943
  return;
@@ -9241,6 +9269,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9241
9269
  const ON_CHAT = 'phone/ON_CHAT';
9242
9270
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9243
9271
  const ON_DISCONNECTED = 'onDisconnected';
9272
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9244
9273
 
9245
9274
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9246
9275
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9282,6 +9311,7 @@ const events = [
9282
9311
  ON_SIGNAL,
9283
9312
  ON_NETWORK_STATS,
9284
9313
  ON_DISCONNECTED,
9314
+ ON_EARLY_MEDIA,
9285
9315
  ];
9286
9316
 
9287
9317
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10711,6 +10741,10 @@ class WebRTCPhone extends Emitter {
10711
10741
  logger$7.info('WebRTC disconnected');
10712
10742
  this.eventEmitter.emit(ON_DISCONNECTED);
10713
10743
  });
10744
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10745
+ logger$7.info('WebRTC early media');
10746
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10747
+ });
10714
10748
 
10715
10749
  this.client.on(this.client.REGISTERED, () => {
10716
10750
  logger$7.info('WebRTC registered', {
@@ -10994,6 +11028,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10994
11028
  ON_CHAT: ON_CHAT,
10995
11029
  ON_SIGNAL: ON_SIGNAL,
10996
11030
  ON_DISCONNECTED: ON_DISCONNECTED,
11031
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10997
11032
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10998
11033
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10999
11034
  events: events,