@100mslive/react-native-hms 0.9.8 → 0.9.92

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 (91) hide show
  1. package/README.md +50 -43
  2. package/android/.gradle/6.9/fileHashes/fileHashes.bin +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/outputFiles.bin +0 -0
  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/.idea/libraries/{Gradle__com_github_100mslive_android_sdk_lib_2_4_2_aar.xml → Gradle__com_github_100mslive_android_sdk_lib_2_4_7_aar.xml} +4 -4
  10. package/android/.idea/libraries/Gradle__com_github_100mslive_webrtc_m97_hms_1_1_aar.xml +11 -0
  11. package/android/.idea/modules/android.androidTest.iml +4 -4
  12. package/android/.idea/modules/android.main.iml +4 -4
  13. package/android/.idea/modules/android.unitTest.iml +4 -4
  14. package/android/build.gradle +2 -2
  15. package/android/src/main/java/com/reactnativehmssdk/HMSAudioshareActivity.kt +84 -0
  16. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +77 -8
  17. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +95 -22
  18. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +88 -2
  19. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +282 -49
  20. package/ios/HMSDecoder.swift +9 -8
  21. package/ios/HMSHelper.swift +5 -8
  22. package/ios/HMSManager.m +4 -1
  23. package/ios/HMSManager.swift +28 -6
  24. package/ios/HMSRNSDK.swift +146 -101
  25. package/lib/commonjs/classes/HMSAudioDevice.js +17 -0
  26. package/lib/commonjs/classes/HMSAudioDevice.js.map +1 -0
  27. package/lib/commonjs/classes/HMSAudioMixingMode.js +15 -0
  28. package/lib/commonjs/classes/HMSAudioMixingMode.js.map +1 -0
  29. package/lib/commonjs/classes/HMSAudioMode.js +17 -0
  30. package/lib/commonjs/classes/HMSAudioMode.js.map +1 -0
  31. package/lib/commonjs/classes/HMSEncoder.js +15 -0
  32. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  33. package/lib/commonjs/classes/HMSException.js +18 -13
  34. package/lib/commonjs/classes/HMSException.js.map +1 -1
  35. package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -1
  36. package/lib/commonjs/classes/HMSLogger.js +2 -2
  37. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  38. package/lib/commonjs/classes/HMSPermissions.js +7 -4
  39. package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
  40. package/lib/commonjs/classes/HMSSDK.js +267 -58
  41. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  42. package/lib/commonjs/classes/HMSUpdateListenerActions.js +1 -0
  43. package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
  44. package/lib/commonjs/index.js +42 -0
  45. package/lib/commonjs/index.js.map +1 -1
  46. package/lib/module/classes/HMSAudioDevice.js +10 -0
  47. package/lib/module/classes/HMSAudioDevice.js.map +1 -0
  48. package/lib/module/classes/HMSAudioMixingMode.js +8 -0
  49. package/lib/module/classes/HMSAudioMixingMode.js.map +1 -0
  50. package/lib/module/classes/HMSAudioMode.js +10 -0
  51. package/lib/module/classes/HMSAudioMode.js.map +1 -0
  52. package/lib/module/classes/HMSEncoder.js +14 -0
  53. package/lib/module/classes/HMSEncoder.js.map +1 -1
  54. package/lib/module/classes/HMSException.js +18 -13
  55. package/lib/module/classes/HMSException.js.map +1 -1
  56. package/lib/module/classes/HMSHLSConfig.js.map +1 -1
  57. package/lib/module/classes/HMSLogger.js +2 -2
  58. package/lib/module/classes/HMSLogger.js.map +1 -1
  59. package/lib/module/classes/HMSPermissions.js +7 -4
  60. package/lib/module/classes/HMSPermissions.js.map +1 -1
  61. package/lib/module/classes/HMSSDK.js +267 -52
  62. package/lib/module/classes/HMSSDK.js.map +1 -1
  63. package/lib/module/classes/HMSUpdateListenerActions.js +1 -0
  64. package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
  65. package/lib/module/index.js +3 -0
  66. package/lib/module/index.js.map +1 -1
  67. package/lib/typescript/classes/HMSAudioDevice.d.ts +7 -0
  68. package/lib/typescript/classes/HMSAudioMixingMode.d.ts +5 -0
  69. package/lib/typescript/classes/HMSAudioMode.d.ts +7 -0
  70. package/lib/typescript/classes/HMSEncoder.d.ts +2 -0
  71. package/lib/typescript/classes/HMSException.d.ts +8 -14
  72. package/lib/typescript/classes/HMSHLSConfig.d.ts +2 -2
  73. package/lib/typescript/classes/HMSLogger.d.ts +1 -1
  74. package/lib/typescript/classes/HMSPermissions.d.ts +6 -4
  75. package/lib/typescript/classes/HMSSDK.d.ts +112 -12
  76. package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +2 -1
  77. package/lib/typescript/index.d.ts +3 -0
  78. package/package.json +1 -19
  79. package/react-native-hms.podspec +2 -1
  80. package/src/classes/HMSAudioDevice.ts +7 -0
  81. package/src/classes/HMSAudioMixingMode.ts +5 -0
  82. package/src/classes/HMSAudioMode.ts +7 -0
  83. package/src/classes/HMSEncoder.ts +12 -0
  84. package/src/classes/HMSException.ts +15 -24
  85. package/src/classes/HMSHLSConfig.ts +2 -2
  86. package/src/classes/HMSLogger.ts +2 -2
  87. package/src/classes/HMSPermissions.ts +9 -6
  88. package/src/classes/HMSSDK.tsx +352 -67
  89. package/src/classes/HMSUpdateListenerActions.ts +1 -0
  90. package/src/index.ts +3 -0
  91. package/android/.idea/libraries/Gradle__com_github_100mslive_webrtc_m97_aar.xml +0 -11
