@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
@@ -6701,6 +6701,7 @@ const MESSAGE = 'message';
6701
6701
  const ACCEPTED = 'accepted';
6702
6702
  const REJECTED = 'rejected';
6703
6703
  const ON_TRACK$1 = 'onTrack';
6704
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6704
6705
  const ON_REINVITE$1 = 'reinvite';
6705
6706
  const ON_ERROR = 'onError';
6706
6707
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6784,6 +6785,7 @@ class WebRTCClient extends Emitter {
6784
6785
 
6785
6786
 
6786
6787
 
6788
+
6787
6789
 
6788
6790
 
6789
6791
  static isAPrivateIp(ip ) {
@@ -6852,6 +6854,7 @@ class WebRTCClient extends Emitter {
6852
6854
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6853
6855
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6854
6856
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6857
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6855
6858
  }
6856
6859
 
6857
6860
  configureMedia(media ) {
@@ -7139,6 +7142,11 @@ class WebRTCClient extends Emitter {
7139
7142
  }
7140
7143
  this._onAccepted(session, response.session, true);
7141
7144
  },
7145
+ onProgress: (payload) => {
7146
+ if (payload.message.statusCode === 183) {
7147
+ this._onEarlyProgress(payload.session);
7148
+ }
7149
+ },
7142
7150
  onReject: (response ) => {
7143
7151
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7144
7152
  this._stopSendingStats(session);
@@ -8531,6 +8539,17 @@ class WebRTCClient extends Emitter {
8531
8539
  };
8532
8540
  }
8533
8541
 
8542
+ _onEarlyProgress(session ) {
8543
+ this._setupMedias(session);
8544
+
8545
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8546
+ this.updateRemoteStream(sessionId);
8547
+
8548
+ logger$9.info('Early media progress progress received', { sessionId });
8549
+
8550
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8551
+ }
8552
+
8534
8553
  _onAccepted(session , sessionDialog , withEvent = true) {
8535
8554
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8536
8555
 
@@ -8582,15 +8601,24 @@ class WebRTCClient extends Emitter {
8582
8601
 
8583
8602
  _setupMedias(session , newStream ) {
8584
8603
  // Safari hack, because you cannot call .play() from a non user action
8585
- const sessionId = this.getSipSessionId(session);
8604
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8586
8605
  const isConference = this.isConference(sessionId);
8587
8606
 
8607
+ if (sessionId in this.audioElements) {
8608
+ logger$9.info('html element already exists for session', { sessionId });
8609
+ return;
8610
+ }
8611
+
8588
8612
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8589
8613
  this.createAudioElementFor(sessionId);
8590
8614
  }
8591
8615
 
8592
8616
  const audioElement = this.audioElements[sessionId];
8593
- const stream = newStream || this.getRemoteStream(sessionId);
8617
+ const sipSession = this.sipSessions[session.callId];
8618
+ const removeStream = this.getRemoteStream(sessionId);
8619
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8620
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8621
+ const stream = newStream || removeStream || earlyStream;
8594
8622
 
8595
8623
  if (!this._isWeb() || !stream) {
8596
8624
  return;
@@ -8922,6 +8950,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8922
8950
  const ON_CHAT = 'phone/ON_CHAT';
8923
8951
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8924
8952
  const ON_DISCONNECTED = 'onDisconnected';
8953
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8925
8954
 
8926
8955
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8927
8956
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8963,6 +8992,7 @@ const events = [
8963
8992
  ON_SIGNAL,
8964
8993
  ON_NETWORK_STATS,
8965
8994
  ON_DISCONNECTED,
8995
+ ON_EARLY_MEDIA,
8966
8996
  ];
8967
8997
 
8968
8998
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10392,6 +10422,10 @@ class WebRTCPhone extends Emitter {
10392
10422
  logger$8.info('WebRTC disconnected');
10393
10423
  this.eventEmitter.emit(ON_DISCONNECTED);
10394
10424
  });
10425
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10426
+ logger$8.info('WebRTC early media');
10427
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10428
+ });
10395
10429
 
10396
10430
  this.client.on(this.client.REGISTERED, () => {
10397
10431
  logger$8.info('WebRTC registered', {
@@ -10675,6 +10709,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10675
10709
  ON_CHAT: ON_CHAT,
10676
10710
  ON_SIGNAL: ON_SIGNAL,
10677
10711
  ON_DISCONNECTED: ON_DISCONNECTED,
10712
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10678
10713
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10679
10714
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10680
10715
  events: events,
@@ -6699,6 +6699,7 @@ const MESSAGE = 'message';
6699
6699
  const ACCEPTED = 'accepted';
6700
6700
  const REJECTED = 'rejected';
6701
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6702
6703
  const ON_REINVITE$1 = 'reinvite';
6703
6704
  const ON_ERROR = 'onError';
6704
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6782,6 +6783,7 @@ class WebRTCClient extends Emitter {
6782
6783
 
6783
6784
 
6784
6785
 
6786
+
6785
6787
 
6786
6788
 
6787
6789
  static isAPrivateIp(ip ) {
@@ -6850,6 +6852,7 @@ class WebRTCClient extends Emitter {
6850
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6851
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6852
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6853
6856
  }
6854
6857
 
6855
6858
  configureMedia(media ) {
@@ -7137,6 +7140,11 @@ class WebRTCClient extends Emitter {
7137
7140
  }
7138
7141
  this._onAccepted(session, response.session, true);
7139
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7140
7148
  onReject: (response ) => {
7141
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7142
7150
  this._stopSendingStats(session);
@@ -8529,6 +8537,17 @@ class WebRTCClient extends Emitter {
8529
8537
  };
8530
8538
  }
8531
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8532
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8533
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8534
8553
 
@@ -8580,15 +8599,24 @@ class WebRTCClient extends Emitter {
8580
8599
 
8581
8600
  _setupMedias(session , newStream ) {
8582
8601
  // Safari hack, because you cannot call .play() from a non user action
8583
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8584
8603
  const isConference = this.isConference(sessionId);
8585
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8586
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8587
8611
  this.createAudioElementFor(sessionId);
8588
8612
  }
8589
8613
 
8590
8614
  const audioElement = this.audioElements[sessionId];
8591
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8618
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8619
+ const stream = newStream || removeStream || earlyStream;
8592
8620
 
8593
8621
  if (!this._isWeb() || !stream) {
8594
8622
  return;
@@ -8920,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8948
  const ON_CHAT = 'phone/ON_CHAT';
8921
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8952
 
8924
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8990,7 @@ const events = [
8961
8990
  ON_SIGNAL,
8962
8991
  ON_NETWORK_STATS,
8963
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8964
8994
  ];
8965
8995
 
8966
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10390
10420
  logger$8.info('WebRTC disconnected');
10391
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10422
  });
10423
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10424
+ logger$8.info('WebRTC early media');
10425
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10426
+ });
10393
10427
 
10394
10428
  this.client.on(this.client.REGISTERED, () => {
10395
10429
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10707
  ON_CHAT: ON_CHAT,
10674
10708
  ON_SIGNAL: ON_SIGNAL,
10675
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10713
  events: events,
@@ -6699,6 +6699,7 @@ const MESSAGE = 'message';
6699
6699
  const ACCEPTED = 'accepted';
6700
6700
  const REJECTED = 'rejected';
6701
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6702
6703
  const ON_REINVITE$1 = 'reinvite';
6703
6704
  const ON_ERROR = 'onError';
6704
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6782,6 +6783,7 @@ class WebRTCClient extends Emitter {
6782
6783
 
6783
6784
 
6784
6785
 
6786
+
6785
6787
 
6786
6788
 
6787
6789
  static isAPrivateIp(ip ) {
@@ -6850,6 +6852,7 @@ class WebRTCClient extends Emitter {
6850
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6851
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6852
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6853
6856
  }
6854
6857
 
6855
6858
  configureMedia(media ) {
@@ -7137,6 +7140,11 @@ class WebRTCClient extends Emitter {
7137
7140
  }
7138
7141
  this._onAccepted(session, response.session, true);
7139
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7140
7148
  onReject: (response ) => {
7141
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7142
7150
  this._stopSendingStats(session);
@@ -8529,6 +8537,17 @@ class WebRTCClient extends Emitter {
8529
8537
  };
8530
8538
  }
8531
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8532
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8533
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8534
8553
 
@@ -8580,15 +8599,24 @@ class WebRTCClient extends Emitter {
8580
8599
 
8581
8600
  _setupMedias(session , newStream ) {
8582
8601
  // Safari hack, because you cannot call .play() from a non user action
8583
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8584
8603
  const isConference = this.isConference(sessionId);
8585
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8586
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8587
8611
  this.createAudioElementFor(sessionId);
8588
8612
  }
8589
8613
 
8590
8614
  const audioElement = this.audioElements[sessionId];
8591
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8618
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8619
+ const stream = newStream || removeStream || earlyStream;
8592
8620
 
8593
8621
  if (!this._isWeb() || !stream) {
8594
8622
  return;
@@ -8920,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8948
  const ON_CHAT = 'phone/ON_CHAT';
8921
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8952
 
8924
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8990,7 @@ const events = [
8961
8990
  ON_SIGNAL,
8962
8991
  ON_NETWORK_STATS,
8963
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8964
8994
  ];
8965
8995
 
8966
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10390
10420
  logger$8.info('WebRTC disconnected');
10391
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10422
  });
10423
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10424
+ logger$8.info('WebRTC early media');
10425
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10426
+ });
10393
10427
 
10394
10428
  this.client.on(this.client.REGISTERED, () => {
10395
10429
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10707
  ON_CHAT: ON_CHAT,
10674
10708
  ON_SIGNAL: ON_SIGNAL,
10675
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10713
  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,
@@ -6699,6 +6699,7 @@ const MESSAGE = 'message';
6699
6699
  const ACCEPTED = 'accepted';
6700
6700
  const REJECTED = 'rejected';
6701
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6702
6703
  const ON_REINVITE$1 = 'reinvite';
6703
6704
  const ON_ERROR = 'onError';
6704
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6782,6 +6783,7 @@ class WebRTCClient extends Emitter {
6782
6783
 
6783
6784
 
6784
6785
 
6786
+
6785
6787
 
6786
6788
 
6787
6789
  static isAPrivateIp(ip ) {
@@ -6850,6 +6852,7 @@ class WebRTCClient extends Emitter {
6850
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6851
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6852
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6853
6856
  }
6854
6857
 
6855
6858
  configureMedia(media ) {
@@ -7137,6 +7140,11 @@ class WebRTCClient extends Emitter {
7137
7140
  }
7138
7141
  this._onAccepted(session, response.session, true);
7139
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7140
7148
  onReject: (response ) => {
7141
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7142
7150
  this._stopSendingStats(session);
@@ -8529,6 +8537,17 @@ class WebRTCClient extends Emitter {
8529
8537
  };
8530
8538
  }
8531
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8532
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8533
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8534
8553
 
@@ -8580,15 +8599,24 @@ class WebRTCClient extends Emitter {
8580
8599
 
8581
8600
  _setupMedias(session , newStream ) {
8582
8601
  // Safari hack, because you cannot call .play() from a non user action
8583
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8584
8603
  const isConference = this.isConference(sessionId);
8585
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8586
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8587
8611
  this.createAudioElementFor(sessionId);
8588
8612
  }
8589
8613
 
8590
8614
  const audioElement = this.audioElements[sessionId];
8591
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8618
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8619
+ const stream = newStream || removeStream || earlyStream;
8592
8620
 
8593
8621
  if (!this._isWeb() || !stream) {
8594
8622
  return;
@@ -8920,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8948
  const ON_CHAT = 'phone/ON_CHAT';
8921
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8952
 
8924
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8990,7 @@ const events = [
8961
8990
  ON_SIGNAL,
8962
8991
  ON_NETWORK_STATS,
8963
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8964
8994
  ];
8965
8995
 
8966
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10390
10420
  logger$8.info('WebRTC disconnected');
10391
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10422
  });
10423
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10424
+ logger$8.info('WebRTC early media');
10425
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10426
+ });
10393
10427
 
10394
10428
  this.client.on(this.client.REGISTERED, () => {
10395
10429
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10707
  ON_CHAT: ON_CHAT,
10674
10708
  ON_SIGNAL: ON_SIGNAL,
10675
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10713
  events: events,
@@ -6699,6 +6699,7 @@ const MESSAGE = 'message';
6699
6699
  const ACCEPTED = 'accepted';
6700
6700
  const REJECTED = 'rejected';
6701
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6702
6703
  const ON_REINVITE$1 = 'reinvite';
6703
6704
  const ON_ERROR = 'onError';
6704
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6782,6 +6783,7 @@ class WebRTCClient extends Emitter {
6782
6783
 
6783
6784
 
6784
6785
 
6786
+
6785
6787
 
6786
6788
 
6787
6789
  static isAPrivateIp(ip ) {
@@ -6850,6 +6852,7 @@ class WebRTCClient extends Emitter {
6850
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6851
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6852
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6853
6856
  }
6854
6857
 
6855
6858
  configureMedia(media ) {
@@ -7137,6 +7140,11 @@ class WebRTCClient extends Emitter {
7137
7140
  }
7138
7141
  this._onAccepted(session, response.session, true);
7139
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7140
7148
  onReject: (response ) => {
7141
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7142
7150
  this._stopSendingStats(session);
@@ -8529,6 +8537,17 @@ class WebRTCClient extends Emitter {
8529
8537
  };
8530
8538
  }
8531
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8532
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8533
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8534
8553
 
@@ -8580,15 +8599,24 @@ class WebRTCClient extends Emitter {
8580
8599
 
8581
8600
  _setupMedias(session , newStream ) {
8582
8601
  // Safari hack, because you cannot call .play() from a non user action
8583
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8584
8603
  const isConference = this.isConference(sessionId);
8585
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8586
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8587
8611
  this.createAudioElementFor(sessionId);
8588
8612
  }
8589
8613
 
8590
8614
  const audioElement = this.audioElements[sessionId];
8591
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8618
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8619
+ const stream = newStream || removeStream || earlyStream;
8592
8620
 
8593
8621
  if (!this._isWeb() || !stream) {
8594
8622
  return;
@@ -8920,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8948
  const ON_CHAT = 'phone/ON_CHAT';
8921
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8952
 
8924
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8990,7 @@ const events = [
8961
8990
  ON_SIGNAL,
8962
8991
  ON_NETWORK_STATS,
8963
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8964
8994
  ];
8965
8995
 
8966
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10390
10420
  logger$8.info('WebRTC disconnected');
10391
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10422
  });
10423
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10424
+ logger$8.info('WebRTC early media');
10425
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10426
+ });
10393
10427
 
10394
10428
  this.client.on(this.client.REGISTERED, () => {
10395
10429
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10707
  ON_CHAT: ON_CHAT,
10674
10708
  ON_SIGNAL: ON_SIGNAL,
10675
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10713
  events: events,