agora-appbuilder-core 3.0.13 → 3.0.28-beta-9

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 (572) hide show
  1. package/Readme.md +6 -0
  2. package/package.json +3 -3
  3. package/template/.bundle/config +2 -0
  4. package/template/Gemfile +4 -0
  5. package/template/Gulpfile.js +31 -30
  6. package/template/_eslintrc.js +3 -3
  7. package/template/_gitignore +12 -11
  8. package/template/_package-lock.json +34387 -27128
  9. package/template/_prettierrc.js +2 -2
  10. package/template/agora-rn-uikit/.eslintrc.js +5 -0
  11. package/template/agora-rn-uikit/package-lock.json +25024 -0
  12. package/template/agora-rn-uikit/package.json +14 -14
  13. package/template/agora-rn-uikit/src/AgoraUIKit.tsx +6 -6
  14. package/template/agora-rn-uikit/src/Contexts/ContentContext.tsx +10 -0
  15. package/template/agora-rn-uikit/src/Contexts/DispatchContext.tsx +22 -0
  16. package/template/agora-rn-uikit/src/Contexts/LocalUserContext.tsx +10 -6
  17. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +98 -37
  18. package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +27 -16
  19. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +31 -26
  20. package/template/agora-rn-uikit/src/Controls/Icons.ts +81 -83
  21. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +6 -6
  22. package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +6 -4
  23. package/template/agora-rn-uikit/src/Controls/Local/FullScreen.tsx +3 -1
  24. package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +5 -2
  25. package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +5 -2
  26. package/template/agora-rn-uikit/src/Controls/Local/Recording.tsx +0 -2
  27. package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +7 -6
  28. package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +5 -5
  29. package/template/agora-rn-uikit/src/Controls/Remote/RemoteAudioMute.tsx +5 -4
  30. package/template/agora-rn-uikit/src/Controls/Remote/RemoteSwap.tsx +3 -1
  31. package/template/agora-rn-uikit/src/Controls/Remote/RemoteVideoMute.tsx +5 -4
  32. package/template/agora-rn-uikit/src/Controls/RemoteControls.tsx +2 -2
  33. package/template/agora-rn-uikit/src/Reducer/ActiveSpeaker.ts +30 -0
  34. package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +8 -6
  35. package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +8 -6
  36. package/template/agora-rn-uikit/src/Reducer/LocalPermissionState.ts +23 -0
  37. package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +7 -7
  38. package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +9 -8
  39. package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +7 -7
  40. package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +24 -14
  41. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +6 -6
  42. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +6 -6
  43. package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +14 -5
  44. package/template/agora-rn-uikit/src/Reducer/UserPin.ts +28 -0
  45. package/template/agora-rn-uikit/src/Reducer/UserSecondaryPin.ts +23 -0
  46. package/template/agora-rn-uikit/src/Reducer/index.ts +4 -0
  47. package/template/agora-rn-uikit/src/Rtc/Create.tsx +197 -66
  48. package/template/agora-rn-uikit/src/Rtc/Join.tsx +60 -33
  49. package/template/agora-rn-uikit/src/RtcConfigure.tsx +194 -57
  50. package/template/agora-rn-uikit/src/Utils/isBotUser.ts +15 -0
  51. package/template/agora-rn-uikit/src/Utils/quality.tsx +8 -0
  52. package/template/agora-rn-uikit/src/Views/MaxVideoView.native.tsx +67 -13
  53. package/template/agora-rn-uikit/src/Views/MaxVideoView.tsx +53 -17
  54. package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +19 -11
  55. package/template/agora-rn-uikit/src/index.ts +19 -10
  56. package/template/android/app/build.gradle +67 -155
  57. package/template/android/app/src/debug/AndroidManifest.xml +6 -1
  58. package/template/android/app/src/debug/java/com/helloworld/ReactNativeFlipper.java +7 -4
  59. package/template/android/app/src/main/AndroidManifest.xml +21 -27
  60. package/template/android/app/src/main/assets/fonts/SourceSansPro-Regular.ttf +0 -0
  61. package/template/android/app/src/main/assets/fonts/icomoon.ttf +0 -0
  62. package/template/android/app/src/main/java/com/helloworld/MainActivity.java +67 -0
  63. package/template/android/app/src/main/java/com/helloworld/MainApplication.java +22 -36
  64. package/template/android/app/src/main/java/com/helloworld/SSLPinningFactory.java +30 -0
  65. package/template/android/app/src/main/res/values/colors.xml +7 -0
  66. package/template/android/app/src/main/res/values/strings.xml +3 -0
  67. package/template/android/app/src/release/java/com/helloworld/ReactNativeFlipper.java +20 -0
  68. package/template/android/build.gradle +20 -31
  69. package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  70. package/template/android/gradle/wrapper/gradle-wrapper.properties +3 -2
  71. package/template/android/gradle.properties +18 -4
  72. package/template/android/gradlew +165 -104
  73. package/template/android/gradlew.bat +12 -23
  74. package/template/android/link-assets-manifest.json +13 -0
  75. package/template/android/settings.gradle +1 -0
  76. package/template/babel.config.js +1 -0
  77. package/template/bridge/rtc/webNg/RtcEngine.ts +940 -98
  78. package/template/bridge/rtc/webNg/{SurfaceView.tsx → RtcSurfaceView.tsx} +20 -27
  79. package/template/bridge/rtc/webNg/Types.ts +20 -5
  80. package/template/bridge/rtc/webNg/index.ts +81 -14
  81. package/template/bridge/rtm/web/index.ts +86 -35
  82. package/template/configTransform.js +16 -1
  83. package/template/customization-api/action-library.ts +4 -16
  84. package/template/customization-api/app-state.ts +18 -8
  85. package/template/customization-api/atoms.ts +8 -0
  86. package/template/customization-api/customEvents.ts +7 -2
  87. package/template/customization-api/customize.ts +30 -11
  88. package/template/customization-api/index.ts +5 -0
  89. package/template/customization-api/sub-components.ts +43 -18
  90. package/template/customization-api/temp.ts +51 -0
  91. package/template/customization-api/typeDefinition.ts +65 -49
  92. package/template/customization-api/types.ts +48 -0
  93. package/template/customization-api/utils.ts +19 -1
  94. package/template/customization-implementation/createHook.ts +24 -6
  95. package/template/customization-implementation/index.ts +1 -2
  96. package/template/customization-implementation/useCustomization.tsx +5 -7
  97. package/template/defaultConfig.js +84 -0
  98. package/template/electron/index.html +27 -27
  99. package/template/electron/renderer/index.js +1 -0
  100. package/template/global.d.ts +97 -6
  101. package/template/index.js +18 -1
  102. package/template/index.rsdk.tsx +1 -0
  103. package/template/index.web.js +1 -0
  104. package/template/index.wsdk.tsx +2 -13
  105. package/template/ios/.xcode.env +11 -0
  106. package/template/ios/HelloWorld/AppDelegate.h +2 -4
  107. package/template/ios/HelloWorld/AppDelegate.mm +64 -0
  108. package/template/ios/HelloWorld/HelloWorldDebug.entitlements +10 -0
  109. package/template/ios/HelloWorld/Info.plist +20 -1
  110. package/template/ios/HelloWorld/main.m +2 -1
  111. package/template/ios/HelloWorld.xcodeproj/project.pbxproj +596 -11
  112. package/template/ios/HelloWorld.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  113. package/template/ios/HelloWorld.xcodeproj/xcshareddata/xcschemes/ScreenSharing.xcscheme +95 -0
  114. package/template/ios/HelloWorld.xcworkspace/contents.xcworkspacedata +10 -0
  115. package/template/ios/HelloWorld.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  116. package/template/ios/HelloWorldTests/HelloWorldTests.m +14 -13
  117. package/template/ios/HelloWorldTests/Info.plist +2 -2
  118. package/template/ios/Podfile +54 -20
  119. package/template/ios/Podfile.lock +975 -0
  120. package/template/ios/ScreenSharing/Info.plist +15 -0
  121. package/template/ios/ScreenSharing/SampleHandler.h +5 -0
  122. package/template/ios/ScreenSharing/SampleHandler.m +39 -0
  123. package/template/ios/link-assets-manifest.json +13 -0
  124. package/template/jest.config.js +4 -0
  125. package/template/metro.config.js +7 -32
  126. package/template/package-lock.json +57746 -0
  127. package/template/package.json +71 -35
  128. package/template/react-native-toast-message/index.d.ts +46 -44
  129. package/template/react-native-toast-message/index.js +1 -0
  130. package/template/react-native-toast-message/package-lock.json +10553 -0
  131. package/template/react-native-toast-message/src/colors/index.js +3 -2
  132. package/template/react-native-toast-message/src/components/base/index.js +38 -63
  133. package/template/react-native-toast-message/src/components/base/styles.js +20 -39
  134. package/template/react-native-toast-message/src/components/checkbox.js +183 -0
  135. package/template/react-native-toast-message/src/components/error.js +3 -2
  136. package/template/react-native-toast-message/src/components/info.js +3 -2
  137. package/template/react-native-toast-message/src/components/success.js +3 -2
  138. package/template/react-native-toast-message/src/index.js +125 -32
  139. package/template/react-native-toast-message/src/index.sdk.tsx +129 -36
  140. package/template/react-native-toast-message/src/styles.js +3 -4
  141. package/template/react-native-toast-message/src/styles.sdk.ts +3 -4
  142. package/template/react-native.config.js +7 -0
  143. package/template/src/App.tsx +53 -63
  144. package/template/src/AppRoutes.tsx +101 -0
  145. package/template/src/AppWrapper.tsx +83 -29
  146. package/template/src/SDKAppWrapper.tsx +145 -58
  147. package/template/src/app-state/useBeautyEffects.ts +30 -0
  148. package/template/src/app-state/useLocalUserInfo.ts +3 -3
  149. package/template/src/app-state/useMessages.ts +49 -9
  150. package/template/src/app-state/useNoiseSupression.native.tsx +73 -0
  151. package/template/src/app-state/useNoiseSupression.tsx +151 -0
  152. package/template/src/app-state/useVideoQuality.tsx +182 -0
  153. package/template/src/app-state/useVirtualBackground.ts +152 -0
  154. package/template/src/assets/font-styles.css +677 -0
  155. package/template/src/assets/fonts/SourceSansPro-Regular.ttf +0 -0
  156. package/template/src/assets/fonts/icomoon.ttf +0 -0
  157. package/template/src/assets/permission.png +0 -0
  158. package/template/src/assets/selection.json +3491 -0
  159. package/template/src/atoms/ActionMenu.tsx +326 -0
  160. package/template/src/atoms/AnimatedActiveSpeaker.native.tsx +71 -0
  161. package/template/src/atoms/AnimatedActiveSpeaker.tsx +84 -0
  162. package/template/src/atoms/AnimatedRings.native.tsx +68 -0
  163. package/template/src/atoms/AnimatedRings.tsx +70 -0
  164. package/template/src/atoms/Avatar.tsx +51 -0
  165. package/template/src/atoms/Card.tsx +74 -0
  166. package/template/src/atoms/Carousel.native.tsx +105 -0
  167. package/template/src/atoms/Carousel.tsx +109 -0
  168. package/template/src/atoms/Checkbox.tsx +98 -0
  169. package/template/src/atoms/CircularProgress.native.tsx +121 -0
  170. package/template/src/atoms/CircularProgress.tsx +101 -0
  171. package/template/src/atoms/ClipboardIconButton.tsx +91 -0
  172. package/template/src/atoms/CustomIcon.tsx +153 -0
  173. package/template/src/atoms/CustomSwitch.tsx +287 -0
  174. package/template/src/atoms/DropDownMulti.tsx +349 -0
  175. package/template/src/atoms/Dropdown.tsx +307 -0
  176. package/template/src/atoms/HorizontalRule.tsx +3 -1
  177. package/template/src/atoms/IconButton.tsx +205 -0
  178. package/template/src/atoms/ImageIcon.tsx +127 -0
  179. package/template/src/atoms/InfoBubble.tsx +291 -0
  180. package/template/src/atoms/InlineNotification.tsx +81 -0
  181. package/template/src/atoms/InlinePopup.tsx +185 -0
  182. package/template/src/atoms/Input.tsx +87 -0
  183. package/template/src/atoms/InviteInfo.tsx +166 -0
  184. package/template/src/atoms/LinkButton.tsx +29 -0
  185. package/template/src/atoms/MeetingLink.tsx +160 -0
  186. package/template/src/atoms/OutlineButton.tsx +61 -0
  187. package/template/src/atoms/ParticipantsCount.tsx +78 -0
  188. package/template/src/atoms/Popup.tsx +178 -0
  189. package/template/src/atoms/PrimaryButton.tsx +65 -26
  190. package/template/src/atoms/RecordingInfo.tsx +47 -0
  191. package/template/src/atoms/SecondaryButton.tsx +10 -5
  192. package/template/src/atoms/Spacer.tsx +23 -0
  193. package/template/src/atoms/TertiaryButton.tsx +108 -0
  194. package/template/src/atoms/TextInput.tsx +13 -14
  195. package/template/src/atoms/Toggle.tsx +47 -0
  196. package/template/src/atoms/Toolbar.tsx +94 -0
  197. package/template/src/atoms/ToolbarItem.tsx +99 -0
  198. package/template/src/atoms/ToolbarMenu.tsx +40 -0
  199. package/template/src/atoms/ToolbarMenuItem.tsx +104 -0
  200. package/template/src/atoms/ToolbarPreset.tsx +147 -0
  201. package/template/src/atoms/Tooltip.native.tsx +65 -0
  202. package/template/src/atoms/Tooltip.tsx +111 -0
  203. package/template/src/atoms/UserAvatar.tsx +60 -0
  204. package/template/src/atoms/pagination/Pagination.tsx +127 -0
  205. package/template/src/atoms/pagination/usePagination.tsx +88 -0
  206. package/template/src/auth/AuthProvider.tsx +710 -0
  207. package/template/src/auth/AuthRoute.tsx +94 -0
  208. package/template/src/auth/IDPAuth.electron.tsx +32 -0
  209. package/template/src/auth/IDPAuth.tsx +73 -0
  210. package/template/src/auth/IDPLogoutComponent.tsx +158 -0
  211. package/template/src/auth/UserCancelPopup.tsx +115 -0
  212. package/template/src/auth/config.ts +53 -0
  213. package/template/src/auth/openIDPURL.electron.tsx +39 -0
  214. package/template/src/auth/openIDPURL.native.tsx +62 -0
  215. package/template/src/auth/openIDPURL.tsx +20 -0
  216. package/template/src/auth/useIDPAuth.electron.tsx +125 -0
  217. package/template/src/auth/useIDPAuth.native.tsx +130 -0
  218. package/template/src/auth/useIDPAuth.tsx +124 -0
  219. package/template/src/auth/useTokenAuth.tsx +267 -0
  220. package/template/src/components/Chat.tsx +177 -279
  221. package/template/src/components/ChatContext.ts +22 -1
  222. package/template/src/components/ColorConfigure.tsx +1 -2
  223. package/template/src/components/ColorContext.ts +1 -1
  224. package/template/src/components/CommonStyles.ts +51 -0
  225. package/template/src/components/Controls.tsx +1275 -108
  226. package/template/src/components/{Controls.native.tsx → Controls1.native.tsx} +15 -9
  227. package/template/src/components/CustomSidePanel.tsx +82 -0
  228. package/template/src/components/DeviceConfigure.native.tsx +2 -2
  229. package/template/src/components/DeviceConfigure.tsx +789 -122
  230. package/template/src/components/DeviceContext.tsx +10 -4
  231. package/template/src/components/EventsConfigure.tsx +773 -12
  232. package/template/src/components/GraphQLProvider.tsx +83 -37
  233. package/template/src/components/GridVideo.tsx +86 -53
  234. package/template/src/components/HostControlView.tsx +118 -42
  235. package/template/src/components/JoinPhrase.tsx +0 -1
  236. package/template/src/components/Leftbar.tsx +129 -0
  237. package/template/src/components/Navbar.tsx +469 -488
  238. package/template/src/components/NavbarMobile.tsx +138 -0
  239. package/template/src/components/Navigation.native.tsx +1 -14
  240. package/template/src/components/{Settings.native.tsx → Navigation.sdk.tsx} +17 -6
  241. package/template/src/components/NetworkQualityContext.tsx +32 -26
  242. package/template/src/components/ParticipantsView.tsx +195 -165
  243. package/template/src/components/PinnedVideo.tsx +317 -122
  244. package/template/src/components/Precall.native.tsx +472 -116
  245. package/template/src/components/Precall.tsx +493 -154
  246. package/template/src/components/RTMConfigure.tsx +477 -83
  247. package/template/src/components/Rightbar.tsx +129 -0
  248. package/template/src/components/Router.electron.ts +2 -0
  249. package/template/src/components/Router.native.ts +2 -0
  250. package/template/src/components/Router.sdk.ts +2 -0
  251. package/template/src/components/Router.ts +2 -0
  252. package/template/src/components/SdkApiContext.tsx +319 -0
  253. package/template/src/components/SdkMuteToggleListener.tsx +88 -0
  254. package/template/src/components/SessionContext.tsx +0 -1
  255. package/template/src/components/Settings.tsx +51 -114
  256. package/template/src/components/SettingsView.tsx +293 -54
  257. package/template/src/components/Share.tsx +415 -297
  258. package/template/src/components/StorageContext.tsx +82 -7
  259. package/template/src/components/ToastComponent.tsx +17 -0
  260. package/template/src/components/WhiteboardLayout.tsx +291 -0
  261. package/template/src/components/beauty-effect/useBeautyEffects.native.tsx +119 -0
  262. package/template/src/components/beauty-effect/useBeautyEffects.tsx +152 -0
  263. package/template/src/components/chat/chatConfigure.native.tsx +511 -0
  264. package/template/src/components/chat/chatConfigure.tsx +529 -0
  265. package/template/src/components/chat-messages/useChatMessages.tsx +513 -386
  266. package/template/src/components/chat-ui/useChatUIControls.tsx +132 -0
  267. package/template/src/components/common/Error.tsx +36 -6
  268. package/template/src/components/common/Logo.tsx +16 -15
  269. package/template/src/components/contexts/LiveStreamDataContext.tsx +23 -17
  270. package/template/src/components/contexts/ScreenShareContext.tsx +15 -1
  271. package/template/src/components/contexts/VideoMeetingDataContext.tsx +41 -11
  272. package/template/src/components/contexts/WaitingRoomContext.tsx +61 -0
  273. package/template/src/components/contexts/WhiteboardContext.tsx +54 -54
  274. package/template/src/components/disable-chat/useDisableChat.tsx +32 -0
  275. package/template/src/components/livestream/LiveStreamContext.tsx +493 -165
  276. package/template/src/components/livestream/Types.ts +58 -17
  277. package/template/src/components/livestream/index.ts +1 -0
  278. package/template/src/components/livestream/views/LiveStreamAttendeeLandingTile.tsx +295 -0
  279. package/template/src/components/livestream/views/LiveStreamControls.tsx +8 -4
  280. package/template/src/components/meeting-info-invite/MeetingInfo.tsx +82 -0
  281. package/template/src/components/meeting-info-invite/MeetingInfoCardHeader.tsx +86 -0
  282. package/template/src/components/meeting-info-invite/MeetingInfoGridTile.tsx +221 -0
  283. package/template/src/components/meeting-info-invite/MeetingInfoLinks.tsx +122 -0
  284. package/template/src/components/participants/AllAudienceParticipants.tsx +105 -35
  285. package/template/src/components/participants/AllHostParticipants.tsx +108 -38
  286. package/template/src/components/participants/Participant.tsx +330 -0
  287. package/template/src/components/participants/ParticipantName.tsx +13 -7
  288. package/template/src/components/participants/ParticipantSectionTitle.tsx +38 -10
  289. package/template/src/components/participants/ScreenshareParticipants.tsx +142 -12
  290. package/template/src/components/participants/UserActionMenuOptions.tsx +510 -0
  291. package/template/src/components/participants/WaitingRoomParticipants.tsx +74 -0
  292. package/template/src/components/popups/InvitePopup.tsx +196 -0
  293. package/template/src/components/popups/StartScreenSharePopup.native.tsx +182 -0
  294. package/template/src/components/popups/StartScreenSharePopup.tsx +6 -0
  295. package/template/src/components/popups/StopRecordingPopup.tsx +120 -0
  296. package/template/src/components/popups/StopScreenSharePopup.native.tsx +135 -0
  297. package/template/src/components/popups/StopScreenSharePopup.tsx +6 -0
  298. package/template/src/components/popups/WhiteboardClearAllPopup.tsx +123 -0
  299. package/template/src/components/precall/LocalMute.tsx +109 -15
  300. package/template/src/components/precall/{LocalMute.native.tsx → LocalMute1.native.tsx} +21 -5
  301. package/template/src/components/precall/PermissionHelper.native.tsx +5 -0
  302. package/template/src/components/precall/PermissionHelper.tsx +154 -0
  303. package/template/src/components/precall/PreCallSettings.tsx +53 -0
  304. package/template/src/components/precall/VideoFallback.tsx +173 -0
  305. package/template/src/components/precall/VideoPreview.native.tsx +19 -8
  306. package/template/src/components/precall/VideoPreview.tsx +28 -7
  307. package/template/src/components/precall/index.tsx +2 -0
  308. package/template/src/components/precall/joinCallBtn.native.tsx +12 -5
  309. package/template/src/components/precall/joinCallBtn.tsx +34 -6
  310. package/template/src/components/precall/joinWaitingRoomBtn.native.tsx +215 -0
  311. package/template/src/components/precall/joinWaitingRoomBtn.tsx +255 -0
  312. package/template/src/components/precall/meetingTitle.tsx +42 -13
  313. package/template/src/components/precall/selectDevice.tsx +5 -25
  314. package/template/src/components/precall/textInput.tsx +40 -14
  315. package/template/src/components/precall/usePreCall.tsx +66 -2
  316. package/template/src/components/recording-bot/RecordingBotRoute.tsx +48 -0
  317. package/template/src/components/recordings/RecordingsDateTable.tsx +62 -0
  318. package/template/src/components/recordings/RecordingsModal.tsx +135 -0
  319. package/template/src/components/recordings/ViewRecordingsModal.tsx +51 -0
  320. package/template/src/components/recordings/recording-table.tsx +250 -0
  321. package/template/src/components/recordings/style.ts +238 -0
  322. package/template/src/components/recordings/utils.ts +122 -0
  323. package/template/src/components/room-info/useRoomInfo.tsx +142 -0
  324. package/template/src/components/{meeting-info/useSetMeetingInfo.tsx → room-info/useSetRoomInfo.tsx} +12 -12
  325. package/template/src/components/styles.ts +42 -21
  326. package/template/src/components/useShareLink.tsx +33 -70
  327. package/template/src/{utils/useButtonTemplate.tsx → components/useToast.tsx} +18 -20
  328. package/template/src/components/useUserPreference.tsx +157 -16
  329. package/template/src/components/useVideoCall.tsx +157 -0
  330. package/template/src/components/useWakeLock.tsx +18 -4
  331. package/template/src/components/virtual-background/VBButton.tsx +62 -0
  332. package/template/src/components/virtual-background/VBCard.native.tsx +280 -0
  333. package/template/src/components/virtual-background/VBCard.tsx +308 -0
  334. package/template/src/components/virtual-background/VBPanel.tsx +282 -0
  335. package/template/src/components/virtual-background/VButils.native.ts +72 -0
  336. package/template/src/components/virtual-background/VButils.ts +144 -0
  337. package/template/src/components/virtual-background/VideoPreview.native.tsx +43 -0
  338. package/template/src/components/virtual-background/VideoPreview.tsx +116 -0
  339. package/template/src/components/virtual-background/imagePaths.ts +82 -0
  340. package/template/src/components/virtual-background/images/beachImageBase64.ts +1 -0
  341. package/template/src/components/virtual-background/images/bedroomImageBase64.ts +1 -0
  342. package/template/src/components/virtual-background/images/bookImageBase64.ts +1 -0
  343. package/template/src/components/virtual-background/images/earthImageBase64.ts +1 -0
  344. package/template/src/components/virtual-background/images/index.ts +37 -0
  345. package/template/src/components/virtual-background/images/lampImageBase64.ts +1 -0
  346. package/template/src/components/virtual-background/images/mountainsImageBase64.ts +1 -0
  347. package/template/src/components/virtual-background/images/office1ImageBase64.ts +1 -0
  348. package/template/src/components/virtual-background/images/officeImageBase64.ts +1 -0
  349. package/template/src/components/virtual-background/images/plantsImageBase64.ts +1 -0
  350. package/template/src/components/virtual-background/images/skyImageBase64.ts +1 -0
  351. package/template/src/components/virtual-background/images/wallImageBase64.ts +1 -0
  352. package/template/src/components/virtual-background/useVB.native.tsx +205 -0
  353. package/template/src/components/virtual-background/useVB.tsx +294 -0
  354. package/template/src/components/whiteboard/StrokeWidthTool.tsx +137 -0
  355. package/template/src/components/whiteboard/WhiteboardButton.tsx +93 -0
  356. package/template/src/components/whiteboard/WhiteboardCanvas.tsx +99 -0
  357. package/template/src/components/whiteboard/WhiteboardConfigure.native.tsx +148 -0
  358. package/template/src/components/whiteboard/WhiteboardConfigure.tsx +473 -0
  359. package/template/src/components/whiteboard/WhiteboardCursor.tsx +152 -0
  360. package/template/src/components/whiteboard/WhiteboardToolBox.tsx +1448 -0
  361. package/template/src/components/whiteboard/WhiteboardView.native.tsx +212 -0
  362. package/template/src/components/whiteboard/WhiteboardView.tsx +81 -0
  363. package/template/src/components/whiteboard/WhiteboardWidget.tsx +729 -0
  364. package/template/src/components/whiteboard/WhiteboardWrapper.tsx +38 -0
  365. package/template/src/language/default-labels/commonLabels.ts +51 -14
  366. package/template/src/language/default-labels/createScreenLabels.ts +97 -17
  367. package/template/src/language/default-labels/joinScreenLabels.ts +45 -6
  368. package/template/src/language/default-labels/precallScreenLabels.ts +158 -25
  369. package/template/src/language/default-labels/shareLinkScreenLabels.ts +85 -37
  370. package/template/src/language/default-labels/videoCallScreenLabels.ts +1290 -158
  371. package/template/src/language/i18nTypes.ts +1 -1
  372. package/template/src/language/useLanguage.tsx +10 -4
  373. package/template/src/logger/AppBuilderLogger.tsx +313 -0
  374. package/template/src/logger/constants.ts +18 -0
  375. package/template/src/logger/transports/agora-transport.native.ts +64 -0
  376. package/template/src/logger/transports/agora-transport.ts +36 -0
  377. package/template/src/logger/transports/customer-transport.ts +162 -0
  378. package/template/src/pages/Authenticate.tsx +5 -15
  379. package/template/src/pages/Create.tsx +394 -202
  380. package/template/src/pages/Endcall.tsx +153 -0
  381. package/template/src/pages/Join.tsx +188 -78
  382. package/template/src/pages/Login.tsx +26 -0
  383. package/template/src/pages/VideoCall.tsx +381 -130
  384. package/template/src/pages/video-call/ActionSheet.native.tsx +343 -0
  385. package/template/src/pages/video-call/ActionSheet.tsx +349 -0
  386. package/template/src/pages/video-call/ActionSheetContent.tsx +655 -0
  387. package/template/src/pages/video-call/ActionSheetHandle.tsx +54 -0
  388. package/template/src/pages/video-call/ActionSheetStyles.css +138 -0
  389. package/template/src/pages/video-call/DefaultLayouts.ts +32 -12
  390. package/template/src/pages/video-call/NameWithMicIcon.tsx +104 -51
  391. package/template/src/pages/video-call/PinchableView.tsx +119 -0
  392. package/template/src/pages/video-call/RenderComponent.tsx +16 -31
  393. package/template/src/pages/video-call/SidePanelHeader.tsx +424 -0
  394. package/template/src/pages/video-call/VideoCallMobileView.tsx +299 -0
  395. package/template/src/pages/video-call/VideoCallScreen.native.tsx +38 -0
  396. package/template/src/pages/video-call/VideoCallScreen.tsx +379 -74
  397. package/template/src/pages/video-call/VideoCallScreenWrapper.tsx +51 -0
  398. package/template/src/pages/video-call/VideoComponent.tsx +81 -6
  399. package/template/src/pages/video-call/VideoRenderer.tsx +525 -63
  400. package/template/src/pages/video-call/VisibilitySensor.tsx +104 -0
  401. package/template/src/pages/video-call/ZoomableWrapper.native.tsx +34 -0
  402. package/template/src/pages/video-call/ZoomableWrapper.tsx +5 -0
  403. package/template/src/pages/video-call/index.ts +51 -7
  404. package/template/src/rtm/RTMEngine.ts +22 -4
  405. package/template/src/rtm-events/constants.ts +26 -9
  406. package/template/src/rtm-events-api/Events.ts +114 -23
  407. package/template/src/rtm-events-api/LocalEvents.ts +15 -0
  408. package/template/src/rtm-events-api/types.ts +10 -5
  409. package/template/src/selection.json +1 -0
  410. package/template/src/subComponents/BlockUI.tsx +70 -0
  411. package/template/src/subComponents/ChatBubble.tsx +413 -96
  412. package/template/src/subComponents/ChatContainer.tsx +305 -101
  413. package/template/src/subComponents/ChatInput.native.tsx +269 -0
  414. package/template/src/subComponents/ChatInput.tsx +308 -156
  415. package/template/src/subComponents/Checkbox.native.tsx +46 -35
  416. package/template/src/subComponents/Checkbox.tsx +9 -8
  417. package/template/src/subComponents/CopyJoinInfo.tsx +52 -62
  418. package/template/src/subComponents/EndcallPopup.tsx +182 -0
  419. package/template/src/subComponents/FallbackLogo.tsx +122 -40
  420. package/template/src/subComponents/LanguageSelector.tsx +35 -31
  421. package/template/src/subComponents/LayoutIconButton.tsx +210 -0
  422. package/template/src/subComponents/LayoutIconDropdown.tsx +149 -133
  423. package/template/src/subComponents/{LayoutIconDropdown.native.tsx → LayoutIconDropdown1.native.tsx} +4 -18
  424. package/template/src/subComponents/Loading.tsx +60 -0
  425. package/template/src/subComponents/LocalAudioMute.tsx +181 -30
  426. package/template/src/subComponents/LocalEndCall.tsx +118 -36
  427. package/template/src/subComponents/LocalSwitchCamera.tsx +72 -40
  428. package/template/src/subComponents/LocalVideoMute.tsx +177 -30
  429. package/template/src/subComponents/Logo.tsx +3 -4
  430. package/template/src/subComponents/LogoutButton.tsx +2 -2
  431. package/template/src/subComponents/NetworkQualityPill.tsx +65 -84
  432. package/template/src/subComponents/OpenInNativeButton.tsx +3 -3
  433. package/template/src/subComponents/Recording.tsx +44 -31
  434. package/template/src/subComponents/RemoteAudioMute.tsx +83 -29
  435. package/template/src/subComponents/RemoteEndCall.tsx +8 -5
  436. package/template/src/subComponents/RemoteMutePopup.tsx +115 -0
  437. package/template/src/subComponents/RemoteVideoMute.tsx +74 -21
  438. package/template/src/subComponents/RemoveMeetingPopup.tsx +122 -0
  439. package/template/src/subComponents/RemoveScreensharePopup.tsx +124 -0
  440. package/template/src/subComponents/ScreenShareNotice.tsx +95 -12
  441. package/template/src/subComponents/SelectDevice.tsx +548 -66
  442. package/template/src/subComponents/SelectDeviceSettings.backup.tsx +210 -0
  443. package/template/src/subComponents/SelectOAuth.tsx +9 -8
  444. package/template/src/subComponents/SidePanelButtons.ts +0 -3
  445. package/template/src/subComponents/SidePanelEnum.tsx +6 -4
  446. package/template/src/subComponents/SidePanelHeader.tsx +146 -0
  447. package/template/src/subComponents/ToastConfig.tsx +160 -11
  448. package/template/src/subComponents/caption/Caption.tsx +132 -0
  449. package/template/src/subComponents/caption/CaptionContainer.tsx +331 -0
  450. package/template/src/subComponents/caption/CaptionIcon.tsx +115 -0
  451. package/template/src/subComponents/caption/CaptionText.tsx +182 -0
  452. package/template/src/subComponents/caption/DownloadTranscriptBtn.tsx +65 -0
  453. package/template/src/subComponents/caption/LanguageSelectorPopup.tsx +192 -0
  454. package/template/src/subComponents/caption/Transcript.tsx +452 -0
  455. package/template/src/subComponents/caption/TranscriptIcon.tsx +126 -0
  456. package/template/src/subComponents/caption/TranscriptText.tsx +98 -0
  457. package/template/src/subComponents/caption/index.ts +3 -0
  458. package/template/src/subComponents/caption/proto/ptoto.js +91 -0
  459. package/template/src/subComponents/caption/proto/test.proto +23 -0
  460. package/template/src/subComponents/caption/useCaption.tsx +123 -0
  461. package/template/src/subComponents/caption/useCaptionWidth.ts +27 -0
  462. package/template/src/subComponents/caption/useSTTAPI.tsx +275 -0
  463. package/template/src/subComponents/caption/useStreamMessageUtils.native.ts +211 -0
  464. package/template/src/subComponents/caption/useStreamMessageUtils.ts +235 -0
  465. package/template/src/subComponents/caption/useTranscriptDownload.native.ts +93 -0
  466. package/template/src/subComponents/caption/useTranscriptDownload.ts +62 -0
  467. package/template/src/subComponents/caption/utils.ts +126 -0
  468. package/template/src/subComponents/chat/ChatActionMenu.tsx +224 -0
  469. package/template/src/subComponents/chat/ChatAttachment.native.tsx +237 -0
  470. package/template/src/subComponents/chat/ChatAttachment.tsx +205 -0
  471. package/template/src/subComponents/chat/ChatEmoji.native.tsx +75 -0
  472. package/template/src/subComponents/chat/ChatEmoji.tsx +182 -0
  473. package/template/src/subComponents/chat/ChatParticipants.tsx +232 -81
  474. package/template/src/subComponents/chat/ChatSendButton.tsx +209 -0
  475. package/template/src/subComponents/chat/ChatUploadStatus.tsx +84 -0
  476. package/template/src/subComponents/chat/ImagePopup.tsx +400 -0
  477. package/template/src/subComponents/livestream/ApprovedLiveStreamControlsView.tsx +2 -2
  478. package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +109 -47
  479. package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +61 -45
  480. package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +9 -8
  481. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +29 -12
  482. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +33 -17
  483. package/template/src/subComponents/recording/useIsRecordingBot.tsx +76 -0
  484. package/template/src/subComponents/recording/useRecording.tsx +761 -108
  485. package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +93 -9
  486. package/template/src/subComponents/screenshare/ScreenshareButton.tsx +82 -75
  487. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +494 -78
  488. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +247 -110
  489. package/template/src/subComponents/screenshare/useScreenshare.tsx +6 -4
  490. package/template/src/subComponents/waiting-rooms/WaitingRoomControls.tsx +85 -0
  491. package/template/src/subComponents/waiting-rooms/useWaitingRoomAPI.ts +126 -0
  492. package/template/src/theme/index.ts +59 -0
  493. package/template/src/utils/PlatformWrapper.tsx +21 -0
  494. package/template/src/utils/SdkEvents.ts +37 -14
  495. package/template/src/utils/SdkMethodEvents.ts +105 -0
  496. package/template/src/utils/axiomLogger.ts +122 -0
  497. package/template/src/utils/book.jpg +0 -0
  498. package/template/src/utils/common.tsx +350 -7
  499. package/template/src/utils/constants.ts +4 -0
  500. package/template/src/utils/fetch-retry.ts +23 -0
  501. package/template/src/utils/getCustomRoute.ts +7 -0
  502. package/template/src/utils/hexadecimalTransparency.ts +108 -0
  503. package/template/src/utils/index.tsx +83 -0
  504. package/template/src/utils/isMobileOrTablet.ts +7 -2
  505. package/template/src/utils/pendingStateUpdateHelper.ts +19 -0
  506. package/template/src/utils/useActionSheet.tsx +50 -0
  507. package/template/src/utils/useActiveSpeaker.ts +38 -0
  508. package/template/src/utils/useAppState.ts +17 -0
  509. package/template/src/utils/useAsyncEffect.ts +138 -0
  510. package/template/src/utils/useCreateRoom.ts +152 -0
  511. package/template/src/utils/useEndCall.ts +74 -0
  512. package/template/src/utils/useFindActiveSpeaker.native.ts +4 -0
  513. package/template/src/utils/useFindActiveSpeaker.ts +373 -0
  514. package/template/src/utils/useFocus.tsx +51 -0
  515. package/template/src/utils/useFullScreen.native.ts +12 -0
  516. package/template/src/utils/useFullScreen.ts +161 -0
  517. package/template/src/utils/useGetMeetingPhrase.ts +61 -10
  518. package/template/src/utils/useIsAudioEnabled.ts +3 -3
  519. package/template/src/utils/useIsHandRaised.ts +13 -0
  520. package/template/src/utils/useIsLocalUserSpeaking.native.ts +4 -0
  521. package/template/src/utils/useIsLocalUserSpeaking.ts +119 -0
  522. package/template/src/utils/useIsPSTN.ts +3 -3
  523. package/template/src/utils/useIsVideoEnabled.ts +3 -3
  524. package/template/src/utils/useJoinRoom.ts +304 -0
  525. package/template/src/utils/useLayout.tsx +9 -3
  526. package/template/src/utils/useLocalAudio.ts +69 -0
  527. package/template/src/utils/useLocalVideo.ts +69 -0
  528. package/template/src/{subComponents/screenshare/ScreenshareButton.native.tsx → utils/useMenu.tsx} +16 -3
  529. package/template/src/utils/useModal.tsx +8 -0
  530. package/template/src/utils/useMutePSTN.ts +45 -2
  531. package/template/src/utils/useMuteToggleLocal.ts +125 -49
  532. package/template/src/utils/useOrientation.native.tsx +3 -0
  533. package/template/src/utils/useOrientation.tsx +59 -0
  534. package/template/src/utils/useRemoteEndCall.ts +4 -4
  535. package/template/src/utils/useRemoteEndScreenshare.ts +26 -0
  536. package/template/src/utils/useRemoteMute.ts +7 -7
  537. package/template/src/utils/useRemoteRequest.ts +84 -0
  538. package/template/src/utils/useSearchParams.tsx +28 -0
  539. package/template/src/utils/useSidePanel.tsx +16 -5
  540. package/template/src/utils/useSpeechToText.ts +102 -0
  541. package/template/src/utils/useString.ts +19 -7
  542. package/template/src/utils/useSwitchCamera.native.tsx +25 -0
  543. package/template/src/utils/useSwitchCamera.tsx +19 -0
  544. package/template/src/utils/useToolbar.tsx +59 -0
  545. package/template/src/wasms/agora-virtual-background.wasm +0 -0
  546. package/template/static.d.ts +42 -0
  547. package/template/tsconfig_rsdk_index.json +3 -3
  548. package/template/tsconfig_wsdk_index.json +3 -3
  549. package/template/web/index.html +45 -17
  550. package/template/webpack.commons.js +16 -0
  551. package/template/webpack.rsdk.config.js +1 -2
  552. package/template/webpack.web.config.js +8 -3
  553. package/template/_buckconfig +0 -6
  554. package/template/_gitattributes +0 -1
  555. package/template/agora-rn-uikit/src/Contexts/RenderContext.tsx +0 -10
  556. package/template/android/app/_BUCK +0 -55
  557. package/template/android/app/build_defs.bzl +0 -19
  558. package/template/bridge/rtc/webNg/LocalView.tsx +0 -20
  559. package/template/ios/HelloWorld/AppDelegate.m +0 -74
  560. package/template/src/assets/icons.ts +0 -102
  561. package/template/src/components/OAuth.electron.tsx +0 -40
  562. package/template/src/components/OAuth.native.tsx +0 -53
  563. package/template/src/components/OAuth.tsx +0 -29
  564. package/template/src/components/OAuthConfig.ts +0 -77
  565. package/template/src/components/StoreToken.tsx +0 -38
  566. package/template/src/components/chat-ui/useChatUIControl.tsx +0 -69
  567. package/template/src/components/meeting-info/useMeetingInfo.tsx +0 -70
  568. package/template/src/components/participants/MeParticipant.tsx +0 -38
  569. package/template/src/components/participants/RemoteParticipants.tsx +0 -71
  570. package/template/src/pages/video-call/CustomUserContextHolder.tsx +0 -20
  571. package/template/src/utils/useCreateMeeting.ts +0 -88
  572. package/template/src/utils/useJoinMeeting.ts +0 -132