@@ -28,6 +28,9 @@ import type { HMSVideoViewMode } from './HMSVideoViewMode';
28
28
  import type { HMSTrackSettings } from './HMSTrackSettings';
29
29
  import type { HMSRTMPConfig } from './HMSRTMPConfig';
30
30
  import type { HMSHLSConfig } from './HMSHLSConfig';
31
+ import type { HMSAudioDevice } from './HMSAudioDevice';
32
+ import type { HMSAudioMode } from './HMSAudioMode';
33
+ import type { HMSAudioMixingMode } from './HMSAudioMixingMode';
31
34
 
32
35
  interface HmsViewProps {
33
36
  trackId: string;
@@ -75,6 +78,7 @@ export class HMSSDK {
75
78
  onLocalVideoStatsDelegate?: any;
76
79
  onRemoteAudioStatsDelegate?: any;
77
80
  onRemoteVideoStatsDelegate?: any;
81
+ onAudioDeviceChangedDelegate?: any;
78
82
 
79
83
  constructor(id: string) {
80
84
  this.id = id;
@@ -88,8 +92,20 @@ export class HMSSDK {
88
92
  * @returns
89
93
  * @memberof HMSSDK
90
94
  */
91
- static async build(params?: { trackSettings: HMSTrackSettings }) {
92
- let id = await HMSManager.build(params?.trackSettings || {});
95
+ static async build({
96
+ trackSettings,
97
+ appGroup,
98
+ preferredExtension,
99
+ }: {
100
+ trackSettings?: HMSTrackSettings;
101
+ appGroup?: String;
102
+ preferredExtension?: String;
103
+ }) {
104
+ let id = await HMSManager.build({
105
+ trackSettings: trackSettings,
106
+ appGroup: appGroup,
107
+ preferredExtension: preferredExtension,
108
+ });
93
109
  HmsSdk = new HMSSDK(id);
94
110
  HmsSdk.attachPreviewListener();
95
111
  HmsSdk.attachListeners();
@@ -110,8 +126,8 @@ export class HMSSDK {
110
126
  * @param {HMSLogger} hmsLogger
111
127
  * @memberof HMSSDK
112
128
  */
113
- setLogger = (hmsLogger: HMSLogger) => {
114
- setLogger(hmsLogger, this.id);
129
+ setLogger = (hmsLogger?: HMSLogger) => {
130
+ setLogger(this.id, hmsLogger);
115
131
  };
116
132
 
117
133
  /**
@@ -228,6 +244,11 @@ export class HMSSDK {
228
244
  HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
229
245
  this.onRemoteVideoStatsListener
230
246
  );
247
+
248
+ HmsEventEmitter.addListener(
249
+ HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED,
250
+ this.onAudioDeviceChangedListener
251
+ );
231
252
  };
232
253
 
233
254
  /**
@@ -320,6 +341,11 @@ export class HMSSDK {
320
341
  HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
321
342
  this.onRemoteVideoStatsListener
322
343
  );
344
+
345
+ HmsEventEmitter.removeListener(
346
+ HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED,
347
+ this.onAudioDeviceChangedListener
348
+ );
323
349
  };
324
350
 
325
351
  /**
@@ -376,13 +402,14 @@ export class HMSSDK {
376
402
  };
377
403
 
378
404
  /**
379
- * - HmsView is react component that takes one track and starts showing that track on a tile.
405
+ * - HmsView is react component that takes trackId and starts showing that track on a tile.
380
406
  * - The appearance of tile is completely customizable with style prop.
381
- * - scale type can determine how the incoming video will fit in the canvas check {@link HMSVideoViewMode} for more information.
407
+ * - Scale type can determine how the incoming video will fit in the canvas check {@link HMSVideoViewMode} for more information.
408
+ * - Mirror to flip the video vertically.
382
409
  *
383
410
  * checkout {@link https://www.100ms.live/docs/react-native/v2/features/render-video} for more info
384
411
  *
385
- * @param {HmsComponentProps}
412
+ * @param {HmsViewProps}
386
413
  * @memberof HMSSDK
387
414
  */
388
415
  HmsView = React.forwardRef<any, HmsViewProps>((props, ref) => {
@@ -510,9 +537,9 @@ export class HMSSDK {
510
537
  * @param {string}
511
538
  * @memberof HMSSDK
512
539
  */
513
- changeMetadata = (metadata: string) => {
540
+ changeMetadata = async (metadata: string) => {
514
541
  logger?.verbose('#Function changeMetadata', { metadata, id: this.id });
515
- HMSManager.changeMetadata({ metadata, id: this.id });
542
+ return await HMSManager.changeMetadata({ metadata, id: this.id });
516
543
  };
517
544
 
518
545
  /**
@@ -557,7 +584,7 @@ export class HMSSDK {
557
584
  * @param {HMSHLSConfig}
558
585
  * @memberof HMSSDK
559
586
  */
560
- startHLSStreaming = async (data: HMSHLSConfig) => {
587
+ startHLSStreaming = async (data?: HMSHLSConfig) => {
561
588
  logger?.verbose('#Function startHLSStreaming', {
562
589
  ...data,
563
590
  id: this.id,
@@ -605,7 +632,7 @@ export class HMSSDK {
605
632
 
606
633
  /**
607
634
  * - This function can be used to manipulate mute status of any track.
608
- * - Targeted peer affected by this action will get a callback in {@link onChangeTrackStateRequestListener}.
635
+ * - Targeted peer affected by this action will get a callback in onChangeTrackStateRequestListener.
609
636
  *
610
637
  * * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-track-state} for more info
611
638
  *
@@ -631,7 +658,7 @@ export class HMSSDK {
631
658
  * - changeTrackStateForRoles is an enhancement on the functionality of {@link changeTrackState}.
632
659
  * - We can change mute status for all the tracks of peers having a particular role.
633
660
  * - @param source determines the source of the track ex. video, audio etc.
634
- * - The peers affected by this action will get a callback in {@link onChangeTrackStateRequestListener}.
661
+ * - The peers affected by this action will get a callback in onChangeTrackStateRequestListener.
635
662
  *
636
663
  * @memberof HMSSDK
637
664
  */
@@ -736,7 +763,7 @@ export class HMSSDK {
736
763
  };
737
764
 
738
765
  /**
739
- * - setPlaybackForAllAudio is an extension of the abilities of {@link setPlaybackAllowed} in
766
+ * - setPlaybackForAllAudio is an extension of the abilities of setPlaybackAllowed in
740
767
  * {@link HMSRemoteAudioTrack}, it sets mute status for all peers in the room
741
768
  *
742
769
  * checkout {@link https://www.100ms.live/docs/react-native/v2/features/playback-allowed} for more info
@@ -754,9 +781,9 @@ export class HMSSDK {
754
781
  *
755
782
  * @memberof HMSSDK
756
783
  */
757
- remoteMuteAllAudio = () => {
784
+ remoteMuteAllAudio = async () => {
758
785
  logger?.verbose('#Function remoteMuteAllAudio', { id: this.id });
759
- HMSManager.remoteMuteAllAudio({ id: this.id });
786
+ return await HMSManager.remoteMuteAllAudio({ id: this.id });
760
787
  };
761
788
 
762
789
  /**
@@ -832,12 +859,7 @@ export class HMSSDK {
832
859
  */
833
860
  startScreenshare = async () => {
834
861
  logger?.verbose('#Function startScreenshare', { id: this.id });
835
- if (Platform.OS === 'android') {
836
- return await HMSManager.startScreenshare({ id: this.id });
837
- } else {
838
- console.log('API currently not available for iOS');
839
- return 'API currently not available for iOS';
840
- }
862
+ return await HMSManager.startScreenshare({ id: this.id });
841
863
  };
842
864
 
843
865
  /**
@@ -849,12 +871,7 @@ export class HMSSDK {
849
871
  */
850
872
  isScreenShared = async () => {
851
873
  logger?.verbose('#Function isScreenShared', { id: this.id });
852
- if (Platform.OS === 'android') {
853
- return await HMSManager.isScreenShared({ id: this.id });
854
- } else {
855
- console.log('API currently not available for iOS');
856
- return 'API currently not available for iOS';
857
- }
874
+ return await HMSManager.isScreenShared({ id: this.id });
858
875
  };
859
876
 
860
877
  /**
@@ -866,12 +883,7 @@ export class HMSSDK {
866
883
  */
867
884
  stopScreenshare = async () => {
868
885
  logger?.verbose('#Function stopScreenshare', { id: this.id });
869
- if (Platform.OS === 'android') {
870
- return await HMSManager.stopScreenshare({ id: this.id });
871
- } else {
872
- console.log('API currently not available for iOS');
873
- return 'API currently not available for iOS';
874
- }
886
+ return await HMSManager.stopScreenshare({ id: this.id });
875
887
  };
876
888
 
877
889
  /**
@@ -888,11 +900,7 @@ export class HMSSDK {
888
900
  */
889
901
  enableRTCStats = () => {
890
902
  logger?.verbose('#Function enableRTCStats', { id: this.id });
891
- if (Platform.OS === 'ios') {
892
- HMSManager.enableRTCStats({ id: this.id });
893
- } else {
894
- console.log('API currently not avaialble for android');
895
- }
903
+ HMSManager.enableRTCStats({ id: this.id });
896
904
  };
897
905
 
898
906
  /**
@@ -905,10 +913,209 @@ export class HMSSDK {
905
913
  */
906
914
  disableRTCStats = () => {
907
915
  logger?.verbose('#Function disableRTCStats', { id: this.id });
908
- if (Platform.OS === 'ios') {
909
- HMSManager.disableRTCStats({ id: this.id });
916
+ HMSManager.disableRTCStats({ id: this.id });
917
+ };
918
+
919
+ /**
920
+ * - This wrapper function is used to start streaming device audio, currently available only for android.
921
+ *
922
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-share#how-to-stream-device-audio-from-the-app} for more info.
923
+ *
924
+ * @param {HMSAudioMixingMode}
925
+ * @memberof HMSSDK
926
+ */
927
+ startAudioshare = async (audioMixingMode: HMSAudioMixingMode) => {
928
+ logger?.verbose('#Function startAudioshare', {
929
+ id: this.id,
930
+ audioMixingMode,
931
+ });
932
+ if (Platform.OS === 'android') {
933
+ return await HMSManager.startAudioshare({ id: this.id, audioMixingMode });
934
+ } else {
935
+ console.log('API currently not available for iOS');
936
+ return 'API currently not available for iOS';
937
+ }
938
+ };
939
+
940
+ /**
941
+ * - This wrapper function returns true if audio is being shared and vice versa, currently available only for android.
942
+ *
943
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-share#how-to-get-audio-share-status} for more info.
944
+ *
945
+ * @memberof HMSSDK
946
+ */
947
+ isAudioShared = async () => {
948
+ logger?.verbose('#Function isAudioShared', { id: this.id });
949
+ if (Platform.OS === 'android') {
950
+ return await HMSManager.isAudioShared({ id: this.id });
910
951
  } else {
911
- console.log('API currently not avaialble for android');
952
+ console.log('API currently not available for iOS');
953
+ return 'API currently not available for iOS';
954
+ }
955
+ };
956
+
957
+ /**
958
+ * - This wrapper function is used to stop streaming device audio, currently available only for android.
959
+ *
960
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-share#how-to-stop-audio-sharing} for more info.
961
+ *
962
+ * @memberof HMSSDK
963
+ */
964
+ stopAudioshare = async () => {
965
+ logger?.verbose('#Function stopAudioshare', { id: this.id });
966
+ if (Platform.OS === 'android') {
967
+ return await HMSManager.stopAudioshare({ id: this.id });
968
+ } else {
969
+ console.log('API currently not available for iOS');
970
+ return 'API currently not available for iOS';
971
+ }
972
+ };
973
+
974
+ /**
975
+ * - This wrapper function returns the current audio mixing mode, currently available only for android.
976
+ *
977
+ * @memberof HMSSDK
978
+ * @return HMSAudioMixingMode
979
+ */
980
+ getAudioMixingMode = async () => {
981
+ logger?.verbose('#Function getAudioMixingMode', { id: this.id });
982
+ if (Platform.OS === 'android') {
983
+ return await HMSManager.getAudioMixingMode({ id: this.id });
984
+ } else {
985
+ console.log('API currently not available for iOS');
986
+ return 'API currently not available for iOS';
987
+ }
988
+ };
989
+
990
+ /**
991
+ * - This wrapper function used to change the mode while the user is streaming audio, currently available only for android.
992
+ *
993
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-share#how-to-change-mode} for more info
994
+ *
995
+ * @param {HMSAudioMixingMode}
996
+ * @memberof HMSSDK
997
+ */
998
+ setAudioMixingMode = async (audioMixingMode: HMSAudioMixingMode) => {
999
+ logger?.verbose('#Function setAudioMixingMode', {
1000
+ id: this.id,
1001
+ audioMixingMode,
1002
+ });
1003
+ if (Platform.OS === 'android') {
1004
+ return await HMSManager.setAudioMixingMode({
1005
+ id: this.id,
1006
+ audioMixingMode,
1007
+ });
1008
+ } else {
1009
+ console.log('API currently not available for iOS');
1010
+ return 'API currently not available for iOS';
1011
+ }
1012
+ };
1013
+
1014
+ /**
1015
+ * - This wrapper function returns the array of audio output devices which is of
1016
+ * type {@link HMSAudioDevice[]}, currently available only for android.
1017
+ *
1018
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-output-routing#get-list-of-audio-device} for more info
1019
+ *
1020
+ * @memberof HMSSDK
1021
+ * @return HMSAudioDevice[]
1022
+ */
1023
+ getAudioDevicesList = async () => {
1024
+ logger?.verbose('#Function getAudioDevicesList', {
1025
+ id: this.id,
1026
+ });
1027
+ if (Platform.OS === 'android') {
1028
+ return await HMSManager.getAudioDevicesList({ id: this.id });
1029
+ } else {
1030
+ console.log('API currently not available for iOS');
1031
+ return 'API currently not available for iOS';
1032
+ }
1033
+ };
1034
+
1035
+ /**
1036
+ * - This wrapper function returns the current audio output device which is of
1037
+ * type {@link HMSAudioDevice}, currently available only for android.
1038
+ *
1039
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-output-routing#get-current-focussed-device} for more info
1040
+ *
1041
+ * @memberof HMSSDK
1042
+ * @return HMSAudioDevice
1043
+ */
1044
+ getAudioOutputRouteType = async () => {
1045
+ logger?.verbose('#Function getAudioOutputRouteType', {
1046
+ id: this.id,
1047
+ });
1048
+ if (Platform.OS === 'android') {
1049
+ return await HMSManager.getAudioOutputRouteType({ id: this.id });
1050
+ } else {
1051
+ console.log('API currently not available for iOS');
1052
+ return 'API currently not available for iOS';
1053
+ }
1054
+ };
1055
+
1056
+ /**
1057
+ * - This wrapper function used to switch output to device other than the default, currently available only for android.
1058
+ *
1059
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-output-routing#switch-audio-focus-to-another-device} for more info
1060
+ *
1061
+ * @param {HMSAudioDevice}
1062
+ * @memberof HMSSDK
1063
+ */
1064
+ switchAudioOutput = (audioDevice: HMSAudioDevice) => {
1065
+ logger?.verbose('#Function switchAudioOutput', {
1066
+ id: this.id,
1067
+ audioDevice,
1068
+ });
1069
+ if (Platform.OS === 'android') {
1070
+ return HMSManager.switchAudioOutput({ id: this.id, audioDevice });
1071
+ } else {
1072
+ console.log('API currently not available for iOS');
1073
+ return 'API currently not available for iOS';
1074
+ }
1075
+ };
1076
+
1077
+ /**
1078
+ * - This wrapper function used to change Audio Mode manually, currently available only for android.
1079
+ *
1080
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-mode-change} for more info
1081
+ *
1082
+ * @param {HMSAudioMode}
1083
+ * @memberof HMSSDK
1084
+ */
1085
+ setAudioMode = (audioMode: HMSAudioMode) => {
1086
+ logger?.verbose('#Function setAudioMode', {
1087
+ id: this.id,
1088
+ audioMode,
1089
+ });
1090
+ if (Platform.OS === 'android') {
1091
+ return HMSManager.setAudioMode({ id: this.id, audioMode });
1092
+ } else {
1093
+ console.log('API currently not available for iOS');
1094
+ return 'API currently not available for iOS';
1095
+ }
1096
+ };
1097
+
1098
+ /**
1099
+ * - This is a wrapper function which adds a listener which is triggered when audio output device is switched, currently available only for android.
1100
+ *
1101
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-output-routing#adding-a-listener} for more info
1102
+ *
1103
+ * @param {Function}
1104
+ * @memberof HMSSDK
1105
+ */
1106
+ setAudioDeviceChangeListener = (callback: Function) => {
1107
+ logger?.verbose('#Function setAudioDeviceChangeListener', {
1108
+ id: this.id,
1109
+ });
1110
+ if (Platform.OS === 'android') {
1111
+ this.addEventListener(
1112
+ HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED,
1113
+ callback
1114
+ );
1115
+ return HMSManager.setAudioDeviceChangeListener({ id: this.id });
1116
+ } else {
1117
+ console.log('API currently not available for iOS');
1118
+ return 'API currently not available for iOS';
912
1119
  }
913
1120
  };
914
1121
 
@@ -979,6 +1186,9 @@ export class HMSSDK {
979
1186
  case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
980
1187
  this.onRemoteVideoStatsDelegate = callback;
981
1188
  break;
1189
+ case HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED:
1190
+ this.onAudioDeviceChangedDelegate = callback;
1191
+ break;
982
1192
  default:
983
1193
  }
984
1194
  };
@@ -1047,6 +1257,9 @@ export class HMSSDK {
1047
1257
  case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
1048
1258
  this.onRemoteVideoStatsDelegate = null;
1049
1259
  break;
1260
+ case HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED:
1261
+ this.onAudioDeviceChangedDelegate = null;
1262
+ break;
1050
1263
  default:
1051
1264
  }
1052
1265
  };
@@ -1093,7 +1306,6 @@ export class HMSSDK {
1093
1306
  if (data.id !== this.id) {
1094
1307
  return;
1095
1308
  }
1096
- logger?.verbose('#Listener ON_PREVIEW', data);
1097
1309
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
1098
1310
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
1099
1311
  data.localPeer,
@@ -1112,6 +1324,8 @@ export class HMSSDK {
1112
1324
  previewTracks,
1113
1325
  });
1114
1326
  this.onPreviewDelegate({ ...data, room, localPeer, previewTracks });
1327
+ } else {
1328
+ logger?.verbose('#Listener ON_PREVIEW', data);
1115
1329
  }
1116
1330
  };
1117
1331
 
@@ -1119,7 +1333,6 @@ export class HMSSDK {
1119
1333
  if (data.id !== this.id) {
1120
1334
  return;
1121
1335
  }
1122
- logger?.verbose('#LISTENER ON_JOIN', data);
1123
1336
  // Preprocessing
1124
1337
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
1125
1338
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
@@ -1143,6 +1356,8 @@ export class HMSSDK {
1143
1356
  remotePeers,
1144
1357
  });
1145
1358
  this.onJoinDelegate({ ...data, room, localPeer, remotePeers });
1359
+ } else {
1360
+ logger?.verbose('#LISTENER ON_JOIN', data);
1146
1361
  }
1147
1362
  };
1148
1363
 
@@ -1150,7 +1365,6 @@ export class HMSSDK {
1150
1365
  if (data.id !== this.id) {
1151
1366
  return;
1152
1367
  }
1153
- logger?.verbose('#Listener ON_ROOM', data);
1154
1368
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
1155
1369
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
1156
1370
  data.localPeer,
@@ -1171,6 +1385,8 @@ export class HMSSDK {
1171
1385
  remotePeers,
1172
1386
  });
1173
1387
  this.onRoomDelegate({ ...data, room, localPeer, remotePeers });
1388
+ } else {
1389
+ logger?.verbose('#Listener ON_ROOM', data);
1174
1390
  }
1175
1391
  };
1176
1392
 
@@ -1178,7 +1394,6 @@ export class HMSSDK {
1178
1394
  if (data.id !== this.id) {
1179
1395
  return;
1180
1396
  }
1181
- logger?.verbose('#Listener ON_PEER', data);
1182
1397
  const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1183
1398
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
1184
1399
  const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
@@ -1194,8 +1409,16 @@ export class HMSSDK {
1194
1409
  this.remotePeers = remotePeers;
1195
1410
  this.room = room;
1196
1411
  if (this.onPeerDelegate) {
1197
- logger?.verbose('#Listener ON_PEER_LISTENER_CALL', data);
1412
+ logger?.verbose('#Listener ON_PEER_LISTENER_CALL', {
1413
+ ...data,
1414
+ localPeer,
1415
+ remotePeers,
1416
+ room,
1417
+ peer,
1418
+ });
1198
1419
  this.onPeerDelegate({ ...data, localPeer, remotePeers, room, peer });
1420
+ } else {
1421
+ logger?.verbose('#Listener ON_PEER', data);
1199
1422
  }
1200
1423
  };
1201
1424
 
@@ -1203,7 +1426,6 @@ export class HMSSDK {
1203
1426
  if (data.id !== this.id) {
1204
1427
  return;
1205
1428
  }
1206
- logger?.verbose('#Listener ON_TRACK', data);
1207
1429
  const track: HMSTrack = HMSEncoder.encodeHmsTrack(data.track, this.id);
1208
1430
  const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1209
1431
  const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
@@ -1226,7 +1448,14 @@ export class HMSSDK {
1226
1448
  this.localPeer = localPeer;
1227
1449
  this.remotePeers = remotePeers;
1228
1450
  if (this.onTrackDelegate) {
1229
- logger?.verbose('#Listener ON_TRACK_LISTENER_CALL', data);
1451
+ logger?.verbose('#Listener ON_TRACK_LISTENER_CALL', {
1452
+ ...data,
1453
+ localPeer,
1454
+ remotePeers,
1455
+ room,
1456
+ peer,
1457
+ track,
1458
+ });
1230
1459
  this.onTrackDelegate({
1231
1460
  ...data,
1232
1461
  localPeer,
@@ -1235,6 +1464,8 @@ export class HMSSDK {
1235
1464
  peer,
1236
1465
  track,
1237
1466
  });
1467
+ } else {
1468
+ logger?.verbose('#Listener ON_TRACK', data);
1238
1469
  }
1239
1470
  };
1240
1471
 
@@ -1242,11 +1473,12 @@ export class HMSSDK {
1242
1473
  if (data.id !== this.id) {
1243
1474
  return;
1244
1475
  }
1245
- logger?.verbose('#Listener ON_MESSAGE', data);
1246
1476
  const message = HMSEncoder.encodeHMSMessage(data, this.id);
1247
1477
  if (this.onMessageDelegate) {
1248
1478
  logger?.verbose('#Listener ON_MESSAGE_LISTENER_CALL', message);
1249
1479
  this.onMessageDelegate(message);
1480
+ } else {
1481
+ logger?.verbose('#Listener ON_MESSAGE', data);
1250
1482
  }
1251
1483
  };
1252
1484
 
@@ -1254,12 +1486,13 @@ export class HMSSDK {
1254
1486
  if (data.id !== this.id) {
1255
1487
  return;
1256
1488
  }
1257
- logger?.verbose('#Listener ON_SPEAKER', data?.speakers);
1258
1489
  if (this.onSpeakerDelegate) {
1259
1490
  logger?.verbose('#Listener ON_SPEAKER_LISTENER_CALL', data?.speakers);
1260
1491
  this.onSpeakerDelegate(
1261
1492
  HMSEncoder.encodeHmsSpeakers(data?.speakers, this.id)
1262
1493
  );
1494
+ } else {
1495
+ logger?.verbose('#Listener ON_SPEAKER', data?.speakers);
1263
1496
  }
1264
1497
  };
1265
1498
 
@@ -1267,12 +1500,13 @@ export class HMSSDK {
1267
1500
  if (data.id !== this.id) {
1268
1501
  return;
1269
1502
  }
1270
- logger?.warn('#Listener ON_ERROR', data);
1271
- logger?.verbose('#Listener ON_ERROR', data);
1272
1503
  if (this.onErrorDelegate) {
1273
1504
  logger?.verbose('#Listener ON_ERROR_LISTENER_CALL', data);
1274
1505
  logger?.warn('#Listener ON_ERROR_LISTENER_CALL', data);
1275
- this.onErrorDelegate(data);
1506
+ this.onErrorDelegate(HMSEncoder.encodeHMSException(data));
1507
+ } else {
1508
+ logger?.warn('#Listener ON_ERROR', data);
1509
+ logger?.verbose('#Listener ON_ERROR', data);
1276
1510
  }
1277
1511
  };
1278
1512
 
@@ -1280,7 +1514,6 @@ export class HMSSDK {
1280
1514
  if (data.id !== this.id) {
1281
1515
  return;
1282
1516
  }
1283
- logger?.verbose('#Listener ON_ROLE_CHANGE_REQUEST', data);
1284
1517
  if (this.onRoleChangeRequestDelegate) {
1285
1518
  const encodedRoleChangeRequest = HMSEncoder.encodeHmsRoleChangeRequest(
1286
1519
  data,
@@ -1291,6 +1524,8 @@ export class HMSSDK {
1291
1524
  encodedRoleChangeRequest
1292
1525
  );
1293
1526
  this.onRoleChangeRequestDelegate(encodedRoleChangeRequest);
1527
+ } else {
1528
+ logger?.verbose('#Listener ON_ROLE_CHANGE_REQUEST', data);
1294
1529
  }
1295
1530
  };
1296
1531
 
@@ -1298,7 +1533,6 @@ export class HMSSDK {
1298
1533
  if (data.id !== this.id) {
1299
1534
  return;
1300
1535
  }
1301
- logger?.verbose('#Listener ON_CHANGE_TRACK_STATE_REQUEST', data);
1302
1536
  if (this.onChangeTrackStateRequestDelegate) {
1303
1537
  const encodedRoleChangeRequest =
1304
1538
  HMSEncoder.encodeHmsChangeTrackStateRequest(data, this.id);
@@ -1307,6 +1541,8 @@ export class HMSSDK {
1307
1541
  encodedRoleChangeRequest
1308
1542
  );
1309
1543
  this.onChangeTrackStateRequestDelegate(encodedRoleChangeRequest);
1544
+ } else {
1545
+ logger?.verbose('#Listener ON_CHANGE_TRACK_STATE_REQUEST', data);
1310
1546
  }
1311
1547
  };
1312
1548
 
@@ -1314,7 +1550,6 @@ export class HMSSDK {
1314
1550
  if (data.id !== this.id) {
1315
1551
  return;
1316
1552
  }
1317
- logger?.verbose('#Listener ON_REMOVED_FROM_ROOM', data);
1318
1553
  if (this.onRemovedFromRoomDelegate) {
1319
1554
  let requestedBy = null;
1320
1555
  if (data.requestedBy) {
@@ -1330,6 +1565,8 @@ export class HMSSDK {
1330
1565
  id: this.id,
1331
1566
  });
1332
1567
  this.onRemovedFromRoomDelegate({ requestedBy, reason, roomEnded });
1568
+ } else {
1569
+ logger?.verbose('#Listener ON_REMOVED_FROM_ROOM', data);
1333
1570
  }
1334
1571
  };
1335
1572
 
@@ -1337,9 +1574,11 @@ export class HMSSDK {
1337
1574
  if (data.id !== this.id) {
1338
1575
  return;
1339
1576
  }
1340
- logger?.verbose('#Listener ON_RECONNECTING', data);
1341
1577
  if (this.onReconnectingDelegate) {
1578
+ logger?.verbose('#Listener ON_RECONNECTING_CALL', data);
1342
1579
  this.onReconnectingDelegate(data);
1580
+ } else {
1581
+ logger?.verbose('#Listener ON_RECONNECTING', data);
1343
1582
  }
1344
1583
  };
1345
1584
 
@@ -1349,7 +1588,10 @@ export class HMSSDK {
1349
1588
  }
1350
1589
  logger?.verbose('#Listener ON_RECONNECTED', data);
1351
1590
  if (this.onReconnectedDelegate) {
1591
+ logger?.verbose('#Listener ON_RECONNECTED_CALL', data);
1352
1592
  this.onReconnectedDelegate(data);
1593
+ } else {
1594
+ logger?.verbose('#Listener ON_RECONNECTED', data);
1353
1595
  }
1354
1596
  };
1355
1597
 
@@ -1358,12 +1600,13 @@ export class HMSSDK {
1358
1600
  return;
1359
1601
  }
1360
1602
 
1361
- logger?.verbose('#Listener RTCStatsListener', data);
1362
-
1363
1603
  let rtcStats = HMSEncoder.encodeRTCStats(data);
1364
1604
 
1365
1605
  if (this.onRtcStatsDelegate) {
1606
+ logger?.verbose('#Listener RTCStatsListener_CALL', { rtcStats });
1366
1607
  this.onRtcStatsDelegate({ rtcStats });
1608
+ } else {
1609
+ logger?.verbose('#Listener RTCStatsListener', data);
1367
1610
  }
1368
1611
  };
1369
1612
 
@@ -1372,14 +1615,20 @@ export class HMSSDK {
1372
1615
  return;
1373
1616
  }
1374
1617
 
1375
- logger?.verbose('#Listener onLocalAudioStatsListener', data);
1376
-
1377
1618
  let localAudioStats = new HMSLocalAudioStats(data.localAudioStats);
1378
1619
  let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1379
1620
  let track = HMSEncoder.encodeHmsLocalAudioTrack(data.track, this.id);
1380
1621
 
1381
1622
  if (this.onLocalAudioStatsDelegate) {
1623
+ logger?.verbose('#Listener onLocalAudioStatsListener_CALL', {
1624
+ ...data,
1625
+ localAudioStats,
1626
+ peer,
1627
+ track,
1628
+ });
1382
1629
  this.onLocalAudioStatsDelegate({ ...data, localAudioStats, peer, track });
1630
+ } else {
1631
+ logger?.verbose('#Listener onLocalAudioStatsListener', data);
1383
1632
  }
1384
1633
  };
1385
1634
 
@@ -1388,14 +1637,20 @@ export class HMSSDK {
1388
1637
  return;
1389
1638
  }
1390
1639
 
1391
- logger?.verbose('#Listener onLocalVideoStatsListener', data);
1392
-
1393
1640
  let localVideoStats = new HMSLocalVideoStats(data.localVideoStats);
1394
1641
  let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1395
1642
  let track = HMSEncoder.encodeHmsLocalVideoTrack(data.track, this.id);
1396
1643
 
1397
1644
  if (this.onLocalVideoStatsDelegate) {
1645
+ logger?.verbose('#Listener onLocalVideoStatsListener_CALL', {
1646
+ ...data,
1647
+ localVideoStats,
1648
+ peer,
1649
+ track,
1650
+ });
1398
1651
  this.onLocalVideoStatsDelegate({ ...data, localVideoStats, peer, track });
1652
+ } else {
1653
+ logger?.verbose('#Listener onLocalVideoStatsListener', data);
1399
1654
  }
1400
1655
  };
1401
1656
 
@@ -1404,19 +1659,25 @@ export class HMSSDK {
1404
1659
  return;
1405
1660
  }
1406
1661
 
1407
- logger?.verbose('#Listener onRemoteAudioStatsListener', data);
1408
-
1409
1662
  let remoteAudioStats = new HMSRemoteAudioStats(data.remoteAudioStats);
1410
1663
  let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1411
1664
  let track = HMSEncoder.encodeHmsRemoteAudioTrack(data.track, this.id);
1412
1665
 
1413
1666
  if (this.onRemoteAudioStatsDelegate) {
1667
+ logger?.verbose('#Listener onRemoteAudioStatsListener_CALL', {
1668
+ ...data,
1669
+ remoteAudioStats,
1670
+ peer,
1671
+ track,
1672
+ });
1414
1673
  this.onRemoteAudioStatsDelegate({
1415
1674
  ...data,
1416
1675
  remoteAudioStats,
1417
1676
  peer,
1418
1677
  track,
1419
1678
  });
1679
+ } else {
1680
+ logger?.verbose('#Listener onRemoteAudioStatsListener', data);
1420
1681
  }
1421
1682
  };
1422
1683
 
@@ -1425,19 +1686,43 @@ export class HMSSDK {
1425
1686
  return;
1426
1687
  }
1427
1688
 
1428
- logger?.verbose('#Listener onRemoteVideoStatsListener', data);
1429
-
1430
1689
  let remoteVideoStats = new HMSRemoteVideoStats(data.remoteVideoStats);
1431
1690
  let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1432
1691
  let track = HMSEncoder.encodeHmsRemoteVideoTrack(data.track, this.id);
1433
1692
 
1434
1693
  if (this.onRemoteVideoStatsDelegate) {
1694
+ logger?.verbose('#Listener onRemoteVideoStatsListener_CALL', {
1695
+ ...data,
1696
+ remoteVideoStats,
1697
+ peer,
1698
+ track,
1699
+ });
1435
1700
  this.onRemoteVideoStatsDelegate({
1436
1701
  ...data,
1437
1702
  remoteVideoStats,
1438
1703
  peer,
1439
1704
  track,
1440
1705
  });
1706
+ } else {
1707
+ logger?.verbose('#Listener onRemoteVideoStatsListener', data);
1708
+ }
1709
+ };
1710
+
1711
+ onAudioDeviceChangedListener = (data: {
1712
+ id: string;
1713
+ device: string;
1714
+ audioDevicesList: string[];
1715
+ }) => {
1716
+ if (data.id !== this.id) {
1717
+ return;
1718
+ }
1719
+ if (this.onAudioDeviceChangedDelegate) {
1720
+ logger?.verbose('#Listener onAudioDeviceChangedListener_CALL', data);
1721
+ this.onAudioDeviceChangedDelegate({
1722
+ ...data,
1723
+ });
1724
+ } else {
1725
+ logger?.verbose('#Listener onAudioDeviceChangedListener', data);
1441
1726
  }
1442
1727
  };
1443
1728
  }