jitsi / jitsi-meet

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
https://jitsi.org/meet
Apache License 2.0
22.84k stars 6.68k forks source link

Unable to start video recording automatically on the Android app without manually starting recording #15067

Open Abhishek-Khanduri opened 2 weeks ago

Abhishek-Khanduri commented 2 weeks ago

What happened?

I'm trying to automatically start the recording for the meeting as soon as the user joins.

Platform

SDK version

@jitsi/react-native-sdk:^0.3.0

More details?

On my Web I was I am able to achieve this using the following code:

if (!recording) {
        // if current user is not the first participant
        jitsiAPI.stopRecording('file');
}

if (numParticipants === 1 && recording) {
        // if current user is the first participant
        jitsiAPI.startRecording({ mode: 'file' });
}

But on my React Native, I tried using the following to accomplish it but nothing worked out for me jitsiMeeting.current.startRecording({ mode: 'file' });

This is the complete code

import React, { useCallback, useEffect, useRef } from 'react';
import { BackHandler } from 'react-native';
import { JitsiMeeting } from '@jitsi/react-native-sdk/index';
import config from "src/config";
import { useNavigation } from '@react-navigation/native';

const VideoCallFrame = ({ room, displayName = '', logVideoEvent, callEnded, consent }) => {
  const jitsiMeeting = useRef(null);
  const meetFeatureFlags = {
    'add-people.enabled': false,
    'calendar.enabled': false,
    'call-integration.enabled': false,
    'chat.enabled': false,
    'close-captions.enabled': false,
    'invite.enabled': false,
    'android.screensharing.enabled': false,
    'live-streaming.enabled': false,
    'meeting-name.enabled': false,
    'meeting-password.enabled': true,
    'pip.enabled': true,
    'kick-out.enabled': false,
    'conference-timer.enabled': true,
    'video-share.enabled': false,
    'recording.enabled': true,
    'reactions.enabled': false,
    'raise-hand.enabled': true,
    'tile-view.enabled': true,
    'toolbox.alwaysVisible': true,
    'toolbox.enabled': true,
    'welcomepage.enabled': false,
  };
  const meetConfig = {
    subject: 'Meeting Room',
  };
  const navigation = useNavigation();

  useEffect(() => {
    const backAction = () => {
      jitsiMeeting.current.close();
      callEnded();
      navigation.navigate('mentorshipChat');
    };

    const backHandler = BackHandler.addEventListener(
      "hardwareBackPress",
      backAction
    );

    return () => backHandler.remove();
  }, []);

  const onConferenceLeft = useCallback(() => {
    logVideoEvent(room.room, 'leave', '');
    callEnded();
    console.log("VideoCallFrame onConferenceTerminated");
  }, []);

  const onConferenceWillJoin = useCallback(() => {
    console.log("VideoCallFrame onConferenceWillJoin");
    /* Conference will join event */
  }, []);

  const onConferenceJoined = useCallback(() => {
    console.log(`Debug Room Data: ${JSON.stringify(room)}`);
    logVideoEvent(room.room, 'join', '');
    console.log("VideoCallFrame onConferenceJoined");
    // if (consent?.key === true) {
    jitsiMeeting.current.executeCommand('startRecording', { mode: 'file' });
    // }
  }, []);

  const onReadyToClose = useCallback(() => {
    jitsiMeeting.current.close();
    callEnded();
  }, [navigation]);

  const eventListeners = {
    onReadyToClose,
    onConferenceWillJoin,
    onConferenceLeft,
    onConferenceJoined,
  };

  return (
    <JitsiMeeting
      config={meetConfig}
      eventListeners={eventListeners}
      flags={meetFeatureFlags}
      ref={jitsiMeeting}
      style={{ flex: 1, height: '100%', width: '100%', backgroundColor: 'black' }}
      room={room.room}
      token={room?.token}
      serverURL={config.VIDEO_SERVER_URL}
    />
  );
};

export default VideoCallFrame;

I have a Jibri setup (the Jitsi server is self-hosted using jitsi-docker). Starting and stopping the recording manually works as expected. Any help to do this programmatically would be appreciated!

Abhishek-Khanduri commented 2 weeks ago

@saghul, Could you please help me with this?