createRoom static method

Room createRoom({
  1. required String roomId,
  2. required String displayName,
  3. required String token,
  4. bool micEnabled = true,
  5. bool camEnabled = true,
  6. String participantId = '',
  7. String maxResolution = 'sd',
  8. int defaultCameraIndex = 0,
  9. bool multiStream = true,
  10. CustomTrack? customCameraVideoTrack,
  11. CustomTrack? customMicrophoneAudioTrack,
  12. NotificationInfo notification = const NotificationInfo(title: "Video SDK", message: "Video SDK is sharing screen in the meeting", icon: "notification_share"),
  13. Mode mode = Mode.SEND_AND_RECV,
  14. Map<String, dynamic> metaData = const {},
  15. String signalingBaseUrl = '',
  16. PreferredProtocol preferredProtocol = PreferredProtocol.UDP_OVER_TCP,
  17. bool debugMode = true,
})

Method to join Room

Implementation

static Room createRoom(
    {required String roomId,
    required String displayName,
    required String token,
    bool micEnabled = true,
    bool camEnabled = true,
    String participantId = '',
    String maxResolution = 'sd',
    int defaultCameraIndex = 0,
    bool multiStream = true,
    CustomTrack? customCameraVideoTrack,
    CustomTrack? customMicrophoneAudioTrack,
    NotificationInfo notification = const NotificationInfo(
      title: "Video SDK",
      message: "Video SDK is sharing screen in the meeting",
      icon: "notification_share",
    ),
    // Mode mode = Mode.CONFERENCE,
    Mode mode = Mode.SEND_AND_RECV,
    Map<String, dynamic> metaData = const {},
    String signalingBaseUrl = '',
    PreferredProtocol preferredProtocol = PreferredProtocol.UDP_OVER_TCP,
    bool debugMode = true}) {
  //
  participantId = participantId.isNotEmpty ? participantId : randomAlpha(8);

  signalingBaseUrl =
      signalingBaseUrl.isNotEmpty ? signalingBaseUrl : "api.videosdk.live";

  //
  if (token.isEmpty) {
    //
    //
    // VideoSDKLog.createLog(
    //     message: "Token is empty or invalid.",
    //     logLevel: "ERROR");
    //
    throw "Token is empty or invalid.";
  }

  Room room = Room(
      participantId: participantId,
      displayName: displayName,
      maxResolution: maxResolution,
      camEnabled: camEnabled,
      micEnabled: micEnabled,
      meetingId: roomId,
      multiStream: multiStream,
      token: token,
      notification: notification,
      defaultCameraIndex: defaultCameraIndex,
      customCameraVideoTrack: customCameraVideoTrack,
      customMicrophoneAudioTrack: customMicrophoneAudioTrack,
      mode: mode,
      metaData: metaData,
      signalingBaseUrl: signalingBaseUrl,
      preferredProtocol: preferredProtocol,
      debugMode: debugMode);

  if (!kIsWeb) {
    if (!Platform.isMacOS && !Platform.isWindows) {
      _eventChannel.receiveBroadcastStream().listen((event) {
        if (event == "STOP_SCREENSHARE") {
          room.disableScreenShare();
        } else if (event == "START_SCREENSHARE") {
          room.enableShare(null, iosPermissionGiven: true);
        }
      });
    }
  }

  //
  return room;
}