This topic describes the IAliRtcEngine interface of the Unity SDK.

Contents

Basic methods

API Description Supported earliest version
SetH5CompatibleMode Set the H5 compatibility mode. 1.15
GetH5CompatibleMode Check whether H5 is currently compatible. 1.15
GetEngine Create an IAliRtcEngine instance (only one instance exists at the same time). 1.15
QueryEngine Queries an IAliRtcEngine instance. 1.15
Destroy Destroy the SDK. 1.15

Channel-related interfaces

API Description Supported earliest version
SetAutoPublish Specify whether to automatically publish and subscribe. 1.15
JoinChannel Join the channel. 1.15
LeaveChannel Off the channel. 1.15
IsInCall Check whether you are currently in the channel. 1.15
SetChannelProfile Set the channel mode. 1.15

Publish related interfaces

API Description Supported earliest version
IsAutoPublish You can call this operation to query whether the automatic publishing mode is current. 1.15
ConfigLocalCameraPublish Specify whether to allow the camera stream to be published. 1.15
IsLocalCameraPublishEnabled Queries whether the camera stream is currently allowed to be published. 1.15
ConfigLocalScreenPublish Specify whether to allow publishing screen streams (Mac, Windows only). 1.15
IsLocalScreenPublishEnabled Queries whether publishing screen streams are currently allowed (Mac, Windows only). 1.15
ConfigLocalAudioPublish Specify whether to allow the audio stream to be published. 1.15
IsLocalAudioPublishEnabled Queries whether the current audio stream is allowed to be published. 1.15
ConfigLocalSimulcast Specifies whether to allow secondary video streams to be published. 1.15
IsLocalSimulcastEnabled Queries whether secondary video streams are currently allowed to be published. 1.15
Publish Manually publish video and audio streams. 1.15

Subscription-related interfaces

API Description Supported earliest version
IsAutoSubscribe Query whether the current subscription mode is automatic. 1.15
ConfigRemoteCameraTrack Specifies whether to subscribe to the remote camera stream. 1.15
ConfigRemoteScreenTrack Specifies whether to subscribe to a remote screen stream. 1.15
ConfigRemoteAudio Specifies whether to subscribe to remote audio streams. 1.15
Subscribe Manually subscribe to video and audio streams. 1.15

Video-related methods

API Description Supported earliest version
SetVideoProfile Set parameters for the video stream. 1.15
GenerateTexture Generate rendered textures (iOS and Android only). 1.15
SetTexture Set the texture (iOS and Android only). 1.15
RemoveTexture Remove the rendered texture (iOS, Android only). 1.15
ConfigExternalVideoRendering Set external rendering (Mac, Windows only). 1.15
GetVideoRenderData Get video data (Mac, Windows only). 1.15
SetLocalViewConfig Set up an image for local preview (Mac, Windows only). 1.15
MuteLocalCamera Specify whether to stop publishing local video streams. 1.15
GetCameraList Gets the list of cameras (Mac, Windows only). 1.15
GetCurrentCamera Gets the name of the camera currently in use (Mac, Windows only). 1.15
SetCurrentCamera Select the camera (Mac, Windows only). 1.15
SwitchCamera Switch the front and rear cameras (iOS and Android only). 1.15
SetCameraZoom Set camera parameters (iOS and Android only). 1.15
IsCameraOn Check whether the camera is turned on (iOS and Android only). 1.15
IsCameraFocusPointSupported Whether the camera supports manual focus (iOS and Android only). 1.15
IsCameraExposurePointSupported Specifies whether the camera supports setting the exposure area (iOS and Android only). 1.15
SetCameraFocusPoint Set the camera to focus manually (iOS and Android only). 1.15
SetCameraExposurePoint Set the camera exposure point (iOS and Android only). 1.15

Audio-related methods

