@wazo/sdk 0.37.2 → 0.37.6

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 (99) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +84 -22
  3. package/esm/__tests__/web-rtc-client.test.js +156 -55
  4. package/esm/api/call-logd.js +10 -22
  5. package/esm/api/calld.js +3 -0
  6. package/esm/api/confd.js +71 -0
  7. package/esm/api-client.js +84 -22
  8. package/esm/checker/Checker.js +160 -55
  9. package/esm/checker/checks/aor.js +84 -22
  10. package/esm/checker/checks/api.js +84 -22
  11. package/esm/checker/checks/index.js +160 -55
  12. package/esm/checker/checks/wazo-websocket.js +4 -0
  13. package/esm/checker/checks/webrtc-transport.js +156 -55
  14. package/esm/checker/checks/webrtc.js +156 -55
  15. package/esm/domain/AdHocAPIConference.js +84 -22
  16. package/esm/domain/CallLog.js +10 -22
  17. package/esm/domain/Features.js +84 -22
  18. package/esm/domain/Meeting.js +71 -0
  19. package/esm/domain/Phone/CTIPhone.js +84 -22
  20. package/esm/domain/Phone/WebRTCPhone.js +22 -8
  21. package/esm/domain/__tests__/CallLog.test.js +10 -22
  22. package/esm/index.js +726 -371
  23. package/esm/lib/WazoSessionDescriptionHandler.js +17 -9
  24. package/esm/service/CallApi.js +84 -22
  25. package/esm/service/getApiClient.js +84 -22
  26. package/esm/simple/Auth.js +717 -363
  27. package/esm/simple/Configuration.js +717 -363
  28. package/esm/simple/Directory.js +84 -22
  29. package/esm/simple/Phone.js +709 -355
  30. package/esm/simple/Websocket.js +6 -0
  31. package/esm/simple/index.js +719 -365
  32. package/esm/simple/room/LocalParticipant.js +689 -335
  33. package/esm/simple/room/Participant.js +689 -335
  34. package/esm/simple/room/RemoteParticipant.js +689 -335
  35. package/esm/simple/room/Room.js +689 -335
  36. package/esm/simple/room/SipRoom.js +13001 -0
  37. package/esm/simple/room/Stream.js +719 -365
  38. package/esm/simple/room/__tests__/RemoteParticipant.test.js +4130 -3774
  39. package/esm/simple/utils.js +719 -365
  40. package/esm/web-rtc-client.js +156 -55
  41. package/esm/websocket-client.js +5 -1
  42. package/lib/__tests__/api-client.test.js +84 -22
  43. package/lib/__tests__/web-rtc-client.test.js +156 -55
  44. package/lib/api/call-logd.js +10 -22
  45. package/lib/api/calld.js +3 -0
  46. package/lib/api/confd.js +71 -0
  47. package/lib/api-client.js +84 -22
  48. package/lib/checker/Checker.js +160 -55
  49. package/lib/checker/checks/aor.js +84 -22
  50. package/lib/checker/checks/api.js +84 -22
  51. package/lib/checker/checks/index.js +160 -55
  52. package/lib/checker/checks/wazo-websocket.js +4 -0
  53. package/lib/checker/checks/webrtc-transport.js +156 -55
  54. package/lib/checker/checks/webrtc.js +156 -55
  55. package/lib/domain/AdHocAPIConference.js +84 -22
  56. package/lib/domain/CallLog.js +10 -22
  57. package/lib/domain/Features.js +84 -22
  58. package/lib/domain/Meeting.js +73 -0
  59. package/lib/domain/Phone/CTIPhone.js +84 -22
  60. package/lib/domain/Phone/WebRTCPhone.js +22 -8
  61. package/lib/domain/__tests__/CallLog.test.js +10 -22
  62. package/lib/index.js +726 -371
  63. package/lib/lib/WazoSessionDescriptionHandler.js +17 -9
  64. package/lib/service/CallApi.js +84 -22
  65. package/lib/service/getApiClient.js +84 -22
  66. package/lib/simple/Auth.js +717 -363
  67. package/lib/simple/Configuration.js +717 -363
  68. package/lib/simple/Directory.js +84 -22
  69. package/lib/simple/Phone.js +709 -355
  70. package/lib/simple/Websocket.js +6 -0
  71. package/lib/simple/index.js +719 -365
  72. package/lib/simple/room/LocalParticipant.js +689 -335
  73. package/lib/simple/room/Participant.js +689 -335
  74. package/lib/simple/room/RemoteParticipant.js +689 -335
  75. package/lib/simple/room/Room.js +689 -335
  76. package/lib/simple/room/SipRoom.js +13011 -0
  77. package/lib/simple/room/Stream.js +719 -365
  78. package/lib/simple/room/__tests__/RemoteParticipant.test.js +4131 -3775
  79. package/lib/simple/utils.js +719 -365
  80. package/lib/web-rtc-client.js +156 -55
  81. package/lib/websocket-client.js +6 -0
  82. package/package.json +1 -1
  83. package/src/api/calld.js +3 -0
  84. package/src/api/confd.js +13 -0
  85. package/src/domain/CallLog.js +10 -22
  86. package/src/domain/Meeting.js +59 -0
  87. package/src/domain/Phone/WebRTCPhone.js +22 -8
  88. package/src/index.js +2 -0
  89. package/src/lib/WazoSessionDescriptionHandler.js +17 -9
  90. package/src/simple/Phone.js +13 -4
  91. package/src/simple/index.js +4 -0
  92. package/src/simple/room/Participant.js +7 -0
  93. package/src/simple/room/Room.js +158 -79
  94. package/src/simple/room/SipRoom.js +147 -0
  95. package/src/simple/room/Stream.js +1 -3
  96. package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
  97. package/src/types/WebSocketMessage.js +21 -0
  98. package/src/web-rtc-client.js +55 -24
  99. package/src/websocket-client.js +4 -0
@@ -1848,7 +1848,7 @@ var IssueReporter$1 = new IssueReporter();
1848
1848
 
1849
1849
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1850
1850
 
1851
- const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1851
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1852
1852
 
1853
1853
  // Use a function here to be able to mock it in tests