@@ -9,162 +9,829 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import React, {useState, useEffect, useCallback} from 'react';
13
- import {ClientRole} from '../../agora-rn-uikit';
12
+ import React, {
13
+ useState,
14
+ useEffect,
15
+ useCallback,
16
+ useMemo,
17
+ useRef,
18
+ useContext,
19
+ } from 'react';
20
+ import {ClientRoleType, RtcContext} from '../../agora-rn-uikit';
14
21
  import DeviceContext from './DeviceContext';
15
- import AgoraRTC from 'agora-rtc-sdk-ng';
22
+ import AgoraRTC, {DeviceInfo} from 'agora-rtc-sdk-ng';
16
23
  import {useRtc} from 'customization-api';
24
+ import Toast from '../../react-native-toast-message';
25
+ import {Text} from 'react-native';
26
+ import StorageContext from './StorageContext';
27
+
28
+ import type RtcEngine from '../../bridge/rtc/webNg/';
29
+ import ColorContext from './ColorContext';
30
+ import {SdkApiContext} from './SdkApiContext';
31
+ import SDKEvents from '../utils/SdkEvents';
32
+ import {getOS} from '../utils/common';
33
+ import LocalEventEmitter, {
34
+ LocalEventsEnum,
35
+ } from '../rtm-events-api/LocalEvents';
36
+ import {useString} from '../utils/useString';
37
+ import {
38
+ deviceDetectionSecondaryBtnText,
39
+ deviceDetectionCheckboxText,
40
+ deviceDetectionPrimaryBtnText,
41
+ deviceDetectionToastHeading,
42
+ deviceDetectionToastSubHeading,
43
+ } from '../language/default-labels/videoCallScreenLabels';
44
+ import {LogSource, logger} from '../logger/AppBuilderLogger';
45
+
46
+ const log = (...args: any[]) => {
47
+ console.log('[DeviceConfigure] ', ...args);
48
+ };
49
+
50
+ type WebRtcEngineInstance = InstanceType<typeof RtcEngine>;
17
51
 
