Individual Stream Recording
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.
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
Initialize SDK
Call the InitSDK interface to initialize the SDK, and pass the applied AppID into the parameter "uiAppID".
- Request Method and Endpoint:
ZEGO_API bool InitSDK(unsigned int uiAppID)
- parameter:
uiAppID
: The digital ID distributed by ZEGO, the unique identifier of each developer.
- Asynchronous callback interface:
class ICallback
{
public:
virtual void OnInitSDK(int errorCode) {}
}
errorCode == 0 means the initialization was successful.
Set token
Call the SetCustomToken interface to pass the Token into the SDK before logging in to the room.
- Request Method and Endpoint:
ZEGO_API void SetCustomToken(const char *thirdPartyToken)
- parameter:
thirdPartyToken
: Authentication Token.
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 { public: virtual void OnLoginRoom(int errorCode, const char *pszRoomID) = 0; }
Start Recording
- Before you call the interface, the SDK must be initialized successfully.
- 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.- 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 { public: virtual void OnStreamRecordBegin(const char* pszStreamID, const char *pszPathAndName) = 0; }
When the recording starts successfully, you will receive a callback named OnStreamRecordBegin.
Stop Recording
Interface Prototype:
ZEGO_API bool StopRecordSingleStream(const char* pszStreamID)
Parameters:
pszStreamID
:Stream ID。Asynchronous Callback Interface:
class ICallback { public: 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:
- Call the interface
LogoutRoom
to logout the room. - Call the interface
LIVEROOM::SetCallback(nullptr);
to Remove the callback listener. - Call the interface
UnInitSDK
to deinitialization the SDK。
- Call the interface