Recording API

Version: v2.2.2

C++ Interface Class description
IRecordingEngine The IRecordingEngine class provides the main methods that can be invoked by your application
IRecordingEngineEventHandler The IRecordingEngineEventHandler class enables callback event notifications to your application

IRecordingEngine

The IRecordingEngine class provides the following main methods that can be invoked by your application:

Creates a Recording Engine (createAgoraRecordingEngine)

This method creates the Agora recording engine object.

public static IRecordingEngine* createAgoraRecordingEngine(const char * appId, IRecordingEngineEventHandler *eventHandler);
Name Description
appId The App ID used in the communications to be recorded. For details, see Getting an App ID.
eventHandler The Agora Recording SDK notifies the application of the triggered events according to IRecordingEngineEventHandler.

Allows an Application to Join a Channel (joinChannel)

This method allows the recording application to join a channel and start recording.

virtual int joinChannel(const char * token, const char *channelId, uid_t uid, const RecordingConfig &config) = 0;
Name Description
token The token used in the communications to be recorded. For details, see Getting an App ID.
channelId Name of the channel to be recorded
uid User ID: A 32-bit unsigned integer ranging from 1 to (2^32-1) that is unique in a channel.
config Detailed recording configuration. See the definition in the table below.
Returns:
  • 0: Success.
  • < 0: Failure.
  • The Recording SDK has requestToken and renewToken as private interfaces. Make sure that you set expireTimestamp as 0 when generating a Token, which means that the privilege, once generated, never expires.
  • A channel does not accept duplicate uids, otherwise there will be unpredictable behaviors.

The structure of RecordingConfig:

typedef struct RecordingConfig {
    bool isAudioOnly;
    bool isVideoOnly;
    bool isMixingEnabled;
    agora::linuxsdk::MIXED_AV_CODEC_TYPE mixedVideoAudio;
    char * mixResolution;
    char * decryptionMode;
    char * secret;
    char * appliteDir;
    char * recordFileRootDir;
    char * cfgFilePath;
    agora::linuxsdk::VIDEO_FORMAT_TYPE decodeVideo;
    agora::linuxsdk::AUDIO_FORMAT_TYPE decodeAudio;
    int lowUdpPort;
    int highUdpPort;
    int idleLimitSec;
    int captureInterval;
    int audioIndicationInterval;
    agora::linuxsdk::CHANNEL_PROFILE_TYPE channelProfile;
    agora::linuxsdk::REMOTE_VIDEO_STREAM_TYPE streamType;
    agora::linuxsdk::TRIGGER_MODE_TYPE triggerMode;
    agora::linuxsdk::LANGUAGE_TYPE lang;
    char * proxyServer;
    agora::linuxsdk::AUDIO_PROFILE_TYPE audioProfile;
    char * defaultVideoBg;
    char * defaultUserBg;
    agora::linuxsdk::avsyncType avSyncMode;

    RecordingConfig(): channelProfile(agora::linuxsdk::CHANNEL_PROFILE_COMMUNICATION),
        isAudioOnly(false),
        isVideoOnly(false),
        isMixingEnabled(false),
        mixResolution(NULL),
        decryptionMode(NULL),
        secret(NULL),
        idleLimitSec(300),
        appliteDir(NULL),
        recordFileRootDir(NULL),
        cfgFilePath(NULL),
        lowUdpPort(0),
        highUdpPort(0),
        captureInterval(5),
        audioIndicationInterval(0),
        decodeAudio(agora::linuxsdk::AUDIO_FORMAT_DEFAULT_TYPE),
        decodeVideo(agora::linuxsdk::VIDEO_FORMAT_DEFAULT_TYPE),
        mixedVideoAudio(agora::linuxsdk::MIXED_AV_DEFAULT),
        streamType(agora::linuxsdk::REMOTE_VIDEO_STREAM_HIGH),
        triggerMode(agora::linuxsdk::AUTOMATICALLY_MODE),
        lang(agora::linuxsdk::CPP_LANG),
        proxyServer(NULL),
        audioProfile(agora::linuxsdk::AUDIO_PROFILE_DEFAULT),
        defaultVideoBg(NULL),
        defaultUserBg(NULL),
        avSyncMode(agora::linuxsdk::avsyncType::AVSYNC_V0)
    {}

    virtual ~RecordingConfig() {}
 } RecordingConfig;
