This topic describes the AliRtcEngine operation of the Linux SDK for C++.

Contents

Basic methods

API Description Supported earliest version
CreateAliRTCEngine Create an AliRTCEngine instance. 1.18.1
Release Release the AliRTCEngine instance. 1.18.1
GetEventHandler Gets the event callback handle. 1.18.1

Channel-related interfaces

API Description Supported earliest version
JoinChannel Join the channel. 1.18.1
LeaveChannel Off the channel. 1.18.1

Publish related interfaces

API Description Supported earliest version
SetVideoProfile Set video stream ingest parameters. 1.18.1
GetVideoProfile Obtain the stream ingest parameters of a video stream. 1.18.1
ConfigLocalCameraPublish Specify whether to allow pushing camera streams. 1.18.1
IsLocalCameraPublishEnabled Queries whether to allow pushing camera streams. 1.18.1
ConfigLocalScreenPublish Specify whether to allow push screen streams. 1.18.1
IsLocalScreenPublishEnabled Queries whether push screen streams are allowed. 1.18.1
ConfigLocalAudioPublish Specifies whether to allow pushing audio streams. 1.18.1
IsLocalAudioPublishEnabled Queries whether push audio streams are allowed. 1.18.1
ConfigLocalSimulcast Specifies whether to allow the push of minor video streams. 1.18.1
IsLocalSimulcastEnabled You can call this operation to query whether minor video streams are allowed to be pushed. 1.18.1
Publish Manually push video and audio streams. 1.18.1

Recording-related interfaces

API Description Supported earliest version
StartRecording Manually enable recording. 1.18.1
StopRecording Manually stop recording. 1.18.1

Video-related methods

API Description Supported earliest version
SetExternalVideoSource Specifies whether to enable an external video input source. 1.18.1
PushExternalVideoFrame Enter external video data. 1.18.1
AddVideoWatermark Add a watermark. 1.18.11
ClearVideoWatermark Clears the watermark information of the corresponding data stream. 1.18.11

Audio-related methods

API Description Supported earliest version
SetExternalAudioSource Specifies whether to enable external audio input ingest. 1.18.1
PushExternalAudioFrameRawData Inputting external audio data into streams. 1.18.1
SetExternalAudioPublishVolume Set the volume of the external input audio ingest mix. 1.18.1
GetExternalAudioPublishVolume Gets the volume of the external input audio ingest mix. 1.18.1
setAudioChannels Sets the streaming mode of the audio. 1.18.12

Media player-related interfaces

API Description Supported earliest version
CreateMediaPlayer Create a media player. 1.18.1
DestroyMediaPlayer Destroy the media player. 1.18.1
SetEventHandler Set player status and event callback notifications. 1.18.1
GetEventHandler Gets the player status and event callback handles. 1.18.1
LoadResource Loads playback resources. 1.18.1
Start Start the playback. 1.18.1
Stop Stop the playback. 1.18.1
Pause Pause the playback. 1.18.1
Resume Resume playback. 1.18.1
SeekTo Jump to play. 1.18.1
SetVolume Sets the volume of the player (affects the volume of the stream). 1.18.1
SetVideoSource Specifies whether the video data of the player is ingested. 1.18.1
EnableAudioSource Specifies whether the audio data of the player is ingested. 1.18.1
GetDuration Gets the total duration of playback. 1.18.1
GetCurrentPlaybackTime Gets the current playback position. 1.18.1
GetCurrentVomume Gets the current playback volume. 1.18.1
GetCurrentPlaybackState Gets the current playback status. 1.18.1
GetIndex Obtains the current player ID. 1.18.1

