@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';
@@ -5688,6 +5689,7 @@ class WebRTCClient extends Emitter {
5688
5689
 
5689
5690
 
5690
5691
 
5692
+
5691
5693
 
5692
5694
 
5693
5695
  static isAPrivateIp(ip ) {
@@ -5756,6 +5758,7 @@ class WebRTCClient extends Emitter {
5756
5758
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5757
5759
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5758
5760
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5761
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5759
5762
  }
5760
5763
 
5761
5764
  configureMedia(media ) {
@@ -6043,6 +6046,11 @@ class WebRTCClient extends Emitter {
6043
6046
  }
6044
6047
  this._onAccepted(session, response.session, true);
6045
6048
  },
6049
+ onProgress: (payload) => {
6050
+ if (payload.message.statusCode === 183) {
6051
+ this._onEarlyProgress(payload.session);
6052
+ }
6053
+ },
6046
6054
  onReject: (response ) => {
6047
6055
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6048
6056
  this._stopSendingStats(session);
@@ -7435,6 +7443,17 @@ class WebRTCClient extends Emitter {
7435
7443
  };
7436
7444
  }
7437
7445
 
7446
+ _onEarlyProgress(session ) {
7447
+ this._setupMedias(session);
7448
+
7449
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7450
+ this.updateRemoteStream(sessionId);
7451
+
7452
+ logger.info('Early media progress progress received', { sessionId });
7453
+
7454
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7455
+ }
7456
+
7438
7457
  _onAccepted(session , sessionDialog , withEvent = true) {
7439
7458
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7440
7459
 
@@ -7486,15 +7505,24 @@ class WebRTCClient extends Emitter {
7486
7505
 
7487
7506
  _setupMedias(session , newStream ) {
7488
7507
  // Safari hack, because you cannot call .play() from a non user action
7489
- const sessionId = this.getSipSessionId(session);
7508
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7490
7509
  const isConference = this.isConference(sessionId);
7491
7510
 
7511
+ if (sessionId in this.audioElements) {
7512
+ logger.info('html element already exists for session', { sessionId });
7513
+ return;
7514
+ }
7515
+
7492
7516
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7493
7517
  this.createAudioElementFor(sessionId);
7494
7518
  }
7495
7519
 
7496
7520
  const audioElement = this.audioElements[sessionId];
7497
- const stream = newStream || this.getRemoteStream(sessionId);
7521
+ const sipSession = this.sipSessions[session.callId];
7522
+ const removeStream = this.getRemoteStream(sessionId);
7523
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7524
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7525
+ const stream = newStream || removeStream || earlyStream;
7498
7526
 
7499
7527
  if (!this._isWeb() || !stream) {
7500
7528
  return;
@@ -6195,6 +6195,7 @@ const MESSAGE = 'message';
6195
6195
  const ACCEPTED = 'accepted';
6196
6196
  const REJECTED = 'rejected';
6197
6197
  const ON_TRACK = 'onTrack';
6198
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
6198
6199
  const ON_REINVITE = 'reinvite';
6199
6200
  const ON_ERROR = 'onError';
6200
6201
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6275,6 +6276,7 @@ class WebRTCClient extends Emitter {
6275
6276
 
6276
6277
 
6277
6278
 
6279
+
6278
6280
 
6279
6281
 
6280
6282
  static isAPrivateIp(ip ) {
@@ -6343,6 +6345,7 @@ class WebRTCClient extends Emitter {
6343
6345
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6344
6346
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6345
6347
  this.ON_DISCONNECTED = ON_DISCONNECTED;
6348
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
6346
6349
  }
6347
6350
 
6348
6351
  configureMedia(media ) {
@@ -6630,6 +6633,11 @@ class WebRTCClient extends Emitter {
6630
6633
  }
6631
6634
  this._onAccepted(session, response.session, true);
6632
6635
  },
6636
+ onProgress: (payload) => {
6637
+ if (payload.message.statusCode === 183) {
6638
+ this._onEarlyProgress(payload.session);
6639
+ }
6640
+ },
6633
6641
  onReject: (response ) => {
6634
6642
  logger$1.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6635
6643
  this._stopSendingStats(session);
@@ -8022,6 +8030,17 @@ class WebRTCClient extends Emitter {
8022
8030
  };
8023
8031
  }
8024
8032
 
8033
+ _onEarlyProgress(session ) {
8034
+ this._setupMedias(session);
8035
+
8036
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8037
+ this.updateRemoteStream(sessionId);
8038
+
8039
+ logger$1.info('Early media progress progress received', { sessionId });
8040
+
8041
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
8042
+ }
8043
+
8025
8044
  _onAccepted(session , sessionDialog , withEvent = true) {
8026
8045
  logger$1.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8027
8046
 
@@ -8073,15 +8092,24 @@ class WebRTCClient extends Emitter {
8073
8092
 
8074
8093
  _setupMedias(session , newStream ) {
8075
8094
  // Safari hack, because you cannot call .play() from a non user action
8076
- const sessionId = this.getSipSessionId(session);
8095
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8077
8096
  const isConference = this.isConference(sessionId);
8078
8097
 
8098
+ if (sessionId in this.audioElements) {
8099
+ logger$1.info('html element already exists for session', { sessionId });
8100
+ return;
8101
+ }
8102
+
8079
8103
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8080
8104
  this.createAudioElementFor(sessionId);
8081
8105
  }
8082
8106
 
8083
8107
  const audioElement = this.audioElements[sessionId];
8084
- const stream = newStream || this.getRemoteStream(sessionId);
8108
+ const sipSession = this.sipSessions[session.callId];
8109
+ const removeStream = this.getRemoteStream(sessionId);
8110
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8111
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8112
+ const stream = newStream || removeStream || earlyStream;
8085
8113
 
8086
8114
  if (!this._isWeb() || !stream) {
8087
8115
  return;
@@ -6195,6 +6195,7 @@ const MESSAGE = 'message';
6195
6195
  const ACCEPTED = 'accepted';
6196
6196
  const REJECTED = 'rejected';
6197
6197
  const ON_TRACK = 'onTrack';
6198
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
6198
6199
  const ON_REINVITE = 'reinvite';
6199
6200
  const ON_ERROR = 'onError';
6200
6201
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6275,6 +6276,7 @@ class WebRTCClient extends Emitter {
6275
6276
 
6276
6277
 
6277
6278
 
6279
+
6278
6280
 
6279
6281
 
6280
6282
  static isAPrivateIp(ip ) {
@@ -6343,6 +6345,7 @@ class WebRTCClient extends Emitter {
6343
6345
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6344
6346
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6345
6347
  this.ON_DISCONNECTED = ON_DISCONNECTED;
6348
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
6346
6349
  }
6347
6350
 
6348
6351
  configureMedia(media ) {
@@ -6630,6 +6633,11 @@ class WebRTCClient extends Emitter {
6630
6633
  }
6631
6634
  this._onAccepted(session, response.session, true);
6632
6635
  },
6636
+ onProgress: (payload) => {
6637
+ if (payload.message.statusCode === 183) {
6638
+ this._onEarlyProgress(payload.session);
6639
+ }
6640
+ },
6633
6641
  onReject: (response ) => {
6634
6642
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6635
6643
  this._stopSendingStats(session);
@@ -8022,6 +8030,17 @@ class WebRTCClient extends Emitter {
8022
8030
  };
8023
8031
  }
8024
8032
 
8033
+ _onEarlyProgress(session ) {
8034
+ this._setupMedias(session);
8035
+
8036
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8037
+ this.updateRemoteStream(sessionId);
8038
+
8039
+ logger.info('Early media progress progress received', { sessionId });
8040
+
8041
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
8042
+ }
8043
+
8025
8044
  _onAccepted(session , sessionDialog , withEvent = true) {
8026
8045
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8027
8046
 
@@ -8073,15 +8092,24 @@ class WebRTCClient extends Emitter {
8073
8092
 
8074
8093
  _setupMedias(session , newStream ) {
8075
8094
  // Safari hack, because you cannot call .play() from a non user action
8076
- const sessionId = this.getSipSessionId(session);
8095
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8077
8096
  const isConference = this.isConference(sessionId);
8078
8097
 
8098
+ if (sessionId in this.audioElements) {
8099
+ logger.info('html element already exists for session', { sessionId });
8100
+ return;
8101
+ }
8102
+
8079
8103
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8080
8104
  this.createAudioElementFor(sessionId);
8081
8105
  }
8082
8106
 
8083
8107
  const audioElement = this.audioElements[sessionId];
8084
- const stream = newStream || this.getRemoteStream(sessionId);
8108
+ const sipSession = this.sipSessions[session.callId];
8109
+ const removeStream = this.getRemoteStream(sessionId);
8110
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8111
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8112
+ const stream = newStream || removeStream || earlyStream;
8085
8113
 
8086
8114
  if (!this._isWeb() || !stream) {
8087
8115
  return;
@@ -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';
@@ -5688,6 +5689,7 @@ class WebRTCClient extends Emitter {
5688
5689
 
5689
5690
 
5690
5691
 
5692
+
5691
5693
 
5692
5694
 
5693
5695
  static isAPrivateIp(ip ) {
@@ -5756,6 +5758,7 @@ class WebRTCClient extends Emitter {
5756
5758
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5757
5759
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5758
5760
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5761
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5759
5762
  }
5760
5763
 
5761
5764
  configureMedia(media ) {
@@ -6043,6 +6046,11 @@ class WebRTCClient extends Emitter {
6043
6046
  }
6044
6047
  this._onAccepted(session, response.session, true);
6045
6048
  },
6049
+ onProgress: (payload) => {
6050
+ if (payload.message.statusCode === 183) {
6051
+ this._onEarlyProgress(payload.session);
6052
+ }
6053
+ },
6046
6054
  onReject: (response ) => {
6047
6055
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6048
6056
  this._stopSendingStats(session);
@@ -7435,6 +7443,17 @@ class WebRTCClient extends Emitter {
7435
7443
  };
7436
7444
  }
7437
7445
 
7446
+ _onEarlyProgress(session ) {
7447
+ this._setupMedias(session);
7448
+
7449
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7450
+ this.updateRemoteStream(sessionId);
7451
+
7452
+ logger.info('Early media progress progress received', { sessionId });
7453
+
7454
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7455
+ }
7456
+
7438
7457
  _onAccepted(session , sessionDialog , withEvent = true) {
7439
7458
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7440
7459
 
@@ -7486,15 +7505,24 @@ class WebRTCClient extends Emitter {
7486
7505
 
7487
7506
  _setupMedias(session , newStream ) {
7488
7507
  // Safari hack, because you cannot call .play() from a non user action
7489
- const sessionId = this.getSipSessionId(session);
7508
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7490
7509
  const isConference = this.isConference(sessionId);
7491
7510
 
7511
+ if (sessionId in this.audioElements) {
7512
+ logger.info('html element already exists for session', { sessionId });
7513
+ return;
7514
+ }
7515
+
7492
7516
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7493
7517
  this.createAudioElementFor(sessionId);
7494
7518
  }
7495
7519
 
7496
7520
  const audioElement = this.audioElements[sessionId];
7497
- const stream = newStream || this.getRemoteStream(sessionId);
7521
+ const sipSession = this.sipSessions[session.callId];
7522
+ const removeStream = this.getRemoteStream(sessionId);
7523
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7524
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7525
+ const stream = newStream || removeStream || earlyStream;
7498
7526
 
7499
7527
  if (!this._isWeb() || !stream) {
7500
7528
  return;
@@ -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';
@@ -5688,6 +5689,7 @@ class WebRTCClient extends Emitter {
5688
5689
 
5689
5690
 
5690
5691
 
5692
+
5691
5693
 
5692
5694
 
5693
5695
  static isAPrivateIp(ip ) {
@@ -5756,6 +5758,7 @@ class WebRTCClient extends Emitter {
5756
5758
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5757
5759
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5758
5760
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5761
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5759
5762
  }
5760
5763
 
5761
5764
  configureMedia(media ) {
@@ -6043,6 +6046,11 @@ class WebRTCClient extends Emitter {
6043
6046
  }
6044
6047
  this._onAccepted(session, response.session, true);
6045
6048
  },
6049
+ onProgress: (payload) => {
6050
+ if (payload.message.statusCode === 183) {
6051
+ this._onEarlyProgress(payload.session);
6052
+ }
6053
+ },
6046
6054
  onReject: (response ) => {
6047
6055
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6048
6056
  this._stopSendingStats(session);
@@ -7435,6 +7443,17 @@ class WebRTCClient extends Emitter {
7435
7443
  };
7436
7444
  }
7437
7445
 
7446
+ _onEarlyProgress(session ) {
7447
+ this._setupMedias(session);
7448
+
7449
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7450
+ this.updateRemoteStream(sessionId);
7451
+
7452
+ logger.info('Early media progress progress received', { sessionId });
7453
+
7454
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7455
+ }
7456
+
7438
7457
  _onAccepted(session , sessionDialog , withEvent = true) {
7439
7458
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7440
7459
 
@@ -7486,15 +7505,24 @@ class WebRTCClient extends Emitter {
7486
7505
 
7487
7506
  _setupMedias(session , newStream ) {
7488
7507
  // Safari hack, because you cannot call .play() from a non user action
7489
- const sessionId = this.getSipSessionId(session);
7508
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7490
7509
  const isConference = this.isConference(sessionId);
7491
7510
 
7511
+ if (sessionId in this.audioElements) {
7512
+ logger.info('html element already exists for session', { sessionId });
7513
+ return;
7514
+ }
7515
+
7492
7516
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7493
7517
  this.createAudioElementFor(sessionId);
7494
7518
  }
7495
7519
 
7496
7520
  const audioElement = this.audioElements[sessionId];
7497
- const stream = newStream || this.getRemoteStream(sessionId);
7521
+ const sipSession = this.sipSessions[session.callId];
7522
+ const removeStream = this.getRemoteStream(sessionId);
7523
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
7524
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
7525
+ const stream = newStream || removeStream || earlyStream;
7498
7526
 
7499
7527
  if (!this._isWeb() || !stream) {
7500
7528
  return;
@@ -959,6 +959,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
959
959
  const ON_CHAT = 'phone/ON_CHAT';
960
960
  const ON_SIGNAL = 'phone/ON_SIGNAL';
961
961
  const ON_DISCONNECTED = 'onDisconnected';
962
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
962
963
 
963
964
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
964
965
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -1000,6 +1001,7 @@ const events = [
1000
1001
  ON_SIGNAL,
1001
1002
  ON_NETWORK_STATS,
1002
1003
  ON_DISCONNECTED,
1004
+ ON_EARLY_MEDIA,
1003
1005
  ];
1004
1006
 
1005
1007
  const logger = IssueReporter$1.loggerFor('webrtc-phone');
@@ -2429,6 +2431,10 @@ class WebRTCPhone extends Emitter {
2429
2431
  logger.info('WebRTC disconnected');
2430
2432
  this.eventEmitter.emit(ON_DISCONNECTED);
2431
2433
  });
2434
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
2435
+ logger.info('WebRTC early media');
2436
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
2437
+ });
2432
2438
 
2433
2439
  this.client.on(this.client.REGISTERED, () => {
2434
2440
  logger.info('WebRTC registered', {
@@ -2670,4 +2676,4 @@ class WebRTCPhone extends Emitter {
2670
2676
  }
2671
2677
 
2672
2678
  export default WebRTCPhone;
2673
- export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
2679
+ export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_EARLY_MEDIA, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
package/esm/index.js CHANGED
@@ -6511,6 +6511,7 @@ const MESSAGE = 'message';
6511
6511
  const ACCEPTED = 'accepted';
6512
6512
  const REJECTED = 'rejected';
6513
6513
  const ON_TRACK$1 = 'onTrack';
6514
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6514
6515
  const ON_REINVITE$1 = 'reinvite';
6515
6516
  const ON_ERROR = 'onError';
6516
6517
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6594,6 +6595,7 @@ class WebRTCClient extends Emitter {
6594
6595
 
6595
6596
 
6596
6597
 
6598
+
6597
6599
 
6598
6600
 
6599
6601
  static isAPrivateIp(ip ) {
@@ -6662,6 +6664,7 @@ class WebRTCClient extends Emitter {
6662
6664
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6663
6665
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6664
6666
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6667
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6665
6668
  }
6666
6669
 
6667
6670
  configureMedia(media ) {
@@ -6949,6 +6952,11 @@ class WebRTCClient extends Emitter {
6949
6952
  }
6950
6953
  this._onAccepted(session, response.session, true);
6951
6954
  },
6955
+ onProgress: (payload) => {
6956
+ if (payload.message.statusCode === 183) {
6957
+ this._onEarlyProgress(payload.session);
6958
+ }
6959
+ },
6952
6960
  onReject: (response ) => {
6953
6961
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6954
6962
  this._stopSendingStats(session);
@@ -8341,6 +8349,17 @@ class WebRTCClient extends Emitter {
8341
8349
  };
8342
8350
  }
8343
8351
 
8352
+ _onEarlyProgress(session ) {
8353
+ this._setupMedias(session);
8354
+
8355
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8356
+ this.updateRemoteStream(sessionId);
8357
+
8358
+ logger$9.info('Early media progress progress received', { sessionId });
8359
+
8360
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8361
+ }
8362
+
8344
8363
  _onAccepted(session , sessionDialog , withEvent = true) {
8345
8364
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8346
8365
 
@@ -8392,15 +8411,24 @@ class WebRTCClient extends Emitter {
8392
8411
 
8393
8412
  _setupMedias(session , newStream ) {
8394
8413
  // Safari hack, because you cannot call .play() from a non user action
8395
- const sessionId = this.getSipSessionId(session);
8414
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8396
8415
  const isConference = this.isConference(sessionId);
8397
8416
 
8417
+ if (sessionId in this.audioElements) {
8418
+ logger$9.info('html element already exists for session', { sessionId });
8419
+ return;
8420
+ }
8421
+
8398
8422
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8399
8423
  this.createAudioElementFor(sessionId);
8400
8424
  }
8401
8425
 
8402
8426
  const audioElement = this.audioElements[sessionId];
8403
- const stream = newStream || this.getRemoteStream(sessionId);
8427
+ const sipSession = this.sipSessions[session.callId];
8428
+ const removeStream = this.getRemoteStream(sessionId);
8429
+ const earlyStream = sipSession && sipSession.sessionDescriptionHandler
8430
+ ? sipSession.sessionDescriptionHandler.remoteMediaStream : null;
8431
+ const stream = newStream || removeStream || earlyStream;
8404
8432
 
8405
8433
  if (!this._isWeb() || !stream) {
8406
8434
  return;
@@ -9640,6 +9668,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9640
9668
  const ON_CHAT = 'phone/ON_CHAT';
9641
9669
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9642
9670
  const ON_DISCONNECTED = 'onDisconnected';
9671
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9643
9672
 
9644
9673
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9645
9674
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9681,6 +9710,7 @@ const events = [
9681
9710
  ON_SIGNAL,
9682
9711
  ON_NETWORK_STATS,
9683
9712
  ON_DISCONNECTED,
9713
+ ON_EARLY_MEDIA,
9684
9714
  ];
9685
9715
 
9686
9716
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -11110,6 +11140,10 @@ class WebRTCPhone extends Emitter {
11110
11140
  logger$7.info('WebRTC disconnected');
11111
11141
  this.eventEmitter.emit(ON_DISCONNECTED);
11112
11142
  });
11143
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
11144
+ logger$7.info('WebRTC early media');
11145
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
11146
+ });
11113
11147
 
11114
11148
  this.client.on(this.client.REGISTERED, () => {
11115
11149
  logger$7.info('WebRTC registered', {
@@ -11393,6 +11427,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11393
11427
  ON_CHAT: ON_CHAT,
11394
11428
  ON_SIGNAL: ON_SIGNAL,
11395
11429
  ON_DISCONNECTED: ON_DISCONNECTED,
11430
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11396
11431
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11397
11432
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11398
11433
  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,