Name Description
channelProfile

Sets the channel mode:

  • CHANNEL_PROFILE_COMMUNICATION: (Default) Communication mode. This is used in one-on-one calls or group calls, where all users in the channel can talk freely.
  • CHANNEL_PROFILE_LIVE_BROADCAST: Live broadcast. Host and audience roles that can be set by calling setClientRole. The host sends and receives voice/video, while the audience only receives voice/video.
isAudioOnly

Sets whether to record audio only:

  • true: Enable audio recording only.
  • false: (Default) Record both audio and video.
isVideoOnly

Sets whether to record video only:

  • true: Enable video recording only.
  • false: (Default) Record both audio and video.
isMixingEnabled

Sets whether to enable audio-mixing or/and video-mixing mode:

  • false: (Default) Enable individual mode. The bitrate and audio channel number of the recording file are the same as those of the original audio stream.
  • true: Enable composite mode. The sample rate, the bitrate and audio channel number of the recording file are the same as the highest level of those of the original audio streams.

If composite mode is enabled:

  • If isAudioOnly is true and isVideoOnly is false, this parameter sets to record audio only.
  • If isAudioOnly is false and isVideoOnly is true, this parameter sets to record video only.
  • If both isAudioOnly and isVideoOnly are false, this parameter sets to enable voice mixing and video mixing, that is, to record the audio and video of all uids respectively.
  • isVideoOnly and isVideoOnly cannot be set to true at the same time.
mixResolution [1] If you have enabled the video mixing mode, this parameter sets the resolution in the format: width, height, fps, and Kbps, representing the width, height, frame rate, and bitrate of the video stream.
decryptionMode

When the whole channel is encrypted, the recording SDK uses this parameter to enable the built-in decryption function:

  • “aes-128-xts”: AES-128, XTS mode
  • “aes-128-ecb”: AES-128, ECB mode
  • “aes-256-xts”: AES-256, XTS mode
secret (Default: NULL) The decryption password when decryption mode is enabled.
idleLimitSec The Agora Recording SDK automatically stops recording after there is no user in the recorded channel for a time period of idleLimitSec. The value must be ≥ three seconds, and the default value is 300 seconds.
appliteDir (Default: NULL) The directory to store AgoraCoreService.
recordFilrRootDir (Default: NULL) The root directory to store the recording files. Do not set recordFileRootDir and cfgFilePath at the same time.
cfgFilePath (Default: NULL) The path of the configuration file. In this configuration file, you can set the absolute path of the recording file, and the content in the configuration file must be in JSON format. Do not set recordFileRootDir and cfgFilePath at the same time. For example, {“Recording_Dir” :”<recording path>”}, where Recording_Dir is fixed
lowUdpPort (Default: 0) The lowest UDP port. Ensure that the value of highUdpPort - lowUdpPort is ≥ 4.
highUdpPort (Default: 0) The highest UDP port. Ensure that the value of highUdpPort - lowUdpPort is ≥ 4.
captureInterval Time interval between two consecutive screen captures. The value ranges from one second to five seconds. Need to be used with decodeVideo = 3/4 when joining the channel. See joinChannel to allows a user to join a channel.
audioIndicationInterval

Time interval (ms) between two consecutive detection of active speakers.

  • ≤ 0: Disables the speaker detection;
  • > 0: The time interval between two consecutive detection of active speakers in milliseconds. When an active speaker found, the SDK returns the user ID of the speaker in the onActiveSpeaker callback function.
decodeAudio [2]
  • AUDIO_FORMAT_DEFAULT_TYPE = 0: Default audio format
  • AUDIO_FORMAT_AAC_FRAME_TYPE = 1: AAC format
  • AUDIO_FORMAT_PCM_FRAME_TYPE = 2: PCM format
  • AUDIO_FORMAT_MIXED_PCM_FRAME_TYPE = 3: PCM audio-mixing format
