This topic describes the API operations that are encapsulated in the AliLiveSDK for iOS and the configuration list.

API

Based on features, API operations are classified into basic operations, basic audio and video operations, and basic stream pushing and pulling operations. The following tables describe the API operations based on features.

Table 1. Basic operations
Operation Description Class and description
getSdkVersion Obtains the current version of the AliLiveSDK for iOS. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
initWithConfig Uses an object of the AliLiveConfig class to initialize stream pushing.
destorySdk Destroys AliLiveEngine objects and releases related resources.
setStatusDelegate Sets the callback for the stream pushing status. For more information, see AliLivePushInfoStatusDelegate.
setNetworkDelegate Sets the callback for the network status during stream pushing. For more information, see AliLiveNetworkDelegate.
setRtsDelegate Sets the callback for the audio and video streams of a fan during stream pushing over RTC. For more information, see AliLiveRtsDelegate.
setVidePreProcessDelegate Sets the callback for video preprocessing.
setDataStatsDelegate Sets the callback for parameters that are related to live streaming media.
setLogDirPath Sets the path for storing the log files of the AliLiveSDK for iOS. To prevent log loss, you must call this operation before other API operations. In addition, make sure that the specified path exists and is writable.
setLogLevel Sets the log level.
Table 2. Preview operations
API Description Class and description
startPreview:renderMode:mirrorMode Starts the camera preview. You can specify the rendering mode and mirroring mode. During the preview, streams are not published to Alibaba Cloud CDN. You must call the startPushWithURL operation to push streams. After the preview starts, the onPreviewStarted callback is fired. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
startPreview Starts the camera preview. By default, the renderMode parameter is set to AliLiveRenderModeAuto, and the mirrorMode parameter is set to AliLiveRenderMirrorModeOnlyFrontCameraPreviewEnabled. During the preview, streams are not published to Alibaba Cloud CDN. You must call the startPushWithURL operation to push streams. After the preview is started, the onPreviewStarted callback is fired.
stopPreview Stops the camera preview. After the preview is stopped, the onPreviewStoped callback is fired.
Table 3. Basic stream pushing operations
API Description Class and description
startPushWithURL Starts to push streams. After the stream pushing is started, the onLivePushStarted callback is fired. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
stopPush Stops publishing streams. After the stream pushing is stopped, the onLivePushStoped callback is fired.
pausePush Stops the camera from collecting live streams and publishs standby streams. This operation is supported only for stream pushing over RTMP. You must call the startPushWithURL operation before the pausePush operation to ensure a valid call order.
resumePush Enables the camera to collect live streams again and stops publishing standby streams. This operation is supported only for stream pushing over RTMP. You must call the pausePush operation before the resumePush operation to ensure a valid call order.
isPublishing Queries whether streams are being published.
livePushURL Queries the current publish URL.
Table 4. Basic stream pulling operations
API Description Class and description
subscribeStream Subscribes to the video streams of the member who requests a RTC stream. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
unSubscribeStream Unsubscribes from the video streams of the member who requests a RTC stream.
renderRemoteStreamWithView:url:renderMode:mirrorMode Renders the view for the video streams of the member who requests a co-stream. After you call this operation, the onFirstRemoteVideoFrameDrawn operation is also called, which indicates that the video streams of the member who requests a co-stream start to be rendered.
renderRemoteStreamWithView:url Renders the view for the video streams of the member who requests a co-stream. By default, the renderMode parameter is set to AliLiveRenderModeAuto, and the mirrorMode parameter is set to AliLiveRenderMirrorModeAllDisabled. After you call this operation, the onFirstRemoteVideoFrameDrawn operation is also called, which indicates that the video streams of the member who requests a co-stream start to be rendered.
Table 5. Beautification-related operations
API Description Class and description
getRaceBeautyManager Obtains the objects of the AliLiveRaceBeautyManager class. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
enableBeautyEffect Enables or disables beautification. AliLiveRaceBeautyManager: the class that controls beautification features, which can be used to specify a beautification type. Beautification types include skin whitening and skin smoothing.
setRaceBeautyParams:value Sets a beautification parameter.
Table 6. Audio and video operations
API Description Class and description
isCameraOn Queries whether the camera is enabled. AliLiveEngine: the core class that is used to push streams. It can be used to push streams over Real-Time Messaging Protocol (RTMP) and Real-Time Communication (RTC), pull streams over RTC, render videos, and enable or disable beautification. It is the most important class of the AliLiveSDK for iOS.
switchCamera Switches between the front camera and the rear camera.
setDeviceOrientationMode Specifies the device orientation to determine whether streams are published in landscape or portrait mode. If this operation is not called at the access layer, the adaptive rotation mode is enabled by default. In this case, when the device is in landscape mode, streams are published in landscape mode. When the device is in portrait mode, streams are published in portrait mode.
setCameraZoom:flash Sets the zoom factor of the camera and specifies whether to enable the flash.
isCameraFocusPointSupported Queries whether the camera supports manual focus.
setCameraFocusPoint Sets the manual focus point for the camera.
isCameraExposurePointSupported Queries whether you can set an exposure point for the camera.
setCameraExposurePoint Sets an exposure point for the camera.
isAudioOnly Queries whether the published streams are audio-only streams.
setMute Specifies whether to collect mute frames from the local audio.
enableSpeakerphone Sets the headset or speaker as the audio output device.
isEnableSpeakerphone Queries whether the audio output device is the headset or the speaker.
setPlayoutVolume Sets the playback volume.
setRecordingVolume Sets the recording volume.
setAudioSessionOperationRestriction Sets the control permission of the AliLiveSDK for iOS on AVAudioSession.
enableEarBack Enables in-ear monitoring. To prevent echoes, we recommend that you enable in-ear monitoring after you insert the headset.
setEarBackVolume Sets the headset volume when earback is enabled.
playBGM:publish:loop Plays background music.
stopBGM Stop playing background music.
pauseBGM Pauses the playback of background music.
resumeBGM Resumes the playback of background music.
setBGMVolume Sets the volume of background music.
getBGMDuration Queries the total duration of background music. Unit: milliseconds.
getBGMCurrentPosition Queries the playback progress of background music. Unit: milliseconds.
setBGMPosition Sets the playback position of background music.
setPicthValue Sets the pitch.
setReverbMode Sets the reverberation mode.
setVoiceChangerMode Sets the voice change mode.
Table 7. Callbacks
API Description Class and description
onSubscribe:result:url The status callback that is fired when you subscribe to a URL. After you call the subscribeStream operation, the stream pushing engine calls back the subscription status of this URL. In the co-stream scenario, a URL uniquely identifies the stream information of a fan. If you subscribe to the URL of the streams of a fan, you will receive audio and video streams from the fan. AliLiveRtsDelegate: the callback class for the statuses of audio and video streams from a fan that you subscribe to in the co-stream scenario. This class is supported only for stream pushing over RTC, not stream pushing over RTMP.
onUnSubscribe:result:url The status callback that is fired when you unsubscribe from a URL. After you call the unSubscribeStream operation, the stream pushing engine calls back the subscription status of the URL. In the co-stream scenario, a URL uniquely identifies the stream information of a fan. If you unsubscribe from the URL of the streams of a fan, you will not receive audio and video streams from the fan.
onFirstPacketReceived:url The callback that is fired when the first media data packet is received from the URL that you subscribe to. Call the renderRemoteStreamWithView:url operation after this callback to render and display video streams.
onFirstRemoteVideoFrameDrawn The callback that is fired when the first video frame of the streams that you subscribe to is displayed.
onLiveTotalStats:stats The callback for real-time statistics during stream pushing over RTC. This callback is fired every 2 seconds. AliLiveDataStatsDelegate: the callback class for statistics on stream pushing media.
onLiveLocalVideoStats:stats The callback for statistics on local videos that are sent during stream pushing over RTC. This callback is fired every 2 seconds.
onLiveRemoteVideoStats:stats The callback for statistics on remote videos that are received during stream pushing over RTC. This callback is fired every 2 seconds.
onNetworkStatusChange The callback for network status changes. This callback is fired when the network type changes or the network is interrupted. For example, this callback is fired if the network is switched from the Wi-Fi network to the 4G network. AliLiveNetworkDelegate: the callback class for network status changes during stream pushing. It can be used to notify the access party of the network status of the current stream pushing engine.
onNetworkPoor The callback that is fired when the network bandwidth is low.
onNetworkRecovery The callback that is fired when the network is recovered.
onReconnectStart The callback that is fired when the stream pushing engine starts to reconnect to the network. In cases of low network bandwidth, stream pushing may be interrupted. Then, the stream pushing engine tries to reconnect to the network. This callback is fired in this case.
onReconnectSuccess The callback that is fired when the stream pushing engine reconnects to the network and resumes stream pushing.
onConnectionLost The callback that is fired when the stream pushing process of the stream pushing engine is interrupted.
onTexture:width:height:rotate The callback that is fired in an OpenGL thread to process the collected images. For example, you can beautify the collected images. AliLiveVidePreProcessDelegate: the callback class for video preprocessing. You can use this class to customize the parameters for video image processing. For example, you can customize beautification parameters.
onTextureDestoryed The callback that is fired in an OpenGL thread to release the created OpenGL resources.
onVideoPixelBuffer The callback for the collected video objects. You can use this callback to process the collected video objects.
onPreviewStarted The callback that is fired when the preview starts. AliLivePushInfoStatusDelegate: the callback class for the stream pushing status. You can use this class to obtain the stream pushing status during stream pushing over RTMP or RTC.
onPreviewStoped The callback that is fired when the preview stops.
onFirstVideoFramePreviewed The callback that is fired when the first video frame is rendered.
onLivePushStarted The callback that is fired when stream pushing starts.
onLivePushStoped The callback that is fired when stream pushing stops.
onLiveSdkError The callback that is fired to notify the application of an error in the AliLiveEngine class.
onBGMStateChanged The callback for the audio playback status.

