mediasfu-reactnative-expo
Version:
mediasfu-reactnative-expo – Expo-managed React Native WebRTC SDK for video conferencing, webinars, live streaming, broadcast, screen sharing, whiteboard, chat, recording, live subtitles, translation, and AI agent rooms on iOS, Android, and web. Prebuilt r
73 lines • 2.44 kB
JavaScript
import { updatePermissionConfig as sharedUpdatePermissionConfig } from 'mediasfu-shared';
/**
* Default permission configuration.
*/
export const getDefaultPermissionConfig = () => ({
level0: {
useMic: "approval",
useCamera: "approval",
useScreen: "disallow",
useChat: "allow",
},
level1: {
useMic: "allow",
useCamera: "allow",
useScreen: "approval",
useChat: "allow",
},
});
/**
* Creates a PermissionConfig from event settings.
* This is useful when permissionConfig is not yet set, extracting initial values
* from the room's event settings. Both level0 and level1 will have the same initial permissions.
*
* @param audioSetting - 'allow' | 'approval' | 'disallow'
* @param videoSetting - 'allow' | 'approval' | 'disallow'
* @param screenshareSetting - 'allow' | 'approval' | 'disallow'
* @param chatSetting - 'allow' | 'disallow'
* @returns PermissionConfig with both levels set to the same permissions
*/
export const getPermissionConfigFromEventSettings = (audioSetting = "approval", videoSetting = "approval", screenshareSetting = "disallow", chatSetting = "allow") => {
const capabilities = {
useMic: audioSetting,
useCamera: videoSetting,
useScreen: screenshareSetting,
useChat: (chatSetting === "allow" ? "allow" : "disallow"),
};
return {
level0: { ...capabilities },
level1: { ...capabilities },
};
};
/**
* Updates the permission configuration for the room.
* Only hosts (islevel === "2") can update the configuration.
*
* @param {UpdatePermissionConfigOptions} options - Options for updating permission config.
*
* @example
* ```typescript
* await updatePermissionConfig({
* socket,
* config: {
* level0: { useMic: "disallow", useCamera: "disallow", useScreen: "disallow", useChat: "allow" },
* level1: { useMic: "allow", useCamera: "allow", useScreen: "allow", useChat: "allow" },
* },
* member: "currentUser",
* islevel: "2",
* roomName: "room123",
* showAlert: (alert) => console.log(alert.message),
* });
* ```
*/
export const updatePermissionConfig = async ({ socket, config, member, islevel, roomName, showAlert, }) => {
await sharedUpdatePermissionConfig({
socket,
config,
member,
islevel,
roomName,
showAlert,
});
};
//# sourceMappingURL=updatePermissionConfig.js.map