decodeVideo [2]
  • VIDEO_FORMAT_DEFAULT_TYPE = 0: Default video format

  • VIDEO_FORMAT_H264_FRAME_TYPE = 1: H.264 format

  • VIDEO_FORMAT_YUV_FRAME_TYPE = 2: YUV format

  • VIDEO_FORMAT_JPG_FRAME_TYPE = 3: JPEG format

  • VIDEO_FORMAT_JPG_FILE_TYPE = 4: JPEG file format

  • VIDEO_FORMAT_JPG_VIDEO_FILE_TYPE = 5:

    • Individual Mode (isMixingEnabled=false): MPEG-4 video and JPEG files.
    • Mixing Mode (isMixingEnabled=true): MPEG-4 video file for combined streams and JPEG files for individual streams.
mixedVideoAudio

If you have set isMixingEnabled as true, this parameter allows you to mix audio and video in real time:

  • 0: (Default) Mix audio and video respectively.
  • 1: Mix audio and video in real time into an MP4 file. Supported limited players.
  • 2: Mix audio and video in real time into an MP4 file. Support more players.
streamType

This parameter takes effect only when the Agora Native SDK has enabled dual-stream mode (high stream by default).

  • 0: (Default) High stream
  • 1: Low stream
triggerMode

Choose to record automatically or manually.

  • 0: Automatically
  • 1: Manually. To start and stop recording, call startRecording and stopRecording respectively.
lang CPP_LANG or java
proxyserver You can set the parameter to record the content with the Intranet server. For details, please contact sales@agora.io.
audioProfile

Audio profile of the recording file.

  • AUDIO_PROFILE_DEFAULT = 0: (Default) Sampling rate of 48 kHz, communication encoding, mono.
  • AUDIO_PROFILE_MUSIC_HIGH_QUALITY = 4: Sampling rate of 48 kHz, music encoding, mono, and bitrate up to 128 Kbps.
  • AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO = 5: Sampling rate of 48 kHz, music encoding, stereo, and bitrate up to 192 Kbps.
defaultVideoBg The default background image of the video.
defaultUserBg The default background image of the user.
avSyncMode

Audio and video sync mode

  • UNKNOWN_AVSYNC = -1: Sync error.
  • AVSYNC_V0 = 0: Compatible with older versions.
  • AVSYNC_V1 = 1: New audio and video sync mode.
  • [1] The isAudioOnly and isVideoOnly parameters are disabled by default, and do not set isAudioOnly and isVideoOnly as true at the same time.
  • [2] Once the raw data is enabled, video mixing is not supported. The Web currently supports raw audio data but not raw video data.

Video Profile for the Communication Mode:

Resolution Frame Rate Minimum Bitrate Maximum Bitrate Recommended Bitrate
3840 × 2160 15 3000 9000 6000
2560 × 1440 15 1600 4800 3200
1920 × 1080 15 1000 3000 2000
1280 × 720 15 600 1800 1200
960 × 720 15 480 1440 960
848 × 480 15 300 900 600
640 × 480 15 250 750 500
480 × 480 15 200 600 400
640 × 360 15 200 600 400
360 × 360 15 130 390 260
424 × 240 15 110 330 220
320 × 240 15 90 270 180
240 × 240 15 70 210 140
320 × 180 15 70 210 140
240 × 180 15 60 180 120
180 × 180 15 50 150 100
160 × 120 15 30 90 60
120 × 120 15 25 75 50

Video Profile for the Live Broadcast Mode:

Resolution Frame Rate Minimum Bitrate Maximum Bitrate Recommended Bitrate
3840 × 2160 15 6000 18000 12000
2560 × 1440 15 3200 9600 6400
1920 × 1080 15 2000 6000 4000
1280 × 720 15 1200 3600 2400
960 × 720 15 960 2880 1920
848 × 480 15 600 1800 1200
640 × 480 15 500 1500 1000
480 × 480 15 400 1200 800
640 × 360 15 400 1200 800
360 × 360 15 260 780 520
424 × 240 15 220 660 440
320 × 240 15 180 540 360
240 × 240 15 140 420 280
320 × 180 15 140 420 280
240 × 180 15 120 360 240
180 × 180 15 100 300 200
160 × 120 15 60 180 120
120 × 120 15 50 150 100