Configurations list

AliLiveConfig: the class that ApsaraVideo Live SDK provides to set the initialization parameters for stream pushing over RTMP and RTC. When you create a live streaming engine, you must pass objects of the class as parameters. You must set the parameters before stream pushing. The parameters do not take effect if you set them after stream pushing.

Parameter Type Default value Description
cameraPosition AliLiveCameraPosition AliLiveCameraPositionFront The position of the camera.
beautyOn BOOL true Specifies whether to enable beautification.
enablePureAudioPush BOOL false Specifies whether to enable audio-only stream pushing.
autoFocus BOOL false Specifies whether to support autofocus.
videoProfile int AliLiveVideoProfile_540P The resolution of the published video streams.
videoFPS int 20 The frame rate of the video.
enableHighDefPreview BOOL false Specifies whether to enable high-definition preview. If the resolution of the collected video streams is lower than or equal to 720p, the video streams are previewed at a resolution of 720p. If the resolution of the collected video streams is higher than 720p, the video streams are previewed at the actual resolution.
enableVideoHWAcceleration BOOL true Specifies whether to enable hardware encoding for videos.
enableVideoDecodeHWAcceleration BOOL true Specifies whether to enable hardware decoding for videos.
enableAudioHWAcceleration BOOL false Specifies whether to enable software encoding for audio.
videoGopSize AliLivePushVideoEncodeGOP AliLivePushVideoEncodeGOP_2 The size of the group of pictures (GOP). Unit: seconds.
pauseImage UIImage NULL The default image that is published when the stream pushing over RTMP is paused. The image must be in PNG format.
videoInitBitrate int 1000 The initial bitrate of the video before encoding. Unit: Kbit/s.
videoTargetBitrate int 1500 The destination bitrate of the video after encoding. Unit: Kbit/s.
videoMinBitrate int 600 The minimum bitrate of the video. Unit: Kbit/s.
audioChannel AliLivePushAudioChannel AliLivePushAudioChannel_1 The number of audio channels.
audioSampleRate AliLivePushAudioSampleRate AliLivePushAudioSampleRate44100 The audio sample rate.
audioEncoderProfile AliLiveAudioEncoderProfile AliLiveAudioEncoderProfile_AAC_LC The audio encoding format.
autoReconnectRetryCount int 5 The number of automatic reconnection attempts during stream pushing.
autoReconnectRetryInterval int 1000 The interval between two consecutive automatic reconnection attempts during stream pushing. Unit: milliseconds.
accountID NSString NULL The ID that is generated when you activate HTTPDNS and bound to your Alibaba Cloud account. This parameter is required in the co-stream scenario.
extra NSString NULL The auxiliary field that helps you troubleshoot SDK issues based on logs. You can specify the URL of the video streams of the member who joins in the live stream in this parameter.

