@100mslive/react-native-hms 0.8.1 → 0.9.0

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 (141) hide show
  1. package/README.md +6 -6
  2. package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  6. package/android/.gradle/checksums/checksums.lock +0 -0
  7. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  8. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  9. package/android/build.gradle +3 -2
  10. package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +226 -256
  11. package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +82 -31
  12. package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +99 -22
  13. package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +368 -221
  14. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +66 -0
  15. package/android/src/main/java/com/reactnativehmssdk/HmsView.kt +43 -24
  16. package/android/src/main/java/com/reactnativehmssdk/HmssdkPackage.kt +1 -2
  17. package/android/src/main/java/com/reactnativehmssdk/HmssdkViewManager.kt +14 -11
  18. package/android/src/main/res/layout/hms_view.xml +19 -0
  19. package/ios/HmsDecoder.swift +91 -22
  20. package/ios/HmsHelper.swift +34 -3
  21. package/ios/HmsManager.m +11 -9
  22. package/ios/HmsManager.swift +32 -18
  23. package/ios/HmsSDK.swift +193 -43
  24. package/ios/HmsView.swift +22 -54
  25. package/lib/commonjs/classes/HMSChangeTrackStateRequest.js +3 -0
  26. package/lib/commonjs/classes/HMSChangeTrackStateRequest.js.map +1 -1
  27. package/lib/commonjs/classes/HMSEncoder.js +10 -6
  28. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  29. package/lib/commonjs/classes/HMSHLSConfig.js +20 -0
  30. package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -0
  31. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js +23 -0
  32. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  33. package/lib/commonjs/classes/HMSHLSStreamingState.js +23 -0
  34. package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -0
  35. package/lib/commonjs/classes/HMSHLSVariant.js +29 -0
  36. package/lib/commonjs/classes/HMSHLSVariant.js.map +1 -0
  37. package/lib/commonjs/classes/HMSLocalAudioTrack.js +20 -0
  38. package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
  39. package/lib/commonjs/classes/HMSLocalPeer.js.map +1 -1
  40. package/lib/commonjs/classes/HMSLocalVideoTrack.js +18 -0
  41. package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
  42. package/lib/commonjs/classes/HMSLogger.js +55 -1
  43. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  44. package/lib/commonjs/classes/HMSRemoteAudioTrack.js +19 -0
  45. package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
  46. package/lib/commonjs/classes/HMSRemoteVideoTrack.js +19 -0
  47. package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
  48. package/lib/commonjs/classes/HMSRoom.js +3 -0
  49. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  50. package/lib/commonjs/classes/HMSRoomUpdate.js +6 -0
  51. package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
  52. package/lib/commonjs/classes/HMSSDK.js +297 -145
  53. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  54. package/lib/commonjs/classes/HMSTrackSettings.js +3 -0
  55. package/lib/commonjs/classes/HMSTrackSettings.js.map +1 -1
  56. package/lib/commonjs/classes/HMSVideoCodec.js +4 -4
  57. package/lib/commonjs/classes/HMSVideoCodec.js.map +1 -1
  58. package/lib/commonjs/classes/HmsView.js +26 -4
  59. package/lib/commonjs/classes/HmsView.js.map +1 -1
  60. package/lib/commonjs/index.js +70 -0
  61. package/lib/commonjs/index.js.map +1 -1
  62. package/lib/module/classes/HMSChangeTrackStateRequest.js +3 -0
  63. package/lib/module/classes/HMSChangeTrackStateRequest.js.map +1 -1
  64. package/lib/module/classes/HMSEncoder.js +10 -6
  65. package/lib/module/classes/HMSEncoder.js.map +1 -1
  66. package/lib/module/classes/HMSHLSConfig.js +11 -0
  67. package/lib/module/classes/HMSHLSConfig.js.map +1 -0
  68. package/lib/module/classes/HMSHLSMeetingURLVariant.js +14 -0
  69. package/lib/module/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  70. package/lib/module/classes/HMSHLSStreamingState.js +14 -0
  71. package/lib/module/classes/HMSHLSStreamingState.js.map +1 -0
  72. package/lib/module/classes/HMSHLSVariant.js +20 -0
  73. package/lib/module/classes/HMSHLSVariant.js.map +1 -0
  74. package/lib/module/classes/HMSLocalAudioTrack.js +17 -0
  75. package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
  76. package/lib/module/classes/HMSLocalPeer.js.map +1 -1
  77. package/lib/module/classes/HMSLocalVideoTrack.js +15 -0
  78. package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
  79. package/lib/module/classes/HMSLogger.js +55 -1
  80. package/lib/module/classes/HMSLogger.js.map +1 -1
  81. package/lib/module/classes/HMSRemoteAudioTrack.js +16 -0
  82. package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
  83. package/lib/module/classes/HMSRemoteVideoTrack.js +16 -0
  84. package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
  85. package/lib/module/classes/HMSRoom.js +3 -0
  86. package/lib/module/classes/HMSRoom.js.map +1 -1
  87. package/lib/module/classes/HMSRoomUpdate.js +6 -0
  88. package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
  89. package/lib/module/classes/HMSSDK.js +295 -146
  90. package/lib/module/classes/HMSSDK.js.map +1 -1
  91. package/lib/module/classes/HMSTrackSettings.js +3 -0
  92. package/lib/module/classes/HMSTrackSettings.js.map +1 -1
  93. package/lib/module/classes/HMSVideoCodec.js +4 -4
  94. package/lib/module/classes/HMSVideoCodec.js.map +1 -1
  95. package/lib/module/classes/HmsView.js +23 -4
  96. package/lib/module/classes/HmsView.js.map +1 -1
  97. package/lib/module/index.js +5 -0
  98. package/lib/module/index.js.map +1 -1
  99. package/lib/typescript/classes/HMSChangeTrackStateRequest.d.ts +2 -0
  100. package/lib/typescript/classes/HMSHLSConfig.d.ts +7 -0
  101. package/lib/typescript/classes/HMSHLSMeetingURLVariant.d.ts +8 -0
  102. package/lib/typescript/classes/HMSHLSStreamingState.d.ts +9 -0
  103. package/lib/typescript/classes/HMSHLSVariant.d.ts +12 -0
  104. package/lib/typescript/classes/HMSLocalPeer.d.ts +3 -0
  105. package/lib/typescript/classes/HMSLogger.d.ts +9 -0
  106. package/lib/typescript/classes/HMSRoom.d.ts +3 -0
  107. package/lib/typescript/classes/HMSRoomUpdate.d.ts +7 -1
  108. package/lib/typescript/classes/HMSSDK.d.ts +22 -13
  109. package/lib/typescript/classes/HMSTrackSettings.d.ts +2 -0
  110. package/lib/typescript/classes/HMSVideoCodec.d.ts +4 -4
  111. package/lib/typescript/index.d.ts +5 -0
  112. package/package.json +1 -1
  113. package/react-native-hms.podspec +1 -1
  114. package/src/classes/HMSChangeTrackStateRequest.ts +7 -1
  115. package/src/classes/HMSEncoder.ts +5 -1
  116. package/src/classes/HMSHLSConfig.ts +9 -0
  117. package/src/classes/HMSHLSMeetingURLVariant.ts +9 -0
  118. package/src/classes/HMSHLSStreamingState.ts +11 -0
  119. package/src/classes/HMSHLSVariant.ts +18 -0
  120. package/src/classes/HMSLocalAudioTrack.ts +16 -0
  121. package/src/classes/HMSLocalPeer.ts +3 -0
  122. package/src/classes/HMSLocalVideoTrack.ts +15 -0
  123. package/src/classes/HMSLogger.ts +28 -1
  124. package/src/classes/HMSRemoteAudioTrack.ts +16 -0
  125. package/src/classes/HMSRemoteVideoTrack.ts +16 -0
  126. package/src/classes/HMSRoom.ts +4 -0
  127. package/src/classes/HMSRoomUpdate.ts +6 -0
  128. package/src/classes/HMSSDK.tsx +221 -84
  129. package/src/classes/HMSTrackSettings.ts +3 -0
  130. package/src/classes/HMSVideoCodec.ts +4 -4
  131. package/src/classes/HmsView.tsx +32 -4
  132. package/src/index.ts +5 -0
  133. package/android/.gradle/6.9/executionHistory/executionHistory.bin +0 -0
  134. package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
  135. package/android/.gradle/6.9/fileHashes/resourceHashesCache.bin +0 -0
  136. package/android/.gradle/6.9/javaCompile/classAnalysis.bin +0 -0
  137. package/android/.gradle/6.9/javaCompile/jarAnalysis.bin +0 -0
  138. package/android/.gradle/6.9/javaCompile/javaCompile.lock +0 -0
  139. package/android/.gradle/6.9/javaCompile/taskHistory.bin +0 -0
  140. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  141. package/android/.project +0 -34
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
- import { NativeEventEmitter, NativeModules, ViewStyle } from 'react-native';
2
+ import {
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ Platform,
6
+ ViewStyle,
7
+ AppState,
8
+ } from 'react-native';
3
9
  import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