Supported Players:

Platform Player/Explorer mixedVideoAudio=0 mixedVideoAudio=1
Linux Default Player Supported Supported
Linux VLC Media Player Supported Supported
Linux ffplay Supported Supported
Windows Media Player Supported Supported
Windows KMPlayer Supported Supported
Windows VLC Player Supported Supported
Windows Chrome (49.0.2623+) Supported Supported
macOS QuickTime Player Supported Supported
macOS Movist Supported Supported
macOS MPlayerX Supported Supported
macOS KMPlayer Not Supported Not Supported
macOS Chrome (47.0.2526.111+) Supported Supported
macOS Safari (11.0.3+) Supported Supported
iOS Default Player Supported Supported
iOS VLC Not Supported Supported
iOS KMPlayer Supported Supported
iOS Safari (9.0+) Supported Supported
Android Default Player Supported Supported
Android MXPlayer Supported Supported
Android VLC for Android Supported Supported
Android KMPlayer Supported Supported
Android Chrome (49.0.2623+) Supported Supported

Sets the Video Mixing Layout (setVideoMixingLayout)

This method sets the video mixing layout.

virtual int setVideoMixingLayout(const agora::linuxsdk::VideoMixingLayout &layout) = 0;

The structure of VideoMixingLayout:

 typedef struct VideoMixingLayout
 {
     struct Region {
       uid_t uid;
       double x;//[0,1]
       double y;//[0,1]
       double width;//[0,1]
       double height;//[0,1]
       int zOrder; //optional, [0, 100] //0 (default): bottom most, 100: top most

       //  Optional
       //  [0, 1.0] where 0 denotes throughly transparent, 1.0 opaque
       double alpha;

       int renderMode;//RENDER_MODE_HIDDEN: Crop, RENDER_MODE_FIT: Zoom to fit
       Region()
           :uid(0)
            , x(0)
            , y(0)
            , width(0)
            , height(0)
            , zOrder(0)
            , alpha(1.0)
            , renderMode(1)
      {}

   };
   int canvasWidth;
   int canvasHeight;
   const char* backgroundColor;//e.g. "#C0C0C0" in RGB
   uint32_t regionCount;
   const Region* regions;
   const char* appData;
   int appDataLength;
   VideoMixingLayout()
       :canvasWidth(0)
        , canvasHeight(0)
        , backgroundColor(NULL)
        , regionCount(0)
        , regions(NULL)
        , appData(NULL)
        , appDataLength(0)
   {}
} VideoMixingLayout;
Name Description
canvasWidth Width of the canvas (the display window or screen).
canvasHeight Height of the canvas (the display window or screen).
backgroundColor The background color of the canvas (the display window or screen) in RGB hex value.
regionCount The number of the hosts in the channel.
regions

The host list of VideoMixingLayout. Each host in the channel has a region to display the video on the screen with the following parameters to be set:

  • uid: User ID of the host displaying the video in the region.
  • x: Relative horizontal position of the top-left corner of the region. The value is in the range of [0.0,1.0].
  • y: Relative vertical position of the top-left corner of the region. The value is in the range of [0.0,1.0].
  • width: Relative width of the region. The value is in the range of [0.0,1.0].
  • height: Actual height of the region. The value is in the range of [0.0,1.0].
  • zOrder: The index of the layer. The value is in the range of [1,100]. 1 means the bottom layer, and 100 means the top layer.
  • alpha: The transparency of the image. The value is in the range of [0.0,1.0]. 0 means transparent, and 1 means opaque.
  • renderMode
    • RENDER_MODE_HIDDEN(1): Cropped
    • RENDER_MODE_FIT(2): Proportionate
appData User-defined data.
appDataLength The length of user-defined data.
Returns
  • 0: Success.
  • < 0: Failure.

Here is an example to show the position and size of the host’s head portrait. x, y, width and height are 0.5, 0.4, 0.2 and 0.3 respectively.

../_images/sei_overview.png

Allows the Application to Leave the Channel (leaveChannel)

This method allows the recording application to leave the channel and release the thread resources.

virtual int leaveChannel() = 0;
Returns
  • 0: Success.
  • < 0: Failure.