1854
1854
  const realFetch = () => {
@@ -1987,7 +1987,7 @@ class ApiRequester {
1987
1987
  };
1988
1988
 
1989
1989
  if (this.refreshTokenPromise) {
1990
- logger$b.info('A token is already refreshing, waiting ...', { url });
1990
+ logger$c.info('A token is already refreshing, waiting ...', { url });
1991
1991
  await this.refreshTokenPromise;
1992
1992
  }
1993
1993
 
@@ -2007,7 +2007,7 @@ class ApiRequester {
2007
2007
  return promise.then(async (err ) => {
2008
2008
  // Check if the token is still valid
2009
2009
  if (firstCall && this._checkTokenExpired(response, err)) {
2010
- logger$b.warn('token expired', { error: err.reason });
2010
+ logger$c.warn('token expired', { error: err.reason });
2011
2011
  // Replay the call after refreshing the token
2012
2012
  return this._replayWithNewToken(err, path, method, body, headers, parse);
2013
2013
  }
@@ -2017,7 +2017,7 @@ class ApiRequester {
2017
2017
  : exceptionClass.fromResponse(err, response.status);
2018
2018
 
2019
2019
  if (this.shouldLogErrors) {
2020
- logger$b.error('API error', error);
2020
+ logger$c.error('API error', error);
2021
2021
  }
2022
2022
 
2023
2023
  throw error;
@@ -2027,7 +2027,7 @@ class ApiRequester {
2027
2027
  return newParse(response, isJson);
2028
2028
  }).catch(error => {
2029
2029
  if (this.shouldLogErrors) {
2030
- logger$b.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2030
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2031
2031
  }
2032
2032
 
2033
2033
  throw error;
@@ -2055,13 +2055,13 @@ class ApiRequester {
2055
2055
  ) {
2056
2056
  const isTokenNotFound = this._isTokenNotFound(err);
2057
2057
  let newPath = path;
2058
- logger$b.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2058
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2059
2059
 
2060
2060
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
2061
2061
 
2062
2062
  return this.refreshTokenPromise.then(() => {
2063
2063
  this.refreshTokenPromise = null;
2064
- logger$b.info('token refreshed', { isTokenNotFound });
2064
+ logger$c.info('token refreshed', { isTokenNotFound });
2065
2065
  if (isTokenNotFound) {
2066
2066
  const pathParts = path.split('/');
2067
2067
  pathParts.pop();
@@ -2522,6 +2522,65 @@ class ExternalApp {
2522
2522
  }
2523
2523
  }
2524
2524
 
2525
+ //
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+ class Meeting {
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+ static parse(plain ) {
2549
+ return new Meeting({
2550
+ guestSipAuthorization: plain.guest_sip_authorization,
2551
+ hostname: plain.hostname,
2552
+ name: plain.name,
2553
+ ownerUuids: plain.owner_uuids,
2554
+ port: plain.port,
2555
+ uuid: plain.uuid,
2556
+ number: plain.number,
2557
+ });
2558
+ }
2559
+
2560
+ static newFrom(meeting ) {
2561
+ return newFrom(meeting, Meeting);
2562
+ }
2563
+
2564
+ constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
2565
+ this.guestSipAuthorization = guestSipAuthorization;
2566
+ this.hostname = hostname;
2567
+ this.name = name;
2568
+ this.ownerUuids = ownerUuids;
2569
+ this.port = port;
2570
+ this.uuid = uuid;
2571
+ this.number = number;
2572
+
2573
+ // Useful to compare instead of instanceof with minified code
2574
+ this.type = 'Meeting';
2575
+ }
2576
+
2577
+ getGuestSipCredentials() {
2578
+ // eslint-disable-next-line no-undef
2579
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
2580
+ return { username, secret };
2581
+ }
2582
+ }
2583
+
2525
2584
  /* */
2526
2585
 
2527
2586
  var confdMethods = (client , baseUrl ) => ({
@@ -2586,6 +2645,18 @@ var confdMethods = (client , baseUrl ) => ({
2586
2645
  return null;
2587
2646
  }
2588
2647
  },
2648
+
2649
+ createMyMeeting: (name ) =>
2650
+ client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2651
+
2652
+ deleteMyMeeting: (meetingUuid ) =>
2653
+ client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
2654
+
2655
+ getMeeting: (meetingUuid ) =>
2656
+ client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2657
+
2658
+ guestGetMeeting: (meetingUuid ) =>
2659
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2589
2660
  });
2590
2661
 
2591
2662
  //
@@ -3528,7 +3599,11 @@ class CallLog {
3528
3599
  answered: plain.answered,
3529
3600
  callDirection: plain.call_direction,
3530
3601
  destination: {
3531
- extension: plain.requested_extension || plain.destination_extension,
3602
+ // @TEMP: Temporarily assuming empty numbers are meetings
3603
+ // which is admittedly a very dangerous assumption. Did i mention it was temporary?
3604
+ extension: plain.requested_extension
3605
+ || plain.destination_extension
3606
+ || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3532
3607
  name: plain.requested_name || plain.destination_name || '',
3533
3608
  },
3534
3609
  source: {
@@ -3544,27 +3619,11 @@ class CallLog {
3544
3619
  }
3545
3620
 
3546
3621
  static parseNew(plain , session ) {
3547
- return new CallLog({
3548
- answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3549
- answered: plain.answered,
3550
- callDirection: plain.call_direction,
3551
- destination: {
3552
- extension: plain.requested_extension || plain.destination_extension,
3553
- name: plain.requested_name || plain.destination_name || '',
3554
- },
3555
- source: {
3556
- extension: plain.source_extension,
3557
- name: plain.source_name,
3558
- },
3559
- id: plain.id,
3560
- duration: (plain.duration || 0) * 1000, // duration is in seconds
3561
- start: moment__default['default'](plain.start).toDate(),
3562
- end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3563
- recordings: Recording.parseMany(plain.recordings),
3564
- // @TODO: FIXME add verification declined vs missed call
3565
- newMissedCall: session
3566
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
3567
- });
3622
+ const callLog = CallLog.parse(plain);
3623
+ // @TODO: FIXME add verification declined vs missed call
3624
+ callLog.newMissedCall = session
3625
+ && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
3626
+ return callLog;
3568
3627
  }
3569
3628
 
3570
3629
  static newFrom(profile ) {
@@ -3829,7 +3888,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
3829
3888
 
3830
3889
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
3831
3890
 
3832
- const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
3891
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
3833
3892
 
3834
3893
  class CTIPhone extends Emitter {
3835
3894
 
@@ -3842,7 +3901,7 @@ class CTIPhone extends Emitter {
3842
3901
 
3843
3902
  constructor(session , isMobile = false, callbackAllLines = false) {
3844
3903
  super();
3845
- logger$a.info('CTI Phone created');
3904
+ logger$b.info('CTI Phone created');
3846
3905
  this.session = session;
3847
3906
  this.isMobile = isMobile;
3848
3907
  this.callbackAllLines = callbackAllLines;
@@ -3903,7 +3962,7 @@ class CTIPhone extends Emitter {
3903
3962
  }
3904
3963
 
3905
3964
  async makeCall(number , line ) {
3906
- logger$a.info('make CTI call', { number });
3965
+ logger$b.info('make CTI call', { number });
3907
3966
 
3908
3967
  if (!number) {
3909
3968
  return null;
@@ -3926,7 +3985,7 @@ class CTIPhone extends Emitter {
3926
3985
  if (!callSession) {
3927
3986
  return Promise.resolve(null);
3928
3987
  }
3929
- logger$a.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
3988
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
3930
3989
 
3931
3990
  if (!this.currentCall) {
3932
3991
  this.currentCall = callSession.call;
@@ -3939,7 +3998,7 @@ class CTIPhone extends Emitter {
3939
3998
  if (!callSession) {
3940
3999
  return;
3941
4000
  }
3942
- logger$a.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4001
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
3943
4002
 
3944
4003
  this.currentCall = undefined;
3945
4004
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -3949,7 +4008,7 @@ class CTIPhone extends Emitter {
3949
4008
  if (!callSession) {
3950
4009
  return Promise.resolve(false);
3951
4010
  }
3952
- logger$a.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4011
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
3953
4012
 
3954
4013
  try {
3955
4014
  await CallApi.cancelCall(callSession);
@@ -3960,7 +4019,7 @@ class CTIPhone extends Emitter {
3960
4019
  this.eventEmitter.emit('onCallEnded', callSession);
3961
4020
  return true;
3962
4021
  } catch (e) {
3963
- logger$a.error('hangup CTI call, error', e);
4022
+ logger$b.error('hangup CTI call, error', e);
3964
4023
 
3965
4024
  this.eventEmitter.emit('onCallFailed', callSession);
3966
4025
  return false;
@@ -3973,7 +4032,7 @@ class CTIPhone extends Emitter {
3973
4032
  if (!callSession) {
3974
4033
  return;
3975
4034
  }
3976
- logger$a.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4035
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
3977
4036
 
3978
4037
  await CallApi.cancelCall(callSession);
3979
4038
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -3983,7 +4042,7 @@ class CTIPhone extends Emitter {
3983
4042
  if (!callSession) {
3984
4043
  return;
3985
4044
  }
3986
- logger$a.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4045
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
3987
4046
 
3988
4047
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
3989
4048
  }
@@ -3994,19 +4053,19 @@ class CTIPhone extends Emitter {
3994
4053
  if (!callSession) {
3995
4054
  return;
3996
4055
  }
3997
- logger$a.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4056
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
3998
4057
 
3999
4058
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4000
4059
  }
4001
4060
 
4002
4061
  async cancelCTIIndirectTransfer(transferId ) {
4003
- logger$a.info('cancel CTI transfer', { transferId });
4062
+ logger$b.info('cancel CTI transfer', { transferId });
4004
4063
 
4005
4064
  return CallApi.cancelCallTransfer(transferId);
4006
4065
  }
4007
4066
 
4008
4067
  async confirmCTIIndirectTransfer(transferId ) {
4009
- logger$a.info('confirm CTI transfer', { transferId });
4068
+ logger$b.info('confirm CTI transfer', { transferId });
4010
4069
 
4011
4070
  return CallApi.confirmCallTransfer(transferId);
4012
4071
  }
@@ -4015,19 +4074,19 @@ class CTIPhone extends Emitter {
4015
4074
  if (!callSession) {
4016
4075
  return;
4017
4076
  }
4018
- logger$a.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4077
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4019
4078
 
4020
4079
  return CallApi.sendDTMF(callSession.callId, digits);
4021
4080
  }
4022
4081
 
4023
4082
  onConnectionMade() {
4024
- logger$a.info('on CTI connection made');
4083
+ logger$b.info('on CTI connection made');
4025
4084
 
4026
4085
  this.eventEmitter.emit('onCallAccepted');
4027
4086
  }
4028
4087
 
4029
4088
  async close() {
4030
- logger$a.info('CTI close');
4089
+ logger$b.info('CTI close');
4031
4090
 
4032
4091
  return Promise.resolve();
4033
4092
  }
@@ -4036,7 +4095,7 @@ class CTIPhone extends Emitter {
4036
4095
  if (!callSession) {
4037
4096
  return;
4038
4097
  }
4039
- logger$a.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4098
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4040
4099
 
4041
4100
  return CallApi.hold(callSession.callId);
4042
4101
  }
@@ -4045,7 +4104,7 @@ class CTIPhone extends Emitter {
4045
4104
  if (!callSession) {
4046
4105
  return;
4047
4106
  }
4048
- logger$a.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4107
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4049
4108
 
4050
4109
  return CallApi.resume(callSession.callId);
4051
4110
  }
@@ -4054,7 +4113,7 @@ class CTIPhone extends Emitter {
4054
4113
  if (!callSession) {
4055
4114
  return;
4056
4115
  }
4057
- logger$a.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4116
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4058
4117
 
4059
4118
  return CallApi.mute(callSession.callId);
4060
4119
  }
@@ -4063,7 +4122,7 @@ class CTIPhone extends Emitter {
4063
4122
  if (!callSession) {
4064
4123
  return;
4065
4124
  }
4066
- logger$a.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4125
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4067
4126
 
4068
4127
  return CallApi.unmute(callSession.callId);
4069
4128
  }
@@ -4709,6 +4768,9 @@ var calldMethods = (client , baseUrl ) => ({
4709
4768
  getConferenceParticipantsAsUser: async (conferenceId ) =>
4710
4769
  client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
4711
4770
 
4771
+ getMeetingParticipantsAsUser: async (meetingUuid ) =>
4772
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4773
+
4712
4774
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4713
4775
 
4714
4776
  mute: (callId ) =>
@@ -5062,7 +5124,7 @@ const AGENTD_VERSION = '1.0';
5062
5124
  const WEBHOOKD_VERSION = '1.0';
5063
5125
  const AMID_VERSION = '1.0';
5064
5126
 
5065
- const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5127
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5066
5128
 
5067
5129
  class ApiClient {
5068
5130
 
@@ -5114,12 +5176,12 @@ class ApiClient {
5114
5176
  }
5115
5177
 
5116
5178
  async forceRefreshToken() {
5117
- logger$9.info('forcing refresh token, calling callback');
5179
+ logger$a.info('forcing refresh token, calling callback');
5118
5180
  return this.refreshTokenCallback();
5119
5181
  }
5120
5182
 
5121
5183
  async refreshTokenCallback() {
5122
- logger$9.info('refresh token callback called', {
5184
+ logger$a.info('refresh token callback called', {
5123
5185
  refreshToken: this.refreshToken,
5124
5186
  refreshBackend: this.refreshBackend,
5125
5187
  refreshExpiration: this.refreshExpiration,
@@ -5137,7 +5199,7 @@ class ApiClient {
5137
5199
  this.isMobile,
5138
5200
  );
5139
5201
 
5140
- logger$9.info('token refreshed', { token: session.token });
5202
+ logger$a.info('token refreshed', { token: session.token });
5141
5203
 
5142
5204
  if (this.onRefreshToken) {
5143
5205
  this.onRefreshToken(session.token, session);
@@ -5278,7 +5340,7 @@ var getApiClient = (forServer ) => {
5278
5340
  class InvalidSubscription extends Error {}
5279
5341
  class InvalidAuthorization extends Error {}
5280
5342
 
5281
- const logger$8 = IssueReporter$1.loggerFor('simple-auth');
5343
+ const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5282
5344
 
5283
5345
  class Auth {
5284
5346
 
@@ -5313,7 +5375,7 @@ class Auth {
5313
5375
  setApiClientId(this.clientId);
5314
5376
  setRefreshExpiration(this.expiration);
5315
5377
  setOnRefreshToken((token , session ) => {
5316
- logger$8.info('on refresh token done', { token });
5378
+ logger$9.info('on refresh token done', { token });
5317
5379
  setApiToken(token);
5318
5380
  Wazo.Websocket.updateToken(token);
5319
5381
 
@@ -5872,7 +5934,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5872
5934
  .then(() => {
5873
5935
  if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
5874
5936
  // Add a video an empty bundle to be able to replaceTrack when joining a conference without video
5875
- this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
5937
+ if (this.peerConnection.addTransceiver) {
5938
+ this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
5939
+ }
5876
5940
  }
5877
5941
  })
5878
5942
  .then(() => this.createLocalOfferOrAnswer(options))
@@ -5899,12 +5963,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5899
5963
  };
5900
5964
  })
5901
5965
  .then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
5902
- .then((sessionDescription) => {
5903
- // Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
5904
- this.localMediaStreamConstraints = options.constraints;
5905
-
5906
- return sessionDescription;
5907
- })
5908
5966
  .then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
5909
5967
  .catch((error) => {
5910
5968
  wazoLogger.error('error when creating media', error);
@@ -6099,6 +6157,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6099
6157
 
6100
6158
  // set the transceiver direction to the answer direction
6101
6159
  this._peerConnection.getTransceivers().forEach((transceiver) => {
6160
+ if (transceiver.stopped) {
6161
+ return;
6162
+ }
6102
6163
  if (transceiver.direction /* guarding, but should always be true */) {
6103
6164
  const { receiver } = transceiver;
6104
6165
  if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
@@ -6143,10 +6204,15 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6143
6204
  if (kind !== 'audio' && kind !== 'video') {
6144
6205
  throw new Error(`Unknown new track kind ${kind}.`);
6145
6206
  }
6146
- const sender = pc.getSenders().find((otherSender) => otherSender.track && otherSender.track.kind === kind);
6207
+ const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
6208
+ otherSender.track && otherSender.track.kind === kind);
6147
6209
 
6148
6210
  // Do not reuse sender video tracks in SFU
6149
6211
  if (sender && (!sfu || newTrack.kind === 'audio')) {
6212
+ if (sender.track) {
6213
+ // eslint-disable-next-line no-param-reassign
6214
+ newTrack.enabled = sender.track.enabled;
6215
+ }
6150
6216
  trackUpdates.push(
6151
6217
  new Promise((resolve) => {
6152
6218
  this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
@@ -6180,7 +6246,11 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6180
6246
  // Review: could make streamless tracks a configurable option?
6181
6247
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
6182
6248
  try {
6183
- pc.addTrack(newTrack, localStream);
6249
+ if (pc.addTrack) {
6250
+ pc.addTrack(newTrack, localStream);
6251
+ } else {
6252
+ pc.addStream(localStream);
6253
+ }
6184
6254
  } catch (error) {
6185
6255
  this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
6186
6256
  throw error;
@@ -6316,7 +6386,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6316
6386
  const SEND_STATS_DELAY = 5000;
6317
6387
 
6318
6388
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6319
- const logger$7 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6389
+ const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6320
6390
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6321
6391
 
6322
6392
  // events
@@ -6362,6 +6432,7 @@ const MAX_REGISTER_TRIES = 10;
6362
6432
 
6363
6433
 
6364
6434
 
6435
+
6365
6436
 
6366
6437
 
6367
6438
 
@@ -6388,6 +6459,7 @@ class WebRTCClient extends Emitter {
6388
6459
 
6389
6460
 
6390
6461
 
6462
+
6391
6463
 
6392
6464
  // sugar
6393
6465
 
@@ -6426,6 +6498,8 @@ class WebRTCClient extends Emitter {
6426
6498
  super();
6427
6499
  this.uaConfigOverrides = uaConfigOverrides;
6428
6500
  this.config = config;
6501
+ this.skipRegister = config.skipRegister;
6502
+
6429
6503
  this._buildConfig(config, session).then((newConfig ) => {
6430
6504
  this.config = newConfig;
6431
6505
  this.userAgent = this.createUserAgent(uaConfigOverrides);
@@ -6481,13 +6555,13 @@ class WebRTCClient extends Emitter {
6481
6555
 
6482
6556
  createUserAgent(configOverrides ) {
6483
6557
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6484
- logger$7.info('sdk webrtc, creating UA', { webRTCConfiguration });
6558
+ logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6485
6559
 
6486
6560
  webRTCConfiguration.delegate = {
6487
6561
  onConnect: this.onConnect.bind(this),
6488
6562
  onDisconnect: this.onDisconnect.bind(this),
6489
6563
  onInvite: (invitation ) => {
6490
- logger$7.info('sdk webrtc on invite', {
6564
+ logger$8.info('sdk webrtc on invite', {
6491
6565
  method: 'delegate.onInvite',
6492
6566
  id: invitation.id,
6493
6567
  remoteURI: invitation.remoteURI,
@@ -6530,7 +6604,7 @@ class WebRTCClient extends Emitter {
6530
6604
  }
6531
6605
 
6532
6606
  onConnect() {
6533
- logger$7.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6607
+ logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6534
6608
  this.eventEmitter.emit(CONNECTED);
6535
6609
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6536
6610
  this.registerer.waitingToggle(false);
@@ -6539,7 +6613,7 @@ class WebRTCClient extends Emitter {
6539
6613
  }
6540
6614
 
6541
6615
  async onDisconnect(error ) {
6542
- logger$7.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6616
+ logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6543
6617
  this.connectionPromise = null;
6544
6618
  // The UA will attempt to reconnect automatically when an error occurred
6545
6619
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6553,40 +6627,48 @@ class WebRTCClient extends Emitter {
6553
6627
  }
6554
6628
 
6555
6629
  register(tries = 0) {
6556
- logger$7.info('sdk webrtc registering...', {
6630
+ const logInfo = {
6557
6631
  userAgent: !!this.userAgent,
6558
6632
  registered: this.isRegistered(),
6559
6633
  connectionPromise: !!this.connectionPromise,
6560
6634
  registerer: !!this.registerer,
6561
6635
  waiting: this.registerer && this.registerer.waiting,
6562
6636
  tries,
6563
- });
6637
+ skipRegister: this.skipRegister,
6638
+ };
6639
+
6640
+ if (this.skipRegister) {
6641
+ logger$8.info('sdk webrtc skip register...', logInfo);
6642
+ return Promise.resolve();
6643
+ }
6644
+
6645
+ logger$8.info('sdk webrtc registering...', logInfo);
6564
6646
 
6565
6647
  if (!this.userAgent) {
6566
- logger$7.info('sdk webrtc recreating User Agent');
6648
+ logger$8.info('sdk webrtc recreating User Agent');
6567
6649
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6568
6650
  }
6569
6651
  if (!this.userAgent || this.isRegistered()) {
6570
- logger$7.info('sdk webrtc registering aborted, already registered or no UA can be created');
6652
+ logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6571
6653
  return Promise.resolve();
6572
6654
  }
6573
6655
 
6574
6656
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6575
- logger$7.info('sdk webrtc registering aborted due to a registration in progress.');
6657
+ logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6576
6658
  return Promise.resolve();
6577
6659
  }
6578
6660
 
6579
6661
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6580
6662
 
6581
6663
  const onRegisterFailed = () => {
6582
- logger$7.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6664
+ logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6583
6665
  this.connectionPromise = null;
6584
6666
  if (this.registerer && this.registerer.waiting) {
6585
6667
  this.registerer.waitingToggle(false);
6586
6668
  }
6587
6669
 
6588
6670
  if (tries <= MAX_REGISTER_TRIES) {
6589
- logger$7.info('sdk webrtc registering, retrying...', { tries });
6671
+ logger$8.info('sdk webrtc registering, retrying...', { tries });
6590
6672
  setTimeout(() => this.register(tries + 1), 300);
6591
6673
  }
6592
6674
  };
@@ -6595,18 +6677,18 @@ class WebRTCClient extends Emitter {
6595
6677
  // Avoid race condition with the close method called just before register and setting userAgent to null
6596
6678
  // during the resolution of the primise.
6597
6679
  if (!this.userAgent) {
6598
- logger$7.info('sdk webrtc recreating User Agent after connection');
6680
+ logger$8.info('sdk webrtc recreating User Agent after connection');
6599
6681
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6600
6682
  }
6601
6683
 
6602
- logger$7.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6684
+ logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6603
6685
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6604
6686
  this.connectionPromise = null;
6605
6687
  this._monkeyPatchRegisterer(this.registerer);
6606
6688
 
6607
6689
  // Bind registerer events
6608
6690
  this.registerer.stateChange.addListener(newState => {
6609
- logger$7.info('sdk webrtc registering, state changed', { newState });
6691
+ logger$8.info('sdk webrtc registering, state changed', { newState });
6610
6692
 
6611
6693
  if (newState === registererState.RegistererState.Registered && this.registerer
6612
6694
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6619,7 +6701,7 @@ class WebRTCClient extends Emitter {
6619
6701
  const options = {
6620
6702
  requestDelegate: {
6621
6703
  onReject: response => {
6622
- logger$7.error('sdk webrtc registering, rejected', { response });
6704
+ logger$8.error('sdk webrtc registering, rejected', { response });
6623
6705
 
6624
6706
  onRegisterFailed();
6625
6707
  },
@@ -6627,13 +6709,13 @@ class WebRTCClient extends Emitter {
6627
6709
  };
6628
6710
 
6629
6711
  return this.registerer.register(options).catch((e) => {
6630
- logger$7.error('sdk webrtc registering, error', e);
6712
+ logger$8.error('sdk webrtc registering, error', e);
6631
6713
 
6632
6714
  this.eventEmitter.emit(REGISTRATION_FAILED);
6633
6715
  return e;
6634
6716
  });
6635
6717
  }).catch(error => {
6636
- logger$7.error('sdk webrtc registering, transport error', error);
6718
+ logger$8.error('sdk webrtc registering, transport error', error);
6637
6719
  onRegisterFailed();
6638
6720
  });
6639
6721
  }
@@ -6662,21 +6744,21 @@ class WebRTCClient extends Emitter {
6662
6744
  }
6663
6745
 
6664
6746
  unregister() {
6665
- logger$7.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6747
+ logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6666
6748
  if (!this.registerer) {
6667
6749
  return Promise.resolve();
6668
6750
  }
6669
6751
 
6670
6752
  try {
6671
6753
  return this.registerer.unregister().then(() => {
6672
- logger$7.info('sdk webrtc unregistered');
6754
+ logger$8.info('sdk webrtc unregistered');
6673
6755
  this._cleanupRegister();
6674
6756
  }).catch(e => {
6675
- logger$7.error('sdk webrtc unregistering, promise error', e);
6757
+ logger$8.error('sdk webrtc unregistering, promise error', e);
6676
6758
  this._cleanupRegister();
6677
6759
  });
6678
6760
  } catch (e) {
6679
- logger$7.error('sdk webrtc unregistering, error', e);
6761
+ logger$8.error('sdk webrtc unregistering, error', e);
6680
6762
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6681
6763
  // error when the registerer is in a bad state
6682
6764
  this._cleanupRegister();
@@ -6684,7 +6766,7 @@ class WebRTCClient extends Emitter {
6684
6766
  }
6685
6767
 
6686
6768
  stop() {
6687
- logger$7.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6769
+ logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6688
6770
  if (!this.userAgent) {
6689
6771
  return Promise.resolve();
6690
6772
  }
@@ -6692,12 +6774,12 @@ class WebRTCClient extends Emitter {
6692
6774
  return this.userAgent.stop().then(() => {
6693
6775
  return this._cleanupRegister();
6694
6776
  }).catch(e => {
6695
- logger$7.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6777
+ logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6696
6778
  });
6697
6779
  }
6698
6780
 
6699
6781
  call(number , enableVideo , audioOnly = false, conference = false) {
6700
- logger$7.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6782
+ logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6701
6783
  const inviterOptions = {
6702
6784
  sessionDescriptionHandlerOptionsReInvite: {
6703
6785
  conference,
@@ -6726,7 +6808,7 @@ class WebRTCClient extends Emitter {
6726
6808
  this._onAccepted(session, response.session, true);
6727
6809
  },
6728
6810
  onReject: (response ) => {
6729
- logger$7.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6811
+ logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6730
6812
  this._stopSendingStats(session);
6731
6813
 
6732
6814
  this.eventEmitter.emit(REJECTED, session, response);
@@ -6748,11 +6830,11 @@ class WebRTCClient extends Emitter {
6748
6830
  }
6749
6831
 
6750
6832
  answer(session , enableVideo ) {
6751
- logger$7.info('sdk webrtc answer call', { id: session.id, enableVideo });
6833
+ logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
6752
6834
 
6753
6835
  if (!session || !session.accept) {
6754
6836
  const error = 'No session to answer, or not an invitation';
6755
- logger$7.warn(error);
6837
+ logger$8.warn(error);
6756
6838
  return Promise.reject(new Error(error));
6757
6839
  }
6758
6840
  const options = {
@@ -6762,15 +6844,15 @@ class WebRTCClient extends Emitter {
6762
6844
  return session.accept(options).then(() => {
6763
6845
  if (session.isCanceled) {
6764
6846
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6765
- logger$7.error(message, { id: session.id });
6847
+ logger$8.error(message, { id: session.id });
6766
6848
  this.onCallEnded(session);
6767
6849
 
6768
6850
  throw new CanceledCallError(message);
6769
6851
  }
6770
- logger$7.info('sdk webrtc answer, accepted.');
6852
+ logger$8.info('sdk webrtc answer, accepted.');
6771
6853
  this._onAccepted(session);
6772
6854
  }).catch(e => {
6773
- logger$7.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6855
+ logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6774
6856
 
6775
6857
  throw e;
6776
6858
  });
@@ -6778,7 +6860,7 @@ class WebRTCClient extends Emitter {
6778
6860
 
6779
6861
  hangup(session ) {
6780
6862
  const { state, id } = session;
6781
- logger$7.info('sdk webrtc hangup call', { id, state });
6863
+ logger$8.info('sdk webrtc hangup call', { id, state });
6782
6864
 
6783
6865
  try {
6784
6866
  this._stopSendingStats(session);
@@ -6807,24 +6889,24 @@ class WebRTCClient extends Emitter {
6807
6889
 
6808
6890
  return bye();
6809
6891
  } catch (error) {
6810
- logger$7.warn('sdk webrtc hangup, error', error);
6892
+ logger$8.warn('sdk webrtc hangup, error', error);
6811
6893
  }
6812
6894
 
6813
6895
  return null;
6814
6896
  }
6815
6897
 
6816
6898
  reject(session ) {
6817
- logger$7.info('sdk webrtc reject call', { id: session.id });
6899
+ logger$8.info('sdk webrtc reject call', { id: session.id });
6818
6900
 
6819
6901
  try {
6820
6902
  return session.reject ? session.reject() : session.cancel();
6821
6903
  } catch (e) {
6822
- logger$7.warn('Error when rejecting call', e.message, e.stack);
6904
+ logger$8.warn('Error when rejecting call', e.message, e.stack);
6823
6905
  }
6824
6906
  }
6825
6907
 
6826
6908
  async close() {
6827
- logger$7.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6909
+ logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6828
6910
  this._cleanupMedia();
6829
6911
  this.connectionPromise = null;
6830
6912
 
@@ -6855,7 +6937,7 @@ class WebRTCClient extends Emitter {
6855
6937
  // eg: "INVITE not rejectable in state Completed"
6856
6938
  }
6857
6939
  this.userAgent = null;
6858
- logger$7.info('sdk webrtc client closed');
6940
+ logger$8.info('sdk webrtc client closed');
6859
6941
  }
6860
6942
 
6861
6943
  getNumber(session ) {
@@ -6868,13 +6950,13 @@ class WebRTCClient extends Emitter {
6868
6950
  }
6869
6951
 
6870
6952
  mute(session ) {
6871
- logger$7.info('sdk webrtc mute', { id: session.id });
6953
+ logger$8.info('sdk webrtc mute', { id: session.id });
6872
6954
 
6873
6955
  this._toggleAudio(session, true);
6874
6956
  }
6875
6957
 
6876
6958
  unmute(session ) {
6877
- logger$7.info('sdk webrtc unmute', { id: session.id });
6959
+ logger$8.info('sdk webrtc unmute', { id: session.id });
6878
6960
 
6879
6961
  this._toggleAudio(session, false);
6880
6962
  }
@@ -6891,12 +6973,18 @@ class WebRTCClient extends Emitter {
6891
6973
  }
6892
6974
 
6893
6975
  if (pc.getSenders) {
6976
+ if (!pc.getSenders().length) {
6977
+ return false;
6978
+ }
6894
6979
  pc.getSenders().forEach(sender => {
6895
6980
  if (sender && sender.track && sender.track.kind === 'audio') {
6896
6981
  muted = muted && !sender.track.enabled;
6897
6982
  }
6898
6983
  });
6899
6984
  } else {
6985
+ if (!pc.getLocalStreams().length) {
6986
+ return false;
6987
+ }
6900
6988
  pc.getLocalStreams().forEach(stream => {
6901
6989
  stream.getAudioTracks().forEach(track => {
6902
6990
  muted = muted && !track.enabled;
@@ -6908,20 +6996,20 @@ class WebRTCClient extends Emitter {
6908
6996
  }
6909
6997
 
6910
6998
  toggleCameraOn(session ) {
6911
- logger$7.info('sdk webrtc toggle camera on', { id: session.id });
6999
+ logger$8.info('sdk webrtc toggle camera on', { id: session.id });
6912
7000
 
6913
7001
  this._toggleVideo(session, false);
6914
7002
  }
6915
7003
 
6916
7004
  toggleCameraOff(session ) {
6917
- logger$7.info('sdk webrtc toggle camera off', { id: session.id });
7005
+ logger$8.info('sdk webrtc toggle camera off', { id: session.id });
6918
7006
 
6919
7007
  this._toggleVideo(session, true);
6920
7008
  }
6921
7009
 
6922
7010
  hold(session , isConference = false) {
6923
7011
  const sessionId = this.getSipSessionId(session);
6924
- logger$7.info('sdk webrtc hold', {
7012
+ logger$8.info('sdk webrtc hold', {
6925
7013
  sessionId,
6926
7014
  keys: Object.keys(this.heldSessions),
6927
7015
  pendingReinvite: !!session.pendingReinvite,
@@ -6955,6 +7043,8 @@ class WebRTCClient extends Emitter {
6955
7043
  }
6956
7044
  options.sessionDescriptionHandlerOptions = {
6957
7045
  constraints: options.constraints,
7046
+ hold: true,
7047
+ conference: isConference,
6958
7048
  };
6959
7049
 
6960
7050
  // Send re-INVITE
@@ -6964,7 +7054,7 @@ class WebRTCClient extends Emitter {
6964
7054
  unhold(session , isConference = false) {
6965
7055
  const sessionId = this.getSipSessionId(session);
6966
7056
 
6967
- logger$7.info('sdk webrtc unhold', {
7057
+ logger$8.info('sdk webrtc unhold', {
6968
7058
  sessionId,
6969
7059
  keys: Object.keys(this.heldSessions),
6970
7060
  pendingReinvite: !!session.pendingReinvite,
@@ -6997,6 +7087,8 @@ class WebRTCClient extends Emitter {
6997
7087
  }
6998
7088
  options.sessionDescriptionHandlerOptions = {
6999
7089
  constraints: options.constraints,
7090
+ hold: false,
7091
+ conference: isConference,
7000
7092
  };
7001
7093
 
7002
7094
  // Send re-INVITE
@@ -7055,7 +7147,7 @@ class WebRTCClient extends Emitter {
7055
7147
  return;
7056
7148
  }
7057
7149
 
7058
- logger$7.info('send WebRTC message', { sipId: sipSession.id, contentType });
7150
+ logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7059
7151
 
7060
7152
  try {
7061
7153
  sipSession.message({
@@ -7180,7 +7272,8 @@ class WebRTCClient extends Emitter {
7180
7272
  }
7181
7273
  const sdh = session.sessionDescriptionHandler;
7182
7274
  const pc = sdh.peerConnection;
7183
- const localStream = this.getLocalStream(this.getSipSessionId(session));
7275
+ const sessionId = this.getSipSessionId(session);
7276
+ const localStream = this.getLocalStream(sessionId);
7184
7277
 
7185
7278
  // Release old video stream
7186
7279
  if (localStream) {
@@ -7206,11 +7299,8 @@ class WebRTCClient extends Emitter {
7206
7299
 
7207
7300
  // let's update the local stream
7208
7301
  this.eventEmitter.emit('onVideoInputChange', stream);
7209
- try {
7210
- await sdh.setLocalMediaStream(stream);
7211
- } catch (_) {
7212
- // Nothing to do
7213
- }
7302
+ this.setLocalMediaStream(sessionId, stream);
7303
+
7214
7304
  return stream;
7215
7305
  });
7216
7306
  }
@@ -7422,7 +7512,7 @@ class WebRTCClient extends Emitter {
7422
7512
  }
7423
7513
 
7424
7514
  startHeartbeat() {
7425
- logger$7.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7515
+ logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7426
7516
  if (!this.userAgent) {
7427
7517
  this.heartbeat.stop();
7428
7518
  return;
@@ -7435,7 +7525,7 @@ class WebRTCClient extends Emitter {
7435
7525
  }
7436
7526
 
7437
7527
  stopHeartbeat() {
7438
- logger$7.info('sdk webrtc stop heartbeat');
7528
+ logger$8.info('sdk webrtc stop heartbeat');
7439
7529
  this.heartbeat.stop();
7440
7530
  }
7441
7531
 
@@ -7455,7 +7545,7 @@ class WebRTCClient extends Emitter {
7455
7545
  }
7456
7546
 
7457
7547
  attemptReconnection() {
7458
- logger$7.info('attempt reconnection', { userAgent: !!this.userAgent });
7548
+ logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7459
7549
  if (!this.userAgent) {
7460
7550
  return;
7461
7551
  }
@@ -7512,9 +7602,11 @@ class WebRTCClient extends Emitter {
7512
7602
  remoteStream.removeTrack(track);
7513
7603
  });
7514
7604
 
7515
- pc.getReceivers().forEach(receiver => {
7516
- remoteStream.addTrack(receiver.track);
7517
- });
7605
+ if (pc.getReceivers) {
7606
+ pc.getReceivers().forEach(receiver => {
7607
+ remoteStream.addTrack(receiver.track);
7608
+ });
7609
+ }
7518
7610
  }
7519
7611
 
7520
7612
  getMediaConfiguration(enableVideo , conference = false, constraints = null) {
@@ -7549,6 +7641,25 @@ class WebRTCClient extends Emitter {
7549
7641
  return sessionId in this.conferences;
7550
7642
  }
7551
7643
 
7644
+ createAudioElementFor(sessionId ) {
7645
+ const audio = document.createElement('audio');
7646
+ audio.setAttribute('id', `audio-${sessionId}`);
7647
+
7648
+ if (audio.setSinkId && this.audioOutputDeviceId) {
7649
+ audio.setSinkId(this.audioOutputDeviceId);
7650
+ }
7651
+
7652
+ if (document.body) {
7653
+ document.body.appendChild(audio);
7654
+ }
7655
+ this.audioElements[sessionId] = audio;
7656
+
7657
+ audio.volume = this.audioOutputVolume;
7658
+ audio.autoplay = true;
7659
+
7660
+ return audio;
7661
+ }
7662
+
7552
7663
  _onTransportError() {
7553
7664
  this.eventEmitter.emit(TRANSPORT_ERROR);
7554
7665
  this.attemptReconnection();
@@ -7558,7 +7669,7 @@ class WebRTCClient extends Emitter {
7558
7669
  const body = message && typeof message === 'object' ? message.data : message;
7559
7670
  if (body && body.indexOf('200 OK') !== -1) {
7560
7671
  if (this.hasHeartbeat()) {
7561
- logger$7.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7672
+ logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7562
7673
 
7563
7674
  this.heartbeat.onHeartbeat();
7564
7675
  if (this.heartbeatCb) {
@@ -7569,7 +7680,7 @@ class WebRTCClient extends Emitter {
7569
7680
  }
7570
7681
 
7571
7682
  async _onHeartbeatTimeout() {
7572
- logger$7.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7683
+ logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7573
7684
 
7574
7685
  if (this.heartbeatTimeoutCb) {
7575
7686
  this.heartbeatTimeoutCb();
@@ -7581,7 +7692,7 @@ class WebRTCClient extends Emitter {
7581
7692
  try {
7582
7693
  await this.userAgent.transport.disconnect();
7583
7694
  } catch (e) {
7584
- logger$7.error('Transport disconnection after heartbeat timeout, error', e);
7695
+ logger$8.error('Transport disconnection after heartbeat timeout, error', e);
7585
7696
  }
7586
7697
  }
7587
7698
 
@@ -7614,31 +7725,31 @@ class WebRTCClient extends Emitter {
7614
7725
  }
7615
7726
 
7616
7727
  _connectIfNeeded() {
7617
- logger$7.info('connect if needed, checking', { connected: this.isConnected() });
7728
+ logger$8.info('connect if needed, checking', { connected: this.isConnected() });
7618
7729
  if (!this.userAgent) {
7619
- logger$7.info('need to recreate User Agent');
7730
+ logger$8.info('need to recreate User Agent');
7620
7731
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7621
7732
  }
7622
7733
 
7623
7734
  if (this.isConnected()) {
7624
- logger$7.info('webrtc sdk, already connected');
7735
+ logger$8.info('webrtc sdk, already connected');
7625
7736
  return Promise.resolve();
7626
7737
  }
7627
7738
 
7628
7739
  if (this.isConnecting()) {
7629
- logger$7.info('webrtc sdk, already connecting...');
7740
+ logger$8.info('webrtc sdk, already connecting...');
7630
7741
 
7631
7742
  this.connectionPromise = this.userAgent.transport.connectPromise;
7632
7743
  return this.connectionPromise;
7633
7744
  }
7634
7745
 
7635
7746
  if (this.connectionPromise) {
7636
- logger$7.info('webrtc sdk, connection promise connecting...');
7747
+ logger$8.info('webrtc sdk, connection promise connecting...');
7637
7748
  // $FlowFixMe
7638
7749
  return this.connectionPromise;
7639
7750
  }
7640
7751
 
7641
- logger$7.info('WebRTC UA needs to connect');
7752
+ logger$8.info('WebRTC UA needs to connect');
7642
7753
 
7643
7754
  // Force UA to reconnect
7644
7755
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -7763,7 +7874,7 @@ class WebRTCClient extends Emitter {
7763
7874
 
7764
7875
  sdh.peerConnectionDelegate = {
7765
7876
  onicecandidateerror: (error ) => {
7766
- logger$7.error('on icecandidate error', {
7877
+ logger$8.error('on icecandidate error', {
7767
7878
  address: error.address,
7768
7879
  port: error.port,
7769
7880
  errorCode: error.errorCode,
@@ -7778,7 +7889,7 @@ class WebRTCClient extends Emitter {
7778
7889
  let hadRemoteVideo = false;
7779
7890
 
7780
7891
  // Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
7781
- // Becase when `onInvite` is called we already got the video track
7892
+ // Because when `onInvite` is called we already got the video track
7782
7893
  session.onInviteRequest = (request) => {
7783
7894
  hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
7784
7895
 
@@ -7792,7 +7903,7 @@ class WebRTCClient extends Emitter {
7792
7903
  updatedNumber = session.assertedIdentity.uri.normal.user;
7793
7904
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
7794
7905
  }
7795
- logger$7.info('re-invite received', { updatedCalleeName, updatedNumber });
7906
+ logger$8.info('re-invite received', { updatedCalleeName, updatedNumber });
7796
7907
 
7797
7908
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
7798
7909
 
@@ -7813,7 +7924,7 @@ class WebRTCClient extends Emitter {
7813
7924
  }
7814
7925
 
7815
7926
  _onAccepted(session , sessionDialog , withEvent = true) {
7816
- logger$7.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7927
+ logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7817
7928
 
7818
7929
  this.storeSipSession(session);
7819
7930
 
@@ -7853,20 +7964,10 @@ class WebRTCClient extends Emitter {
7853
7964
  const isConference = this.isConference(sessionId);
7854
7965
 
7855
7966
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7856
- const audio = document.createElement('audio');
7857
- audio.setAttribute('id', `audio-${sessionId}`);
7858
-
7859
- if (audio.setSinkId && this.audioOutputDeviceId) {
7860
- audio.setSinkId(this.audioOutputDeviceId);
7861
- }
7862
-
7863
- if (document.body) {
7864
- document.body.appendChild(audio);
7865
- }
7866
- this.audioElements[sessionId] = audio;
7967
+ this.createAudioElementFor(sessionId);
7867
7968
  }
7868
7969
 
7869
- const audioElement = this.audioElements[this.getSipSessionId(session)];
7970
+ const audioElement = this.audioElements[sessionId];
7870
7971
  const stream = newStream || this.getRemoteStream(sessionId);
7871
7972
 
7872
7973
  if (!this._isWeb() || !stream) {
@@ -8013,10 +8114,10 @@ class WebRTCClient extends Emitter {
8013
8114
 
8014
8115
  _stopSendingStats(session ) {
8015
8116
  const sessionId = this.getSipSessionId(session);
8016
- logger$7.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8117
+ logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8017
8118
 
8018
8119
  if (sessionId in this.statsIntervals) {
8019
- logger$7.trace('Stop sending stats for call', { sessionId });
8120
+ logger$8.trace('Stop sending stats for call', { sessionId });
8020
8121
  this.statsIntervals[sessionId]();
8021
8122
  delete this.statsIntervals[sessionId];
8022
8123
  }
@@ -8032,7 +8133,7 @@ class WebRTCClient extends Emitter {
8032
8133
  try {
8033
8134
  await this.userAgent.transport.disconnect();
8034
8135
  } catch (e) {
8035
- logger$7.error('WebRTC transport disconnect, error', e);
8136
+ logger$8.error('WebRTC transport disconnect, error', e);
8036
8137
  }
8037
8138
  }
8038
8139
  }
@@ -8119,7 +8220,7 @@ const events = [
8119
8220
  ON_SIGNAL,
8120
8221
  ];
8121
8222
 
8122
- const logger$6 = IssueReporter$1.loggerFor('webrtc-phone');
8223
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8123
8224
 
8124
8225
  class WebRTCPhone extends Emitter {
8125
8226
 
@@ -8190,7 +8291,7 @@ class WebRTCPhone extends Emitter {
8190
8291
  }).catch(error => {
8191
8292
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8192
8293
  console.error('register error', error, error.message, error.stack);
8193
- logger$6.error('WebRTC register error', { message: error.message, stack: error.stack });
8294
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8194
8295
  });
8195
8296
  }
8196
8297
 
@@ -8205,7 +8306,7 @@ class WebRTCPhone extends Emitter {
8205
8306
  if (!this.client) {
8206
8307
  return;
8207
8308
  }
8208
- logger$6.info('WebRTC phone stop');
8309
+ logger$7.info('WebRTC phone stop');
8209
8310
  this.client.stop();
8210
8311
  }
8211
8312
 
@@ -8220,14 +8321,14 @@ class WebRTCPhone extends Emitter {
8220
8321
  async sendReinvite(callSession , constraints = null, conference = false,
8221
8322
  audioOnly = false) {
8222
8323
  const sipSession = this.findSipSession(callSession);
8223
- logger$6.info('WebRTC phone - send reinvite', {
8324
+ logger$7.info('WebRTC phone - send reinvite', {
8224
8325
  sessionId: sipSession ? sipSession.id : null,
8225
8326
  constraints,
8226
8327
  audioOnly,
8227
8328
  });
8228
8329
 
8229
8330
  if (!sipSession) {
8230
- return null;
8331
+ return false;
8231
8332
  }
8232
8333
 
8233
8334
  // $FlowFixMe
@@ -8237,19 +8338,17 @@ class WebRTCPhone extends Emitter {
8237
8338
  // Downgrade
8238
8339
  if (constraints && !isUpgrade) {
8239
8340
  // No reinvite needed
8240
- return this._downgradeToAudio(callSession);
8341
+ this._downgradeToAudio(callSession);
8342
+ return false;
8241
8343
  }
8242
8344
 
8243
8345
  if (isUpgrade) {
8244
8346
  const shouldReinvite = await this._upgradeToVideo(callSession, constraints, conference);
8245
8347
  if (!shouldReinvite) {
8246
- return;
8348
+ return false;
8247
8349
  }
8248
8350
  }
8249
8351
 
8250
- // Force reinvite in SDH
8251
- sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
8252
-
8253
8352
  return this.client.reinvite(sipSession, constraints, conference, audioOnly);
8254
8353
  }
8255
8354
 
@@ -8258,7 +8357,7 @@ class WebRTCPhone extends Emitter {
8258
8357
  }
8259
8358
 
8260
8359
  startHeartbeat() {
8261
- logger$6.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8360
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8262
8361
  if (!this.client || this.client.hasHeartbeat()) {
8263
8362
  return;
8264
8363
  }
@@ -8267,7 +8366,7 @@ class WebRTCPhone extends Emitter {
8267
8366
  }
8268
8367
 
8269
8368
  stopHeartbeat() {
8270
- logger$6.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8369
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8271
8370
  if (!this.client) {
8272
8371
  return;
8273
8372
  }
@@ -8284,7 +8383,7 @@ class WebRTCPhone extends Emitter {
8284
8383
  }
8285
8384
 
8286
8385
  reconnect() {
8287
- logger$6.info('WebRTC phone - reconnect', { client: !!this.client });
8386
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8288
8387
  if (!this.client) {
8289
8388
  return;
8290
8389
  }
@@ -8322,7 +8421,7 @@ class WebRTCPhone extends Emitter {
8322
8421
  _downgradeToAudio(callSession ) {
8323
8422
  const sipSession = this.findSipSession(callSession);
8324
8423
  if (!sipSession) {
8325
- return;
8424
+ return false;
8326
8425
  }
8327
8426
 
8328
8427
  // Release local video stream when downgrading to audio
@@ -8435,7 +8534,7 @@ class WebRTCPhone extends Emitter {
8435
8534
  // Monkey patch to know when canceled with the CANCEL message
8436
8535
  const onCancel = sipSession._onCancel.bind(sipSession);
8437
8536
  sipSession._onCancel = (message ) => {
8438
- logger$6.trace('on sip session canceled', { callId: message.callId });
8537
+ logger$7.trace('on sip session canceled', { callId: message.callId });
8439
8538
 
8440
8539
  onCancel(message);
8441
8540
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -8460,13 +8559,13 @@ class WebRTCPhone extends Emitter {
8460
8559
  this.audioOutputVolume,
8461
8560
  );
8462
8561
  case sessionState.SessionState.Terminating:
8463
- logger$6.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8562
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8464
8563
 
8465
8564
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
8466
8565
 
8467
8566
  break;
8468
8567
  case sessionState.SessionState.Terminated:
8469
- logger$6.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8568
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8470
8569
 
8471
8570
  this._onCallTerminated(sipSession);
8472
8571
 
@@ -8502,7 +8601,7 @@ class WebRTCPhone extends Emitter {
8502
8601
  }
8503
8602
 
8504
8603
  async startScreenSharing(constraints , callSession ) {
8505
- logger$6.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8604
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8506
8605
 
8507
8606
  const screenShareStream = await this._getStreamFromConstraints(constraints);
8508
8607
  if (!screenShareStream) {
@@ -8524,6 +8623,10 @@ class WebRTCPhone extends Emitter {
8524
8623
  localStream.removeTrack(videoTrack);
8525
8624
  }
8526
8625
 
8626
+ if (localStream) {
8627
+ localStream.addTrack(screenTrack);
8628
+ }
8629
+
8527
8630
  if (sender) {
8528
8631
  sender.replaceTrack(screenTrack);
8529
8632
  }
@@ -8538,7 +8641,8 @@ class WebRTCPhone extends Emitter {
8538
8641
  return;
8539
8642
  }
8540
8643
 
8541
- logger$6.info('WebRTC phone - stop screen sharing');
8644
+ logger$7.info('WebRTC phone - stop screen sharing');
8645
+ let reinvited = false;
8542
8646
 
8543
8647
  try {
8544
8648
  if (this.currentScreenShare.stream) {
@@ -8553,7 +8657,8 @@ class WebRTCPhone extends Emitter {
8553
8657
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
8554
8658
  // We have to downgrade to audio.
8555
8659
  const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
8556
- await this.sendReinvite(targetCallSession, { audio: false, video: screenshareStopped }, conference);
8660
+ const constraints = { audio: false, video: screenshareStopped };
8661
+ reinvited = await this.sendReinvite(targetCallSession, constraints, conference);
8557
8662
  }
8558
8663
  } catch (e) {
8559
8664
  console.warn(e);
@@ -8567,6 +8672,8 @@ class WebRTCPhone extends Emitter {
8567
8672
  );
8568
8673
 
8569
8674
  this.currentScreenShare = null;
8675
+
8676
+ return reinvited;
8570
8677
  }
8571
8678
 
8572
8679
  async _getStreamFromConstraints(constraints , conference = false) {
@@ -8604,7 +8711,7 @@ class WebRTCPhone extends Emitter {
8604
8711
  }
8605
8712
 
8606
8713
  _onCallAccepted(sipSession , cameraEnabled ) {
8607
- logger$6.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
8714
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
8608
8715
 
8609
8716
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
8610
8717
  this.currentSipSession = sipSession;
@@ -8622,11 +8729,15 @@ class WebRTCPhone extends Emitter {
8622
8729
  }
8623
8730
 
8624
8731
  changeAudioDevice(id ) {
8625
- logger$6.info('WebRTC phone - change audio device', { deviceId: id });
8732
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
8626
8733
  this.audioOutputDeviceId = id;
8627
8734
  this.client.changeAudioOutputDevice(id);
8628
8735
  }
8629
8736
 
8737
+ createAudioElementFor(sessionId ) {
8738
+ return this.client.createAudioElementFor(sessionId);
8739
+ }
8740
+
8630
8741
  changeRingDevice(id ) {
8631
8742
  this.audioRingDeviceId = id;
8632
8743
  }
@@ -8643,25 +8754,25 @@ class WebRTCPhone extends Emitter {
8643
8754
  }
8644
8755
 
8645
8756
  changeAudioInputDevice(id ) {
8646
- logger$6.info('WebRTC phone - changeAudio input device', { deviceId: id });
8757
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
8647
8758
 
8648
8759
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
8649
8760
  }
8650
8761
 
8651
8762
  changeVideoInputDevice(id ) {
8652
- logger$6.info('WebRTC phone - change video input device', { deviceId: id });
8763
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
8653
8764
 
8654
8765
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
8655
8766
  }
8656
8767
 
8657
8768
  changeSessionVideoInputDevice(id ) {
8658
- logger$6.info('WebRTC phone - change session video input device', { deviceId: id });
8769
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
8659
8770
 
8660
8771
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
8661
8772
  }
8662
8773
 
8663
8774
  _onCallTerminated(sipSession ) {
8664
- logger$6.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
8775
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
8665
8776
 
8666
8777
  const callSession = this._createCallSession(sipSession);
8667
8778
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -8695,7 +8806,7 @@ class WebRTCPhone extends Emitter {
8695
8806
  const hasIncomingCallSession = this.hasIncomingCallSession();
8696
8807
 
8697
8808
  // Re-trigger incoming call event for remaining incoming calls
8698
- logger$6.info('WebRTC phone - check to re-trigger incoming call', {
8809
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
8699
8810
  sipId: sipSession.id,
8700
8811
  shouldRetrigger,
8701
8812
  hasIncomingCallSession,
@@ -8784,37 +8895,37 @@ class WebRTCPhone extends Emitter {
8784
8895
 
8785
8896
  // Deprecated
8786
8897
  getLocalStreamForCall(callSession ) {
8787
- logger$6.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
8898
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
8788
8899
 
8789
8900
  return this.getLocalStream(callSession);
8790
8901
  }
8791
8902
 
8792
8903
  // Deprecated
8793
8904
  getRemoteStreamForCall(callSession ) {
8794
- logger$6.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
8905
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
8795
8906
 
8796
8907
  return this.getRemoteVideoStream(callSession);
8797
8908
  }
8798
8909
 
8799
8910
  getRemoteStreamsForCall(callSession ) {
8800
- logger$6.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
8911
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
8801
8912
 
8802
8913
  return this.getRemoteStream(callSession);
8803
8914
  }
8804
8915
 
8805
8916
  accept(callSession , cameraEnabled ) {
8806
- logger$6.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
8917
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
8807
8918
  if (this.currentSipSession) {
8808
8919
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
8809
8920
  }
8810
8921
 
8811
8922
  if (!callSession) {
8812
- logger$6.warn('no CallSession to accept.');
8923
+ logger$7.warn('no CallSession to accept.');
8813
8924
  return Promise.resolve(null);
8814
8925
  }
8815
8926
 
8816
8927
  if (callSession.getId() in this.acceptedSessions) {
8817
- logger$6.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
8928
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
8818
8929
  return Promise.resolve(callSession.sipCallId);
8819
8930
  }
8820
8931
 
@@ -8826,24 +8937,24 @@ class WebRTCPhone extends Emitter {
8826
8937
  const sipSession = this.client.getSipSession(callSession.getId());
8827
8938
  if (sipSession) {
8828
8939
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
8829
- logger$6.warn('Trying to answer a terminated sipSession.');
8940
+ logger$7.warn('Trying to answer a terminated sipSession.');
8830
8941
 
8831
8942
  return Promise.resolve(null);
8832
8943
  }
8833
8944
 
8834
- logger$6.info('accept call, session found', { sipId: sipSession.id });
8945
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
8835
8946
 
8836
8947
  // $FlowFixMe
8837
8948
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
8838
8949
  return callSession.sipCallId;
8839
8950
  }).catch(e => {
8840
- logger$6.error(e);
8951
+ logger$7.error(e);
8841
8952
  this.endCurrentCall(callSession);
8842
8953
  throw e;
8843
8954
  });
8844
8955
  }
8845
8956
 
8846
- logger$6.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
8957
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
8847
8958
 
8848
8959
  return Promise.resolve(null);
8849
8960
  }
@@ -8853,7 +8964,7 @@ class WebRTCPhone extends Emitter {
8853
8964
  }
8854
8965
 
8855
8966
  async reject(callSession ) {
8856
- logger$6.info('reject WebRTC called', { id: callSession.getId() });
8967
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
8857
8968
 
8858
8969
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
8859
8970
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -8865,14 +8976,14 @@ class WebRTCPhone extends Emitter {
8865
8976
 
8866
8977
  const sipSession = this.findSipSession(callSession);
8867
8978
  if (sipSession) {
8868
- logger$6.info('WebRTC rejecting', { sipId: sipSession.id });
8979
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
8869
8980
 
8870
8981
  this.client.hangup(sipSession);
8871
8982
  }
8872
8983
  }
8873
8984
 
8874
8985
  async ignore(callSession ) {
8875
- logger$6.info('WebRTC ignore', { id: callSession.getId() });
8986
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
8876
8987
 
8877
8988
  // kill the ring
8878
8989
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -8881,7 +8992,7 @@ class WebRTCPhone extends Emitter {
8881
8992
  }
8882
8993
 
8883
8994
  hold(callSession , withEvent = true, isConference = false) {
8884
- logger$6.info('WebRTC hold', { id: callSession.getId() });
8995
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
8885
8996
 
8886
8997
  const sipSession = this.findSipSession(callSession);
8887
8998
 
@@ -8892,7 +9003,7 @@ class WebRTCPhone extends Emitter {
8892
9003
 
8893
9004
  // @Deprecated
8894
9005
  unhold(callSession , withEvent = true, isConference = false) {
8895
- logger$6.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
9006
+ logger$7.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
8896
9007
 
8897
9008
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
8898
9009
 
@@ -8907,7 +9018,7 @@ class WebRTCPhone extends Emitter {
8907
9018
  const sipSession = this.findSipSession(callSession);
8908
9019
 
8909
9020
  if (sipSession) {
8910
- logger$6.info('WebRTC atxfer', { sipId: sipSession.id });
9021
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
8911
9022
 
8912
9023
  return this.client.atxfer(sipSession);
8913
9024
  }
@@ -8922,7 +9033,7 @@ class WebRTCPhone extends Emitter {
8922
9033
  if (!sipSession) {
8923
9034
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
8924
9035
  }
8925
- logger$6.info('WebRTC hold sip session', { sipId: sipSession.id });
9036
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id });
8926
9037
 
8927
9038
  const promise = this.client.hold(sipSession, isConference);
8928
9039
  if (withEvent) {
@@ -8941,7 +9052,7 @@ class WebRTCPhone extends Emitter {
8941
9052
  if (!sipSession) {
8942
9053
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
8943
9054
  }
8944
- logger$6.info('WebRTC unhold', { sipId: sipSession.id });
9055
+ logger$7.info('WebRTC unhold', { sipId: sipSession.id });
8945
9056
 
8946
9057
  const promise = this.client.unhold(sipSession, isConference);
8947
9058
  if (withEvent) {
@@ -8952,18 +9063,18 @@ class WebRTCPhone extends Emitter {
8952
9063
  }
8953
9064
 
8954
9065
  resume(callSession , isConference = false) {
8955
- logger$6.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9066
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
8956
9067
 
8957
9068
  const sipSession = this.findSipSession(callSession);
8958
9069
  if (!sipSession) {
8959
9070
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
8960
9071
  }
8961
9072
 
8962
- logger$6.info('WebRTC resuming', { sipId: sipSession.id });
9073
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
8963
9074
 
8964
9075
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
8965
9076
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
8966
- logger$6.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9077
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
8967
9078
  this.holdSipSession(this.currentSipSession, callSession);
8968
9079
  }
8969
9080
 
@@ -8978,14 +9089,14 @@ class WebRTCPhone extends Emitter {
8978
9089
  }
8979
9090
 
8980
9091
  mute(callSession , withEvent = true) {
8981
- logger$6.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9092
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
8982
9093
 
8983
9094
  const sipSession = this.findSipSession(callSession);
8984
9095
  if (!sipSession) {
8985
9096
  return;
8986
9097
  }
8987
9098
 
8988
- logger$6.info('WebRTC muting', { sipId: sipSession.id });
9099
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
8989
9100
  this.client.mute(sipSession);
8990
9101
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
8991
9102
 
@@ -8999,14 +9110,14 @@ class WebRTCPhone extends Emitter {
8999
9110
  }
9000
9111
 
9001
9112
  unmute(callSession , withEvent = true) {
9002
- logger$6.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9113
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9003
9114
 
9004
9115
  const sipSession = this.findSipSession(callSession);
9005
9116
  if (!sipSession) {
9006
9117
  return;
9007
9118
  }
9008
9119
 
9009
- logger$6.info('WebRTC unmuting', { sipId: sipSession.id });
9120
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9010
9121
  this.client.unmute(sipSession);
9011
9122
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9012
9123
 
@@ -9033,7 +9144,7 @@ class WebRTCPhone extends Emitter {
9033
9144
  if (!sipSession) {
9034
9145
  return;
9035
9146
  }
9036
- logger$6.info('WebRTC turn camera on', { sipId: sipSession.id });
9147
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9037
9148
 
9038
9149
  this.client.toggleCameraOn(sipSession);
9039
9150
 
@@ -9045,7 +9156,7 @@ class WebRTCPhone extends Emitter {
9045
9156
  if (!sipSession) {
9046
9157
  return;
9047
9158
  }
9048
- logger$6.info('WebRTC turn camera off', { sipId: sipSession.id });
9159
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9049
9160
 
9050
9161
  this.client.toggleCameraOff(sipSession);
9051
9162
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9057,7 +9168,7 @@ class WebRTCPhone extends Emitter {
9057
9168
  return;
9058
9169
  }
9059
9170
 
9060
- logger$6.info('WebRTC send key', { sipId: sipSession.id, tone });
9171
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9061
9172
  this.client.sendDTMF(sipSession, tone);
9062
9173
  }
9063
9174
 
@@ -9065,7 +9176,7 @@ class WebRTCPhone extends Emitter {
9065
9176
  // @TODO: line is not used here
9066
9177
  async makeCall(number , line , cameraEnabled ,
9067
9178
  audioOnly = false, conference = false) {
9068
- logger$6.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9179
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9069
9180
  if (!number) {
9070
9181
  return Promise.resolve(null);
9071
9182
  }
@@ -9075,7 +9186,7 @@ class WebRTCPhone extends Emitter {
9075
9186
  }
9076
9187
  if (this.currentSipSession) {
9077
9188
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9078
- logger$6.warn('Unable to hold current session when making another call', e);
9189
+ logger$7.warn('Unable to hold current session when making another call', e);
9079
9190
  });
9080
9191
  }
9081
9192
 
@@ -9085,7 +9196,7 @@ class WebRTCPhone extends Emitter {
9085
9196
  this._bindEvents(sipSession);
9086
9197
  } catch (error) {
9087
9198
  console.warn(error);
9088
- logger$6.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9199
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9089
9200
  return Promise.resolve(null);
9090
9201
  }
9091
9202
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -9113,7 +9224,7 @@ class WebRTCPhone extends Emitter {
9113
9224
  return;
9114
9225
  }
9115
9226
 
9116
- logger$6.info('WebRTC transfer', { sipId: sipSession.id, target });
9227
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9117
9228
 
9118
9229
  this.client.transfer(sipSession, target);
9119
9230
  }
@@ -9122,7 +9233,7 @@ class WebRTCPhone extends Emitter {
9122
9233
  const sipSession = this.client.getSipSession(source.sipCallId);
9123
9234
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9124
9235
 
9125
- logger$6.info('WebRTC indirect transfer', {
9236
+ logger$7.info('WebRTC indirect transfer', {
9126
9237
  sipId: sipSession ? sipSession.id : null,
9127
9238
  target: sipSessionTarget ? sipSessionTarget.id : null,
9128
9239
  });
@@ -9150,7 +9261,7 @@ class WebRTCPhone extends Emitter {
9150
9261
  return false;
9151
9262
  }
9152
9263
 
9153
- logger$6.info('WebRTC hangup', { sipId: sipSession.id });
9264
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9154
9265
 
9155
9266
  const sipSessionId = this.getSipSessionId(sipSession);
9156
9267
 
@@ -9195,7 +9306,7 @@ class WebRTCPhone extends Emitter {
9195
9306
  }
9196
9307
 
9197
9308
  async close() {
9198
- logger$6.info('WebRTC close');
9309
+ logger$7.info('WebRTC close');
9199
9310
 
9200
9311
  try {
9201
9312
  await Promise.race([
@@ -9203,7 +9314,7 @@ class WebRTCPhone extends Emitter {
9203
9314
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9204
9315
  ]);
9205
9316
  } catch (e) {
9206
- logger$6.error('WebRTC close, unregister error', e);
9317
+ logger$7.error('WebRTC close, unregister error', e);
9207
9318
  }
9208
9319
 
9209
9320
  this.client.close();
@@ -9221,12 +9332,12 @@ class WebRTCPhone extends Emitter {
9221
9332
  }
9222
9333
 
9223
9334
  enableRinging() {
9224
- logger$6.info('WebRTC enable ringing');
9335
+ logger$7.info('WebRTC enable ringing');
9225
9336
  this.ringingEnabled = true;
9226
9337
  }
9227
9338
 
9228
9339
  disableRinging() {
9229
- logger$6.info('WebRTC disable ringing');
9340
+ logger$7.info('WebRTC disable ringing');
9230
9341
  this.ringingEnabled = false;
9231
9342
  }
9232
9343
 
@@ -9266,7 +9377,7 @@ class WebRTCPhone extends Emitter {
9266
9377
 
9267
9378
  // Deprecated
9268
9379
  getLocalMediaStream(callSession ) {
9269
- logger$6.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9380
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9270
9381
  return this.getLocalStream(callSession);
9271
9382
  }
9272
9383
 
@@ -9274,6 +9385,10 @@ class WebRTCPhone extends Emitter {
9274
9385
  return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : null;
9275
9386
  }
9276
9387
 
9388
+ hasALocalVideoTrack(callSession ) {
9389
+ return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : null;
9390
+ }
9391
+
9277
9392
  getRemoteStream(callSession ) {
9278
9393
  return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
9279
9394
  }
@@ -9296,7 +9411,7 @@ class WebRTCPhone extends Emitter {
9296
9411
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
9297
9412
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
9298
9413
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
9299
- logger$6.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9414
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9300
9415
 
9301
9416
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
9302
9417
  this.incomingSessions.push(callSession.getId());
@@ -9319,7 +9434,7 @@ class WebRTCPhone extends Emitter {
9319
9434
  });
9320
9435
 
9321
9436
  this.client.on(this.client.ON_REINVITE, (...args) => {
9322
- logger$6.info('WebRTC on reinvite', {
9437
+ logger$7.info('WebRTC on reinvite', {
9323
9438
  sessionId: args[0].id,
9324
9439
  inviteId: args[1].id,
9325
9440
  updatedCalleeName: args[2],
@@ -9339,7 +9454,7 @@ class WebRTCPhone extends Emitter {
9339
9454
  });
9340
9455
 
9341
9456
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9342
- logger$6.info('WebRTC call accepted', { sipId: sipSession.id });
9457
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
9343
9458
 
9344
9459
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
9345
9460
 
@@ -9350,17 +9465,17 @@ class WebRTCPhone extends Emitter {
9350
9465
  this.client.on('ended', () => {});
9351
9466
 
9352
9467
  this.client.on(this.client.ON_ERROR, e => {
9353
- logger$6.error('WebRTC error', e);
9468
+ logger$7.error('WebRTC error', e);
9354
9469
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9355
9470
  });
9356
9471
 
9357
9472
  this.client.on(this.client.UNREGISTERED, () => {
9358
- logger$6.info('WebRTC unregistered');
9473
+ logger$7.info('WebRTC unregistered');
9359
9474
  this.eventEmitter.emit(ON_UNREGISTERED);
9360
9475
  });
9361
9476
 
9362
9477
  this.client.on(this.client.REGISTERED, () => {
9363
- logger$6.info('WebRTC registered', {
9478
+ logger$7.info('WebRTC registered', {
9364
9479
  shouldSendReinvite: this.shouldSendReinvite,
9365
9480
  state: this.currentSipSession ? this.currentSipSession.state : null,
9366
9481
  currentSipSession: !!this.currentSipSession,
@@ -9376,19 +9491,19 @@ class WebRTCPhone extends Emitter {
9376
9491
  try {
9377
9492
  this.sendReinvite(this.currentCallSession);
9378
9493
  } catch (e) {
9379
- logger$6.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9494
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9380
9495
  }
9381
9496
  }
9382
9497
  });
9383
9498
 
9384
9499
  this.client.on(this.client.CONNECTED, () => {
9385
- logger$6.info('WebRTC client connected');
9500
+ logger$7.info('WebRTC client connected');
9386
9501
 
9387
9502
  this.stopHeartbeat();
9388
9503
  });
9389
9504
 
9390
9505
  this.client.on(this.client.DISCONNECTED, () => {
9391
- logger$6.info('WebRTC client disconnected');
9506
+ logger$7.info('WebRTC client disconnected');
9392
9507
 
9393
9508
  this.eventEmitter.emit(ON_UNREGISTERED);
9394
9509
 
@@ -9620,7 +9735,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
9620
9735
 
9621
9736
  //
9622
9737
 
9623
- const logger$5 = IssueReporter$1.loggerFor('simple-phone');
9738
+ const logger$6 = IssueReporter$1.loggerFor('simple-phone');
9624
9739
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
9625
9740
  const protocolLogger = IssueReporter$1.loggerFor('sip');
9626
9741
 
@@ -9727,7 +9842,7 @@ class Phone extends Emitter {
9727
9842
  async disconnect() {
9728
9843
  if (this.phone) {
9729
9844
  if (this.phone.hasAnActiveCall()) {
9730
- logger$5.info('hangup call on disconnect');
9845
+ logger$6.info('hangup call on disconnect');
9731
9846
  // $FlowFixMe
9732
9847
  await this.phone.hangup();
9733
9848
  }
@@ -9750,13 +9865,13 @@ class Phone extends Emitter {
9750
9865
  }
9751
9866
 
9752
9867
  async hangup(callSession ) {
9753
- logger$5.info('hangup via simple phone', { callId: callSession.getId() });
9868
+ logger$6.info('hangup via simple phone', { callId: callSession.getId() });
9754
9869
 
9755
9870
  return this.phone && this.phone.hangup(callSession);
9756
9871
  }
9757
9872
 
9758
9873
  async accept(callSession , cameraEnabled ) {
9759
- logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
9874
+ logger$6.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
9760
9875
 
9761
9876
  return this.phone && this.phone.accept(callSession, cameraEnabled);
9762
9877
  }
@@ -9776,13 +9891,18 @@ class Phone extends Emitter {
9776
9891
  return adHocConference.start();
9777
9892
  }
9778
9893
 
9779
- mute(callSession ) {
9780
- this.muteViaAPI(callSession);
9894
+ mute(callSession , withApi = true) {
9895
+ if (withApi) {
9896
+ this.muteViaAPI(callSession);
9897
+ }
9898
+
9781
9899
  return this.phone && this.phone.mute(callSession);
9782
9900
  }
9783
9901
 
9784
- unmute(callSession ) {
9785
- this.unmuteViaAPI(callSession);
9902
+ unmute(callSession , withApi = true) {
9903
+ if (withApi) {
9904
+ this.unmuteViaAPI(callSession);
9905
+ }
9786
9906
 
9787
9907
  return this.phone && this.phone.unmute(callSession);
9788
9908
  }
@@ -9790,7 +9910,7 @@ class Phone extends Emitter {
9790
9910
  muteViaAPI(callSession ) {
9791
9911
  if (callSession && callSession.callId) {
9792
9912
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
9793
- logger$5.error('Mute via API, error', e);
9913
+ logger$6.error('Mute via API, error', e);
9794
9914
  });
9795
9915
  }
9796
9916
  }
@@ -9798,7 +9918,7 @@ class Phone extends Emitter {
9798
9918
  unmuteViaAPI(callSession ) {
9799
9919
  if (callSession && callSession.callId) {
9800
9920
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
9801
- logger$5.error('Unmute via API, error', e);
9921
+ logger$6.error('Unmute via API, error', e);
9802
9922
  });
9803
9923
  }
9804
9924
  }
@@ -9888,9 +10008,13 @@ class Phone extends Emitter {
9888
10008
  return this.phone && this.phone.hasLocalVideo(callSession);
9889
10009
  }
9890
10010
 
10011
+ hasALocalVideoTrack(callSession ) {
10012
+ return this.phone && this.phone.hasALocalVideoTrack(callSession);
10013
+ }
10014
+
9891
10015
  // @Deprecated
9892
10016
  getLocalMediaStream(callSession ) {
9893
- logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10017
+ logger$6.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
9894
10018
 
9895
10019
  return this.phone && this.phone.getLocalStream(callSession);
9896
10020
  }
@@ -9909,20 +10033,20 @@ class Phone extends Emitter {
9909
10033
 
9910
10034
  // @Deprecated
9911
10035
  getRemoteStreamForCall(callSession ) {
9912
- logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10036
+ logger$6.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
9913
10037
  return this.getRemoteStream(callSession);
9914
10038
  }
9915
10039
 
9916
10040
  // Returns remote streams directly from the peerConnection
9917
10041
  // @Deprecated
9918
10042
  getRemoteStreamsForCall(callSession ) {
9919
- logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10043
+ logger$6.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
9920
10044
  return this.getLocalStream(callSession);
9921
10045
  }
9922
10046
 
9923
10047
  // @Deprecated
9924
10048
  getRemoteVideoStreamForCall(callSession ) {
9925
- logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10049
+ logger$6.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
9926
10050
 
9927
10051
  return this.getRemoteVideoStream(callSession);
9928
10052
  }
@@ -10052,6 +10176,8 @@ const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
10052
10176
  const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
10053
10177
  const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
10054
10178
  const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
10179
+ const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
10180
+ const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
10055
10181
  const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
10056
10182
  const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
10057
10183
  const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
@@ -10093,7 +10219,7 @@ const BLACKLIST_EVENTS = [
10093
10219
  ];
10094
10220
 
10095
10221
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10096
- const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
10222
+ const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10097
10223
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10098
10224
 
10099
10225
  class WebSocketClient extends Emitter {
@@ -10142,19 +10268,19 @@ class WebSocketClient extends Emitter {
10142
10268
  }
10143
10269
 
10144
10270
  connect() {
10145
- logger$4.info('connect method started', { host: this.host, token: this.token });
10271
+ logger$5.info('connect method started', { host: this.host, token: this.token });
10146
10272
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
10147
10273
  if (this.options.binaryType) {
10148
10274
  this.socket.binaryType = this.options.binaryType;
10149
10275
  }
10150
10276
 
10151
10277
  this.socket.onopen = () => {
10152
- logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
10278
+ logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
10153
10279
  this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10154
10280
  };
10155
10281
 
10156
10282
  this.socket.onerror = event => {
10157
- logger$4.error('on Wazo WS error', event.target);
10283
+ logger$5.error('on Wazo WS error', event.target);
10158
10284
  this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10159
10285
  };
10160
10286
 
@@ -10184,7 +10310,7 @@ class WebSocketClient extends Emitter {
10184
10310
 
10185
10311
  this.socket.onclose = event => {
10186
10312
  // Can't be converted to JSON (circular structure)
10187
- logger$4.info('on Wazo WS close', {
10313
+ logger$5.info('on Wazo WS close', {
10188
10314
  reason: event.reason,
10189
10315
  code: event.code,
10190
10316
  readyState: event.target.readyState,
@@ -10202,12 +10328,12 @@ class WebSocketClient extends Emitter {
10202
10328
  };
10203
10329
 
10204
10330
  this.socket.onerror = event => {
10205
- logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
10331
+ logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
10206
10332
  };
10207
10333
  }
10208
10334
 
10209
10335
  close(force = false) {
10210
- logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
10336
+ logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
10211
10337
 
10212
10338
  if (!this.socket) {
10213
10339
  return;
@@ -10225,7 +10351,7 @@ class WebSocketClient extends Emitter {
10225
10351
 
10226
10352
  updateToken(token ) {
10227
10353
  this.token = token;
10228
- logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
10354
+ logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
10229
10355
 
10230
10356
  if (this.socket) {
10231
10357
  // If still connected, send the token to the WS
@@ -10243,7 +10369,7 @@ class WebSocketClient extends Emitter {
10243
10369
  }
10244
10370
 
10245
10371
  startHeartbeat() {
10246
- logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
10372
+ logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
10247
10373
 
10248
10374
  if (!this.socket) {
10249
10375
  this.heartbeat.stop();
@@ -10257,7 +10383,7 @@ class WebSocketClient extends Emitter {
10257
10383
  }
10258
10384
 
10259
10385
  stopHeartbeat() {
10260
- logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
10386
+ logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
10261
10387
 
10262
10388
  this.heartbeat.stop();
10263
10389
  }
@@ -10287,7 +10413,7 @@ class WebSocketClient extends Emitter {
10287
10413
  }
10288
10414
 
10289
10415
  reconnect(reason ) {
10290
- logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
10416
+ logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
10291
10417
  if (!this.socket) {
10292
10418
  return;
10293
10419
  }
@@ -10343,7 +10469,7 @@ class WebSocketClient extends Emitter {
10343
10469
  this.close();
10344
10470
  }
10345
10471
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
10346
- logger$4.log('Wazo WS url computed to reconnect', { url });
10472
+ logger$5.log('Wazo WS url computed to reconnect', { url });
10347
10473
 
10348
10474
  return url;
10349
10475
  }
@@ -10351,12 +10477,12 @@ class WebSocketClient extends Emitter {
10351
10477
  _onHeartbeat(message ) {
10352
10478
  if (message.payload === 'pong') {
10353
10479
  this.heartbeat.onHeartbeat();
10354
- logger$4.log('on heartbeat received from Wazo WS');
10480
+ logger$5.log('on heartbeat received from Wazo WS');
10355
10481
  }
10356
10482
  }
10357
10483
 
10358
10484
  async _onHeartbeatTimeout() {
10359
- logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
10485
+ logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
10360
10486
 
10361
10487
  this.close();
10362
10488
  this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
@@ -10398,6 +10524,8 @@ WebSocketClient.eventLists = [
10398
10524
  CHATD_USER_ROOM_CREATED,
10399
10525
  CONFERENCE_USER_PARTICIPANT_JOINED,
10400
10526
  CONFERENCE_USER_PARTICIPANT_LEFT,
10527
+ MEETING_USER_PARTICIPANT_JOINED,
10528
+ MEETING_USER_PARTICIPANT_LEFT,
10401
10529
  CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
10402
10530
  CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
10403
10531
  SWITCHBOARD_QUEUED_CALLS_UPDATED,
@@ -10468,6 +10596,8 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10468
10596
  CONFERENCE_USER_PARTICIPANT_LEFT: CONFERENCE_USER_PARTICIPANT_LEFT,
10469
10597
  CONFERENCE_USER_PARTICIPANT_TALK_STARTED: CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
10470
10598
  CONFERENCE_USER_PARTICIPANT_TALK_STOPPED: CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
10599
+ MEETING_USER_PARTICIPANT_JOINED: MEETING_USER_PARTICIPANT_JOINED,
10600
+ MEETING_USER_PARTICIPANT_LEFT: MEETING_USER_PARTICIPANT_LEFT,
10471
10601
  SWITCHBOARD_QUEUED_CALLS_UPDATED: SWITCHBOARD_QUEUED_CALLS_UPDATED,
10472
10602
  SWITCHBOARD_QUEUED_CALL_ANSWERED: SWITCHBOARD_QUEUED_CALL_ANSWERED,
10473
10603
  SWITCHBOARD_HELD_CALLS_UPDATED: SWITCHBOARD_HELD_CALLS_UPDATED,
@@ -10509,7 +10639,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10509
10639
  const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
10510
10640
  const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
10511
10641
 
10512
- const logger$3 = IssueReporter$1.loggerFor('simple-ws-client');
10642
+ const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
10513
10643
 
10514
10644
  class Websocket extends Emitter {
10515
10645
 
@@ -10533,7 +10663,7 @@ class Websocket extends Emitter {
10533
10663
  }
10534
10664
 
10535
10665
  open(host , session ) {
10536
- logger$3.info('open simple WebSocket', { host, token: session.token });
10666
+ logger$4.info('open simple WebSocket', { host, token: session.token });
10537
10667
  this.ws = new WebSocketClient(
10538
10668
  {
10539
10669
  host,
@@ -10561,7 +10691,7 @@ class Websocket extends Emitter {
10561
10691
  }
10562
10692
 
10563
10693
  updateToken(token ) {
10564
- logger$3.info('update token via simple Websocket', { token, ws: !!this.ws });
10694
+ logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
10565
10695
 
10566
10696
  if (!this.ws) {
10567
10697
  return;
@@ -10589,7 +10719,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
10589
10719
 
10590
10720
  //
10591
10721
 
10592
- const logger$2 = IssueReporter$1.loggerFor('room');
10722
+ const logger$3 = IssueReporter$1.loggerFor('room');
10593
10723
 
10594
10724
  class Participant extends Emitter {
10595
10725
 
@@ -10623,6 +10753,7 @@ class Participant extends Emitter {
10623
10753
 
10624
10754
 
10625
10755
  /**
10756
+ * @param room Room The room where the participant is
10626
10757
  * @param rawParticipant string Participant sent via the Wazo WS
10627
10758
  * @param extra Object extra status of the participant
10628
10759
  */
@@ -10710,7 +10841,7 @@ class Participant extends Emitter {
10710
10841
  }
10711
10842
 
10712
10843
  onTalking(isTalking ) {
10713
- logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
10844
+ logger$3.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
10714
10845
  this.isTalking = isTalking;
10715
10846
  // you may notice we're not broadcasting: since all participants are getting this info
10716
10847
  // directly from asterisk, there's no need to do so
@@ -10813,7 +10944,7 @@ class Participant extends Emitter {
10813
10944
  }
10814
10945
 
10815
10946
  updateStatus(status , broadcast = true) {
10816
- logger$2.info('updating participant status', { name: this.name, status });
10947
+ logger$3.info('updating participant status', { name: this.name, status });
10817
10948
 
10818
10949
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
10819
10950
  if (status.audioMuted) {
@@ -10850,13 +10981,18 @@ class Participant extends Emitter {
10850
10981
  // Poor man's object comparison
10851
10982
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
10852
10983
  this.extra = { ...this.extra, ...status.extra };
10984
+
10985
+ if (this.extra.contact && !(this.extra.contact instanceof Contact)) {
10986
+ this.extra.contact = new Contact(this.extra.contact);
10987
+ }
10988
+
10853
10989
  this.triggerUpdate(this.ON_EXTRA_CHANGE, broadcast);
10854
10990
  }
10855
10991
  }
10856
10992
 
10857
10993
  broadcastStatus(inboundStatus = null) {
10858
10994
  const status = inboundStatus || this.getStatus();
10859
- logger$2.info('broadcasting participant status', { callId: this.callId, status });
10995
+ logger$3.info('broadcasting participant status', { callId: this.callId, status });
10860
10996
 
10861
10997
  this.room.sendSignal({
10862
10998
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -10877,18 +11013,24 @@ class RemoteParticipant extends Participant {
10877
11013
  }
10878
11014
  }
10879
11015
 
10880
- /* global document */
11016
+ //
11017
+
11018
+ class LocalParticipant extends Participant {
11019
+ }
11020
+
11021
+ //
10881
11022
 
10882
11023
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
10883
11024
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
10884
11025
 
10885
- const logger$1 = IssueReporter$1.loggerFor('sdk-room');
11026
+ const logger$2 = IssueReporter$1.loggerFor('sdk-room');
10886
11027
 
10887
11028
  class Room$1 extends Emitter {
10888
11029
 
10889
11030
 
10890
11031
 
10891
11032
 
11033
+
10892
11034
 
10893
11035
 
10894
11036
 
@@ -10910,6 +11052,8 @@ class Room$1 extends Emitter {
10910
11052
 
10911
11053
 
10912
11054
 
11055
+
11056
+
10913
11057
 
10914
11058
 
10915
11059
 
@@ -10927,6 +11071,7 @@ class Room$1 extends Emitter {
10927
11071
  * @param extension string
10928
11072
  * @param sourceId number
10929
11073
  * @param callId string
11074
+ * @param meetingUuid string
10930
11075
  * @param extra Object
10931
11076
  */
10932
11077
  constructor(
@@ -10934,15 +11079,17 @@ class Room$1 extends Emitter {
10934
11079
  extension ,
10935
11080
  sourceId ,
10936
11081
  callId ,
11082
+ meetingUuid ,
10937
11083
  extra = {},
10938
11084
  ) {
10939
11085
  super();
10940
- logger$1.info('room initialized', { callId, extension, sourceId });
11086
+ logger$2.info('room initialized', { callId, extension, sourceId, meetingUuid });
10941
11087
 
10942
11088
  // Represents the room callSession
10943
11089
  this.callSession = callSession;
10944
11090
  this.extension = extension;
10945
11091
  this.sourceId = sourceId;
11092
+ this.meetingUuid = meetingUuid;
10946
11093
  this.callId = callId;
10947
11094
  this.participants = [];
10948
11095
  this.connected = false;
@@ -10962,6 +11109,8 @@ class Room$1 extends Emitter {
10962
11109
  // Sugar syntax for `room.EVENT_NAME`
10963
11110
  this.CONFERENCE_USER_PARTICIPANT_JOINED = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED;
10964
11111
  this.CONFERENCE_USER_PARTICIPANT_LEFT = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT;
11112
+ this.MEETING_USER_PARTICIPANT_JOINED = Wazo.Websocket.MEETING_USER_PARTICIPANT_JOINED;
11113
+ this.MEETING_USER_PARTICIPANT_LEFT = Wazo.Websocket.MEETING_USER_PARTICIPANT_LEFT;
10965
11114
  this.ON_SHARE_SCREEN_ENDED = Wazo.Phone.ON_SHARE_SCREEN_ENDED;
10966
11115
  this.ON_MESSAGE = Wazo.Phone.ON_MESSAGE;
10967
11116
  this.ON_CHAT = Wazo.Phone.ON_CHAT;
@@ -10996,10 +11145,11 @@ class Room$1 extends Emitter {
10996
11145
  * @param audioOnly boolean
10997
11146
  * @param extra Object
10998
11147
  * @param room ?Room
11148
+ * @param meeting ?Meeting
10999
11149
  * @returns {Promise<Room>}
11000
11150
  */
11001
- static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
11002
- logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
11151
+ static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11152
+ logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
11003
11153
 
11004
11154
  if (!room) {
11005
11155
  await Wazo.Phone.connect();
@@ -11012,7 +11162,7 @@ class Room$1 extends Emitter {
11012
11162
 
11013
11163
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11014
11164
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11015
- logger$1.info('room call received via WS', { callId: data.call_id });
11165
+ logger$2.info('room call received via WS', { callId: data.call_id });
11016
11166
  if (room) {
11017
11167
  room.setCallId(data.call_id);
11018
11168
  }
@@ -11033,34 +11183,44 @@ class Room$1 extends Emitter {
11033
11183
  room.setCallId(room.callSession.call.id);
11034
11184
  }
11035
11185
 
11036
- // Fetch conference source
11037
- const sources = await getApiClient().dird.fetchConferenceSource('default');
11038
- // Retrieve conference sources
11039
- const contacts = await getApiClient().dird.fetchConferenceContacts(sources.items[0]);
11040
- // Retrieve conference
11041
- const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11186
+ if (!meeting) {
11187
+ // Fetch conference source
11188
+ const sources = await getApiClient().dird.fetchConferenceSource('default');
11189
+ // Retrieve conference sources
11190
+ const contacts = await getApiClient().dird.fetchConferenceContacts(sources.items[0]);
11191
+ // Retrieve conference
11192
+ const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11042
11193
 
11043
- logger$1.info('connected to room', {
11044
- sourceId: conference ? conference.sourceId : null,
11045
- name: conference ? conference.name : null,
11046
- });
11194
+ logger$2.info('connected to room', {
11195
+ sourceId: conference ? conference.sourceId : null,
11196
+ name: conference ? conference.name : null,
11197
+ });
11047
11198
 
11048
- if (conference) {
11049
- room.setSourceId(conference.sourceId);
11050
- room.setName(conference.name);
11199
+ if (conference) {
11200
+ room.setSourceId(conference.sourceId);
11201
+ room.setName(conference.name);
11202
+ }
11203
+ } else if (meeting) {
11204
+ logger$2.info('Already connected to meeting', {
11205
+ uuid: meeting.uuid,
11206
+ name: meeting.name,
11207
+ });
11208
+
11209
+ room.setMeetingUuid(meeting.uuid);
11210
+ room.setName(meeting.name);
11051
11211
  }
11052
11212
 
11053
11213
  return room;
11054
11214
  }
11055
11215
 
11056
11216
  static disconnect() {
11057
- logger$1.info('static disconnection to room');
11217
+ logger$2.info('static disconnection to room');
11058
11218
 
11059
11219
  Wazo.Phone.disconnect();
11060
11220
  }
11061
11221
 
11062
11222
  async disconnect() {
11063
- logger$1.info('disconnection to room called');
11223
+ logger$2.info('disconnection to room called');
11064
11224
 
11065
11225
  await Wazo.Phone.hangup(this.callSession);
11066
11226
  this.callSession = null;
@@ -11075,20 +11235,24 @@ class Room$1 extends Emitter {
11075
11235
  Wazo.Phone.phone.off(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11076
11236
  Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
11077
11237
  Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
11078
-
11079
- if (this.roomAudioElement && document.body) {
11080
- document.body.removeChild(this.roomAudioElement);
11081
- }
11238
+ Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
11239
+ Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
11082
11240
  }
11083
11241
 
11084
11242
  setSourceId(sourceId ) {
11085
- logger$1.info('set room source id', { sourceId });
11243
+ logger$2.info('set room source id', { sourceId });
11086
11244
 
11087
11245
  this.sourceId = sourceId;
11088
11246
  }
11089
11247
 
11248
+ setMeetingUuid(meetingUuid ) {
11249
+ logger$2.info('set meeting uuid', { meetingUuid });
11250
+
11251
+ this.meetingUuid = meetingUuid;
11252
+ }
11253
+
11090
11254
  setCallId(callId ) {
11091
- logger$1.info('set room call id', { callId });
11255
+ logger$2.info('set room call id', { callId });
11092
11256
 
11093
11257
  if (callId) {
11094
11258
  this.callId = callId;
@@ -11096,7 +11260,7 @@ class Room$1 extends Emitter {
11096
11260
  }
11097
11261
 
11098
11262
  setName(name ) {
11099
- logger$1.info('set room name', { name });
11263
+ logger$2.info('set room name', { name });
11100
11264
 
11101
11265
  this.name = name;
11102
11266
  }
@@ -11115,7 +11279,7 @@ class Room$1 extends Emitter {
11115
11279
  }
11116
11280
 
11117
11281
  async startScreenSharing(constraints ) {
11118
- logger$1.info('start room screen sharing', { constraints });
11282
+ logger$2.info('start room screen sharing', { constraints });
11119
11283
 
11120
11284
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11121
11285
  if (!screensharingStream) {
@@ -11128,18 +11292,26 @@ class Room$1 extends Emitter {
11128
11292
  return screensharingStream;
11129
11293
  }
11130
11294
 
11131
- stopScreenSharing(restoreLocalStream = true) {
11132
- logger$1.info('stop room screen sharing');
11295
+ async stopScreenSharing(restoreLocalStream = true) {
11296
+ logger$2.info('stop room screen sharing');
11133
11297
 
11134
- Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11298
+ const reinvited = await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11135
11299
 
11136
11300
  if (this.localParticipant) {
11137
11301
  this.localParticipant.onStopScreensharing();
11138
11302
  }
11303
+
11304
+ if (!reinvited && this.localParticipant) {
11305
+ // When we had video and we made a screenshare we don't reinvite when stopping the screensahre
11306
+ // So not REINVITE even is fired, we have to restore the video stream manually
11307
+ const localVideoStream = Wazo.Phone.getLocalVideoStream(this.callSession);
11308
+ // $FlowFixMe
11309
+ this._associateStreamTo(localVideoStream, this.localParticipant);
11310
+ }
11139
11311
  }
11140
11312
 
11141
11313
  turnCameraOff() {
11142
- logger$1.info('turn room camera off');
11314
+ logger$2.info('turn room camera off');
11143
11315
 
11144
11316
  Wazo.Phone.turnCameraOff(this.callSession);
11145
11317
 
@@ -11149,7 +11321,7 @@ class Room$1 extends Emitter {
11149
11321
  }
11150
11322
 
11151
11323
  turnCameraOn() {
11152
- logger$1.info('turn room camera on');
11324
+ logger$2.info('turn room camera on');
11153
11325
 
11154
11326
  Wazo.Phone.turnCameraOn(this.callSession);
11155
11327
 
@@ -11159,7 +11331,7 @@ class Room$1 extends Emitter {
11159
11331
  }
11160
11332
 
11161
11333
  mute() {
11162
- logger$1.info('mute room');
11334
+ logger$2.info('mute room');
11163
11335
 
11164
11336
  Wazo.Phone.mute(this.callSession);
11165
11337
 
@@ -11167,7 +11339,7 @@ class Room$1 extends Emitter {
11167
11339
  }
11168
11340
 
11169
11341
  unmute() {
11170
- logger$1.info('unmute room');
11342
+ logger$2.info('unmute room');
11171
11343
 
11172
11344
  Wazo.Phone.unmute(this.callSession);
11173
11345
 
@@ -11187,7 +11359,7 @@ class Room$1 extends Emitter {
11187
11359
  }
11188
11360
 
11189
11361
  hold() {
11190
- logger$1.info('hold room');
11362
+ logger$2.info('hold room');
11191
11363
 
11192
11364
  Wazo.Phone.hold(this.callSession, true);
11193
11365
 
@@ -11197,7 +11369,7 @@ class Room$1 extends Emitter {
11197
11369
  }
11198
11370
 
11199
11371
  resume() {
11200
- logger$1.info('resume room');
11372
+ logger$2.info('resume room');
11201
11373
 
11202
11374
  Wazo.Phone.resume(this.callSession, true);
11203
11375
 
@@ -11207,13 +11379,13 @@ class Room$1 extends Emitter {
11207
11379
  }
11208
11380
 
11209
11381
  sendDTMF(tone ) {
11210
- logger$1.info('send room DTMF', { tone });
11382
+ logger$2.info('send room DTMF', { tone });
11211
11383
 
11212
11384
  Wazo.Phone.sendDTMF(tone, this.callSession);
11213
11385
  }
11214
11386
 
11215
11387
  async sendReinvite(newConstraints = null) {
11216
- logger$1.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11388
+ logger$2.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11217
11389
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
11218
11390
 
11219
11391
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -11238,6 +11410,22 @@ class Room$1 extends Emitter {
11238
11410
  return response;
11239
11411
  }
11240
11412
 
11413
+ hasALocalVideoTrack() {
11414
+ return Wazo.Phone.hasALocalVideoTrack(this.callSession);
11415
+ }
11416
+
11417
+ getLocalStream() {
11418
+ return Wazo.Phone.getLocalStream(this.callSession);
11419
+ }
11420
+
11421
+ getRemoteStream() {
11422
+ return Wazo.Phone.getRemoteStream(this.callSession);
11423
+ }
11424
+
11425
+ getRemoteVideoStream() {
11426
+ return Wazo.Phone.getRemoteVideoStream(this.callSession);
11427
+ }
11428
+
11241
11429
  _bindEvents() {
11242
11430
  if (!Wazo.Phone.phone || !Wazo.Phone.phone.currentSipSession) {
11243
11431
  return;
@@ -11256,35 +11444,18 @@ class Room$1 extends Emitter {
11256
11444
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11257
11445
 
11258
11446
  this.on(this.ON_AUDIO_STREAM, stream => {
11259
- logger$1.info('on room audio stream');
11447
+ logger$2.info('on room audio stream');
11260
11448
 
11261
11449
  this.audioStream = stream;
11262
- if (document.createElement) {
11263
- // $FlowFixMe
11264
- let roomAudioElement = document.getElementById('audio-room');
11265
- if (!this.roomAudioElement) {
11266
- roomAudioElement = document.createElement('audio');
11267
- // $FlowFixMe
11268
- document.body.appendChild(roomAudioElement);
11269
- }
11270
- if (!roomAudioElement) {
11271
- return;
11272
- }
11273
- this.roomAudioElement = roomAudioElement;
11450
+ if (!this.roomAudioElement) {
11451
+ const sessionId = Wazo.Phone.phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
11452
+ this.roomAudioElement = Wazo.Phone.phone.createAudioElementFor(sessionId);
11274
11453
  this.roomAudioElement.srcObject = stream;
11275
- this.roomAudioElement.autoplay = true;
11276
- this.roomAudioElement.id = 'audio-room';
11277
-
11278
- // $FlowFixMe
11279
- if (this.roomAudioElement.setSinkId) {
11280
- // $FlowFixMe
11281
- this.roomAudioElement.setSinkId(Wazo.Phone.getOutputDevice());
11282
- }
11283
11454
  }
11284
11455
  });
11285
11456
 
11286
11457
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
11287
- logger$1.info('on room video stream', { streamId });
11458
+ logger$2.info('on room video stream', { streamId });
11288
11459
 
11289
11460
  this._mapMsid(sipSession.body.body);
11290
11461
 
@@ -11299,7 +11470,7 @@ class Room$1 extends Emitter {
11299
11470
  });
11300
11471
 
11301
11472
  this.on(this.ON_REMOVE_STREAM, stream => {
11302
- logger$1.info('on room remove stream');
11473
+ logger$2.info('on room remove stream');
11303
11474
 
11304
11475
  const participant = this.participants.find(someParticipant =>
11305
11476
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -11354,6 +11525,9 @@ class Room$1 extends Emitter {
11354
11525
  Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
11355
11526
  Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
11356
11527
 
11528
+ Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
11529
+ Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
11530
+
11357
11531
  // Phone events
11358
11532
  Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
11359
11533
  Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
@@ -11364,15 +11538,15 @@ class Room$1 extends Emitter {
11364
11538
  Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
11365
11539
  }
11366
11540
 
11367
- _onMessage(message ) {
11541
+ _onMessage(message ) {
11368
11542
  if (message.method !== 'MESSAGE') {
11369
- return;
11543
+ return null;
11370
11544
  }
11371
11545
  let body;
11372
11546
  try {
11373
11547
  body = JSON.parse(message.body);
11374
11548
  } catch (e) {
11375
- return;
11549
+ return null;
11376
11550
  }
11377
11551
 
11378
11552
  switch (body.type) {
@@ -11391,6 +11565,8 @@ class Room$1 extends Emitter {
11391
11565
  }
11392
11566
 
11393
11567
  this.eventEmitter.emit(this.ON_MESSAGE, body);
11568
+
11569
+ return body;
11394
11570
  }
11395
11571
 
11396
11572
  _onChat(content ) {
@@ -11426,7 +11602,7 @@ class Room$1 extends Emitter {
11426
11602
  const requester = this._getParticipantFromCallId(origin.callId);
11427
11603
  if (requester) {
11428
11604
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
11429
- logger$1.info('trigger room requester status', { origin });
11605
+ logger$2.info('trigger room requester status', { origin });
11430
11606
  requester.triggerUpdate('REQUESTER_UPDATE');
11431
11607
  }
11432
11608
  break;
@@ -11455,25 +11631,26 @@ class Room$1 extends Emitter {
11455
11631
  const session = Wazo.Auth.getSession();
11456
11632
  let participants = [];
11457
11633
 
11458
- // @TODO: we could use a better function name here
11459
- const isJoining = part => {
11460
- this.__associateStreams(part);
11461
- // @VALIDATE: no need to publicize ourselves, no?
11462
- if (part instanceof RemoteParticipant) {
11463
- this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, part);
11464
- }
11465
- };
11466
-
11467
11634
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
11468
11635
  if (participant.user_uuid === session.uuid) {
11469
- logger$1.info('room current user joined');
11636
+ logger$2.info('room current user joined');
11470
11637
 
11471
11638
  // Retrieve participants via an API calls
11472
11639
  const conferenceId = this.sourceId || payload.data.conference_id;
11473
- const response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
11474
- logger$1.info('fetching conference participants', { conferenceId });
11640
+ let response;
11641
+ try {
11642
+ if (this.meetingUuid) {
11643
+ logger$2.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
11644
+ response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
11645
+ } else {
11646
+ logger$2.info('fetching conference participants', { conferenceId });
11647
+ response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
11648
+ }
11649
+ } catch (e) {
11650
+ logger$2.error('room participants fetching, error', e);
11651
+ }
11475
11652
  if (response) {
11476
- logger$1.info('conference participants fetched', { nb: response.items.length });
11653
+ logger$2.info('conference participants fetched', { nb: response.items.length });
11477
11654
  participants = response.items.map(item => {
11478
11655
  const isMe = item.call_id === this.callId;
11479
11656
 
@@ -11486,25 +11663,10 @@ class Room$1 extends Emitter {
11486
11663
 
11487
11664
  const localParticipant = participants.find(someParticipant => someParticipant instanceof Wazo.LocalParticipant);
11488
11665
  if (!this.localParticipant && localParticipant) {
11489
- this.localParticipant = localParticipant;
11490
-
11491
- const localVideoStream = this._getLocalVideoStream();
11492
- if (localVideoStream) {
11493
- this._saveLocalVideoStream(localVideoStream);
11494
- }
11495
-
11496
- this.connected = true;
11497
-
11498
- // we're in the room, now let's request everyone's status
11499
- if (this.localParticipant) {
11500
- this.sendSignal({
11501
- type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
11502
- origin: this.localParticipant.getStatus(),
11503
- });
11504
- }
11666
+ this._onLocalParticipantJoined(localParticipant);
11505
11667
  }
11506
11668
 
11507
- participants.forEach(someParticipant => isJoining(someParticipant));
11669
+ participants.forEach(someParticipant => this._isParticipantJoining(someParticipant));
11508
11670
  this.eventEmitter.emit(this.ON_JOINED, localParticipant, participants);
11509
11671
  }
11510
11672
 
@@ -11515,16 +11677,45 @@ class Room$1 extends Emitter {
11515
11677
  ? new Wazo.RemoteParticipant(this, participant)
11516
11678
  : null;
11517
11679
 
11518
- logger$1.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
11680
+ logger$2.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
11519
11681
 
11520
11682
  if (remoteParticipant) {
11521
11683
  this.participants.push(remoteParticipant);
11522
- isJoining(remoteParticipant);
11684
+ this._isParticipantJoining(remoteParticipant);
11523
11685
  }
11524
11686
 
11525
11687
  return remoteParticipant;
11526
11688
  }
11527
11689
 
11690
+ _onLocalParticipantJoined(localParticipant ) {
11691
+ this.localParticipant = localParticipant;
11692
+
11693
+ const localVideoStream = this._getLocalVideoStream();
11694
+ if (localVideoStream) {
11695
+ this._saveLocalVideoStream(localVideoStream);
11696
+ }
11697
+
11698
+ this.connected = true;
11699
+
11700
+ localParticipant.broadcastStatus();
11701
+
11702
+ // we're in the room, now let's request everyone's status
11703
+ if (this.localParticipant) {
11704
+ this.sendSignal({
11705
+ type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
11706
+ origin: this.localParticipant.getStatus(),
11707
+ });
11708
+ }
11709
+ }
11710
+
11711
+ _isParticipantJoining(participant ) {
11712
+ this.__associateStreams(participant);
11713
+ // @VALIDATE: no need to publicize ourselves, no?
11714
+ if (participant instanceof RemoteParticipant) {
11715
+ this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, participant);
11716
+ }
11717
+ }
11718
+
11528
11719
  _saveLocalVideoStream(stream ) {
11529
11720
  const { localParticipant } = this;
11530
11721
 
@@ -11570,9 +11761,11 @@ class Room$1 extends Emitter {
11570
11761
  _onParticipantTrackUpdate(oldParticipant , update ) {
11571
11762
  const newParticipant = oldParticipant;
11572
11763
 
11573
- const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
11764
+ const { trackId, streamId } = this._callIdStreamIdMap[newParticipant.callId] || {};
11574
11765
  const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
11575
- const stream = pc.getRemoteStreams().find(someStream => someStream.getTracks().some(track => track.id === trackId));
11766
+ // Can't use `getReceivers` here because on FF we make the mapping based on the streamId
11767
+ const stream = pc.getRemoteStreams().find(someStream =>
11768
+ someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
11576
11769
 
11577
11770
  if (update === 'downgrade') {
11578
11771
  newParticipant.streams = [];
@@ -11602,15 +11795,42 @@ class Room$1 extends Emitter {
11602
11795
  return;
11603
11796
  }
11604
11797
 
11605
- if (this._unassociatedVideoStreams[trackId]) {
11798
+ const streamId = this._getStreamIdFrTrackId(trackId);
11799
+ const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
11800
+ const stream = this._unassociatedVideoStreams[key];
11801
+
11802
+ if (stream) {
11606
11803
  // Try to associate stream
11607
- this._associateStreamTo(this._unassociatedVideoStreams[trackId], participant);
11804
+ this._associateStreamTo(stream, participant);
11608
11805
 
11609
- delete this._unassociatedVideoStreams[trackId];
11806
+ delete this._unassociatedVideoStreams[key];
11610
11807
  delete this._unassociatedParticipants[participant.callId];
11611
11808
  }
11612
11809
  }
11613
11810
 
11811
+ _getUnassociatedMapIdFromTrackIdOrStreamId(trackId , streamId ) {
11812
+ // Find by trackId
11813
+ if (trackId in this._unassociatedVideoStreams) {
11814
+ return trackId;
11815
+ }
11816
+
11817
+ // Find by streamId
11818
+ if (streamId && streamId in this._unassociatedVideoStreams) {
11819
+ return streamId;
11820
+ }
11821
+
11822
+ // Find in all the streams by streamId (used on FF where we can't map by trackId)
11823
+ const idx = Object.values(this._unassociatedVideoStreams).findIndex((stream ) =>
11824
+ stream && stream.id === streamId);
11825
+ return idx === -1 ? null : Object.keys(this._unassociatedVideoStreams)[idx];
11826
+ }
11827
+
11828
+ _getStreamIdFrTrackId(trackId ) {
11829
+ const mapping = Object.values(this._callIdStreamIdMap).find((map ) => map.trackId === trackId);
11830
+
11831
+ return mapping ? mapping.streamId : null;
11832
+ }
11833
+
11614
11834
  _associateStreamTo(rawStream , participant ) {
11615
11835
  const stream = new Wazo.Stream(rawStream, participant);
11616
11836
  participant.streams.push(stream);
@@ -11634,7 +11854,141 @@ class Room$1 extends Emitter {
11634
11854
 
11635
11855
  //
11636
11856
 
11637
- class LocalParticipant extends Participant {
11857
+ const logger$1 = IssueReporter$1.loggerFor('sdk-sip-room');
11858
+
11859
+ class SipRoom extends Room$1 {
11860
+
11861
+ static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
11862
+ logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
11863
+
11864
+ if (!room) {
11865
+ await Wazo.Phone.connect();
11866
+
11867
+ const withCamera = constraints && !!constraints.video;
11868
+
11869
+ const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11870
+ // eslint-disable-next-line no-param-reassign
11871
+ room = new SipRoom(callSession, extension, null, null, extra);
11872
+ }
11873
+
11874
+ if (room && room.callSession && room.callSession.call) {
11875
+ room.setCallId(room.callSession.call.id);
11876
+ }
11877
+
11878
+ logger$1.info('connected to room', {
11879
+ extension: room.extension,
11880
+ });
11881
+
11882
+ return room;
11883
+ }
11884
+
11885
+ mute() {
11886
+ logger$1.info('mute sip room');
11887
+
11888
+ Wazo.Phone.mute(this.callSession, false);
11889
+
11890
+ this.sendMuteStatus();
11891
+ }
11892
+
11893
+ unmute() {
11894
+ logger$1.info('unmute sip room');
11895
+
11896
+ Wazo.Phone.unmute(this.callSession, false);
11897
+
11898
+ this.sendUnMuteStatus();
11899
+ }
11900
+
11901
+ getLocalGuestName() {
11902
+ return Wazo.Phone.phone.client.userAgent.options.displayName;
11903
+ }
11904
+
11905
+ // Overridden to not listen to websocket messages
11906
+ _transferEvents() {
11907
+ // Phone events
11908
+ Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
11909
+ Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
11910
+ Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
11911
+ Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
11912
+
11913
+ [this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event =>
11914
+ Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
11915
+ }
11916
+
11917
+ _onMessage(message ) {
11918
+ // eslint-disable-next-line no-underscore-dangle
11919
+ const body = super._onMessage(message);
11920
+ if (!body) {
11921
+ return;
11922
+ }
11923
+
11924
+ const getChannel = () => body.channels[0];
11925
+
11926
+ switch (body.type) {
11927
+ case 'ConfbridgeWelcome':
11928
+ body.channels.forEach(channel => {
11929
+ this._onParticipantJoined(channel);
11930
+ });
11931
+
11932
+ break;
11933
+ case 'ConfbridgeJoin': {
11934
+ const channel = getChannel();
11935
+ this._onParticipantJoined(channel);
11936
+ break;
11937
+ }
11938
+ case 'ConfbridgeLeave': {
11939
+ const channel = getChannel();
11940
+ this._onParticipantLeft({
11941
+ data: {
11942
+ call_id: channel.id,
11943
+ },
11944
+ });
11945
+ break;
11946
+ }
11947
+ }
11948
+ }
11949
+
11950
+ async _onParticipantJoined(channel ) {
11951
+ const isLocal = channel.channelvars.WAZO_SIP_CALL_ID === this._getCurrentSipCallIs();
11952
+ const callId = channel.id;
11953
+ const ParticipantClass = isLocal ? Wazo.LocalParticipant : Wazo.RemoteParticipant;
11954
+ const name = channel.caller ? channel.caller.name : null;
11955
+ const extra = isLocal ? { guestName: this.getLocalGuestName() } : {};
11956
+ const participant = new ParticipantClass(this, {
11957
+ caller_id_name: name,
11958
+ call_id: callId,
11959
+ }, extra);
11960
+
11961
+ const participantIdx = this.participants.findIndex(other => other.callId === participant.callId);
11962
+ if (participantIdx !== -1 && name) {
11963
+ this.participants[participantIdx].name = name;
11964
+ return;
11965
+ }
11966
+
11967
+ if (isLocal) {
11968
+ // Should be updated by the Wazo WS but we don't have it for now
11969
+ if (this.callSession) {
11970
+ this.callSession.ringing = false;
11971
+ }
11972
+
11973
+ this._onLocalParticipantJoined(participant);
11974
+
11975
+ // Give some time for the stream to be updated
11976
+ setTimeout(() => {
11977
+ this.eventEmitter.emit(this.ON_JOINED, participant, this.participants);
11978
+ }, 1000);
11979
+ }
11980
+
11981
+ this.participants.push(participant);
11982
+
11983
+ this._isParticipantJoining(participant);
11984
+
11985
+ return participant;
11986
+ }
11987
+
11988
+ _getCurrentSipCallIs() {
11989
+ return Wazo.Phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
11990
+ }
11991
+
11638
11992
  }
11639
11993
 
11640
11994
  //
@@ -12530,6 +12884,7 @@ const Wazo = {
12530
12884
  Phone: Phone$1,
12531
12885
  Websocket: Websocket$1,
12532
12886
  Room: Room$1,
12887
+ SipRoom,
12533
12888
  RemoteParticipant,
12534
12889
  LocalParticipant,
12535
12890
  Stream,
@@ -12566,6 +12921,7 @@ const Wazo = {
12566
12921
  IndirectTransfer,
12567
12922
  SwitchboardCall,
12568
12923
  WebRTCPhone,
12924
+ Meeting,
12569
12925
  },
12570
12926
 
12571
12927
  // Api
@@ -12644,9 +13000,7 @@ class Stream {
12644
13000
  return false;
12645
13001
  }
12646
13002
 
12647
- // With canvas track (used to fake upgrade in conference), we don't have a width
12648
- return this.htmlStream.getTracks().find(track => track.kind === 'video'
12649
- && track.readyState !== 'ended' && 'width' in track.getSettings());
13003
+ return this.htmlStream.getTracks().some(track => track.kind === 'video' && track.readyState !== 'ended');
12650
13004
  }
12651
13005
 
12652
13006
  get id() {