如何在 Twilio 视频会议中启用录制?

How to enable recording in Twilio Video conference?

我在启用 'RecordParticipantsOnConnect' 时遇到问题,如下所述:https://www.twilio.com/docs/video/api/recordings-resource 在我的 twilio 实现中,但我似乎无法让它工作,我在哪里将 RecordParticipantsOnConnect 设置为 true?

他们说你在创建房间时需要传递这个选项,但我没有创建任何房间,它是自动完成的,我只是将房间名称作为字符串传递,然后我得到了令牌:

class TwilioServices
  ACCOUNT_SID     = ENV['TWILIO_ACCOUNT_SID']
  API_KEY_SID     = ENV['TWILIO_API_KEY_SID']
  API_KEY_SECRET  = ENV['TWILIO_API_KEY_SECRET']

  def self.get_token(type, room)
    # Create an Access Token
    token = Twilio::JWT::AccessToken.new ACCOUNT_SID, API_KEY_SID, API_KEY_SECRET, ttl: 7200, identity: type,

    # Grant access to Video
    grant = Twilio::JWT::AccessToken::VideoGrant.new
    grant.room = room
    token.add_grant grant
    # Serialize the token as a JWT
    token.to_jwt
  end
end

我该如何解决?

此处为 Twilio 开发人员布道师。

如果您让 SDK 在您加入房间时动态创建房间,那么您将无法在代码中设置录音标志。相反,您有两个选择:

  1. 你可以configure your room default settings in the Twilio console。您可以在此处将房间设置为默认分组房间并打开录音。 (您无法录制点对点房间,因为媒体不通过 Twilio 服务器。)

  2. 您可以使用 Video Rooms REST API 预先创建房间。自己创建房间时,还可以设置类型和是否录音。为此,您需要将 get_token 方法更新为:

    class TwilioServices
      ACCOUNT_SID     = ENV['TWILIO_ACCOUNT_SID']
      API_KEY_SID     = ENV['TWILIO_API_KEY_SID']
      API_KEY_SECRET  = ENV['TWILIO_API_KEY_SECRET']
    
      def self.get_token(type, room)
        # Create an Access Token
        token = Twilio::JWT::AccessToken.new ACCOUNT_SID, API_KEY_SID, API_KEY_SECRET, ttl: 7200, identity: type,
    
        client = Twilio::REST::Client.new(API_KEY_SID, API_KEY_SECRET, ACCOUNT_SID)
        video_room = client.video.rooms.create(
          unique_name: room,
          record_participants_on_connect: true,
          type: 'group'
        )
    
        # Grant access to Video
        grant = Twilio::JWT::AccessToken::VideoGrant.new
        grant.room = room
        token.add_grant grant
        # Serialize the token as a JWT
        token.to_jwt
      end
    end
    

如果有帮助请告诉我。