Basic operations

  • getSdkVersion: queries the version of the AliLiveSDK for iOS.
    + (NSString *)getSdkVersion;

    Return result

    The version of the AliLiveSDK for iOS is returned.

  • initWithConfig: uses an object of the AliLiveConfig class to initialize stream pushing.
    - (instancetype)initWithConfig:(AliLiveConfig*)config;

    Parameters

    Parameter Type Description
    config AliLiveConfig The configuration of stream pushing.

    Return result

    An object of the AliLiveEngine class is returned.

  • destorySdk: destroys AliLiveEngine objects and releases related resources.
    - (void)destorySdk;
  • setStatusDelegate: sets the callback for the stream pushing status. For more information, see AliLivePushInfoStatusDelegate.
    - (void) setStatusDelegate:(id<AliLivePushInfoStatusDelegate>)delegate;

    Parameters

    Parameter Type Description
    delegate AliLivePushInfoStatusDelegate The callback for the stream pushing status.
  • setNetworkDelegate: sets the callback for the network status during stream pushing. For more information, see AliLiveNetworkDelegate.
    - (void) setNetworkDelegate:(id<AliLiveNetworkDelegate>)delegate;

    Parameters

    Parameter Type Description
    delegate AliLiveNetworkDelegate The callback for the network status during stream pushing.
  • setRtsDelegate: Sets the callback for the audio and video streams of a fan during stream pushing over RTC. For more information, see AliLiveRtsDelegate.
    - (void) setRtsDelegate:(id<AliLiveRtsDelegate>)delegate;

    Parameters

    Parameter Type Description
    delegate AliLiveRtsDelegate The callback for the audio and video streams of a fan during stream pushing over RTC.
  • setVidePreProcessDelegate: sets the callback for video preprocessing.
    - (void)setVidePreProcessDelegate:(id<AliLiveVidePreProcessDelegate>)delegate;

    Parameters

    Parameter Type Description
    delegate AliLiveVidePreProcessDelegate The callback for video preprocessing.
  • setDataStatsDelegate: sets the callback for parameters that are related to live streaming media.
    - (void) setDataStatsDelegate:(id<AliLiveDataStatsDelegate>)delegate;

    Parameters

    Parameter Type Description
    delegate AliLiveDataStatsDelegate The callback for parameters that are related to live streaming media.
  • setLogDirPath: sets the path for storing the log files of the AliLiveSDK for iOS. To prevent log loss, you must call this operation before other API operations. In addition, make sure that the specified path exists and is writable.
    - (int)setLogDirPath:(NSString *)logDirPath;

    Parameters

    Parameter Type Description
    logDirPath String The path for storing the log files of the AliLiveSDK for iOS.
  • setLogLevel: sets the log level.
    - (void)setLogLevel:(AliLiveLogLevel) level;

    Parameters

    Parameter Type Description
    level AliLiveLogLevel The log level.