Releases the IRecordingEngine Object (release)

This method releases the IRecordingEngine object.

virtual int release() = 0;
Returns
  • 0: Success.
  • < 0: Failure.

Retrieves the Properties (getProperties)

This method allows you to retrieve the recording properties without joining a channel.

  • The recording properties only include the information of the path where the recording files are stored.
  • This method is different from onUserJoined. You must call onUserJoined after joining the channel.
virtual const RecordingEngineProperties* getProperties() = 0;

Starts the Recording (startService)

This method manually starts recording.

The method is only valid when you set triggermode to manually when joining the channel. For more information, see Allows an Application to Join a Channel (joinChannel) about triggerMode.

virtual int startService() = 0;
Returns
  • 0: Success.
  • < 0: Failure.

Stops the Recording (stopService)

This method manually stops recording.

The method is only valid when you set triggermode to manually when joining the channel. For more information, see Allows an Application to Join a Channel (joinChannel) about triggerMode.

virtual int stopService() = 0;
Returns
  • 0: Success.
  • < 0: Failure.

Sets the User Background Image (setUserBackground)

This method sets the background image for a specified user.

virtual int setUserBackground(uid_t uid, const char* img_path) = 0;
Name Description
uid The user ID of the user to set the background image.
image_path The path of the image file.
Returns
  • 0: Success.
  • < 0: Failure.

Sets the Log Level (setLogLevel)

virtual int setLogLevel(agora::linuxsdk::agora_log_level level) = 0;

This method sets the log level. Only log levels preceding the selected level are generated. The default value of level is 6.

Enables the Module Log (enableModuleLog)

virtual int enableModuleLog(uint32_t module, bool enable) = 0;

This method enables/disables generating logs for specified modules.

IRecordingEngineEventHandler Class

The IRecordingEngineEventHandler class provides the following callback functions for the recording engine:

An Error has Occurred During SDK Runtime (onError)

This callback function indicates that an error occurred during SDK runtime.

The SDK cannot fix the issue or resume running, which requires intervention from the application and informs the user on the issue.

virtual void onError(int error, agora::linuxsdk::STAT_CODE_TYPE stat_code) = 0;
Name Description
error

Error codes:

  • ERR_OK = 0: No error.
  • ERR_FAILED = 1: General error (no classified reason).
  • ERR_INVALID_ARGUMENT = 2: Invalid parameter called. For example, the specific channel name includes illegal characters.
  • ERR_NOT_READY = 3: The SDK module is not ready. Agora recommends the following methods to solve this error:
    • Check the state of the audio device.
    • Check the completeness of the App.
    • Try to re-initiate the SDK.
stat_code

State codes:

  • STAT_OK = 0: Everything is normal.
  • STAT_ERR_FROM_ENGINE = 1: Error from the engine.
  • STAT_ERR_ARS_JOIN_CHANNEL = 2: Failure to join the channel.
  • STAT_ERR_CREATE_PROCESS = 3: Failure to create a process.
  • STAT_ERR_MIXED_INVALID_VIDEO_PARAM = 4: Failure to mix video.
  • STAT_ERR_NULL_POINTER = 5: Null pointer.
  • STAT_ERR_PROXY_SERVER_INVALID_PARAM = 6: Invalid parameters of the proxy server.
  • STAT_POLL_ERR = 0x8: Error in polling.
  • STAT_POLL_HANG_UP = 0x10: Polling hangs up.
  • STAT_POLL_NVAL = 0x20: Invalid polling request.

A Warning has Occurred During SDK Runtime (onWarning)

This callback function indicates that some warning occurred during SDK runtime.

In most cases, the application can ignore the warnings reported by the SDK because the SDK can usually fix the issue and resume running.

virtual void onWarning(int warn) = 0;
Name Description
warn