Details

  • CreateAliRTCEngine: creates an AliRTCEngine instance.
    AliRTCEngineInterface * CreateAliRTCEngine(EngineEventHandlerInterface * eventHandler,
                               int lowPort,
                               int highPort,
                               const char * logPath,
                               const char * coreServicePath);
                            
    Parameter Type Description
    eventHandler EngineEventHandlerInterface * The event triggered by the recording SDK is notified by using the EngineEventHandlerInterface class callback.
    lowPort int The smallest available port.
    Note To create an SDK instance, you need to occupy one system port for audio and video Data Transmission Service. We recommend that you set the port range to 42000 to 45000 and ensure that other services do not occupy ports in this range.
    highPort int The largest available port.
    Note To create an SDK instance, you need to occupy one system port for audio and video Data Transmission Service. We recommend that you set the port range to 42000 to 45000 and ensure that other services do not occupy ports in this range.
    logPath const char * The path where logs are saved.
    coreServicePath const char * AliRtcCoreService the absolute path where the executable program is stored.
  • Release: releases the AliRTCEngine instance.
    void Release();
  • GetEventHandler: obtains the event callback handle.
    EngineEventHandlerInterface * GetEventHandler();
  • JoinChannel: joins a channel.
    int JoinChannel(const AuthInfo &authInfo, const JoinChannelConfig &config);
    Parameter Type Description
    authInfo const AuthInfo &a The authentication information is obtained from App Server.
    config const JoinChannelConfig & Specifies the settings items when joining the channel.
  • LeaveChannel: Leave the channel.
    int LeaveChannel();
  • SetVideoProfile: Set video stream ingest parameters.
    Note The settings will not take effect until the next stream ingest.
    void SetVideoProfile(AliRTCSdk::Linux::VideoProfile profile, AliRTCSdk::Linux::VideoTrack track);
    Parameter Type Description
    profile AliRTCSdk::Linux::VideoProfile The predefined video resolution and frame rate. For more information, see VideoProfile.
    track AliRTCSdk::Linux::VideoTrack The type of the video stream. For more information, see VideoTrack.
  • GetVideoProfile: Obtain the stream ingest parameters of the video stream.
    Note The video resolution and frame rate that are in use (already in stream ingest) or will be used soon (the next stream ingest will take effect) are returned. For more information, see VideoProfile. The return value is not necessarily the VideoProfile being used, and VideoTrackScreen is not supported.
    AliRTCSdk::Linux::VideoProfile GetVideoProfile(AliRTCSdk::Linux::VideoTrack track);
    Parameter Type Description
    track AliRTCSdk::Linux:VideoTrack The type of the video stream. For more information, see VideoTrack.
  • ConfigLocalCameraPublish: Specify whether to allow pushing camera streams.
    Note You need to call the Publish operation to take effect. By default, camera stream ingestion is allowed.
    void ConfigLocalCameraPublish(bool enable);
    Parameter Type Description
    enable bool Specifies whether to allow the push camera stream. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • IsLocalCameraPublishEnabled: queries whether to allow pushing camera streams.
    bool IsLocalCameraPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • ConfigLocalScreenPublish: specifies whether to allow push screen streams.
    Note You need to call the Publish operation to take effect. By default, screen stream ingestion is not allowed.
    void ConfigLocalScreenPublish(bool enable);
    Parameter Type Description
    enable bool Specifies whether to allow push screen streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • IsLocalScreenPublishEnabled: queries whether push screen streams are allowed.
    bool IsLocalScreenPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • ConfigLocalAudioPublish: specifies whether to allow audio streams to be pushed.
    Note You need to call the Publish operation to take effect. By default, audio ingestion is allowed.
    void ConfigLocalAudioPublish(bool enable);
    Parameter Type Description
    enable bool Specifies whether to allow small streams of audio streams to be pushed. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • IsLocalAudioPublishEnabled: queries whether to allow small audio streams to be pushed.
    bool IsLocalAudioPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • ConfigLocalSimulcast: specifies whether to allow small streams of secondary video streams to be pushed.
    Note You need to call the Publish operation to take effect. By default, the push of secondary video streams is allowed. Currently, only camera streaming is supported. Screen streaming is not supported.
    int ConfigLocalSimulcast(bool enabled, AliRTCSdk::Linux::VideoTrack track);
    Parameter Type Description
    enabled bool Specifies whether to allow the push of minor video streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    track AliRTCSdk::Linux::VideoTrack The type of the video stream. For more information, see VideoTrack.
  • IsLocalSimulcastEnabled: queries whether small streams of secondary video streams are allowed to be pushed.
    bool IsLocalSimulcastEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • Publish: manually pushes video and audio streams.
    Note The streams to be pushed are set through API ConfigLocalAudioPublish, ConfigLocalCameraPublish, and ConfigLocalScreenPublish.
    int Publish();
  • StartRecording: manually enables recording.
    Note If you need to manually configure all ingest and pull streams, you must JoinChannelConfig the fields and select RecordingManually when JoinChannel.
    int StartRecording();
  • StopRecording: manually stops recording.
    int StopRecording();
  • SetExternalVideoSource: specifies whether to enable an external video input source.
    Note Use the PushExternalVideoFrame port to enter video data when enabled.
    int SetExternalVideoSource(bool enable, bool useTexture, AliRTCSdk::Linux::VideoSource sourceType, AliRTCSdk::Linux::RenderMode renderMode = AliRTCSdk::Linux::RenderModeFill);
    Parameter Type Description
    enabled bool Specifies whether to enable an external video input source. Valid values:
    • true: The alert rule is enabled.
    • false: disables the trigger.
    useTexture bool Specifies whether to use the texture mode. Currently, only false is supported.
    sourceType AliRTCSdk::Linux::VideoSource The type of the streams to query.
  • PushExternalVideoFrame: Enter external video data.
    Note Currently, the input video type only supports I420.
    int PushExternalVideoFrame(AliRTCSdk::Linux::VideoDataSample *frame, AliRTCSdk::Linux::VideoSource sourceType);
    Parameter Type Description
    frame AliRTCSdk::Linux::VideoDataSample * Frame data.
    sourceType AliRTCSdk::Linux::VideoSource The type of the streams to query.
  • AddVideoWatermark: Add a watermark.
    /**
     * @brief Add a watermark through the local file path.
     * @param sourceType The type of the video stream to which the watermark is added.
     * @ The path of the param image_url watermark image. Only the local path is supported.
     * @param options Watermark configuration
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this operation only indicates whether the operation is called successfully and whether the actual watermark is added successfully is returned by the callback function.
     */
    int AddVideoWatermark(AliRTCSdk::Linux::VideoSource sourceType,
                                  const char* image_url,
                                  const AliRTCSdk::Linux::WaterMarkConfig & options);
    /**
     * @brief Add a watermark by using the image memory address.
     * @param sourceType The type of the video stream to which the watermark is added.
     * @param imageData The memory address of the watermark image.
     * @param imageLength The length of the watermark.
     * @param options Watermark configuration
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this operation only indicates whether the operation is called successfully and whether the actual watermark is added successfully is returned by the callback function.
     */
    int AddVideoWatermark(AliRTCSdk::Linux::VideoSource sourceType,
                                  const uint8_t* imageData,
                                  const int32_t imageLength,
                                const AliRTCSdk::Linux::WaterMarkConfig & options);
  • ClearVideoWatermark: clears the watermark information of the corresponding data stream.
    /**
     * @brief Clears the watermark of the corresponding data stream.
     * @param sourceType The type of the video stream for which the watermark is cleared.
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this interface only indicates whether the call is successful and whether the actual watermark is cleared is returned by the callback function.
     */
    virtual int ClearVideoWatermark(AliRTCSdk::Linux::VideoSource sourceType);
  • SetExternalAudioSource: specifies whether to enable external audio input ingest.
    Note Set the input audio ingest volume by SetExternalAudioPublishVolume.
    int SetExternalAudioSource(bool enable, unsigned int sampleRate,  unsigned int channelsPerFrame);
    Parameter Type Description
    enable bool Specifies whether to enable external audio input ingest. Valid values:
    • true: The alert rule is enabled.
    • false: disables the trigger.
    sampleRate unsigned int The sampling rate.
    channelsPerFrame unsigned int The sampling rate.
    Return result

    If the return value is greater than or equal to 0, the setting is successful. If the return value is less than 0, the setting fails.

  • PushExternalAudioFrameRawData: Enter external audio data to ingest streams.
    Note If the return value is ERR_AUDIO_BUFFER_FULL, you need to retry the delivery again after the length of time the data is delivered at the interval.
    int PushExternalAudioFrameRawData(const void* audioSamples, unsigned int sampleLength, long long timestamp);
    Parameter Type Description
    audioSamples const void* The audio data.
    sampleLength unsigned int The length of the audio data.
    timestamp long long Timestamp.
    Return result

    If the return value is greater than or equal to 0, the setting is successful. If the return value is less than 0, the setting fails.

  • SetExternalAudioPublishVolume: Set the volume of the external input audio ingest and mixing.
    int SetExternalAudioPublishVolume(int volume);
    Parameter Type Description
    volume int The volume. Valid values: 0 to 100.
  • GetExternalAudioPublishVolume: obtains the volume of the external input audio ingest stream mixing.
    int GetExternalAudioPublishVolume();
  • setAudioChannels: sets the streaming mode of the audio.
    int SetAudioChannels(AliRTCSdk::Linux::ExpectedAudioType type);

    Parameter description

    Parameter Type Description
    type AliRTCSdk::Linux::ExpectedAudioType The number of sound channels.

    Return result

    If a value of 0 is returned, the call is successful. If a value of -1 is returned, the call fails.

  • CreateMediaPlayer: Create a media player.
    AliRTCMediaPlayerInterface * CreateMediaPlayer();
  • DestroyMediaPlayer: Destroy the media player.
    int DestroyMediaPlayer(AliRTCMediaPlayerInterface *mediaPlayer);
  • SetEventHandler: sets player status and event callback notifications. If 0 is returned, it indicates success, and others indicate failure.
    int SetEventHandler(AliRTCMediaPlayerEventHandlerInterface *eventHandler);
    Parameter Type Description
    eventHandler AliRTCMediaPlayerEventHandlerInterface * Player status and event callback handles.
    Return result

    If 0 is returned, the setting is successful. Others indicate that the setting fails.

  • GetEventHandler: takes the player status and event callback handle.
    AliRTCMediaPlayerEventHandlerInterface *GetEventHandler();
  • LoadResource: Loads playback resources. The success of truly loading resources needs to be determined by the state in the OnStateChange callback interface.
    int LoadResource(const char *path);
    Parameter Type Description
    path const char * The address of the playback resource. Currently, local absolute paths and online addresses are supported.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • Start: The playback starts.
    Note This operation can be called only after the player status changes to MediaPlayerStatePrepared.
    int Start();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • Stop: The playback is stopped.
    int Stop();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • Pause: The playback is paused.
    int Pause();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • Resume: The playback is resumed.
    int Resume();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • SeekTo: redirects to playback.
    int SeekTo(unsigned long long millisecond);
    Parameter Type Description
    millisecond unsigned long long The playback position to which you are redirected. Unit: milliseconds.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • SetVolume: sets the volume of the player (which affects the volume of ingested streams).
    int SetVolume(int volume);
    Parameter Type Description
    volume int The volume. Valid values: 0 to 100.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • SetVideoSource: specifies whether the video data of the player is ingested.
    int SetVideoSource(bool enable, AliRTCSdk::Linux::VideoSource sourceType, AliRTCSdk::Linux::RenderMode renderMode);
    Parameter Type Description
    enable bool Specifies whether to ingest streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    sourceType AliRTCSdk::Linux::VideoSource Select a video source to ingest streams.
    renderMode AliRTCSdk::Linux::RenderMode The zoom mode of the video source.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • EnableAudioSource: specifies whether the audio data of the player is ingested.
    int EnableAudioSource(bool enable);
    Parameter Type Description
    enable bool Specifies whether to ingest streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • GetDuration: obtains the total playback duration.
    Note You need to wait until the status of the player is MediaPlayerStatePrepared to obtain the exact duration.
    unsigned long long GetDuration();
  • GetCurrentPlaybackTime: obtains the current playback position.
    Note You need to wait until the player's status is MediaPlayerStatePrepared to get the exact current location.
    unsigned long long GetCurrentPlaybackTime();
  • GetCurrentVomume: obtains the current playback volume.
    Note You need to wait until the player's status is MediaPlayerStatePrepared to get the exact current volume.
    int GetCurrentVomume();
  • GetCurrentPlaybackState: obtains the current playback status.
    AliRTCSdk::Linux::MediaPlayerState GetCurrentPlaybackState();
  • GetIndex: obtains the current player ID.
    Note You can create multiple players at the same time. This interface can be used to distinguish each player.
    int GetIndex();