Preview operations

  • startPreview:renderMode:mirrorMode: starts the camera preview. You can specify the rendering mode and mirroring mode. During the preview, streams are not published to Alibaba Cloud CDN. You must call the startPushWithURL operation to push streams. After the preview is started, the onPreviewStarted callback is fired.
    - (int)startPreview:(AliLiveRenderView *)previewView renderMode:(AliLiveRenderMode)rMode mirrorMode:(AliLiveRenderMirrorMode)mMode;

    Parameters

    Parameter Type Description
    previewView AliLiveRenderView The view that you can use to display the camera preview.
    rMode AliLiveRenderMode The video rendering mode.
    mMode AliLiveRenderMirrorMode Specifies whether to enable mirroring.
  • startPreview: starts the camera preview. By default, the renderMode parameter is set to AliLiveRenderModeAuto, and the mirrorMode parameter is set to AliLiveRenderMirrorModeOnlyFrontCameraPreviewEnabled. During the preview, streams are not published to Alibaba Cloud CDN. You must call the startPushWithURL operation to push streams. After the preview is started, the onPreviewStarted callback is fired.
    /**
     * @ brief Start the camera preview.
     * @ param previewView The view that you can use to display the camera preview.
     * @ return If the return value is 0, the preview is successful. If the return value is not 0, the preview fails.
    */
    - (int)startPreview:(AliLiveRenderView *)previewView;

    Parameters

    Parameter Type Description
    previewView AliLiveRenderView The view that you can use to display the camera preview.
  • stopPreview: stops the camera preview. After the preview is stopped, the onPreviewStoped callback is fired.
    - (int)stopPreview;

Basic stream pushing operations

  • startPushWithURL: starts to push streams. After the stream pushing is started, the onLivePushStarted callback is fired.
    - (void)startPushWithURL:(NSString *)pushURL;

    Parameters

    Parameter Type Description
    pushURL NSString The publish URL. If the URL starts with rtmp://, streams are published over RTMP. If the URL starts with artc://, streams are published over RTC.
  • stopPush: stops publishing streams. After the stream pushing is stopped, the onLivePushStoped callback is fired.
    - (void)stopPush;
  • pausePush: stops the camera from collecting live streams and publishs standby streams. You must call the startPushWithURL operation before the pausePush operation to ensure a valid call order.
    - (void)pausePush;
  • resumePush: enables the camera to collect live streams again and stops publishing standby streams. You must call the pausePush operation before the resumePush operation to ensure a valid call order.
    - (void)resumePush;
  • isPublishing: queries whether streams are being published.
    - (BOOL)isPublishing;
  • livePushURL: queries the current publish URL.
    @property (nonatomic, readonly) NSString *livePushURL;

Basic stream pulling operations

  • subscribeStream: subscribes to the video streams of the member who requests a RTC stream.
    - (void)subscribeStream:(NSString *)url;

    Parameters

    Parameter Type Description
    url NSString The URL of the video streams of the member who requests a co-stream that you want to subscribe to. The URL uniquely identifies the stream information of the member.
  • unSubscribeStream: unsubscribes from the video streams of the member who requests a RTC stream.
    /**
     * @ brief Unsubscribe from the video streams of the member who requests a RTC stream.
     * @ param url The URL of the video streams of the member who requests a co-stream, which uniquely identifies the stream information of the member.
     */
    - (void)unSubscribeStream:(NSString *)url;

    Parameters

    Parameter Type Description
    url NSString The URL of the video streams of the member who requests a co-stream, which uniquely identifies the stream information of the member.
  • renderRemoteStreamWithView:url:renderMode:mirrorMode: renders the view for the video streams of the member who requests a co-stream. After you call this operation, the onFirstRemoteVideoFrameDrawn operation is also called, which indicates that the video streams of the member who requests a co-stream start to be rendered.
    - (void)renderRemoteStreamWithView:(AliLiveRenderView *)renderView url:(NSString *)url renderMode:(AliLiveRenderMode)rMode mirrorMode:(AliLiveRenderMirrorMode)mMode;

    Parameters

    Parameter Type Description
    renderView AliLiveRenderView The view to be rendered.
    url NSString The unique URL of the video streams of the member who requests a co-stream.
    rMode AliLiveRenderMode The video rendering mode.
    mMode AliLiveRenderMirrorMode Specifies whether to enable mirroring.
  • renderRemoteStreamWithView:url: renders the view for the video streams of the member who requests a co-stream. By default, the renderMode parameter is set to AliLiveRenderModeAuto, and the mirrorMode parameter is set to AliLiveRenderMirrorModeAllDisabled. After you call this operation, the onFirstRemoteVideoFrameDrawn operation is also called, which indicates that the video streams of the member who requests a co-stream start to be rendered.
    - (void)renderRemoteStreamWithView:(AliLiveRenderView *)renderView url:(NSString *)url;

    Parameters

    Parameter Type Description
    renderView AliLiveRenderView The view to be rendered.
    url NSString The unique URL of the video streams of the member who requests a co-stream.