Warning codes:

  • WARN_NO_AVAILABLE_CHANNEL = 103: No channel resources are available. Maybe because the server cannot allocate any channel resource.
  • WARN_LOOKUP_CHANNEL_TIMEOUT = 104: A timeout when looking up the channel. When joining a channel, the SDK looks up the specified channel. The warning usually occurs when the network condition is too poor to connect to the server.
  • WARN_LOOKUP_CHANNEL_REJECTED = 105: The server rejected the request to look up the channel. The server cannot process this request or the request is illegal.
  • WARN_OPEN_CHANNEL_TIMEOUT = 106: A timeout occurred when opening the channel. Once the specific channel is found, the SDK opens the channel. The warning usually occurs when the network condition is too poor to connect to the server.
  • WARN_OPEN_CHANNEL_REJECTED = 107: The server rejected the request to open the channel. The server cannot process this request or the request is illegal.

The User has Joined the Specified Channel (onJoinChannelSuccess)

This callback function indicates that the user has successfully joined the specified channel with an assigned Channel ID and user ID.

virtual void onJoinChannelSuccess(const char * channelId, uid_t uid) = 0;
Name Description
channelId Channel ID assigned based on the channel name specified in joinChannel.
uid User ID of the user.

The User has Left the Channel (onLeaveChannel)

This callback function indicates that the SDK has successfully left the channel.

virtual void onLeaveChannel(agora::linuxsdk::LEAVE_PATH_CODE code) = 0;
Name Description
code
Reason:
  • LEAVE_CODE_INIT(0): Initialization failure
  • LEAVE_CODE_SIG(1<<1): Signal triggered exit
  • LEAVE_CODE_NO_USERS(1<<2): There is no user in the channel except for the recording application.
  • LEAVE_CODE_TIMER_CATCH(1<<3): Timer catch exit
  • LEAVE_CODE_CLIENT_LEAVE(1<<4): The client leaves the channel.

A Remote User or a Host has Joined the Channel. (onUserJoined)

This callback function indicates that another user has joined the channel.

If other users are already in the channel, the SDK reports to the application on these users as well. The callback is called as many times as the number of users in the channel.

virtual void onUserJoined(uid_t uid, agora::linuxsdk::UserJoinInfos &infos) = 0;
Name Description
uid User ID of the user
infos Information about the user

The structure of UserJoinInfos is as follows:

typedef struct UserJoinInfos {
    const char* storageDir;
    //new attached info add below

    UserJoinInfos():
        storageDir(NULL)
    {}
}UserJoinInfos;
Name Description
storageDir Directory of the recorded files.

A User has Left the Channel or Gone Offline (onUserOffline)

This callback function notifies the application that a user has left the channel or gone offline.

The SDK reads the timeout data to determine if a user has left the channel (or has gone offline). If no data package is received from the user within 15 seconds, the SDK assumes the user is offline. A poor network connection may lead to false detections, so use signaling for reliable offline detection.

virtual void onUserOffline(uid_t uid, agora::linuxsdk::USER_OFFLINE_REASON_TYPE reason) = 0;
Name Description
uid User ID of the user
reason

Reason:

  • USER_OFFLINE_QUIT = 0: The user has quit the call.
  • USER_OFFLINE_DROPPED = 1: The SDK timed out and the user dropped offline because it has not received any data package for a period of time. If a user quits the call and the message is not passed to the SDK (due to an unreliable channel), the SDK assumes the user has dropped offline.
  • USER_OFFLINE_BECOME_AUDIENCE = 2: Triggered when the client role has changed from the host to the audience. The option is only valid when you set the channel profile as live broadcast when calling joinChannel.

The Raw Audio Data has Been Received (audioFrameReceived)

This callback function is triggered when raw audio data has been received.

virtual void audioFrameReceived(unsigned int uid, const agora::linuxsdk::AudioFrame *frame) const = 0;
Name Description
uid User ID of the user.
frame Received raw audio data in PCM or AAC format.

The structure of AudioFrame is as follows:

struct AudioFrame {
    AUDIO_FRAME_TYPE type;
    union {
        AudioPcmFrame *pcm;
        AudioAacFrame *aac;
    } frame;

    AudioFrame();
    ~AudioFrame();
    avsyncType avsync_type_;
    MEMORY_TYPE mType;
};

AudioPcmFrame

The structure of AudioPcmFrame is as follows:

class AudioPcmFrame {
    public:
    AudioPcmFrame(u64_t frame_ms, uint_t sample_rates, uint_t samples);
    ~AudioPcmFrame();
    public:
    u64_t frame_ms_;
    uint_t channels_; // 1
    uint_t sample_bits_; // 16
    uint_t sample_rates_; // 8k, 16k, 32k
    uint_t samples_;