API Description Supported earliest version
SetAudioOnlyMode Specifies whether to set this parameter to audio-only mode or audio-video mode. 1.15
IsAudioOnly Query whether the current audio-only mode is displayed. 1.15
MuteLocalMic Specify whether to stop publishing local audio. 1.15
MuteRemoteAudioPlaying Specifies whether to stop playing remote audio streams. 1.15
EnableSpeakerphone Toggle handset, speaker output (iOS, Android only). 1.15
GetAudioCaptures Gets a list of audio capture devices (Mac, Windows only). 1.15
GetCurrentAudioCapture Gets the currently used audio capture device name (Mac, Windows only). 1.15
SetCurrentAudioCapture Select an audio capture device (Mac, Windows only). 1.15
GetAudioRenderers Gets a list of audio playback devices (Mac, Windows only). 1.15
GetCurrentAudioRenderer Gets the audio playback device currently in use (Mac, Windows only). 1.15
SetCurrentAudioRenderer Select an audio playback device (Mac, Windows only). 1.15
StartAudioPlayer Enable audio playback. 1.15
StopAudioPlayer Disables audio playback. 1.15

Preview Port

API Description Supported earliest version
StartPreview Start local preview. 1.15
StopPreview Stop local preview. 1.15

Remote user query interface

API Description Supported earliest version
GetOnlineRemoteUsers Obtains the list of remote online users. 1.15

Other operations

API Description Supported earliest version
SetLogLevel Configures the log level. 1.15
GetSdkVersion Obtain the SDK version number. 1.15
SetClientRole Specify a user role. 1.15