4
10
  import type { HMSConfig } from './HMSConfig';
5
11
  import type { HMSLocalPeer } from './HMSLocalPeer';
@@ -17,6 +23,7 @@ import { HmsView as HMSViewComponent } from './HmsView';
17
23
  import { HMSVideoViewMode } from './HMSVideoViewMode';
18
24
  import type { HMSTrackSettings } from './HMSTrackSettings';
19
25
  import type { HMSRTMPConfig } from './HMSRTMPConfig';
26
+ import type { HMSHLSConfig } from './HMSHLSConfig';
20
27
 
21
28
  interface HmsComponentProps {
22
29
  trackId: string;
@@ -38,14 +45,16 @@ const HmsEventEmitter = new NativeEventEmitter(HmsManager);
38
45
 
39
46
  let HmsSdk: HMSSDK | undefined;
40
47
 
48
+ let logger: HMSLogger | undefined;
49
+
41
50
  export class HMSSDK {
42
51
  room?: HMSRoom;
43
52
  localPeer?: HMSLocalPeer;
44
53
  remotePeers?: HMSRemotePeer[];
45
54
  knownRoles?: HMSRole[];
46
- logger?: HMSLogger;
47
55
  id: string;
48
56
  private muteStatus: boolean | undefined;
57
+ appStateSubscription?: any;
49
58
 
50
59
  onPreviewDelegate?: any;
51
60
  onJoinDelegate?: any;
@@ -73,7 +82,7 @@ export class HMSSDK {
73
82
  * @returns
74
83
  * @memberof HMSSDK
75
84
  */
76
- static async build(params?: { trackSettings?: HMSTrackSettings }) {
85
+ static async build(params?: { trackSettings: HMSTrackSettings }) {
77
86
  let id = await HmsManager.build(params?.trackSettings || {});
78
87
  HmsSdk = new HMSSDK(id);
79
88
  HmsSdk.attachPreviewListener();
@@ -81,6 +90,15 @@ export class HMSSDK {
81
90
  return HmsSdk;
82
91
  }
83
92
 
93
+ static getLogger() {
94
+ return logger;
95
+ }
96
+
97
+ setLogger = (hmsLogger: HMSLogger) => {
98
+ logger = hmsLogger;
99
+ hmsLogger.verbose('#Function setLogger', { id: this.id });
100
+ };
101
+
84
102
  destroy = () => {
85
103
  this.removeListeners();
86
104
  };
@@ -224,12 +242,13 @@ export class HMSSDK {
224
242
  * @memberof HMSSDK
225
243
  */
226
244
  join = async (config: HMSConfig) => {
227
- this.logger?.verbose('JOIN', { config });
245
+ logger?.verbose('#Function join', { config, id: this.id });
246
+ this.addAppStateListener();
228
247
  await HmsManager.join({ ...config, id: this.id });
229
248
  };
230
249
 
231
250
  preview = (config: HMSConfig) => {
232
- this.logger?.verbose('PREVIEW', { config });
251
+ logger?.verbose('#Function preview', { config, id: this.id });
233
252
  HmsManager.preview({ ...config, id: this.id });
234
253
  };
235
254
 
@@ -258,31 +277,46 @@ export class HMSSDK {
258
277
  * @memberof HMSSDK
259
278
  */
260
279
  leave = async () => {
261
- this.logger?.verbose('LEAVE', {});
280
+ logger?.verbose('#Function leave', { id: this.id });
262
281
  const data = {
263
282
  id: this.id,
264
283
  };
265
284
 
266
- await HmsManager.leave(data);
285
+ const op = await HmsManager.leave(data);
267
286
  this.muteStatus = undefined;
268
287
  this.localPeer = undefined;
269
288
  this.remotePeers = undefined;
270
289
  this.room = undefined;
271
290
  this.knownRoles = undefined;
291
+ this?.appStateSubscription?.remove();
292
+ return op;
272
293
  };
273
294
 
274
- sendBroadcastMessage = (message: string, type?: string) => {
275
- this.logger?.verbose('SEND_BROADCAST_MESSAGE', { message });
276
- HmsManager.sendBroadcastMessage({
295
+ sendBroadcastMessage = async (message: string, type: string = 'chat') => {
296
+ logger?.verbose('#Function sendBroadcastMessage', {
297
+ message,
298
+ type: type || null,
299
+ id: this.id,
300
+ });
301
+ return await HmsManager.sendBroadcastMessage({
277
302
  message,
278
303
  type: type || null,
279
304
  id: this.id,
280
305
  });
281
306
  };
282
307
 
283
- sendGroupMessage = (message: string, roles: HMSRole[], type?: string) => {
284
- this.logger?.verbose('SEND_GROUP_MESSAGE', { message, roles });
285
- HmsManager.sendGroupMessage({
308
+ sendGroupMessage = async (
309
+ message: string,
310
+ roles: HMSRole[],
311
+ type: string = 'chat'
312
+ ) => {
313
+ logger?.verbose('#Function sendGroupMessage', {
314
+ message,
315
+ roles,
316
+ id: this.id,
317
+ type: type || null,
318
+ });
319
+ return await HmsManager.sendGroupMessage({
286
320
  message,
287
321
  roles: HMSHelper.getRoleNames(roles),
288
322
  id: this.id,
@@ -290,114 +324,155 @@ export class HMSSDK {
290
324
  });
291
325
  };
292
326
 
293
- sendDirectMessage = (message: string, peerId: string, type?: string) => {
294
- this.logger?.verbose('SEND_DIRECT_MESSAGE', { message, peerId });
295
- HmsManager.sendDirectMessage({
327
+ sendDirectMessage = async (
328
+ message: string,
329
+ peer: HMSPeer,
330
+ type: string = 'chat'
331
+ ) => {
332
+ logger?.verbose('#Function sendDirectMessage', {
296
333
  message,
297
- peerId,
334
+ peerId: peer.peerID,
335
+ id: this.id,
336
+ type: type || null,
337
+ });
338
+ return await HmsManager.sendDirectMessage({
339
+ message,
340
+ peerId: peer.peerID,
298
341
  id: this.id,
299
342
  type: type || null,
300
343
  });
301
344
  };
302
345
 
303
346
  changeMetadata = (metadata: string) => {
304
- this.logger?.verbose('CHANGE_METADATA', { metadata });
347
+ logger?.verbose('#Function changeMetadata', { metadata, id: this.id });
305
348
  HmsManager.changeMetadata({ metadata, id: this.id });
306
349
  };
307
350
 
308
351
  startRTMPOrRecording = async (data: HMSRTMPConfig) => {
309
- this.logger?.verbose('START_RTMP_OR_RECORDING', { data });
352
+ logger?.verbose('#Function startRTMPOrRecording', {
353
+ ...data,
354
+ id: this.id,
355
+ });
310
356
 
311
357
  const op = await HmsManager.startRTMPOrRecording({ ...data, id: this.id });
312
358
  return op;
313
359
  };
314
360
 
315
361
  stopRtmpAndRecording = async () => {
316
- this.logger?.verbose('STOP_RTMP_OR_RECORDING', {});
362
+ logger?.verbose('#Function stopRtmpAndRecording', {});
317
363
  const op = await HmsManager.stopRtmpAndRecording({ id: this.id });
318
364
  return op;
319
365
  };
320
366
 
321
- changeRole = (peer: HMSPeer, role: HMSRole, force: boolean = false) => {
367
+ startHLSStreaming = async (data: HMSHLSConfig) => {
368
+ logger?.verbose('#Function startHLSStreaming', {
369
+ ...data,
370
+ id: this.id,
371
+ });
372
+ return await HmsManager.startHLSStreaming({ ...data, id: this.id });
373
+ };
374
+
375
+ stopHLSStreaming = async () => {
376
+ logger?.verbose('#Function stopHLSStreaming', {});
377
+ return await HmsManager.stopHLSStreaming({ id: this.id });
378
+ };
379
+
380
+ changeRole = async (peer: HMSPeer, role: HMSRole, force: boolean = false) => {
322
381
  const data = {
323
382
  peerId: peer?.peerID,
324
383
  role: role?.name,
325
384
  force: force,
326
385
  id: this.id,
327
386
  };
328
- this.logger?.verbose('CHANGE_ROLE', data);
329
- HmsManager.changeRole(data);
387
+ logger?.verbose('#Function changeRole', data);
388
+ return await HmsManager.changeRole(data);
330
389
  };
331
390
 
332
- changeTrackState = (track: HMSTrack, mute: boolean) => {
333
- this.logger?.verbose('CHANGE_TRACK_STATE', { track, mute });
391
+ changeTrackState = async (track: HMSTrack, mute: boolean) => {
392
+ logger?.verbose('#Function changeTrackState', {
393
+ track,
394
+ mute,
395
+ id: this.id,
396
+ });
334
397
  const data = {
335
398
  trackId: track.trackId,
336
399
  mute,
337
400
  id: this.id,
338
401
  };
339
402
 
340
- HmsManager.changeTrackState(data);
403
+ return await HmsManager.changeTrackState(data);
341
404
  };
342
405
 
343
- changeTrackStateRoles = (
344
- type: HMSTrackType,
406
+ changeTrackStateForRoles = async (
345
407
  mute: boolean,
346
- source: string,
347
- roles: Array<HMSRole>
408
+ type?: HMSTrackType,
409
+ source?: string,
410
+ roles?: Array<HMSRole>
348
411
  ) => {
349
- this.logger?.verbose('CHANGE_TRACK_STATE_ROLES', {
412
+ let roleNames = null;
413
+ if (roles) {
414
+ roleNames = HMSHelper.getRoleNames(roles);
415
+ }
416
+ logger?.verbose('#Function changeTrackStateRoles', {
350
417
  source,
351
418
  mute,
352
419
  type,
353
420
  roles,
421
+ id: this.id,
354
422
  });
355
423
  const data = {
356
424
  source,
357
425
  mute,
358
426
  type,
359
- roles: HMSHelper.getRoleNames(roles),
427
+ roles: roleNames,
360
428
  id: this.id,
361
429
  };
362
430
 
363
- HmsManager.changeTrackStateRoles(data);
431
+ return await HmsManager.changeTrackStateForRoles(data);
364
432
  };
365
433
 
366
- removePeer = (peerId: string, reason: string) => {
367
- this.logger?.verbose('REMOVE_PEER', { peerId, reason });
434
+ removePeer = async (peer: HMSPeer, reason: string) => {
435
+ logger?.verbose('#Function removePeer', {
436
+ peerId: peer.peerID,
437
+ reason,
438
+ id: this.id,
439
+ });
368
440
  const data = {
369
- peerId,
441
+ peerId: peer.peerID,
370
442
  reason,
371
443
  id: this.id,
372
444
  };
373
445
 
374
- HmsManager.removePeer(data);
446
+ return await HmsManager.removePeer(data);
375
447
  };
376
448
 
377
- endRoom = (lock: boolean, reason: string) => {
378
- this.logger?.verbose('END_ROOM', { lock, reason });
449
+ endRoom = async (reason: string, lock: boolean = false) => {
450
+ logger?.verbose('#Function endRoom', { lock, reason, id: this.id });
379
451
  const data = {
380
452
  lock,
381
453
  reason,
382
454
  id: this.id,
383
455
  };
384
456
 
385
- HmsManager.endRoom(data);
457
+ return await HmsManager.endRoom(data);
386
458
  };
387
459
 
388
- acceptRoleChange = () => {
389
- this.logger?.verbose('ACCEPT_ROLE_CHANGE', {});
390
- HmsManager.acceptRoleChange({ id: this.id });
460
+ acceptRoleChange = async () => {
461
+ logger?.verbose('#Function acceptRoleChange', { id: this.id });
462
+ return await HmsManager.acceptRoleChange({ id: this.id });
391
463
  };
392
464
 
393
465
  muteAllPeersAudio = (mute: boolean) => {
394
- this.logger?.verbose('ON_MUTE_ALL_PEERS', { mute });
466
+ logger?.verbose('#Function muteAllPeersAudio', { mute, id: this.id });
395
467
  this.muteStatus = mute;
396
468
  HmsManager.muteAllPeersAudio({ mute, id: this.id });
397
469
  };
398
470
 
399
471
  getRoom = async () => {
400
- this.logger?.verbose('GET_ROOM_API_CALL', { roomID: this.id });
472
+ logger?.verbose('#Function getRoom', {
473
+ roomID: this.room?.id,
474
+ id: this.id,
475
+ });
401
476
  const hmsRoom = await HmsManager.getRoom({ id: this.id });
402
477
 
403
478
  const encodedHmsRoom = HMSEncoder.encodeHmsRoom(hmsRoom, this.id);
@@ -405,13 +480,62 @@ export class HMSSDK {
405
480
  };
406
481
 
407
482
  setVolume = (track: HMSTrack, volume: number) => {
408
- this.logger?.verbose('SET_VOLUME_CALL', { track, volume });
483
+ logger?.verbose('#Function setVolume', {
484
+ track,
485
+ volume,
486
+ id: this.id,
487
+ });
409
488
  HmsManager.setVolume({
410
489
  id: this.id,
411
490
  trackId: track.trackId,
412
491
  volume,
413
492
  });
414
- return;
493
+ };
494
+
495
+ resetVolume = () => {
496
+ logger?.verbose('#Function resetVolume', { id: this.id });
497
+ if (Platform.OS === 'android') HmsManager.resetVolume({ id: this.id });
498
+ };
499
+
500
+ addAppStateListener = () => {
501
+ logger?.verbose('#Function addAppStateListener', { id: this.id });
502
+ this.appStateSubscription = AppState.addEventListener(
503
+ 'change',
504
+ (nextAppState) => {
505
+ if (nextAppState === 'active' && Platform.OS === 'android') {
506
+ this.resetVolume();
507
+ }
508
+ }
509
+ );
510
+ };
511
+
512
+ startScreenshare = () => {
513
+ logger?.verbose('#Function startScreenshare', { id: this.id });
514
+ if (Platform.OS === 'android') {
515
+ HmsManager.startScreenshare({ id: this.id });
516
+ } else {
517
+ console.log('API currently not avaialble for iOS');
518
+ }
519
+ };
520
+
521
+ isScreenShared = async () => {
522
+ logger?.verbose('#Function isScreenShared', { id: this.id });
523
+ if (Platform.OS === 'android') {
524
+ return await HmsManager.isScreenShared({ id: this.id });
525
+ } else {
526
+ console.log('API currently not avaialble for iOS');
527
+ return 'API currently not avaialble for iOS';
528
+ }
529
+ };
530
+
531
+ stopScreenshare = async () => {
532
+ logger?.verbose('#Function stopScreenshare', { id: this.id });
533
+ if (Platform.OS === 'android') {
534
+ return await HmsManager.stopScreenshare({ id: this.id });
535
+ } else {
536
+ console.log('API currently not avaialble for iOS');
537
+ return 'API currently not avaialble for iOS';
538
+ }
415
539
  };
416
540
 
417
541
  /**
@@ -423,7 +547,10 @@ export class HMSSDK {
423
547
  * @memberof HMSSDK
424
548
  */
425
549
  addEventListener = (action: HMSUpdateListenerActions, callback: any) => {
426
- this.logger?.verbose('ON_ATTACH_EVENT_LISTENER', { action });
550
+ logger?.verbose('#Function addEventListener', {
551
+ action,
552
+ id: this.id,
553
+ });
427
554
  switch (action) {
428
555
  case HMSUpdateListenerActions.ON_PREVIEW:
429
556
  this.onPreviewDelegate = callback;
@@ -477,7 +604,7 @@ export class HMSSDK {
477
604
  * @memberof HMSSDK
478
605
  */
479
606
  removeEventListener = (action: HMSUpdateListenerActions) => {
480
- this.logger?.verbose('ON_REMOVE_LISTENER', { action });
607
+ logger?.verbose('#Function removeEventListener', { action, id: this.id });
481
608
  switch (action) {
482
609
  case HMSUpdateListenerActions.ON_PREVIEW:
483
610
  this.onPreviewDelegate = null;
@@ -542,19 +669,14 @@ export class HMSSDK {
542
669
  this.onChangeTrackStateRequestDelegate = null;
543
670
  this.onRemovedFromRoomDelegate = null;
544
671
 
545
- this.logger?.verbose('REMOVE_ALL_LISTENER', {});
546
- };
547
-
548
- setLogger = (hmsLogger: HMSLogger) => {
549
- this.logger = hmsLogger;
550
- hmsLogger.verbose('UPDATE_LOGGER', { hmsLogger });
672
+ logger?.verbose('#Function REMOVE_ALL_LISTENER', { id: this.id });
551
673
  };
552
674
 
553
675
  onPreviewListener = (data: any) => {
554
676
  if (data.id !== this.id) {
555
677
  return;
556
678
  }
557
- this.logger?.verbose('ON_PREVIEW', data);
679
+ logger?.verbose('#Listener ON_PREVIEW', data);
558
680
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
559
681
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
560
682
  data.localPeer,
@@ -566,7 +688,7 @@ export class HMSSDK {
566
688
  this.localPeer = localPeer;
567
689
  this.room = room;
568
690
  if (this.onPreviewDelegate) {
569
- this.logger?.verbose('ON_PREVIEW_LISTENER_CALL', {
691
+ logger?.verbose('#Listener ON_PREVIEW_LISTENER_CALL', {
570
692
  ...data,
571
693
  room,
572
694
  localPeer,
@@ -580,7 +702,7 @@ export class HMSSDK {
580
702
  if (data.id !== this.id) {
581
703
  return;
582
704
  }
583
- this.logger?.verbose('ON_JOIN', data);
705
+ logger?.verbose('#LISTENER ON_JOIN', data);
584
706
  // Preprocessing
585
707
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
586
708
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
@@ -597,7 +719,7 @@ export class HMSSDK {
597
719
  this.remotePeers = remotePeers;
598
720
  this.knownRoles = roles;
599
721
  if (this.onJoinDelegate) {
600
- this.logger?.verbose('ON_JOIN_LISTENER_CALL', {
722
+ logger?.verbose('#Listener ON_JOIN_LISTENER_CALL', {
601
723
  ...data,
602
724
  room,
603
725
  localPeer,
@@ -611,7 +733,7 @@ export class HMSSDK {
611
733
  if (data.id !== this.id) {
612
734
  return;
613
735
  }
614
- this.logger?.verbose('ON_ROOM', data);
736
+ logger?.verbose('#Listener ON_ROOM', data);
615
737
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
616
738
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
617
739
  data.localPeer,
@@ -625,7 +747,7 @@ export class HMSSDK {
625
747
  this.localPeer = localPeer;
626
748
  this.remotePeers = remotePeers;
627
749
  if (this.onRoomDelegate) {
628
- this.logger?.verbose('ON_ROOM_LISTENER_CALL', {
750
+ logger?.verbose('#Listener ON_ROOM_LISTENER_CALL', {
629
751
  ...data,
630
752
  room,
631
753
  localPeer,
@@ -639,7 +761,8 @@ export class HMSSDK {
639
761
  if (data.id !== this.id) {
640
762
  return;
641
763
  }
642
- this.logger?.verbose('ON_PEER', data);
764
+ logger?.verbose('#Listener ON_PEER', data);
765
+ const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
643
766
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
644
767
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
645
768
  data.localPeer,
@@ -654,8 +777,8 @@ export class HMSSDK {
654
777
  this.remotePeers = remotePeers;
655
778
  this.room = room;
656
779
  if (this.onPeerDelegate) {
657
- this.logger?.verbose('ON_PEER_LISTENER_CALL', data);
658
- this.onPeerDelegate({ ...data, localPeer, remotePeers, room });
780
+ logger?.verbose('#Listener ON_PEER_LISTENER_CALL', data);
781
+ this.onPeerDelegate({ ...data, localPeer, remotePeers, room, peer });
659
782
  }
660
783
  };
661
784
 
@@ -663,7 +786,9 @@ export class HMSSDK {
663
786
  if (data.id !== this.id) {
664
787
  return;
665
788
  }
666
- this.logger?.verbose('ON_TRACK', data);
789
+ logger?.verbose('#Listener ON_TRACK', data);
790
+ const track: HMSTrack = HMSEncoder.encodeHmsTrack(data.track, this.id);
791
+ const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
667
792
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
668
793
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
669
794
  data.localPeer,
@@ -680,8 +805,15 @@ export class HMSSDK {
680
805
  this.localPeer = localPeer;
681
806
  this.remotePeers = remotePeers;
682
807
  if (this.onTrackDelegate) {
683
- this.logger?.verbose('ON_TRACK_LISTENER_CALL', data);
684
- this.onTrackDelegate({ ...data, localPeer, remotePeers, room });
808
+ logger?.verbose('#Listener ON_TRACK_LISTENER_CALL', data);
809
+ this.onTrackDelegate({
810
+ ...data,
811
+ localPeer,
812
+ remotePeers,
813
+ room,
814
+ peer,
815
+ track,
816
+ });
685
817
  }
686
818
  };
687
819
 
@@ -689,10 +821,10 @@ export class HMSSDK {
689
821
  if (data.id !== this.id) {
690
822
  return;
691
823
  }
692
- this.logger?.verbose('ON_MESSAGE', data);
824
+ logger?.verbose('#Listener ON_MESSAGE', data);
693
825
  const message = new HMSMessage(data);
694
826
  if (this.onMessageDelegate) {
695
- this.logger?.verbose('ON_MESSAGE_LISTENER_CALL', message);
827
+ logger?.verbose('#Listener ON_MESSAGE_LISTENER_CALL', message);
696
828
  this.onMessageDelegate(message);
697
829
  }
698
830
  };
@@ -701,8 +833,9 @@ export class HMSSDK {
701
833
  if (data.id !== this.id) {
702
834
  return;
703
835
  }
704
- this.logger?.verbose('ON_SPEAKER', data);
836
+ logger?.verbose('#Listener ON_SPEAKER', data);
705
837
  if (this.onSpeakerDelegate) {
838
+ logger?.verbose('#Listener ON_SPEAKER_LISTENER_CALL', data);
706
839
  this.onSpeakerDelegate(data);
707
840
  }
708
841
  };
@@ -711,11 +844,11 @@ export class HMSSDK {
711
844
  if (data.id !== this.id) {
712
845
  return;
713
846
  }
714
- this.logger?.warn('ON_ERROR', data);
715
- this.logger?.verbose('ON_ERROR', data);
847
+ logger?.warn('#Listener ON_ERROR', data);
848
+ logger?.verbose('#Listener ON_ERROR', data);
716
849
  if (this.onErrorDelegate) {
717
- this.logger?.verbose('ON_ERROR_LISTENER_CALL', data);
718
- this.logger?.warn('ON_ERROR_LISTENER_CALL', data);
850
+ logger?.verbose('#Listener ON_ERROR_LISTENER_CALL', data);
851
+ logger?.warn('#Listener ON_ERROR_LISTENER_CALL', data);
719
852
  this.onErrorDelegate(data);
720
853
  }
721
854
  };
@@ -724,14 +857,14 @@ export class HMSSDK {
724
857
  if (data.id !== this.id) {
725
858
  return;
726
859
  }
727
- this.logger?.verbose('ON_ROLE_CHANGE_REQUEST', data);
860
+ logger?.verbose('#Listener ON_ROLE_CHANGE_REQUEST', data);
728
861
  if (this.onRoleChangeRequestDelegate) {
729
862
  const encodedRoleChangeRequest = HMSEncoder.encodeHmsRoleChangeRequest(
730
863
  data,
731
864
  this.id
732
865
  );
733
- this.logger?.verbose(
734
- 'ON_ROLE_CHANGE_LISTENER_CALL',
866
+ logger?.verbose(
867
+ '#Listener ON_ROLE_CHANGE_LISTENER_CALL',
735
868
  encodedRoleChangeRequest
736
869
  );
737
870
  this.onRoleChangeRequestDelegate(encodedRoleChangeRequest);
@@ -739,12 +872,15 @@ export class HMSSDK {
739
872
  };
740
873
 
741
874
  onChangeTrackStateRequestListener = (data: any) => {
742
- this.logger?.verbose('ON_CHANGE_TRACK_STATE_REQUEST', data);
875
+ if (data.id !== this.id) {
876
+ return;
877
+ }
878
+ logger?.verbose('#Listener ON_CHANGE_TRACK_STATE_REQUEST', data);
743
879
  if (this.onChangeTrackStateRequestDelegate) {
744
880
  const encodedRoleChangeRequest =
745
881
  HMSEncoder.encodeHmsChangeTrackStateRequest(data, this.id);
746
- this.logger?.verbose(
747
- 'ON_CHANGE_TRACK_STATE_REQUEST_LISTENER_CALL',
882
+ logger?.verbose(
883
+ '#Listener ON_CHANGE_TRACK_STATE_REQUEST_LISTENER_CALL',
748
884
  encodedRoleChangeRequest
749
885
  );
750
886
  this.onChangeTrackStateRequestDelegate(encodedRoleChangeRequest);
@@ -755,7 +891,7 @@ export class HMSSDK {
755
891
  if (data.id !== this.id) {
756
892
  return;
757
893
  }
758
- this.logger?.verbose('ON_REMOVED_FROM_ROOM', data);
894
+ logger?.verbose('#Listener ON_REMOVED_FROM_ROOM', data);
759
895
  if (this.onRemovedFromRoomDelegate) {
760
896
  let requestedBy = null;
761
897
  if (data.requestedBy) {
@@ -764,10 +900,11 @@ export class HMSSDK {
764
900
  const reason = data.reason;
765
901
  const roomEnded = data.roomEnded;
766
902
 
767
- this.logger?.verbose('ON_REMOVED_FROM_ROOM_LISTENER_CALL', {
903
+ logger?.verbose('#Listener ON_REMOVED_FROM_ROOM_LISTENER_CALL', {
768
904
  requestedBy,
769
905
  reason,
770
906
  roomEnded,
907
+ id: this.id,
771
908
  });
772
909
  this.onRemovedFromRoomDelegate({ requestedBy, reason, roomEnded });
773
910
  }
@@ -777,7 +914,7 @@ export class HMSSDK {
777
914
  if (data.id !== this.id) {
778
915
  return;
779
916
  }
780
- this.logger?.verbose('ON_RECONNECTING', data);
917
+ logger?.verbose('#Listener ON_RECONNECTING', data);
781
918
  if (this.onReconnectingDelegate) {
782
919
  this.onReconnectingDelegate(data);
783
920
  }
@@ -787,7 +924,7 @@ export class HMSSDK {
787
924
  if (data.id !== this.id) {
788
925
  return;
789
926
  }
790
- this.logger?.verbose('ON_RECONNECTED', data);
927
+ logger?.verbose('#Listener ON_RECONNECTED', data);
791
928
  if (this.onReconnectedDelegate) {
792
929
  this.onReconnectedDelegate(data);
793
930
  }
@@ -4,14 +4,17 @@ import type { HMSVideoTrackSettings } from './HMSVideoTrackSettings';
4
4
  export class HMSTrackSettings {
5
5
  video?: HMSVideoTrackSettings;
6
6
  audio?: HMSAudioTrackSettings;
7
+ useHardwareEchoCancellation?: boolean;
7
8
 
8
9
  constructor(params?: {
9
10
  video?: HMSVideoTrackSettings;
10
11
  audio?: HMSAudioTrackSettings;
12
+ useHardwareEchoCancellation?: boolean;
11
13
  }) {
12
14
  if (params) {
13
15
  this.video = params.video;
14
16
  this.audio = params.audio;
17
+ this.useHardwareEchoCancellation = params.useHardwareEchoCancellation;
15
18
  }
16
19
  }
17
20
  }
@@ -1,6 +1,6 @@
1
1
  export enum HMSVideoCodec {
2
- h264 = 'h264',
3
- vp8 = 'vp8',
4
- vp9 = 'vp9',
5
- h265 = 'h265',
2
+ H264 = 'H264',
3
+ VP8 = 'VP8',
4
+ VP9 = 'VP9',
5
+ H265 = 'H265',
6
6
  }