Beautification-related operations

  • getRaceBeautyManager: obtains the objects of the AliLiveRaceBeautyManager class.
    /**
     * @ brief Obtain the objects of the AliLiveRaceBeautyManager class.
     * @return The objects of the AliLiveRaceBeautyManager class.
    */
    - (AliLiveRaceBeautyManager *)getRaceBeautyManager;

    Return result

    Objects of the AliLiveRaceBeautyManager class are returned.

  • enableBeautyEffect: enables or disables beautification.
    - (void)enableBeautyEffect:(BOOL)isOpen;

    Parameters

    Parameter Type Description
    isOpen BOOL Specifies whether to enable or disable beautification.
  • setRaceBeautyParams:value: sets a beautification parameter.
    - (void)setRaceBeautyParams:(AliLiveRaceBeautyParams) param value:(float) value;

    Parameters

    Parameter Type Description
    param AliLiveRaceBeautyParams The beautification parameter. Valid values:
    • kAliLiveRaceBeautyParamsSkinBuffing: skin smoothing.
    • kAliLiveRaceBeautyParamsWhitening: skin whitening.
    value float The value of the beautification parameter. Valid values: 0 to 1.

Audio and video operations

  • isCameraOn: queries whether the camera is enabled.
    - (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.

  • switchCamera: switches between the front camera and the rear camera.
    - (int)switchCamera;
  • setDeviceOrientationMode: specifies the device orientation to determine whether streams are published in landscape or portrait mode. If this operation is not called at the access layer, the adaptive rotation mode is enabled by default. In this case, when the device is in landscape mode, streams are published in landscape mode. When the device is in portrait mode, streams are published in portrait mode.
    - (int)setDeviceOrientationMode:(AliLiveOrientationMode)mode;

    Parameters

    Parameter Type Description
    mode AliLiveOrientationMode The device orientation.
  • setCameraZoom:flash: sets the zoom factor of the camera and specifies whether to enable the flash.
    - (int)setCameraZoom:(float)zoom flash:(BOOL)flash;

    Parameters

    Parameter Type Description
    zoom float The zoom factor.
    flash BOOL Specifies whether to enable the flash.
  • isCameraFocusPointSupported: queries whether the camera supports manual focus.
    - (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.

  • setCameraFocusPoint: sets the manual focus point for the camera.
    - (int)setCameraFocusPoint:(CGPoint)point;

    Parameters

    Parameter Type Description
    point CGPoint The focal point.
  • isCameraExposurePointSupported: queries whether you can set an exposure point for the camera.
    - (BOOL)isCameraExposurePointSupported;

    Return result

    If a value of true is returned, an exposure point can be set for the camera. If a value of false is returned, no exposure point can be set for the camera.

  • setCameraExposurePoint: sets an exposure point for the camera.
    - (int)setCameraExposurePoint:(CGPoint)point;

    Parameters

    Parameter Type Description
    point CGPoint The exposure point.
  • isAudioOnly: queries whether the published streams are audio-only streams.
    - (BOOL)isAudioOnly;

    Return result

    If a value of true is returned, the published streams are audio-only streams. If a value of false is returned, the published streams are not audio-only streams.

  • setMute: specifies whether to collect mute frames from the local audio.
    - (int)setMute:(BOOL)mute;

    Parameters

    Parameter Type Description
    mute BOOL Specifies whether to collect mute frames from the local audio. Valid values:
    • true: collects mute frames from the local audio.
    • false: collects frames that are not mute from the local audio.
  • enableSpeakerphone: sets the headset or speaker as the audio output device.
    - (int)enableSpeakerphone:(BOOL)enable;

    Parameters

    Parameter Type Description
    enable BOOL Specifies whether the headset or speaker is set as the audio output device. Valid values:
    • true: The speaker is set as the audio output device.
    • false (default): The headset is set as the audio output device.
  • isEnableSpeakerphone: queries whether the audio output device is the headset or the speaker.
    - (BOOL)isEnableSpeakerphone;

    Return result

    If a value of true is returned, the speaker is set as the audio output device. If a value of false is returned, the headset is set as the audio output device.

  • setPlayoutVolume: sets the playback volume.
    - (int)setRecordingVolume:(NSInteger)volume;

    Parameters

    Parameter Type Description
    volume NSInteger The playback volume. Default value: 100. Valid values:
    • 0: mute.
    • [0,100): The volume is higher than or equal to 0 and lower than 100.
    • (100,400]: The volume is higher than 100 and lower than or equal to 400.
  • setRecordingVolume: sets the recording volume.
    - (int)setRecordingVolume:(NSInteger)volume;

    Parameters

    Parameter Type Description
    volume NSInteger The recording volume. Default value: 100. Valid values:
    • 0: mute.
    • [0,100): The volume is higher than or equal to 0 and lower than 100.
    • (100,400]: The volume is higher than 100 and lower than or equal to 400.
  • setAudioSessionOperationRestriction: sets the control permission of the AliLiveSDK for iOS on AVAudioSession.
    - (int)setAudioSessionOperationRestriction:(AliLiveAudioSessionOperationRestriction)restriction;

    Parameters

    Parameter Type Description
    restriction AliLiveAudioSessionOperationRestriction The control permission of the AliLiveSDK for iOS on AVAudioSession.
  • enableEarBack: enables in-ear monitoring. To prevent echoes, we recommend that you enable in-ear monitoring after you insert the headset.
    - (int)enableEarBack:(BOOL)enable;

    Parameters

    Parameter Type Description
    enable BOOL Specifies whether to enable in-ear monitoring.
  • setEarBackVolume: sets the headset volume when in-ear monitoring is enabled.
    - (int)setEarBackVolume:(NSInteger)volume;

    Parameters

    Parameter Type Description
    volume NSInteger The headset volume when in-ear monitoring is enabled.
  • playBGM:publish:loop: plays background music.
    - (int)playBGM:(NSString *)path publish:(BOOL)publish loop:(BOOL)loop;

    Parameters

    Parameter Type Description
    path NSString The path for storing on-premises music files. The music files must be in the MP3 or WAV format, and the path cannot contain Chinese characters.
    publish BOOL Specifies whether to push streams. Valid values:
    • true: publishs streams to remote users.
    • false: plays the music only on the local side and does not push streams to remote users.
    loop BOOL Specifies whether to enable loop playback. Valid values:
    • true: enables loop playback.
    • false: disables loop playback.
  • stopBGM: stops playing background music.
    - (int)stopBGM;
  • pauseBGM: pauses the playback of background music.
    - (int)pauseBGM;
  • resumeBGM: resumes the playback of background music.
    - (int)resumeBGM;
  • setBGMVolume: sets the volume of background music.
    - (int)setBGMVolume:(NSInteger)volume;

    Parameters

    Parameter Type Description
    volume NSInteger The volume of background music. Default value: 50. Valid values:
    • 0: mute.
    • (0,100]: The volume is higher than 0 and lower than or equal to 100.
  • getBGMDuration: queries the total duration of background music. Unit: milliseconds.
    - (int)getBGMDuration;
  • getBGMCurrentPosition: queries the playback progress of background music. Unit: milliseconds.
    - (int)getBGMCurrentPosition;
  • setBGMPosition: sets the playback position of background music.
    - (int)setBGMPosition:(NSInteger)pos;

    Parameters

    Parameter Type Description
    posMs NSInteger The position of the progress bar. Unit: milliseconds.
  • setPicthValue: sets the pitch.
    - (int)setPicthValue:(float)pitch;

    Parameters

    Parameter Type Description
    pitch float The pitch. Default value: 1.0f. Valid values: 0.5f to 2.0f.
  • setReverbMode: sets the reverberation mode.
    - (int)setReverbMode:(AliLiveReverbMode)mode;

    Parameters

    Parameter Type Description
    mode AliLiveReverbMode The reverberation mode. Valid values:
    • AliLiveReverb_Off: reverberation disabled.
    • AliLiveReverb_Vocal_I: vocal I.
    • AliLiveReverb_Vocal_II: vocal II.
    • AliLiveReverb_Bathroom: reverberation in bathhouses.
    • AliLiveReverb_Small_Room_Bright: reverberation in small bright rooms.
    • AliLiveReverb_Small_Room_Dark: reverberation in small dark rooms.
    • AliLiveReverb_Medium_Room: reverberation in medium rooms.
    • AliLiveReverb_Large_Room: reverberation in large rooms.
    • AliLiveReverb_Church_Hall: reverberation in church halls.
    • AliLiveReverb_Cathedral: reverberation in cathedrals.
  • setVoiceChangerMode: sets the voice change mode.
    - (int)setVoiceChangerMode:(AliLiveVoiceChangerMode)mode;

    Parameters

    Parameter Type Description
    mode AliLiveVoiceChangerMode The voice change mode. Valid values:
    • AliLiveVoiceChanger_OFF: voice change disabled.
    • AliLiveVoiceChanger_OLD_MAN: changes to the voice of an old man.
    • AliLiveVoiceChanger_BABYBOY: changes to the voice of a boy.
    • AliLiveVoiceChanger_BABYGILR: changes to the voice of a girl.
    • AliLiveVoiceChanger_ROBOT: changes to the voice of a robot.
    • AliLiveVoiceChanger_DAIMO: changes to the voice of the big devil.
    • AliLiveVoiceChanger_KTV: changes to the voice in the KTV.
    • AliLiveVoiceChanger_ECHO: changes to the echo.

Callbacks

  • onSubscribe:result:url: the status callback that is fired when you subscribe to a URL. After you call the subscribeStream operation, the stream pushing engine calls back the subscription status of this URL. In the co-stream scenario, a URL uniquely identifies the stream information of a fan. If you subscribe to the URL of the streams of a fan, you will receive audio and video streams from the fan.
    - (void)onSubscribe:(AliLiveEngine *)publisher result:(AliLiveResult *)result url:(NSString *)url;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    result AliLiveResult The status of the subscription, which can be a success or failure.
    url NSString The URL of the audio and video streams of the member that you subscribe to, which uniquely identifies the member.
  • onUnSubscribe:result:url: the status callback that is fired when you unsubscribe from a URL. After you call the unSubscribeStream operation, the stream pushing engine calls back the subscription status of this URL. In the co-stream scenario, a URL uniquely identifies the stream information of a fan. If you unsubscribe from the URL of the streams of a fan, you will not receive audio and video streams from the fan.
    - (void)onUnSubscribe:(AliLiveEngine *)publisher result:(AliLiveResult *)result url:(NSString *)url;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    result AliLiveResult The status of the subscription, which can be a success or failure.
    url NSString The URL of the audio and video streams of the member that you unsubscribe from, which uniquely identifies the member.
  • onFirstPacketReceived:url: the callback that is fired when the first media data packet is received from the URL that you subscribe to. Call the renderRemoteStreamWithView:url operation after this callback to render and display video streams.
    - (void)onFirstPacketReceived:(AliLiveEngine *)publisher url:(NSString *)url;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    url NSString The URL of the audio and video streams of the member that you subscribe to, which uniquely identifies the member.
  • onFirstRemoteVideoFrameDrawn: the callback that is fired when the first video frame of the streams that you subscribe to is displayed.
    - (void)onFirstRemoteVideoFrameDrawn:(AliLiveEngine *)publisher url:(NSString *)url;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    url NSString The URL of the audio and video streams of the member that you subscribe to, which uniquely identifies the member.
  • onLiveTotalStats:stats: the callback for real-time statistics during stream pushing over RTC. This callback is fired every 2 seconds.
    - (void)onLiveTotalStats:(AliLiveEngine *)publisher stats:(AliLiveStats *)stats;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    stats AliLiveStats The real-time statistics.

    The following table describes the parameters in the real-time statistics.

    Parameter Type Description
    sent_kbitrate long The bitrate of all data that is sent. Unit: Kbit/s. This parameter is to be added to the statistics.
    rcvd_kbitrate long The bitrate of all data that is received. Unit: Kbit/s. This parameter is to be added to the statistics.
    sent_bytes long The total amount of data that is sent. Unit: byte. This parameter is to be added to the statistics.
    rcvd_bytes long The total amount of data that is received. Unit: byte. This parameter is to be added to the statistics.
    video_rcvd_kbitrate long The bitrate of the sent videos. Unit: Kbit/s. This parameter is to be added to the statistics.
    video_sent_kbitrate long The bitrate of the received videos. Unit: Kbit/s. This parameter is to be added to the statistics.
    call_duration long The duration of the co-stream. Unit: seconds. This parameter is to be added to the statistics.
    cpu_usage float The CPU utilization. Unit: %. This parameter is to be added to the statistics.
  • onLiveLocalVideoStats:stats: the callback for statistics on local videos that are sent during stream pushing over RTC. This callback is fired every 2 seconds.
    /**
     * @brief The callback for statistics on local videos that are sent during stream pushing over RTC. This callback is fired every 2 seconds.
     * @param localVideoStats The statistics on local videos.
     * @note The callback is fired every 2 seconds.
     */
    - (void)onLiveLocalVideoStats:(AliLiveEngine *)publisher stats:(AliLiveLocalVideoStats *)localVideoStats;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    localVideoStats AliLiveLocalVideoStats The statistics on local videos.

    The following table describes the parameters in the statistics on local videos.

    Parameter Type Description
    track AliLiveVideoTrack The track type of the video streams. This parameter is to be added to the statistics.
    sent_bitrate int The bitrate of local videos that are sent.
    sent_fps int The frame rate of local videos that are sent.
    encode_fps int The frame rate of video encoding.
  • onLiveRemoteVideoStats:stats: the callback for statistics on remote videos that are received during stream pushing over RTC. This callback is fired every 2 seconds.
    /**
     * @brief The callback for statistics on remote videos that are received during stream pushing over RTC. This callback is fired every 2 seconds.
     * @param remoteVideoStats The statistics on remote videos.
     */
    - (void)onLiveRemoteVideoStats:(AliLiveEngine *)publisher stats:(AliLiveRemoteVideoStats *)remoteVideoStats;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    remoteVideoStats AliLiveRemoteVideoStats The statistics on remote videos.

    The following table describes the parameters in the statistics on remote videos.

    Parameter Type Description
    userId NSString The ID of the remote user.
    track AliLiveVideoTrack The track type of the video streams.
    width int The width of the remote videos.
    height int The height of the remote videos.
    decode_fps int The frame rate of video decoding.
    render_fps int The frame rate of video rendering.
    frozen_times int The number of stuttering times.
  • onNetworkStatusChange: the callback for network status changes. This callback is fired when the network type changes or the network is interrupted. For example, this callback is fired if the network is switched from the Wi-Fi network to the 4G network.
    - (void)onNetworkStatusChange:(AliLiveEngine *)publisher status:(AliLiveNetworkStatus)netStatus;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    status AliLiveNetworkStatus The network type or status. Valid values:
    • 4G
    • Wi-Fi
    • No network
  • onNetworkPoor: the callback that is fired when the network bandwidth is low.
    - (void)onNetworkPoor:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onNetworkRecovery: The callback that is fired when the network is recovered.
    - (void)onNetworkRecovery:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onReconnectStart: The callback that is fired when the stream pushing engine starts to reconnect to the network. In cases of low network bandwidth, stream pushing may be interrupted. Then, the stream pushing engine tries to reconnect to the network. This callback is fired in this case.
    - (void)onReconnectStart:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onReconnectSuccess: The callback that is fired when the stream pushing engine reconnects to the network and resumes stream pushing.
    - (void)onReconnectSuccess:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onConnectionLost: the callback that is fired when the stream pushing process of the stream pushing engine is interrupted.
    - (void)onConnectionLost:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onTexture:width:height:rotate: the callback that is fired in an OpenGL thread to process the collected images. For example, you can beautify the collected images.
    - (int)onTexture:(int)texture width:(int)width height:(int)height rotate:(int)rotate;

    Parameters

    Parameter Type Description
    texture int The ID of the texture.
    width int The width of the texture.
    height int The height of the texture.
    rotate int The rotation angle of the texture.
  • onTextureDestoryed: the callback that is fired in an OpenGL thread to release the created OpenGL resources.
    - (void)onTextureDestoryed;
  • onVideoPixelBuffer: the callback for the collected video objects. You can use this callback to process the collected video objects.
    - (CVPixelBufferRef)onVideoPixelBuffer:(CVPixelBufferRef)pixelBuffer;

    Parameters

    Parameter Type Description
    pixelBuffer CVPixelBufferRef The collected video objects.
  • onPreviewStarted: the callback that is fired when the preview starts.
    - (void)onPreviewStarted:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onPreviewStoped: the callback that is fired when the preview stops.
    - (void)onPreviewStoped:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onFirstVideoFramePreviewed: the callback that is fired when the first video frame is rendered.
    - (void)onFirstVideoFramePreviewed:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onLivePushStarted: the callback that is fired when the stream pushing starts.
    - (void)onLivePushStarted:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onLivePushStoped: the callback that is fired when the stream pushing stops.
    - (void)onLivePushStoped:(AliLiveEngine *)publisher;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
  • onLiveSdkError: the callback that is fired to notify the application of an error in the AliLiveEngine class.
    - (void)onLiveSdkError:(AliLiveEngine *)publisher error:(AliLiveError *)error;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    error AliLiveError The error message.
  • onBGMStateChanged: the callback for the audio playback statuses.
    - (void)onBGMStateChanged:(AliLiveEngine *)publisher
                    playState:(AliLiveAudioPlayingStateCode)playState
                    errorCode:(AliLiveAudioPlayingErrorCode)errorCode;

    Parameters

    Parameter Type Description
    publisher AliLiveEngine The stream pushing instance.
    playState AliLiveAudioPlayingStateCode The playback status. Valid values:
    • AliLiveAudioPlayingStarted: The playback starts.
    • AliLiveAudioPlayingStopped: The playback is stopped.
    • AliLiveAudioPlayingPaused: The playback is paused.
    • AliLiveAudioPlayingResumed: The playback is resumed.
    • AliLiveAudioPlayingEnded: The playback is complete.
    • AliLiveAudioPlayingBuffering: The audio that you want to play is being buffered.
    • AliLiveAudioPlayingBufferingEnd: The audio that you want to play is buffered.
    • AliLiveAudioPlayingFailed: The playback fails.
    errorCode AliLiveAudioPlayingErrorCode The error code about the playback status.