@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
@@ -5608,6 +5608,7 @@ const MESSAGE = 'message';
5608
5608
  const ACCEPTED = 'accepted';
5609
5609
  const REJECTED = 'rejected';
5610
5610
  const ON_TRACK = 'onTrack';
5611
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5611
5612
  const ON_REINVITE = 'reinvite';
5612
5613
  const ON_ERROR = 'onError';
5613
5614
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5691,6 +5692,7 @@ class WebRTCClient extends Emitter {
5691
5692
 
5692
5693
 
5693
5694
 
5695
+
5694
5696
 
5695
5697
 
5696
5698
  static isAPrivateIp(ip ) {
@@ -5759,6 +5761,7 @@ class WebRTCClient extends Emitter {
5759
5761
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5760
5762
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5761
5763
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5764
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5762
5765
  }
5763
5766
 
5764
5767
  configureMedia(media ) {
@@ -6046,6 +6049,11 @@ class WebRTCClient extends Emitter {
6046
6049
  }
6047
6050
  this._onAccepted(session, response.session, true);
6048
6051
  },
6052
+ onProgress: (payload) => {
6053
+ if (payload.message.statusCode === 183) {
6054
+ this._onEarlyProgress(payload.session);
6055
+ }
6056
+ },
6049
6057
  onReject: (response ) => {
6050
6058
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6051
6059
  this._stopSendingStats(session);
@@ -7438,6 +7446,17 @@ class WebRTCClient extends Emitter {
7438
7446
  };
7439
7447
  }
7440
7448
 
7449
+ _onEarlyProgress(session ) {
7450
+ this._setupMedias(session);
7451
+
7452
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7453
+ this.updateRemoteStream(sessionId);
7454
+
7455
+ logger.info('Early media progress progress received', { sessionId });
7456
+
7457
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7458
+ }
7459
+
7441
7460
  _onAccepted(session , sessionDialog , withEvent = true) {
7442
7461
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7443
7462
 
@@ -7489,15 +7508,24 @@ class WebRTCClient extends Emitter {
7489
7508
 
7490
7509
  _setupMedias(session , newStream ) {
7491
7510
  // Safari hack, because you cannot call .play() from a non user action
7492
- const sessionId = this.getSipSessionId(session);
7511
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7493
7512
  const isConference = this.isConference(sessionId);
7494
7513
 
7514
+ if (sessionId in this.audioElements) {
7515
+ logger.info('html element already exists for session', { sessionId });
7516
+ return;
7517
+ }
7518
+
7495
7519
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7496
7520
  this.createAudioElementFor(sessionId);
7497
7521
  }
7498
7522
 
7499
7523
  const audioElement = this.audioElements[sessionId];
7500
- const stream = newStream || this.getRemoteStream(sessionId);
7524
+ const sipSession = this.sipSessions[session.callId];
7525
+ const removeStream = this.getRemoteStream(sessionId);
7526
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7527
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7528
+ const stream = newStream || removeStream || earlyStream;
7501
7529
 
7502
7530
  if (!this._isWeb() || !stream) {
7503
7531
  return;
@@ -5617,6 +5617,7 @@ const MESSAGE = 'message';
5617
5617
  const ACCEPTED = 'accepted';
5618
5618
  const REJECTED = 'rejected';
5619
5619
  const ON_TRACK = 'onTrack';
5620
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5620
5621
  const ON_REINVITE = 'reinvite';
5621
5622
  const ON_ERROR = 'onError';
5622
5623
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5697,6 +5698,7 @@ class WebRTCClient extends Emitter {
5697
5698
 
5698
5699
 
5699
5700
 
5701
+
5700
5702
 
5701
5703
 
5702
5704
  static isAPrivateIp(ip ) {
@@ -5765,6 +5767,7 @@ class WebRTCClient extends Emitter {
5765
5767
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5766
5768
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5767
5769
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5770
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5768
5771
  }
5769
5772
 
5770
5773
  configureMedia(media ) {
@@ -6052,6 +6055,11 @@ class WebRTCClient extends Emitter {
6052
6055
  }
6053
6056
  this._onAccepted(session, response.session, true);
6054
6057
  },
6058
+ onProgress: (payload) => {
6059
+ if (payload.message.statusCode === 183) {
6060
+ this._onEarlyProgress(payload.session);
6061
+ }
6062
+ },
6055
6063
  onReject: (response ) => {
6056
6064
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6057
6065
  this._stopSendingStats(session);
@@ -7444,6 +7452,17 @@ class WebRTCClient extends Emitter {
7444
7452
  };
7445
7453
  }
7446
7454
 
7455
+ _onEarlyProgress(session ) {
7456
+ this._setupMedias(session);
7457
+
7458
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7459
+ this.updateRemoteStream(sessionId);
7460
+
7461
+ logger.info('Early media progress progress received', { sessionId });
7462
+
7463
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7464
+ }
7465
+
7447
7466
  _onAccepted(session , sessionDialog , withEvent = true) {
7448
7467
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7449
7468
 
@@ -7495,15 +7514,24 @@ class WebRTCClient extends Emitter {
7495
7514
 
7496
7515
  _setupMedias(session , newStream ) {
7497
7516
  // Safari hack, because you cannot call .play() from a non user action
7498
- const sessionId = this.getSipSessionId(session);
7517
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7499
7518
  const isConference = this.isConference(sessionId);
7500
7519
 
7520
+ if (sessionId in this.audioElements) {
7521
+ logger.info('html element already exists for session', { sessionId });
7522
+ return;
7523
+ }
7524
+
7501
7525
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7502
7526
  this.createAudioElementFor(sessionId);
7503
7527
  }
7504
7528
 
7505
7529
  const audioElement = this.audioElements[sessionId];
7506
- const stream = newStream || this.getRemoteStream(sessionId);
7530
+ const sipSession = this.sipSessions[session.callId];
7531
+ const removeStream = this.getRemoteStream(sessionId);
7532
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7533
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7534
+ const stream = newStream || removeStream || earlyStream;
7507
7535
 
7508
7536
  if (!this._isWeb() || !stream) {
7509
7537
  return;
@@ -6205,6 +6205,7 @@ const MESSAGE = 'message';
6205
6205
  const ACCEPTED = 'accepted';
6206
6206
  const REJECTED = 'rejected';
6207
6207
  const ON_TRACK = 'onTrack';
6208
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
6208
6209
  const ON_REINVITE = 'reinvite';
6209
6210
  const ON_ERROR = 'onError';
6210
6211
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6285,6 +6286,7 @@ class WebRTCClient extends Emitter {
6285
6286
 
6286
6287
 
6287
6288
 
6289
+
6288
6290
 
6289
6291
 
6290
6292
  static isAPrivateIp(ip ) {
@@ -6353,6 +6355,7 @@ class WebRTCClient extends Emitter {
6353
6355
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6354
6356
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6355
6357
  this.ON_DISCONNECTED = ON_DISCONNECTED;
6358
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
6356
6359
  }
6357
6360
 
6358
6361
  configureMedia(media ) {
@@ -6640,6 +6643,11 @@ class WebRTCClient extends Emitter {
6640
6643
  }
6641
6644
  this._onAccepted(session, response.session, true);
6642
6645
  },
6646
+ onProgress: (payload) => {
6647
+ if (payload.message.statusCode === 183) {
6648
+ this._onEarlyProgress(payload.session);
6649
+ }
6650
+ },
6643
6651
  onReject: (response ) => {
6644
6652
  logger$1.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6645
6653
  this._stopSendingStats(session);
@@ -8032,6 +8040,17 @@ class WebRTCClient extends Emitter {
8032
8040
  };
8033
8041
  }
8034
8042
 
8043
+ _onEarlyProgress(session ) {
8044
+ this._setupMedias(session);
8045
+
8046
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8047
+ this.updateRemoteStream(sessionId);
8048
+
8049
+ logger$1.info('Early media progress progress received', { sessionId });
8050
+
8051
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
8052
+ }
8053
+
8035
8054
  _onAccepted(session , sessionDialog , withEvent = true) {
8036
8055
  logger$1.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8037
8056
 
@@ -8083,15 +8102,24 @@ class WebRTCClient extends Emitter {
8083
8102
 
8084
8103
  _setupMedias(session , newStream ) {
8085
8104
  // Safari hack, because you cannot call .play() from a non user action
8086
- const sessionId = this.getSipSessionId(session);
8105
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8087
8106
  const isConference = this.isConference(sessionId);
8088
8107
 
8108
+ if (sessionId in this.audioElements) {
8109
+ logger$1.info('html element already exists for session', { sessionId });
8110
+ return;
8111
+ }
8112
+
8089
8113
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8090
8114
  this.createAudioElementFor(sessionId);
8091
8115
  }
8092
8116
 
8093
8117
  const audioElement = this.audioElements[sessionId];
8094
- const stream = newStream || this.getRemoteStream(sessionId);
8118
+ const sipSession = this.sipSessions[session.callId];
8119
+ const removeStream = this.getRemoteStream(sessionId);
8120
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8121
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8122
+ const stream = newStream || removeStream || earlyStream;
8095
8123
 
8096
8124
  if (!this._isWeb() || !stream) {
8097
8125
  return;
@@ -6205,6 +6205,7 @@ const MESSAGE = 'message';
6205
6205
  const ACCEPTED = 'accepted';
6206
6206
  const REJECTED = 'rejected';
6207
6207
  const ON_TRACK = 'onTrack';
6208
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
6208
6209
  const ON_REINVITE = 'reinvite';
6209
6210
  const ON_ERROR = 'onError';
6210
6211
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6285,6 +6286,7 @@ class WebRTCClient extends Emitter {
6285
6286
 
6286
6287
 
6287
6288
 
6289
+
6288
6290
 
6289
6291
 
6290
6292
  static isAPrivateIp(ip ) {
@@ -6353,6 +6355,7 @@ class WebRTCClient extends Emitter {
6353
6355
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6354
6356
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6355
6357
  this.ON_DISCONNECTED = ON_DISCONNECTED;
6358
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
6356
6359
  }
6357
6360
 
6358
6361
  configureMedia(media ) {
@@ -6640,6 +6643,11 @@ class WebRTCClient extends Emitter {
6640
6643
  }
6641
6644
  this._onAccepted(session, response.session, true);
6642
6645
  },
6646
+ onProgress: (payload) => {
6647
+ if (payload.message.statusCode === 183) {
6648
+ this._onEarlyProgress(payload.session);
6649
+ }
6650
+ },
6643
6651
  onReject: (response ) => {
6644
6652
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6645
6653
  this._stopSendingStats(session);
@@ -8032,6 +8040,17 @@ class WebRTCClient extends Emitter {
8032
8040
  };
8033
8041
  }
8034
8042
 
8043
+ _onEarlyProgress(session ) {
8044
+ this._setupMedias(session);
8045
+
8046
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8047
+ this.updateRemoteStream(sessionId);
8048
+
8049
+ logger.info('Early media progress progress received', { sessionId });
8050
+
8051
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
8052
+ }
8053
+
8035
8054
  _onAccepted(session , sessionDialog , withEvent = true) {
8036
8055
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8037
8056
 
@@ -8083,15 +8102,24 @@ class WebRTCClient extends Emitter {
8083
8102
 
8084
8103
  _setupMedias(session , newStream ) {
8085
8104
  // Safari hack, because you cannot call .play() from a non user action
8086
- const sessionId = this.getSipSessionId(session);
8105
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8087
8106
  const isConference = this.isConference(sessionId);
8088
8107
 
8108
+ if (sessionId in this.audioElements) {
8109
+ logger.info('html element already exists for session', { sessionId });
8110
+ return;
8111
+ }
8112
+
8089
8113
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8090
8114
  this.createAudioElementFor(sessionId);
8091
8115
  }
8092
8116
 
8093
8117
  const audioElement = this.audioElements[sessionId];
8094
- const stream = newStream || this.getRemoteStream(sessionId);
8118
+ const sipSession = this.sipSessions[session.callId];
8119
+ const removeStream = this.getRemoteStream(sessionId);
8120
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8121
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8122
+ const stream = newStream || removeStream || earlyStream;
8095
8123
 
8096
8124
  if (!this._isWeb() || !stream) {
8097
8125
  return;
@@ -5617,6 +5617,7 @@ const MESSAGE = 'message';
5617
5617
  const ACCEPTED = 'accepted';
5618
5618
  const REJECTED = 'rejected';
5619
5619
  const ON_TRACK = 'onTrack';
5620
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5620
5621
  const ON_REINVITE = 'reinvite';
5621
5622
  const ON_ERROR = 'onError';
5622
5623
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5697,6 +5698,7 @@ class WebRTCClient extends Emitter {
5697
5698
 
5698
5699
 
5699
5700
 
5701
+
5700
5702
 
5701
5703
 
5702
5704
  static isAPrivateIp(ip ) {
@@ -5765,6 +5767,7 @@ class WebRTCClient extends Emitter {
5765
5767
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5766
5768
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5767
5769
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5770
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5768
5771
  }
5769
5772
 
5770
5773
  configureMedia(media ) {
@@ -6052,6 +6055,11 @@ class WebRTCClient extends Emitter {
6052
6055
  }
6053
6056
  this._onAccepted(session, response.session, true);
6054
6057
  },
6058
+ onProgress: (payload) => {
6059
+ if (payload.message.statusCode === 183) {
6060
+ this._onEarlyProgress(payload.session);
6061
+ }
6062
+ },
6055
6063
  onReject: (response ) => {
6056
6064
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6057
6065
  this._stopSendingStats(session);
@@ -7444,6 +7452,17 @@ class WebRTCClient extends Emitter {
7444
7452
  };
7445
7453
  }
7446
7454
 
7455
+ _onEarlyProgress(session ) {
7456
+ this._setupMedias(session);
7457
+
7458
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7459
+ this.updateRemoteStream(sessionId);
7460
+
7461
+ logger.info('Early media progress progress received', { sessionId });
7462
+
7463
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7464
+ }
7465
+
7447
7466
  _onAccepted(session , sessionDialog , withEvent = true) {
7448
7467
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7449
7468
 
@@ -7495,15 +7514,24 @@ class WebRTCClient extends Emitter {
7495
7514
 
7496
7515
  _setupMedias(session , newStream ) {
7497
7516
  // Safari hack, because you cannot call .play() from a non user action
7498
- const sessionId = this.getSipSessionId(session);
7517
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7499
7518
  const isConference = this.isConference(sessionId);
7500
7519
 
7520
+ if (sessionId in this.audioElements) {
7521
+ logger.info('html element already exists for session', { sessionId });
7522
+ return;
7523
+ }
7524
+
7501
7525
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7502
7526
  this.createAudioElementFor(sessionId);
7503
7527
  }
7504
7528
 
7505
7529
  const audioElement = this.audioElements[sessionId];
7506
- const stream = newStream || this.getRemoteStream(sessionId);
7530
+ const sipSession = this.sipSessions[session.callId];
7531
+ const removeStream = this.getRemoteStream(sessionId);
7532
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7533
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7534
+ const stream = newStream || removeStream || earlyStream;
7507
7535
 
7508
7536
  if (!this._isWeb() || !stream) {
7509
7537
  return;
@@ -5617,6 +5617,7 @@ const MESSAGE = 'message';
5617
5617
  const ACCEPTED = 'accepted';
5618
5618
  const REJECTED = 'rejected';
5619
5619
  const ON_TRACK = 'onTrack';
5620
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5620
5621
  const ON_REINVITE = 'reinvite';
5621
5622
  const ON_ERROR = 'onError';
5622
5623
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5697,6 +5698,7 @@ class WebRTCClient extends Emitter {
5697
5698
 
5698
5699
 
5699
5700
 
5701
+
5700
5702
 
5701
5703
 
5702
5704
  static isAPrivateIp(ip ) {
@@ -5765,6 +5767,7 @@ class WebRTCClient extends Emitter {
5765
5767
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5766
5768
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5767
5769
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5770
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5768
5771
  }
5769
5772
 
5770
5773
  configureMedia(media ) {
@@ -6052,6 +6055,11 @@ class WebRTCClient extends Emitter {
6052
6055
  }
6053
6056
  this._onAccepted(session, response.session, true);
6054
6057
  },
6058
+ onProgress: (payload) => {
6059
+ if (payload.message.statusCode === 183) {
6060
+ this._onEarlyProgress(payload.session);
6061
+ }
6062
+ },
6055
6063
  onReject: (response ) => {
6056
6064
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6057
6065
  this._stopSendingStats(session);
@@ -7444,6 +7452,17 @@ class WebRTCClient extends Emitter {
7444
7452
  };
7445
7453
  }
7446
7454
 
7455
+ _onEarlyProgress(session ) {
7456
+ this._setupMedias(session);
7457
+
7458
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7459
+ this.updateRemoteStream(sessionId);
7460
+
7461
+ logger.info('Early media progress progress received', { sessionId });
7462
+
7463
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7464
+ }
7465
+
7447
7466
  _onAccepted(session , sessionDialog , withEvent = true) {
7448
7467
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7449
7468
 
@@ -7495,15 +7514,24 @@ class WebRTCClient extends Emitter {
7495
7514
 
7496
7515
  _setupMedias(session , newStream ) {
7497
7516
  // Safari hack, because you cannot call .play() from a non user action
7498
- const sessionId = this.getSipSessionId(session);
7517
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7499
7518
  const isConference = this.isConference(sessionId);
7500
7519
 
7520
+ if (sessionId in this.audioElements) {
7521
+ logger.info('html element already exists for session', { sessionId });
7522
+ return;
7523
+ }
7524
+
7501
7525
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7502
7526
  this.createAudioElementFor(sessionId);
7503
7527
  }
7504
7528
 
7505
7529
  const audioElement = this.audioElements[sessionId];
7506
- const stream = newStream || this.getRemoteStream(sessionId);
7530
+ const sipSession = this.sipSessions[session.callId];
7531
+ const removeStream = this.getRemoteStream(sessionId);
7532
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7533
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7534
+ const stream = newStream || removeStream || earlyStream;
7507
7535
 
7508
7536
  if (!this._isWeb() || !stream) {
7509
7537
  return;
@@ -968,6 +968,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
968
968
  const ON_CHAT = 'phone/ON_CHAT';
969
969
  const ON_SIGNAL = 'phone/ON_SIGNAL';
970
970
  const ON_DISCONNECTED = 'onDisconnected';
971
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
971
972
 
972
973
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
973
974
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -1009,6 +1010,7 @@ const events = [
1009
1010
  ON_SIGNAL,
1010
1011
  ON_NETWORK_STATS,
1011
1012
  ON_DISCONNECTED,
1013
+ ON_EARLY_MEDIA,
1012
1014
  ];
1013
1015
 
1014
1016
  const logger = IssueReporter$1.loggerFor('webrtc-phone');
@@ -2438,6 +2440,10 @@ class WebRTCPhone extends Emitter {
2438
2440
  logger.info('WebRTC disconnected');
2439
2441
  this.eventEmitter.emit(ON_DISCONNECTED);
2440
2442
  });
2443
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
2444
+ logger.info('WebRTC early media');
2445
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
2446
+ });
2441
2447
 
2442
2448
  this.client.on(this.client.REGISTERED, () => {
2443
2449
  logger.info('WebRTC registered', {
@@ -2700,6 +2706,7 @@ exports.ON_CAMERA_DISABLED = ON_CAMERA_DISABLED;
2700
2706
  exports.ON_CAMERA_RESUMED = ON_CAMERA_RESUMED;
2701
2707
  exports.ON_CHAT = ON_CHAT;
2702
2708
  exports.ON_DISCONNECTED = ON_DISCONNECTED;
2709
+ exports.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
2703
2710
  exports.ON_MESSAGE = ON_MESSAGE;
2704
2711
  exports.ON_MESSAGE_TRACK_UPDATED = ON_MESSAGE_TRACK_UPDATED;
2705
2712
  exports.ON_NETWORK_STATS = ON_NETWORK_STATS;
package/lib/index.js CHANGED
@@ -6522,6 +6522,7 @@ const MESSAGE = 'message';
6522
6522
  const ACCEPTED = 'accepted';
6523
6523
  const REJECTED = 'rejected';
6524
6524
  const ON_TRACK$1 = 'onTrack';
6525
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6525
6526
  const ON_REINVITE$1 = 'reinvite';
6526
6527
  const ON_ERROR = 'onError';
6527
6528
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6605,6 +6606,7 @@ class WebRTCClient extends Emitter {
6605
6606
 
6606
6607
 
6607
6608
 
6609
+
6608
6610
 
6609
6611
 
6610
6612
  static isAPrivateIp(ip ) {
@@ -6673,6 +6675,7 @@ class WebRTCClient extends Emitter {
6673
6675
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6674
6676
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6675
6677
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6678
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6676
6679
  }
6677
6680
 
6678
6681
  configureMedia(media ) {
@@ -6960,6 +6963,11 @@ class WebRTCClient extends Emitter {
6960
6963
  }
6961
6964
  this._onAccepted(session, response.session, true);
6962
6965
  },
6966
+ onProgress: (payload) => {
6967
+ if (payload.message.statusCode === 183) {
6968
+ this._onEarlyProgress(payload.session);
6969
+ }
6970
+ },
6963
6971
  onReject: (response ) => {
6964
6972
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6965
6973
  this._stopSendingStats(session);
@@ -8352,6 +8360,17 @@ class WebRTCClient extends Emitter {
8352
8360
  };
8353
8361
  }
8354
8362
 
8363
+ _onEarlyProgress(session ) {
8364
+ this._setupMedias(session);
8365
+
8366
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8367
+ this.updateRemoteStream(sessionId);
8368
+
8369
+ logger$9.info('Early media progress progress received', { sessionId });
8370
+
8371
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8372
+ }
8373
+
8355
8374
  _onAccepted(session , sessionDialog , withEvent = true) {
8356
8375
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8357
8376
 
@@ -8403,15 +8422,24 @@ class WebRTCClient extends Emitter {
8403
8422
 
8404
8423
  _setupMedias(session , newStream ) {
8405
8424
  // Safari hack, because you cannot call .play() from a non user action
8406
- const sessionId = this.getSipSessionId(session);
8425
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8407
8426
  const isConference = this.isConference(sessionId);
8408
8427
 
8428
+ if (sessionId in this.audioElements) {
8429
+ logger$9.info('html element already exists for session', { sessionId });
8430
+ return;
8431
+ }
8432
+
8409
8433
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8410
8434
  this.createAudioElementFor(sessionId);
8411
8435
  }
8412
8436
 
8413
8437
  const audioElement = this.audioElements[sessionId];
8414
- const stream = newStream || this.getRemoteStream(sessionId);
8438
+ const sipSession = this.sipSessions[session.callId];
8439
+ const removeStream = this.getRemoteStream(sessionId);
8440
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8441
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8442
+ const stream = newStream || removeStream || earlyStream;
8415
8443
 
8416
8444
  if (!this._isWeb() || !stream) {
8417
8445
  return;
@@ -9651,6 +9679,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9651
9679
  const ON_CHAT = 'phone/ON_CHAT';
9652
9680
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9653
9681
  const ON_DISCONNECTED = 'onDisconnected';
9682
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9654
9683
 
9655
9684
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9656
9685
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9692,6 +9721,7 @@ const events = [
9692
9721
  ON_SIGNAL,
9693
9722
  ON_NETWORK_STATS,
9694
9723
  ON_DISCONNECTED,
9724
+ ON_EARLY_MEDIA,
9695
9725
  ];
9696
9726
 
9697
9727
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -11121,6 +11151,10 @@ class WebRTCPhone extends Emitter {
11121
11151
  logger$7.info('WebRTC disconnected');
11122
11152
  this.eventEmitter.emit(ON_DISCONNECTED);
11123
11153
  });
11154
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
11155
+ logger$7.info('WebRTC early media');
11156
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
11157
+ });
11124
11158
 
11125
11159
  this.client.on(this.client.REGISTERED, () => {
11126
11160
  logger$7.info('WebRTC registered', {
@@ -11404,6 +11438,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11404
11438
  ON_CHAT: ON_CHAT,
11405
11439
  ON_SIGNAL: ON_SIGNAL,
11406
11440
  ON_DISCONNECTED: ON_DISCONNECTED,
11441
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11407
11442
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11408
11443
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11409
11444
  events: events,