@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
@@ -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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8594
8620
 
8595
8621
  if (!this._isWeb() || !stream) {
8596
8622
  return;
@@ -8922,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8922
8948
  const ON_CHAT = 'phone/ON_CHAT';
8923
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8924
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8925
8952
 
8926
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8927
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8963,6 +8990,7 @@ const events = [
8963
8990
  ON_SIGNAL,
8964
8991
  ON_NETWORK_STATS,
8965
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8966
8994
  ];
8967
8995
 
8968
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10392,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10392
10420
  logger$8.info('WebRTC disconnected');
10393
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10394
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
+ });
10395
10427
 
10396
10428
  this.client.on(this.client.REGISTERED, () => {
10397
10429
  logger$8.info('WebRTC registered', {
@@ -10675,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10675
10707
  ON_CHAT: ON_CHAT,
10676
10708
  ON_SIGNAL: ON_SIGNAL,
10677
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10678
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10679
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10680
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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8592
8618
 
8593
8619
  if (!this._isWeb() || !stream) {
8594
8620
  return;
@@ -8920,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8946
  const ON_CHAT = 'phone/ON_CHAT';
8921
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8950
 
8924
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8988,7 @@ const events = [
8961
8988
  ON_SIGNAL,
8962
8989
  ON_NETWORK_STATS,
8963
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8964
8992
  ];
8965
8993
 
8966
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10390
10418
  logger$8.info('WebRTC disconnected');
10391
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10393
10425
 
10394
10426
  this.client.on(this.client.REGISTERED, () => {
10395
10427
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10705
  ON_CHAT: ON_CHAT,
10674
10706
  ON_SIGNAL: ON_SIGNAL,
10675
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10711
  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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8592
8618
 
8593
8619
  if (!this._isWeb() || !stream) {
8594
8620
  return;
@@ -8920,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8946
  const ON_CHAT = 'phone/ON_CHAT';
8921
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8950
 
8924
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8988,7 @@ const events = [
8961
8988
  ON_SIGNAL,
8962
8989
  ON_NETWORK_STATS,
8963
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8964
8992
  ];
8965
8993
 
8966
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10390
10418
  logger$8.info('WebRTC disconnected');
10391
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10393
10425
 
10394
10426
  this.client.on(this.client.REGISTERED, () => {
10395
10427
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10705
  ON_CHAT: ON_CHAT,
10674
10706
  ON_SIGNAL: ON_SIGNAL,
10675
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10711
  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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8923
8949
 
8924
8950
  if (!this._isWeb() || !stream) {
8925
8951
  return;
@@ -9251,6 +9277,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9251
9277
  const ON_CHAT = 'phone/ON_CHAT';
9252
9278
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9253
9279
  const ON_DISCONNECTED = 'onDisconnected';
9280
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9254
9281
 
9255
9282
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9256
9283
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9292,6 +9319,7 @@ const events = [
9292
9319
  ON_SIGNAL,
9293
9320
  ON_NETWORK_STATS,
9294
9321
  ON_DISCONNECTED,
9322
+ ON_EARLY_MEDIA,
9295
9323
  ];
9296
9324
 
9297
9325
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10721,6 +10749,10 @@ class WebRTCPhone extends Emitter {
10721
10749
  logger$7.info('WebRTC disconnected');
10722
10750
  this.eventEmitter.emit(ON_DISCONNECTED);
10723
10751
  });
10752
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10753
+ logger$7.info('WebRTC early media');
10754
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10755
+ });
10724
10756
 
10725
10757
  this.client.on(this.client.REGISTERED, () => {
10726
10758
  logger$7.info('WebRTC registered', {
@@ -11004,6 +11036,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11004
11036
  ON_CHAT: ON_CHAT,
11005
11037
  ON_SIGNAL: ON_SIGNAL,
11006
11038
  ON_DISCONNECTED: ON_DISCONNECTED,
11039
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11007
11040
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11008
11041
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11009
11042
  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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8592
8618
 
8593
8619
  if (!this._isWeb() || !stream) {
8594
8620
  return;
@@ -8920,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8946
  const ON_CHAT = 'phone/ON_CHAT';
8921
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8950
 
8924
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8988,7 @@ const events = [
8961
8988
  ON_SIGNAL,
8962
8989
  ON_NETWORK_STATS,
8963
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8964
8992
  ];
8965
8993
 
8966
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10390
10418
  logger$8.info('WebRTC disconnected');
10391
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10393
10425
 
10394
10426
  this.client.on(this.client.REGISTERED, () => {
10395
10427
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10705
  ON_CHAT: ON_CHAT,
10674
10706
  ON_SIGNAL: ON_SIGNAL,
10675
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10711
  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,22 @@ 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 stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8592
8618
 
8593
8619
  if (!this._isWeb() || !stream) {
8594
8620
  return;
@@ -8920,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8920
8946
  const ON_CHAT = 'phone/ON_CHAT';
8921
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8922
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8923
8950
 
8924
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8925
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8961,6 +8988,7 @@ const events = [
8961
8988
  ON_SIGNAL,
8962
8989
  ON_NETWORK_STATS,
8963
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8964
8992
  ];
8965
8993
 
8966
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10390,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10390
10418
  logger$8.info('WebRTC disconnected');
10391
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10392
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10393
10425
 
10394
10426
  this.client.on(this.client.REGISTERED, () => {
10395
10427
  logger$8.info('WebRTC registered', {
@@ -10673,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10673
10705
  ON_CHAT: ON_CHAT,
10674
10706
  ON_SIGNAL: ON_SIGNAL,
10675
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10676
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10677
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10678
10711
  events: events,