18
52
  interface Props {
19
- userRole: ClientRole;
20
- }
21
- interface deviceInfo {
22
- deviceId: string;
23
- groupId: string;
24
- kind: string;
25
- label: string;
26
- }
27
- interface changedDeviceInfo {
28
- device: deviceInfo;
29
- initAt: number;
30
- state: 'INACTIVE' | 'ACTIVE';
31
- updateAt: number;
53
+ userRole: ClientRoleType;
32
54
  }
55
+ export type deviceInfo = MediaDeviceInfo;
56
+ export type deviceId = deviceInfo['deviceId'];
57
+ export type deviceKind = deviceInfo['kind'];
58
+
33
59
  const DeviceConfigure: React.FC<Props> = (props: any) => {
34
- const [selectedCam, setSelectedCam] = useState('');
35
- const [selectedMic, setSelectedMic] = useState('');
36
- const [deviceList, setDeviceList] = useState<any>([]);
37
- const rtc = useRtc();
38
-
39
- const refreshDevices = useCallback(async () => {
40
- rtc.RtcEngine.getDevices(function (devices: deviceInfo[]) {
41
- console.log('DeviceTesting: fetching all devices: ', devices);
42
- /**
43
- * Some browsers list the same microphone twice with different Id's,
44
- * their group Id's match as they are the same physical device.
45
- * deviceId == default is an oddity in chrome which stores the user
46
- * preference
47
- */
48
- /**
49
- * 1. Fetch devices and filter so the deviceId with default or empty
50
- * values are exluded for both audio and video devices. Also exclude
51
- * output devices. ex: Mac speakers are of type audiooutput(device.kind)
52
- * 2. Store only unique devices with unique groupIds
53
- */
54
-
55
- const uniqueDevices = devices.filter(
56
- (device: deviceInfo) =>
57
- device?.deviceId !== 'default' &&
58
- device?.deviceId !== '' &&
59
- (device.kind == 'audioinput' || device.kind == 'videoinput'),
60
- );
61
- console.log('DeviceTesting: set unique devices', uniqueDevices);
62
- setDeviceList(uniqueDevices);
63
- });
64
- }, []);
60
+ const rtc = useContext(RtcContext);
61
+ const [uiSelectedCam, setUiSelectedCam] = useState('');
62
+ const [uiSelectedMic, setUiSelectedMic] = useState('');
63
+ const [uiSelectedSpeaker, setUiSelectedSpeaker] = useState('');
64
+ const [deviceList, setDeviceList] = useState<deviceInfo[]>([]);
65
65
 
66
- useEffect(() => {
67
- AgoraRTC.onMicrophoneChanged = async (changedDevice: changedDeviceInfo) => {
68
- // When new audio device is plugged in ,refresh the devices list.
69
- console.log('DeviceTesting: on-microphone-changed');
70
- if (changedDevice && changedDevice.state === 'ACTIVE') {
71
- if (changedDevice.device?.kind === 'audioinput') {
72
- console.log('DeviceTesting: NEW audio device detected and selected');
73
- setSelectedMic(changedDevice.device?.deviceId);
74
- }
75
- }
76
- if (changedDevice && changedDevice.state === 'INACTIVE') {
77
- if (changedDevice.device?.kind === 'audioinput') {
78
- console.log('DeviceTesting: audio device inactive');
79
- setSelectedMic('');
80
- }
81
- }
82
- };
83
- AgoraRTC.onCameraChanged = async (changedDevice: changedDeviceInfo) => {
84
- // When new video device is plugged in ,refresh the devices list.
85
- console.log('DeviceTesting: on-camera-changed');
86
- if (changedDevice && changedDevice.state === 'ACTIVE') {
87
- if (changedDevice.device?.kind === 'videoinput') {
88
- console.log('DeviceTesting: NEW video device detected and selected');
89
- setSelectedCam(changedDevice.device?.deviceId);
90
- }
91
- }
92
- if (changedDevice && changedDevice.state === 'INACTIVE') {
93
- if (changedDevice.device?.kind === 'videoinput') {
94
- console.log('DeviceTesting: video device inactive');
95
- setSelectedCam('');
66
+ const toastHeading = useString(deviceDetectionToastHeading);
67
+ const toastSubHeading = useString<{name: string; label: string}>(
68
+ deviceDetectionToastSubHeading,
69
+ );
70
+ const toastPrimaryBtnText = useString(deviceDetectionPrimaryBtnText)();
71
+ const toastCancelBtnText = useString(deviceDetectionSecondaryBtnText)();
72
+ const toastCheckboxBtnText = useString(deviceDetectionCheckboxText)();
73
+
74
+ const micSelectInProgress = useRef(false);
75
+ const micSelectQueue = useRef([]);
76
+
77
+ const camSelectInProgress = useRef(false);
78
+ const camSelectQueue = useRef([]);
79
+
80
+ const speakerSelectInProgress = useRef(false);
81
+ const speakerSelectQueue = useRef([]);
82
+
83
+ const muteRefreshDeviceList = useRef(false);
84
+
85
+ const {primaryColor} = useContext(ColorContext);
86
+
87
+ const {store, setStore} = useContext(StorageContext);
88
+ const {rememberedDevicesList, activeDeviceId} = store;
89
+
90
+ // const {mediaDevice: sdkMediaDevice} = useContext(SdkApiContext);
91
+ const {
92
+ microphoneDevice: sdkMicrophoneDevice,
93
+ speakerDevice: sdkSpeakerDevice,
94
+ cameraDevice: sdkCameraDevice,
95
+ clearState,
96
+ } = useContext(SdkApiContext);
97
+
98
+ // const sdkMediaDevice = useMemo(() => {
99
+ // return {
100
+ // audioinput: sdkMicrophoneDevice,
101
+ // audiooutput: sdkSpeakerDevice,
102
+ // videoinput: sdkCameraDevice,
103
+ // };
104
+ // }, [sdkMicrophoneDevice, sdkSpeakerDevice, sdkCameraDevice]);
105
+
106
+ const isChrome = useMemo(() => {
107
+ return (
108
+ deviceList.filter(device => device.deviceId === 'default').length > 0
109
+ );
110
+ }, [deviceList]);
111
+
112
+ // const rememberedDevicesList = useRef<
113
+ // Record<MediaDeviceInfo['kind'], savedDeviceInfo[]>
114
+ // >({
115
+ // audioinput: [],
116
+ // videoinput: [],
117
+ // audiooutput: [],
118
+ // });
119
+
120
+ const updateActiveDeviceId = (
121
+ kind: MediaDeviceInfo['kind'],
122
+ deviceId: string,
123
+ ) => {
124
+ // const {kind, deviceId} = device;
125
+
126
+ setStore(prevState => ({
127
+ ...prevState,
128
+ activeDeviceId: {
129
+ ...activeDeviceId,
130
+ [kind]: deviceId,
131
+ },
132
+ }));
133
+ };
134
+
135
+ const updateRememberedDeviceList = (
136
+ device: MediaDeviceInfo,
137
+ switchOnConnect: boolean,
138
+ ) => {
139
+ const {kind} = device;
140
+ // rememberedDevicesList.current[kind].push({...device, switchOnConnect});
141
+ // window.localStorage.setItem(
142
+ // 'rememberedDevicesList',
143
+ // JSON.stringify(rememberedDevicesList.current),
144
+ // );
145
+ setStore(prevState => ({
146
+ ...prevState,
147
+ rememberedDevicesList: {
148
+ ...prevState.rememberedDevicesList,
149
+ [kind]: {
150
+ [device.deviceId]: switchOnConnect
151
+ ? 'switch-on-connect'
152
+ : 'ignore-on-connect',
153
+ ...prevState.rememberedDevicesList[kind],
154
+ },
155
+ },
156
+ }));
157
+ };
158
+
159
+ const {RtcEngineUnsafe} = rtc as unknown as {
160
+ RtcEngineUnsafe: WebRtcEngineInstance;
161
+ };
162
+ const {localStream} = RtcEngineUnsafe;
163
+
164
+ const refreshDeviceList = useCallback(async (noEmitLog?: boolean) => {
165
+ if (!muteRefreshDeviceList.current) {
166
+ muteRefreshDeviceList.current = true;
167
+ let updatedDeviceList: MediaDeviceInfo[];
168
+ await RtcEngineUnsafe.getDevices(function (devices: deviceInfo[]) {
169
+ !noEmitLog &&
170
+ logger.log(
171
+ LogSource.Internals,
172
+ 'DEVICE_CONFIGURE',
173
+ 'Fetching all devices: ',
174
+ devices,
175
+ );
176
+ /**
177
+ * Some browsers list the same microphone twice with different Id's,
178
+ * their group Id's match as they are the same physical device.
179
+ * deviceId == default is an oddity in chrome which stores the user
180
+ * preference
181
+ */
182
+ /**
183
+ * 1. Fetch devices and filter so the deviceId with empty
184
+ * values are exluded
185
+ * 2. Store only unique devices with unique groupIds
186
+ */
187
+
188
+ updatedDeviceList = devices.filter(
189
+ (device: deviceInfo) =>
190
+ // device?.deviceId !== 'default' &&
191
+ device?.deviceId !== '' &&
192
+ (device.kind == 'audioinput' ||
193
+ device.kind == 'videoinput' ||
194
+ device.kind == 'audiooutput'),
195
+ );
196
+
197
+ !noEmitLog &&
198
+ logger.log(
199
+ LogSource.Internals,
200
+ 'DEVICE_CONFIGURE',
201
+ 'Setting unique devices',
202
+ updatedDeviceList,
203
+ );
204
+ if (updatedDeviceList.length > 0) {
205
+ setDeviceList(updatedDeviceList);
96
206
  }
97
- }
98
- };
207
+ });
208
+ muteRefreshDeviceList.current = false;
209
+ return updatedDeviceList;
210
+ }
99
211
  }, []);
100
212
 
101
- useEffect(() => {
102
- refreshDevices();
103
- }, [selectedCam, selectedMic]);
213
+ const getAgoraTrackDeviceId = (type: 'audio' | 'video') => {
214
+ const mutedState =
215
+ //@ts-ignore
216
+ type === 'audio'
217
+ ? //@ts-ignore
218
+ !RtcEngineUnsafe.isAudioEnabled
219
+ : //@ts-ignore
220
+ !RtcEngineUnsafe.isVideoEnabled;
104
221
 
105
- useEffect(() => {
106
- if (!selectedMic || selectedMic.trim().length == 0) {
107
- for (const i in deviceList) {
108
- if (deviceList[i].kind === 'audioinput') {
109
- console.log('DeviceTesting: set selected audio');
110
- setSelectedMic(deviceList[i].deviceId);
111
- break;
112
- }
113
- }
222
+ let currentDevice: string;
223
+
224
+ if (mutedState) {
225
+ currentDevice =
226
+ //@ts-ignore
227
+ type === 'audio'
228
+ ? //@ts-ignore
229
+ RtcEngineUnsafe.audioDeviceId
230
+ : //@ts-ignore
231
+ RtcEngineUnsafe.videoDeviceId;
232
+ currentDevice &&
233
+ logger.log(
234
+ LogSource.Internals,
235
+ 'DEVICE_CONFIGURE',
236
+ `Agora ${type} Engine is using ${currentDevice}`,
237
+ );
238
+ } else {
239
+ currentDevice = localStream[type]
240
+ ?.getMediaStreamTrack()
241
+ .getSettings().deviceId;
242
+ currentDevice &&
243
+ logger.log(
244
+ LogSource.Internals,
245
+ 'DEVICE_CONFIGURE',
246
+ `Agora ${type} Track is using ${currentDevice}`,
247
+ );
114
248
  }
115
- if (!selectedCam || selectedCam.trim().length == 0) {
116
- for (const i in deviceList) {
117
- if (deviceList[i].kind === 'videoinput') {
118
- console.log('DeviceTesting: set selected camera');
119
- setSelectedCam(deviceList[i].deviceId);
120
- break;
121
- }
122
- }
249
+ return currentDevice ?? '';
250
+ };
251
+
252
+ /**
253
+ * Retrieves the devices being used by agora tracks and
254
+ * updates the selected Ui states with them.
255
+ * Ignores for audioOutput since state acts as ground
256
+ * truth.
257
+ */
258
+ const syncSelectedDeviceUi = (kind?: deviceKind) => {
259
+ logger.log(
260
+ LogSource.Internals,
261
+ 'DEVICE_CONFIGURE',
262
+ 'Refreshing UI for selected device',
263
+ kind ?? 'all',
264
+ );
265
+ switch (kind) {
266
+ case 'audioinput':
267
+ let micId = getAgoraTrackDeviceId('audio');
268
+ micId && SDKEvents.emit('devices-selected-microphone-changed', micId);
269
+ setUiSelectedMic(micId);
270
+ break;
271
+ case 'videoinput':
272
+ let camId = getAgoraTrackDeviceId('video');
273
+ camId && SDKEvents.emit('devices-selected-camera-changed', camId);
274
+ setUiSelectedCam(camId);
275
+ break;
276
+ case 'audiooutput':
277
+ //@ts-ignore
278
+ let speakerId = RtcEngineUnsafe.speakerDeviceId;
279
+ speakerId &&
280
+ SDKEvents.emit('devices-selected-speaker-changed', speakerId);
281
+ setUiSelectedSpeaker(speakerId);
282
+ break;
283
+ default:
284
+ micId = getAgoraTrackDeviceId('audio');
285
+ camId = getAgoraTrackDeviceId('video');
286
+ //@ts-ignore
287
+ speakerId = RtcEngineUnsafe.speakerDeviceId;
288
+
289
+ micId && SDKEvents.emit('devices-selected-microphone-changed', micId);
290
+ setUiSelectedMic(micId);
291
+
292
+ camId && SDKEvents.emit('devices-selected-camera-changed', camId);
293
+ setUiSelectedCam(camId);
294
+
295
+ speakerId &&
296
+ SDKEvents.emit('devices-selected-speaker-changed', speakerId);
297
+ setUiSelectedSpeaker(speakerId);
123
298
  }
124
- }, [deviceList]);
299
+ };
300
+
301
+ /**
302
+ * Sets the devices to the default device on chrome or
303
+ * the first item on the devices list on other browsers
304
+ * optionally takes device list to use that instead
305
+ * of state which might be stale
306
+ */
307
+ const fallbackToDefaultDevice = (
308
+ kind: deviceKind,
309
+ uniqueDevices?: MediaDeviceInfo[],
310
+ ) => {
311
+ const deviceListLocal = uniqueDevices || deviceList;
312
+ switch (kind) {
313
+ case 'audioinput':
314
+ const audioInputFallbackDeviceId = deviceListLocal.find(
315
+ device =>
316
+ device.kind === 'audioinput' &&
317
+ (isChrome ? device.deviceId === 'default' : true),
318
+ )?.deviceId;
319
+ setSelectedMic(audioInputFallbackDeviceId);
320
+ break;
321
+ case 'videoinput':
322
+ const videoInputFallbackDeviceId = deviceListLocal.find(
323
+ device => device.kind === 'videoinput',
324
+ )?.deviceId;
325
+ setSelectedCam(videoInputFallbackDeviceId);
326
+ break;
327
+ case 'audiooutput':
328
+ const audioOutputFallbackDeviceId = deviceListLocal.find(
329
+ device =>
330
+ device.kind === 'audiooutput' &&
331
+ (isChrome ? device.deviceId === 'default' : true),
332
+ )?.deviceId;
333
+
334
+ setSelectedSpeaker(audioOutputFallbackDeviceId);
335
+ break;
336
+ }
337
+ };
338
+
339
+ const checkDeviceExists = (
340
+ deviceId: deviceId,
341
+ deviceList: MediaDeviceInfo[],
342
+ ) => {
343
+ return deviceList.find(device => device.deviceId === deviceId)
344
+ ? true
345
+ : false;
346
+ };
347
+
348
+ const applySdkDeviceChangeRequest = (kind: deviceKind) => {
349
+ const {sdkStateName, sdkState} = {
350
+ audioinput: {
351
+ sdkStateName: 'microphoneDevice',
352
+ sdkState: sdkMicrophoneDevice,
353
+ },
354
+ audiooutput: {sdkStateName: 'speakerDevice', sdkState: sdkSpeakerDevice},
355
+ videoinput: {sdkStateName: 'cameraDevice', sdkState: sdkCameraDevice},
356
+ }[kind];
357
+
358
+ const {deviceId, promise} = sdkState;
359
+ const queuedSetWrapper = (deviceId: deviceId) =>
360
+ setDeviceQueued(deviceId, kind);
361
+
362
+ const {setMethod} = {
363
+ audiooutput: {
364
+ setMethod: speakerSelectInProgress.current
365
+ ? queuedSetWrapper
366
+ : setSelectedSpeaker,
367
+ },
368
+ audioinput: {
369
+ setMethod: micSelectInProgress.current
370
+ ? queuedSetWrapper
371
+ : setSelectedMic,
372
+ },
373
+ videoinput: {
374
+ setMethod: camSelectInProgress.current
375
+ ? queuedSetWrapper
376
+ : setSelectedCam,
377
+ },
378
+ }[kind];
379
+
380
+ setMethod(deviceId)
381
+ .then(() => {
382
+ promise.res();
383
+ })
384
+ .catch(e => {
385
+ promise.rej(e);
386
+ })
387
+ .finally(() => {
388
+ clearState(sdkStateName[kind]);
389
+ });
390
+ };
125
391
 
126
392
  useEffect(() => {
127
- if (selectedCam.length !== 0) {
128
- rtc.RtcEngine.changeCamera(
129
- selectedCam,
130
- () => {},
131
- (e: any) => console.log(e),
132
- );
393
+ // Notify updated state every 20s
394
+ if (getOS() !== 'macos') {
395
+ let count = 0;
396
+ const interval = setInterval(() => {
397
+ count = count + 1;
398
+ refreshDeviceList(true);
399
+ }, 2000);
400
+ return () => {
401
+ clearInterval(interval);
402
+ };
133
403
  }
134
- // eslint-disable-next-line react-hooks/exhaustive-deps
135
- }, [selectedCam]);
404
+ }, []);
136
405
 
137
406
  useEffect(() => {
138
- if (selectedMic.length !== 0) {
139
- rtc.RtcEngine.changeMic(
140
- selectedMic,
141
- () => {},
142
- (e: any) => console.log(e),
143
- );
407
+ if (sdkMicrophoneDevice?.deviceId && uiSelectedMic) {
408
+ applySdkDeviceChangeRequest('audioinput');
409
+ }
410
+ }, [sdkMicrophoneDevice]);
411
+ useEffect(() => {
412
+ if (sdkSpeakerDevice?.deviceId && uiSelectedSpeaker) {
413
+ applySdkDeviceChangeRequest('audiooutput');
414
+ }
415
+ }, [sdkSpeakerDevice]);
416
+ useEffect(() => {
417
+ if (sdkCameraDevice?.deviceId && uiSelectedCam) {
418
+ applySdkDeviceChangeRequest('videoinput');
144
419
  }
145
- // eslint-disable-next-line react-hooks/exhaustive-deps
146
- }, [selectedMic]);
420
+ }, [sdkCameraDevice]);
147
421
 
148
422
  useEffect(() => {
149
- // If stream exists and deviceList are empty, check for devices again
150
- // Labels are empty in firefox when permission is grante first time, refresh device list if labels are empty
423
+ // Labels are empty in firefox when permission is granted first time
424
+ // refresh device list if labels are empty
425
+
426
+ const logTag = 'useEffect[rtc,store]';
427
+
428
+ if (activeDeviceId && deviceList.length > 0) {
429
+ const initializeDevice = (kind: deviceKind) => {
430
+ const {uiSelectedState} = {
431
+ videoinput: {
432
+ uiSelectedState: uiSelectedCam,
433
+ },
434
+ audioinput: {
435
+ uiSelectedState: uiSelectedMic,
436
+ },
437
+ audiooutput: {
438
+ uiSelectedState: uiSelectedSpeaker,
439
+ },
440
+ }[kind];
441
+
442
+ // non chrome, ignore speaker
443
+ if (!isChrome && kind === 'audiooutput') {
444
+ setUiSelectedSpeaker('');
445
+ return;
446
+ }
447
+
448
+ if (uiSelectedState && uiSelectedState.trim().length != 0) {
449
+ return;
450
+ }
451
+
452
+ const defaultSpeaker = deviceList.find(
453
+ device =>
454
+ device.deviceId === 'default' &&
455
+ (isChrome ? device.deviceId === 'default' : true),
456
+ )?.deviceId;
457
+
458
+ const storedDevice = activeDeviceId[kind];
459
+ const {
460
+ currentDevice,
461
+ deviceLogTag,
462
+ setDevice,
463
+ setDeviceUi,
464
+ eventEmitter,
465
+ sdkDevice,
466
+ } = {
467
+ videoinput: {
468
+ currentDevice: getAgoraTrackDeviceId('video'),
469
+ deviceLogTag: 'cam:',
470
+ setDevice: setSelectedCam,
471
+ setDeviceUi: setUiSelectedCam,
472
+ eventEmitter: (deviceId: deviceId) => {
473
+ SDKEvents.emit('devices-selected-camera-changed', deviceId);
474
+ },
475
+ sdkDevice: sdkCameraDevice,
476
+ },
477
+ audioinput: {
478
+ currentDevice: getAgoraTrackDeviceId('audio'),
479
+ deviceLogTag: 'mic:',
480
+ setDevice: setSelectedMic,
481
+ setDeviceUi: setUiSelectedMic,
482
+ eventEmitter: (deviceId: deviceId) => {
483
+ SDKEvents.emit('devices-selected-microphone-changed', deviceId);
484
+ },
485
+ sdkDevice: sdkMicrophoneDevice,
486
+ },
487
+ audiooutput: {
488
+ currentDevice: defaultSpeaker,
489
+ deviceLogTag: 'speaker:',
490
+ setDevice: setSelectedSpeaker,
491
+ setDeviceUi: setUiSelectedSpeaker,
492
+ eventEmitter: (deviceId: deviceId) => {
493
+ SDKEvents.emit('devices-selected-speaker-changed', deviceId);
494
+ },
495
+ sdkDevice: sdkSpeakerDevice,
496
+ },
497
+ }[kind];
498
+
499
+ if (sdkDevice?.deviceId && currentDevice) {
500
+ if (checkDeviceExists(sdkDevice.deviceId, deviceList)) {
501
+ applySdkDeviceChangeRequest(kind);
502
+ } else {
503
+ sdkDevice.promise.rej(new Error('Provided device not detected'));
504
+ }
505
+ } else if (
506
+ storedDevice &&
507
+ currentDevice &&
508
+ currentDevice !== storedDevice &&
509
+ checkDeviceExists(storedDevice, deviceList)
510
+ ) {
511
+ logger.log(
512
+ LogSource.Internals,
513
+ 'DEVICE_CONFIGURE',
514
+ `${logTag} ${deviceLogTag} Setting to active id ${storedDevice}`,
515
+ );
516
+ setDevice(storedDevice).catch((error: Error) => {
517
+ logger.error(
518
+ LogSource.Internals,
519
+ 'DEVICE_CONFIGURE',
520
+ `ERROR: ${logTag} ${deviceLogTag} Setting to active id ${storedDevice}`,
521
+ error,
522
+ );
523
+ });
524
+ } else {
525
+ eventEmitter(currentDevice);
526
+ setDeviceUi(currentDevice);
527
+ }
528
+ };
529
+
530
+ // If stream exists and selected devices are empty, check for devices again
531
+ initializeDevice('videoinput');
532
+ initializeDevice('audioinput');
533
+ initializeDevice('audiooutput');
534
+ }
535
+
151
536
  if (
152
537
  deviceList.length === 0 ||
153
538
  deviceList.find((device: MediaDeviceInfo) => device.label === '')
154
539
  ) {
155
- refreshDevices();
540
+ logger.log(
541
+ LogSource.Internals,
542
+ 'DEVICE_CONFIGURE',
543
+ `${logTag} Empty device list`,
544
+ );
545
+ refreshDeviceList(false);
156
546
  }
157
- }, [rtc]);
547
+ }, [rtc, store, deviceList]);
548
+
549
+ const commonOnChangedEvent = async (changedDeviceData: DeviceInfo) => {
550
+ // Extracted devicelist because we want to perform fallback with
551
+ // the most current version.
552
+ const previousDeviceList = deviceList;
553
+ const updatedDeviceList = await refreshDeviceList(false);
554
+ const changedDevice = changedDeviceData.device;
555
+
556
+ const {logTag, currentDevice, setCurrentDevice} = {
557
+ audioinput: {
558
+ logTag: 'mic: on-microphone-changed',
559
+ currentDevice: uiSelectedMic,
560
+ setCurrentDevice: setSelectedMic,
561
+ },
562
+ audiooutput: {
563
+ logTag: 'speaker: on-speaker-changed',
564
+ currentDevice: uiSelectedSpeaker,
565
+ setCurrentDevice: setSelectedSpeaker,
566
+ },
567
+ videoinput: {
568
+ logTag: 'cam: on-camera-changed',
569
+ currentDevice: uiSelectedCam,
570
+ setCurrentDevice: setSelectedCam,
571
+ },
572
+ }[changedDevice.kind];
573
+
574
+ logger.log(
575
+ LogSource.Internals,
576
+ 'DEVICE_CONFIGURE',
577
+ `${logTag}`,
578
+ changedDeviceData,
579
+ );
580
+ if (currentDevice === 'default') {
581
+ // const previousDefaultDevice = previousDeviceList.find(
582
+ // (device) => device.deviceId === 'default',
583
+ // );
584
+ // const currentDefaultDevice = updatedDeviceList.find(
585
+ // (device) => device.deviceId === 'default',
586
+ // );
587
+ // log(logTag, 'current Default device', {
588
+ // changedDeviceData,
589
+ // previousDeviceList,
590
+ // updatedDeviceList,
591
+ // previousDefaultDevice,
592
+ // currentDefaultDevice,
593
+ // });
594
+ // if (previousDefaultDevice.groupId !== currentDefaultDevice.groupId) {
595
+ // log(logTag, 'Default device changed', {
596
+ // changedDeviceData,
597
+ // previousDeviceList,
598
+ // updatedDeviceList,
599
+ // previousDefaultDevice,
600
+ // currentDefaultDevice,
601
+ // });
602
+ // setCurrentDevice('default');
603
+ // }
604
+ setCurrentDevice('default');
605
+ }
606
+
607
+ const didChangeDeviceExistBefore = previousDeviceList.find(
608
+ device => device.deviceId === changedDevice.deviceId,
609
+ )
610
+ ? true
611
+ : false;
612
+
613
+ if (changedDeviceData.state === 'ACTIVE' && !didChangeDeviceExistBefore) {
614
+ const rememberedDevice =
615
+ rememberedDevicesList[changedDevice.kind][changedDevice.deviceId];
616
+
617
+ if (!rememberedDevice) {
618
+ showNewDeviceDetectedToast(changedDevice);
619
+ } else {
620
+ if (rememberedDevice === 'switch-on-connect') {
621
+ setCurrentDevice(changedDevice.deviceId);
622
+ return;
623
+ }
624
+ }
625
+ } else if (changedDeviceData.state === 'INACTIVE') {
626
+ if (changedDevice.deviceId === currentDevice) {
627
+ fallbackToDefaultDevice(changedDevice.kind, updatedDeviceList);
628
+ return;
629
+ }
630
+ }
631
+ };
632
+
633
+ // Port this to useEffectEvent(https://beta.reactjs.org/reference/react/useEffectEvent) when
634
+ // released
635
+ useEffect(() => {
636
+ AgoraRTC.onMicrophoneChanged = data => {
637
+ LocalEventEmitter.emit(LocalEventsEnum.MIC_CHANGED);
638
+ commonOnChangedEvent(data);
639
+ };
640
+ return () => {
641
+ AgoraRTC.onMicrophoneChanged = null;
642
+ };
643
+ }, [uiSelectedMic, deviceList]);
644
+
645
+ useEffect(() => {
646
+ AgoraRTC.onPlaybackDeviceChanged = commonOnChangedEvent;
647
+ return () => {
648
+ AgoraRTC.onPlaybackDeviceChanged = null;
649
+ };
650
+ }, [uiSelectedSpeaker, deviceList]);
651
+
652
+ useEffect(() => {
653
+ AgoraRTC.onCameraChanged = commonOnChangedEvent;
654
+ return () => {
655
+ AgoraRTC.onCameraChanged = null;
656
+ };
657
+ }, [uiSelectedCam, deviceList]);
658
+
659
+ const setDeviceQueued = async (deviceId: deviceId, kind: deviceId) => {
660
+ const {queue} = {
661
+ audiooutput: {
662
+ queue: speakerSelectQueue.current,
663
+ },
664
+ audioinput: {
665
+ queue: micSelectQueue.current,
666
+ },
667
+ videoinput: {
668
+ queue: camSelectQueue.current,
669
+ },
670
+ }[kind];
671
+
672
+ return new Promise((res, rej) => {
673
+ queue.push({
674
+ deviceId,
675
+ resolveQueued: res,
676
+ rejectQueued: rej,
677
+ });
678
+ });
679
+ };
680
+
681
+ const setDeviceCommon = (deviceId: deviceId, kind: deviceKind) => {
682
+ const {mutexRef, queueRef, setMethod, logtag} = {
683
+ audioinput: {
684
+ mutexRef: micSelectInProgress,
685
+ queueRef: micSelectQueue,
686
+ setMethod: 'changeMic',
687
+ logtag: 'setMic:',
688
+ },
689
+ audiooutput: {
690
+ mutexRef: speakerSelectInProgress,
691
+ queueRef: speakerSelectQueue,
692
+ setMethod: 'changeSpeaker',
693
+ logtag: 'setSpeaker:',
694
+ },
695
+ videoinput: {
696
+ mutexRef: camSelectInProgress,
697
+ queueRef: camSelectQueue,
698
+ setMethod: 'changeCamera',
699
+ logtag: 'setCam:',
700
+ },
701
+ }[kind];
702
+
703
+ logger.log(
704
+ LogSource.Internals,
705
+ 'DEVICE_CONFIGURE',
706
+ `${logtag} ${kind} setting to ${deviceId}`,
707
+ );
708
+
709
+ const handleQueue = () => {
710
+ if (queueRef.current.length > 0) {
711
+ const queueItem = queueRef.current.shift();
712
+ setDeviceCommon(queueItem.deviceId, kind)
713
+ .then(() => {
714
+ queueItem.resolveQueued();
715
+ })
716
+ .catch(e => queueItem.rejectQueued(e));
717
+ }
718
+ };
719
+ return new Promise<void>((res, rej) => {
720
+ if (mutexRef.current) {
721
+ const e = new Error(logtag + ' Change already in progress');
722
+ logger.error(
723
+ LogSource.Internals,
724
+ 'DEVICE_CONFIGURE',
725
+ `${logtag} Error setting ${kind}`,
726
+ e,
727
+ );
728
+ rej(e);
729
+ return;
730
+ }
731
+ mutexRef.current = true;
732
+ RtcEngineUnsafe[setMethod](
733
+ deviceId,
734
+ () => {
735
+ syncSelectedDeviceUi(kind);
736
+ updateActiveDeviceId(kind, deviceId);
737
+ mutexRef.current = false;
738
+ res(null);
739
+ handleQueue();
740
+ },
741
+ (e: any) => {
742
+ mutexRef.current = false;
743
+ logger.error(
744
+ LogSource.Internals,
745
+ 'DEVICE_CONFIGURE',
746
+ `${logtag} Error setting ${kind}`,
747
+ e,
748
+ );
749
+ rej(e);
750
+ handleQueue();
751
+ },
752
+ );
753
+ });
754
+ };
755
+
756
+ const setSelectedMic = (deviceId: deviceId) => {
757
+ return setDeviceCommon(deviceId, 'audioinput');
758
+ };
759
+
760
+ const setSelectedCam = (deviceId: deviceId) => {
761
+ return setDeviceCommon(deviceId, 'videoinput');
762
+ };
763
+
764
+ const setSelectedSpeaker = (deviceId: deviceId) => {
765
+ return setDeviceCommon(deviceId, 'audiooutput');
766
+ };
767
+
768
+ const showNewDeviceDetectedToast = (device: MediaDeviceInfo) => {
769
+ const {name, setAction} = {
770
+ audioinput: {
771
+ name: 'mic',
772
+ setAction: setSelectedMic,
773
+ },
774
+ videoinput: {
775
+ name: 'webcam',
776
+ setAction: setSelectedCam,
777
+ },
778
+ audiooutput: {
779
+ name: 'speaker',
780
+ setAction: setSelectedSpeaker,
781
+ },
782
+ }[device.kind];
783
+
784
+ Toast.show({
785
+ type: 'checked',
786
+ leadingIconName: 'mic-on',
787
+ // leadingIcon: <CustomIcon name={'mic-on'} />,
788
+ text1: toastHeading(name),
789
+ text2: toastSubHeading({name, label: device?.label}),
790
+ // @ts-ignore
791
+ // text2: (
792
+ // <Text>
793
+ // <Text>New {name} named </Text>
794
+ // <Text style={{fontWeight: 'bold'}}>{device.label}</Text>
795
+ // <Text> detected. Do you want to switch?</Text>
796
+ // </Text>
797
+ // ),
798
+ visibilityTime: 6000,
799
+ //@ts-ignore
800
+ checkbox: {
801
+ disabled: false,
802
+ color: primaryColor,
803
+ text: toastCheckboxBtnText,
804
+ },
805
+ primaryBtn: {
806
+ text: toastPrimaryBtnText,
807
+ onPress: (checked: boolean) => {
808
+ setAction(device.deviceId);
809
+ checked && updateRememberedDeviceList(device, true);
810
+ Toast.hide();
811
+ },
812
+ },
813
+ secondaryBtn: {
814
+ text: toastCancelBtnText,
815
+ onPress: (checked: boolean) => {
816
+ checked && updateRememberedDeviceList(device, false);
817
+ Toast.hide();
818
+ },
819
+ },
820
+ });
821
+ };
158
822
 
159
823
  return (
160
824
  <DeviceContext.Provider
161
825
  value={{
162
- selectedCam,
826
+ selectedCam: uiSelectedCam,
163
827
  setSelectedCam,
164
- selectedMic,
828
+ selectedMic: uiSelectedMic,
165
829
  setSelectedMic,
830
+ selectedSpeaker: uiSelectedSpeaker,
831
+ setSelectedSpeaker,
166
832
  deviceList,
167
833
  setDeviceList,
834
+ isChrome,
168
835
  }}>
169
836
  {props.children}
170
837
  </DeviceContext.Provider>