Details

  • SetH5CompatibleMode: checks whether the system is compatible with H5.

    You need to call this operation before creating an AliRtcEngine instance.

    public static void SetH5CompatibleMode(bool comp);
    Parameter Type Description
    comp bool YES is compatible with H5 and NO is incompatible with H5.
  • GetH5CompatibleMode: checks whether the system is compatible with H5.

    You need to call this operation before creating an AliRtcEngine instance.

     public static bool GetH5CompatibleMode();
    Return result

    If true is returned, H5 is compatible. If false is returned, H5 is incompatible.

  • GetEngine: creates an AliRtcEngine instance.

     public static IAliRtcEngine GetEngine(string extras);
    Parameter Type Description
    extras string The SDK initialization configuration. Currently, use @ ".
  • QueryEngine: queries AliRtcEngine instances.

     public static IAliRtcEngine QueryEngine();
  • Destroy: destroys the AliRtcEngine instance.

     public static void Destroy();
  • SetAutoPublish: specifies whether to automatically publish and subscribe. The default is automatic publishing and subscription, which you must set before you join the channel.

    public void SetAutoPublish(bool autoPub, bool autoSub);
    Parameter Type Description
    autoPub bool true indicates automatic publishing. false indicates manual publishing.
    autoSub bool true indicates automatic subscription. false indicates manual subscription.
  • JoinChannel: joins a channel.

    After you join a channel, you must call LeaveChannel to leave the current channel. If you fail to join a channel, you do not need to call LeaveChannel to try again.

    public void JoinChannel(AliRTCAuthInfo authInfo, string userName);
    Parameter Type Description
    authInfo AliRTCAuthInfo The authentication information is sent from the AppServer, which is obtained by using the API.
    userName string The display name of the user, not the user ID.
  • LeaveChannel: Leave the channel.

    public void LeaveChannel();
  • IsInCall: Check whether you are currently in the channel.

    public bool IsInCall();
    Return result

    Returns true to indicate that it is in the channel, and false to indicate that it is not in the channel.

  • SetChannelProfile: Set the channel mode.

    Note You can only call before joining the channel. You cannot reset it in a meeting. You can reset it after leaving the channel.
    public void SetChannelProfile(int profile);
    Parameter Type Description
    profile int The type of the channel mode.
  • IsAutoPublish: queries whether the current mode is automatic publishing.

    public bool IsAutoPublish();
    Return result

    If true is returned, automatic publishing is performed. If false is performed, manual publishing is performed.

  • ConfigLocalCameraPublish: specifies whether to allow the camera stream to be published. By default, it is allowed to publish the camera stream. If you manually publish the camera stream, you need to call Publish to take effect.

    public void ConfigLocalCameraPublish(bool enable);
    Parameter Type Description
    enable bool true is allowed to publish the camera stream, false is not allowed.
  • IsLocalCameraPublishEnabled: queries whether the camera stream is currently allowed to be published.

    public bool IsLocalCameraPublishEnabled();
    Return result

    If true is returned, it is allowed. If false is returned, it is not allowed.

  • ConfigLocalScreenPublish (available only for Mac and Windows): Specify whether to allow publishing screen streams. By default, it is not allowed to publish screen streams. If you manually publish a screen stream, you need to call Publish to take effect.

    public void ConfigLocalScreenPublish(bool enable);
    Parameter Type Description
    enable bool true is allowed to publish screen streams, and false is not allowed to publish screen streams.
  • IsLocalScreenPublishEnabled (available only for Mac and Windows): Queries whether publishing screen streams is currently allowed.

    public bool IsLocalScreenPublishEnabled();
    Return result

    If true is returned, it is allowed. If false is returned, it is not allowed.

  • ConfigLocalAudioPublish: specifies whether to allow audio streams to be published. The default value is allowed to publish audio streams. If you manually publish audio streams, you need to call Publish to take effect.

    public void ConfigLocalAudioPublish(bool enable);
    Parameter Type Description
    enable bool true is allowed to publish audio streams, false is not allowed.
  • IsLocalAudioPublishEnabled: queries whether the current audio stream is allowed to be published.

    public void ConfigLocalSimulcast(bool enable, int track);
    Parameter Type Description
    enabled bool true indicates that secondary streams are allowed to be published. false indicates that secondary streams are not allowed.
    track AliRTCVideoTrack The type of the stream. Currently, only camera streams are supported: VIDEO_TRACK_CAMERA.
  • ConfigLocalSimulcast: specifies whether to allow secondary video streams to be published. By default, it is allowed to publish secondary video streams. If you manually publish a video stream, you need to call Publish to take effect.

    public void ConfigLocalSimulcast(bool enable, int track);
    Parameter Type Description
    enabled bool true indicates that secondary streams are allowed to be published. false indicates that secondary streams are not allowed.
    track AliRTCVideoTrack The type of the stream. Currently, only camera streams are supported: VIDEO_TRACK_CAMERA.
  • IsLocalSimulcastEnabled: queries whether secondary video streams are allowed to be published.

    public bool IsLocalSimulcastEnabled();
    Return result

    If true is returned, it is allowed. If false is returned, it is not allowed.

  • Publish: Manually publish video and audio streams.

    • The actual performance of the call Publish must be determined by combining the ConfigLocalCameraPublish, ConfigLocalAudioPublish, and ConfigLocalSimulcast interfaces.
    • Configure the parameters of the preceding three interfaces based on your specific business requirements to publish the corresponding video and audio streams.
    • Publish and stop publishing are both calls to Publish.
    • If you want to stop publishing, set the parameters of the preceding three configuration interfaces to NO, and then call Publish.
    • You need to call this operation after the channel is successfully added.
    public void Publish();
  • IsAutoSubscribe: queries whether the subscription mode is automatic.

    public bool IsAutoSubscribe();
    Return result

    If true is returned, automatic subscription is returned. If false is returned, manual subscription is returned.

  • ConfigRemoteCameraTrack: specifies whether to subscribe to remote camera streams. The default value is to subscribe to large streams. If you manually subscribe to a large stream, you need to call Subscribe to take effect.

    public void ConfigRemoteCameraTrack(string userId, bool master, bool enable);
    Parameter Type Description
    userId string The user ID, which is a unique identifier obtained from the AppServer.
    master bool Specifies whether to subscribe to large streams first. true indicates that a large stream is subscribed to. false indicates that a small stream is subscribed to.
    enable bool true to subscribe to the remote camera stream. false to stop subscribing to the remote camera stream.
  • ConfigRemoteScreenTrack: specifies whether to subscribe to the remote screen stream. The default value is not to subscribe to remote screen streams. If you manually subscribe, you need to call Subscribe to take effect.

    public void ConfigRemoteScreenTrack(string userId, bool enable);
    Parameter Type Description
    userId string The user ID, which is a unique identifier obtained from the AppServer.
    enable bool true to subscribe to the remote screen stream. false to stop subscribing to the remote screen stream.
  • ConfigRemoteAudio: specifies whether to subscribe to remote audio streams. The default value is to subscribe to remote audio streams. If you manually subscribe, you need to call Subscribe to take effect.

    public void ConfigRemoteAudio(string userId, bool enable);
    Parameter Type Description
    userId string The user ID, which is a unique identifier obtained from the AppServer.
    enable bool true to subscribe to the remote audio stream. false to stop subscribing to the remote audio stream.
  • Subscribe: Manually subscribe to video and audio streams.

    • The actual performance of the Subscribe call must be determined by combining the ConfigRemoteCameraTrack, ConfigRemoteScreenTrack, and ConfigRemoteAudio interfaces.
    • Configure the parameters of the preceding three interfaces based on your specific business requirements to subscribe to the corresponding video and audio streams.
    • Subscribe and Stop Subscribe are both called.
    • To stop the subscription, set the parameters of the preceding three configuration interfaces to false, and then call Subscribe.
    public void Subscribe(string uid);
    Parameter Type Description
    uid string The user ID, which is a unique identifier obtained from the AppServer.
  • setVideoProfile: Set parameters for the video stream.

    public void SetVideoProfile(int profile, int track);
    Parameter Type Description
    profile AliRTCVideoProfile The video stream parameters.
    track AliRTCVideoTrack The videoTrack type to be specified.
  • GenerateTexture (available for iOS and Android only): Generate rendered textures.

    public int GenerateTexture();
    Return result

    A return value greater than 0 indicates a valid texture ID. Others indicate an invalid texture ID.

  • SetTexture: sets the texture (only available for iOS and Android).

    public int SetTexture(AliRTCTextureInfo textureInfo, int track, string userId);
    Parameter Type Description
    textureInfo AliRTCTextureInfo The texture information.
    track AliRTCVideoTrack The videoTrack type to be specified.
    userId int The ID of the user.
  • RemoveTexture: Remove textures (available for iOS and Android only).

    public void RemoveTexture(int textureId);
    Parameter Type Description
    textureId int The ID of the texture.
  • ConfigExternalVideoRendering: Set the external rendering mode (available only for Mac and Windows).

    public void ConfigExternalVideoRendering(bool enable);
    Parameter Type Description
    enable bool true specifies the external rendering mode. false specifies the external rendering mode.
  • GetVideoRenderData: Set the external rendering mode (available only for Mac and Windows).

    public bool GetVideoRenderData(string uid, int track, IntPtr data, ref int width, ref int height);
    Parameter Type Description
    uid string The ID of the user.
    track AliRTCVideoTrack The videoTrack type.
    data IntPtr Data output pointer.
    width int The data width.
    height int The height of the data.
  • SetLocalViewConfig: Set rendering parameters for local preview.

    public void SetLocalViewConfig(bool flip);
    Parameter Type Description
    flip bool true indicates that the image is turned on. false indicates that the image is turned off.
  • MuteLocalCamera: specifies whether to stop publishing the local video stream without changing the collection status of the current video stream.

    public void MuteLocalCamera(bool mute, int track);
    Parameter Type Description
    mute bool true indicates that the video stream is stopped. false indicates that the video stream is resumed.
    track AliRTCVideoTrack The type of the videoTrack whose release status needs to be changed.
  • GetCameraList (available only for Mac and Windows): Get a list of cameras.

    public string GetCameraList();
  • GetCurrentCamera (available only for Mac and Windows): Gets the name of the camera currently in use.

    public string GetCurrentCamera();
  • SetCurrentCamera (available only for Mac and Windows): Select the camera. You must call the getCameraList interface to obtain the device list before calling this interface to set the device.

    public void SetCurrentCamera(string deviceName);
    Parameter Type Description
    deviceName string The name of the camera.
  • SwitchCamera (available only for iOS and Android): Switch the front and rear cameras.

    public int SwitchCamera();
    Return result

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

  • SetCameraZoom (available only for iOS and Android): Set camera parameters.

    public int SetCameraZoom(float zoom, bool flash, bool autoFocus);
    Parameter Type Description
    zoom float The zoom level. Valid values:-3 to 3. Default value: 0.
    flash bool Specifies whether to turn on the flash.
    autoFocus bool Specifies whether to turn on autofocus.
    Return result

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

  • IsCameraOn: Check if the camera is on.

    public bool IsCameraOn();
    Return result

    If a value of true is returned, the camera is enabled. If a value of false is returned, the camera is disabled.

  • IsCameraFocusPointSupported (only available for iOS and Android): Whether the camera supports manual focus.

    public bool IsCameraFocusPointSupported();
    Return result

    If a value of true is returned, the camera supports manual focus. If a value of false is returned, the camera does not support manual focus.

  • IsCameraExposurePointSupported (only available for iOS and Android): Whether the camera supports setting the exposure area.

    public bool IsCameraExposurePointSupported();
    Return result

    If a value of true is returned, the camera supports manual focus. If a value of false is returned, the camera does not support manual focus.

  • SetCameraFocusPoint (available for iOS and Android only): Set the camera to focus manually.

    public int SetCameraFocusPoint(float x, float y);
    Parameter Type Description
    x float The x coordinate of the focus point.
    y float The y coordinate of the focus point.
    Return result

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

  • SetCameraExposurePoint (available only for iOS and Android): Set the camera exposure point.

    public int SetCameraExposurePoint(float x, float y);
    Parameter Type Description
    x float The x coordinate of the focus point.
    y float The y coordinate of the focus point.
    Return result

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

  • SetAudioOnlyMode: specifies whether to set the audio-only mode or audio-video mode. The default value is audio and video mode (non-pure audio), which must be set before JoinChannel.

    public void SetAudioOnlyMode(bool audioOnly);
    Parameter Type Description
    audioOnly bool true indicates that only audio is published and subscribed. false indicates that both audio and video are supported.
  • IsAudioOnly: queries whether the current audio-only mode is displayed.

    public bool IsAudioOnly();
    Return result

    If true is returned, audio is pure. If false is returned, audio is returned.

  • MuteLocalMic: specifies whether to stop publishing local audio without changing the collection status of the current audio.

    public void MuteLocalMic(bool mute);
    Parameter Type Description
    mute bool true indicates that local audio is stopped and false indicates that the local audio is resumed.
  • MuteRemoteAudioPlaying: specifies whether to stop playing the remote audio stream.

    public int MuteRemoteAudioPlaying(string userId, bool mute);
    Parameter Type Description
    userId string The user ID, which is a unique identifier obtained from the AppServer.
    mute bool true indicates that playback is stopped. false indicates that playback is resumed.
    Return result

    If 0 is returned, the setting is successful. -1 indicates that the setting fails.

  • EnableSpeakerphone (available only for iOS and Android): Switch the handset and speaker output.

    public int EnableSpeakerphone(bool enable);
  • GetAudioCaptures (available only for Mac and Windows): Get a list of audio capture devices.

    public string GetAudioCaptures();
  • GetCurrentAudioCapture (available only for Mac and Windows): Obtain the audio capture device name currently in use.

    public string GetCurrentAudioCapture();
  • SetCurrentAudioCapture (available only for Mac and Windows): Select an audio capture device. You must call the GetCurrentAudioCapture interface to obtain the device list before calling this interface to set.

    public void SetCurrentAudioCapture(string deviceName);
    Parameter Type Description
    deviceName string The audio collection device name.
  • GetAudioRenderers (available only for Mac and Windows): Get a list of audio playback devices.

    public string GetAudioRenderers();
  • GetCurrentAudioRenderer (available only for Mac and Windows): Get the audio playback device currently in use.

    public string GetCurrentAudioRenderer();
  • SetCurrentAudioRenderer (available only for Mac and Windows): Select an audio playback device. You must call the GetAudioRenderers interface to obtain the device list before calling this interface to set.

    public void SetCurrentAudioRenderer(string deviceName);
    Parameter Type Description
    deviceName string The audio playback device name.
  • StartAudioPlayer: enables audio playback. You can enable audio playback in advance. If you do not set this parameter, the SDK enables audio playback when the subscription succeeds.

    public void StartAudioPlayer();
  • StopAudioPlayer: Disables audio playback.

    public void StopAudioPlayer();
  • StartPreview: starts the local preview. You need to set the SetLocalViewConfig before you start the preview.

    You can start a local preview before you join the channel.

    public void StartPreview();
  • StopPreview: stops local preview.

    public void StopPreview();
  • GetOnlineRemoteUsers: Obtains the remote online user list and returns the user ID list.

    public string GetOnlineRemoteUsers();
  • SetLogLevel: specifies the log level.

    public void SetLogLevel(int logLevel);
    Parameter Type Description
    logLevel AliRTCLogLevel The level of the log entry.
  • GetSdkVersion: obtains the SDK version number.

    public static string GetSdkVersion();
  • SetClientRole: sets the channel mode.

    • You can call only when the channel mode is InteractiveLive.
    • You can set this parameter before or during a meeting. If the setting is successful, you will receive a OnUpdateRoleNotify.
    • To convert from Interactive to Live, you need to stop streaming first. Otherwise, a failure is returned.
     public void SetClientRole(int role);
    Parameter Type Description
    role AliRTCClientRole The type of the user role.