Skip to content

Cloud Recording for Flutter Video Chat

By Author: Meherdeep Thakur In Developer

Imagine yourself being in the spotlight and giving a great presentation in front of your colleagues. The love and appreciation that you got from your presentation make you wish your video calling platform had a recording feature. Well, hold on as we walk you through the process of building your own video chat application with cloud recording.

The Agora SDK simplifies the process of building your own video chat application and adds cloud recording functionality so that you can record your video chats to various cloud platforms like AWS, Qiniu Cloud, Alibaba Cloud, Tencent Cloud, and Kingsoft Cloud.

So gear up and get coding!

Prerequisites

  1. Clone this repo as the base project to work on.
  2. An Agora developer account (see How to Get Started).
  3. An AWS account.
  4. Heroku or any other service to deploy the back end.
  5. Flutter SDK.
  6. VS Code or Android Studio.
  7. A basic understanding of Flutter development.

Project Overview

This project has three major steps:

  1. Environment: This involves enabling the feature on your Agora account and setting up a client-server and an S3 account.
  2. Server: The code is written in GoLang.
  3. Client: A Flutter application built on the basic video chat project.

Environment Setup — Agora

  1. Generate an App ID and token: From your Agora console, create a project and select the authentication mechanism as Secured Mode. Copy the App ID and token to your clipboard, as we’ll be using them later.
  2. Enable cloud recording: Click the Edit button next to your project and enable cloud recording from there.
  3. Get customer credentials: Visit the RESTful API page and click the Add Secret button. Copy the Customer ID and Customer Secret to a text file as well.

Environment Setup — AWS

Once you’ve created an AWS account, create an S3 bucket that stores all your video recordings.

  1. Go to your AWS IAM Console, create a user, and make sure that you add the AmazonS3FullAccess policy with Programmatic Access.
Cloud Recording for Flutter Video Chat screenshot 1
  1. Copy your AWS Access Key and Secret Key to a text file.
  2. Create an AWS S3 bucket. Give it an appropriate name, and copy the name to your clipboard so that we can use it later. If you already have a bucket, you can skip this step.
  3. Find your region number (depending on your AWS server region), by going to this table and clicking the Amazon S3 tab.

Server Setup

Before deploying our back end we need the following variables. (It’s time to use our text file.) We’ll be using the Heroku one-click deploy to make it super simple to get our back end up and running. You can use any other service as well:

APP_ID=
APP_CERTIFICATE=
RECORDING_VENDOR=
RECORDING_REGION=
BUCKET_NAME=
BUCKET_ACCESS_KEY=
BUCKET_ACCESS_SECRET=
CUSTOMER_ID=
CUSTOMER_CERTIFICATE=

Note: RECORDING_VENDOR=1 for AWS. Click this link for more information.

  1. Create an account on Heroku if you haven’t done so already.
  2. Click this link to use Heroku one-click deploy.
  3. Enter your variables and click the Deploy App button at the bottom of the page.
  4. Wait a few minutes. Once the deployment is complete, save your back-end URL in a text file, which we’ll use in the app.

Client Setup

We will begin by cloning this repo, which demonstrates how to build your own group video calling application using the Agora Flutter SDK. If you want to know more about the SDK, see this blog.

Once you have your Heroku back end up and running, you need to take care of three functions:

  • Get RTC Token: Used to fetch a token from the back end, this token value is used whenever a user tries to enter a channel. A token ensures a safe and secure mode of authentication so that only users with this unique token value can join a call.
_getToken()

Call this function before the joinChannel() method so that you pass the token and uid you received from the _getToken() function.

await _getToken();
await _engine.joinChannel(token, widget.channelName, null, uid);

Start Recording: Sends a POST request with the channelName in the body. Once we get a response, update the state of ridsid, and recUid.

_startRecording()

Stop Recording: Sends a POST request with channelNameridsid, and recUid in the body. In the response, you will get a success or error message based on the parameters you passed.

_stopRecording()

Conclusion

You can now run the sample app and test it for yourself. By running the app and recording the call for some time, you will find the recordings getting added to your S3 bucket in fragments.

You can get the complete code for this application here.

Other Resources

To learn more about the Agora Flutter SDK and other use cases, see the developer guide here.

You can also have a look at the complete documentation for the functions discussed above and many more here.

And I invite you to join the Agora Developer Slack Community.