    const uchar_t *pcmBuf_;
    uint_t pcmBufSize_;
};
Name Description
frame_ms Timestamp of the frame.
channels Number of audio channels.
sample_bits Bit number of the sampling data.
sample_rates Sampling rate.
samples Number of samples of the frame.
pcmBuf Audio frame buffer.
pcmBufSize Size of the audio frame buffer.

AudioAacFrame

The structure of AudioAacFrame is as follows:

class AudioAacFrame {
    public:
    explicit AudioAacFrame(u64_t frame_ms);
    ~AudioAacFrame();

    const uchar_t *aacBuf_;
    u64_t frame_ms_;
    uint_t aacBufSize_;

};
Name Description
frame_ms Timestamp of the frame
aacBuf Audio frame buffer
aacBufSize Size of the audio frame buffer

The Raw Video Data has Been Received (videoFrameReceived)

This callback function is triggered when the raw video data has been received.

Callbacks are available for every frame of the video and this callback function can be used to detect sexually explicit content, if necessary.

Agora recommends capturing the i frame only and neglecting the others.

virtual void videoFrameReceived(unsigned int uid, const agora::linuxsdk::VideoFrame *frame) const = 0;

The structure of VideoFrame is as follows:

struct VideoFrame {
    VIDEO_FRAME_TYPE type;
    union {
        VideoYuvFrame *yuv;
        VideoH264Frame *h264;
        VideoJpgFrame *jpg;
    } frame;

    int rotation_; // 0, 90, 180, 270
    VideoFrame();
    ~VideoFrame();

    MEMORY_TYPE mType;
};

VideoYuvFrame

The structure of VideoYuvFrame is as follows:

class VideoYuvFrame {
    public:
    VideoYuvFrame(u64_t frame_ms, uint_t width, uint_t height, uint_t ystride,
            uint_t ustride, uint_t vstride);
    ~VideoYuvFrame();

    u64_t frame_ms_;

    const uchar_t *ybuf_;
    const uchar_t *ubuf_;
    const uchar_t *vbuf_;

    uint_t width_;
    uint_t height_;

    uint_t ystride_;
    uint_t ustride_;
    uint_t vstride_;

    //all
    const uchar_t *buf_;
    uint_t bufSize_;
};
Name Description
frame_ms Timestamp of the frame.
ybuf Y buffer pointer.
ubuf U buffer pointer.
vbuf V buffer pointer.
width Width of the video in pixel.
height Height of the video in pixel.
ystride Line span of the Y buffer.
ustride Line span of the U buffer.
vstride Line span of the V buffer.
buf Video frame buffer.
bufSize Size of the video frame buffer.

VideoH264Frame

The structure of VideoH264Frame is as follows:

struct VideoH264Frame {
    public:
    VideoH264Frame():
        frame_ms_(0),
        frame_num_(0),
        buf_(NULL),
        bufSize_(0)
    {}

    ~VideoH264Frame(){}
    u64_t frame_ms_;
    uint_t frame_num_;

    //all
    const uchar_t *buf_;
    uint_t bufSize_;
};
Name Description
frame_ms Timestamp of the frame.
frame_num Index of the frame.
buf Video frame buffer.
bufSize Size of the video frame buffer.

VideoJpgFrame

The structure of VideoJpgFrame is as follows:

struct VideoJpgFrame {
    public:
    VideoJpgFrame():
        frame_ms_(0),
        buf_(NULL),
        bufSize_(0){}

   ~VideoJpgFrame() {}
    u64_t frame_ms_;

    //all
    const uchar_t *buf_;
    uint_t bufSize_;
};
Name Description
frame_ms Timestamp of the frame.
buf Video frame buffer.
bufSize Size of the video frame buffer.

The User who is Speaking in the Channel (onActiveSpeaker)

virtual void onActiveSpeaker(uid_t uid);

This callback function returns the user ID of the active speaker.

Name Description
uid The user ID of the active speaker.

Error Codes and Warning Codes

See Error Codes and Warning Codes.