On-Premises Recording
  • Linux : C++
  • Overview
  • SDK Downloads
  • Sample Codes
  • Quick Starts
  • Performance Data
  • API Documents

Individual Stream Recording

Last updated:2021-11-16 17:49

ZEGO no longer classifies environments into production environments and testing environments.

If you create your project in ZEGO Admin Console on/before 2021-11-16, refer to the Testing environment deprecation to upgrade the SDK and adjust related codes.

1 Features

The On-Premises-Recording SDK supports recording an individual stream (Including audio and video) in the room. After integrating the SDK, you can start to use the Individual-Stream-Recording function.

2 Detailed Operation

2.1 Set the Listenner of Callback.

Before initialization, you need to inherit the interface named 'icallback' and set the listenner of the callback.

  • Interface Prototype:

    ZEGO_API bool SetCallback(ICallback* pCB)

  • Parameter:

    pCB:Pointer to the object of callback.

  • Note:

    Before initializing the SDK, you can call the following interfaces as needed:

    SetLogDirAndSize Set the path and size of the log file

2.2 Initialize SDK

Use the obtained AppID and AppSign of ZEGO to initialize the SDK. If the SDK is not initialized, the related interface will be abnormal.If you have no AppID and AppSign, please apply in ZEGO Admin Console; You can refer to User Manual for help.

  • Interface Prototype:

    ZEGO_API bool InitSDK(unsigned int uiAppID, unsigned char* pBufAppSignature, int nSignatureSize)

  • Parameters:

    uiAppID:The digital ID obtained from ZEGO, it is unique for each developer.

    pBufAppSignature:The Signature obtained from ZEGO, it is used to verify the validity of the your appid.

    nSignatureSize:Size of the Signature (byte).

  • Asynchronous Callback Interface:

    class ICallback
        virtual void OnInitSDK(int errorCode) {}

    errorCode == 0 # Initialization succeeded.

2.3 Login Room

When initialize successfully, you also need to login the room before recording.

  • Interface Prototype:

    ZEGO_API bool LoginRoom(const char* pszRoomID)

  • Parameters:

    pszRoomID:Room ID, for the Room with a pushing-stream.

  • Asynchronous Callback Interface:

    class ICallback
        virtual void OnLoginRoom(int errorCode, const char *pszRoomID) = 0;

2.4 Start Recording

  1. Before you call the interface, the SDK must be initialized successfully.
  2. It is recommended to start recording according to the stream-add information, which you can get from the stream information update callback OnStreamUpdate After login the room.
  3. You can get the maximum number of simultaneous recording stream that the SDK allows, by calling the interface GetMaxRecordCount.
  • Interface Prototype:

    ZEGO_API bool StartRecordSingleStream(const char* pszStreamID, const char *pszPathAndName, MuxerStreamType nMuxerStreamType = MuxerStreamTypeBoth, int nFragmentSeconds = 2)

  • Parameters:

    pszStreamID: Stream ID to be recorded.

    pszPathAndName:The full path of the recording file (including the file name) must end with ". MP4". SDK will create the path automatically. If there is a file with the same name, the original one will be overwritten directly.

nMuxerStreamType:The type of recording stream, please refer to MuxerStreamType, By default, audio and video will be recorded at the same time.

nFragmentSeconds:The Fragmentation interval of the recorded file (0~10s), 0 means no fragmentation, >0 means fragmentation interval; the default interval is 2s. When problems such as abnormal interruption happen during the recording process, Fragmentation can ensure that the recording file already saved work well; Note that the Fragmentation here is a logical concept for SDK's internal processing of recording files, rather than dividing the recorded files into multiple small files according to the interval time.

  • Asynchronous Callback Interface:

    class ICallback
        virtual void OnStreamRecordBegin(const char* pszStreamID, const char *pszPathAndName) = 0;

    When the recording starts successfully, you will receive a callback named OnStreamRecordBegin.

2.5 Stop Recording

  • Interface Prototype:

    ZEGO_API bool StopRecordSingleStream(const char* pszStreamID)

  • Parameters:

    pszStreamID:Stream ID。

  • Asynchronous Callback Interface:

    class ICallback
        virtual void OnStreamRecordEnd(const char* pszStreamID, const char *pszPathAndName, RecordEndReason reason) = 0;
  • Notes:

    When recording is no longer needed, it is recommended to do the following:

    1. Call the interface LogoutRoom to logout the room.
    2. Call the interface LIVEROOM::SetCallback(nullptr); to Remove the callback listener.
    3. Call the interface UnInitSDK to deinitialization the SDK。

3 API Reference

Interface Description
SetCallback Set the callback listener
InitSDK Initialize SDK
LoginRoom Login Room
GetMaxRecordCount Get the maximum number of simultaneous recording stream that the SDK allows
StartRecordSingleStream Start individual stream recording
StopRecordSingleStream Stop individual stream recording
SetMuxerOutType Set recording data output type.
SetLogDirAndSize Set the path and size of the log file, size for a single log.
SetConfig Set configuration
SetMuxerCacheSize Set the cache size before the file is created.(64KB~1MB)
GetSDKVersion Get the SDK version
UploadLog Upload log file to ZEGO Server.
UnInitSDK Deinitialization the SDK
LogoutRoom Logout the room