API reference for iOS

更新时间:
复制 MD 格式

This topic describes the iOS API operations in audio and video call scenarios.

List of operations by function

AUIRoomEngine

The AUIRoomEngine API is a non-UI interface for audio and video call components. If the existing interaction does not meet your business requirements, you can use the API to encapsulate custom API operations based on your business requirements.

Operation

Description

init

The constructor used to create and initialize a RoomEngine instance.

destroy

Releases the related objects within a RoomEngine instance.

addObserver

Adds the observer that listens for a channel event callback.

removeObserver

Removes the observer that listens for a channel event callback.

roomUser

Obtains the current channel user.

roomConfig

Obtains channel configurations.

renderViewLayout

Sets or obtains video rendering views in a layout container.

startPreview

Starts the preview.

stopPreview

Stops the preview.

create

Creates a channel.

join

Joins a channel.

leave

Leaves a channel.

isJoin

Specifies whether to join a channel.

requestJoin

Invites other users to join a channel.

cancelRequestJoin

Cancels a request for inviting other users to join a channel.

responseJoin

Responds to an invitation to join a channel.

startPublish

Starts stream ingest.

stopPublish

Stops stream ingest.

isPublishing

Determines whether a stream is being ingested.

requestPublish

Invites other users to ingest streams.

cancelRequestPublish

Cancels a request for inviting other users to ingest streams.

responsePublish

Responds to a stream ingest invitation.

switchCamera

Enables or disables the camera.

switchMicrophone

Enables or disables the microphone.

switchPreviewMirror

Enables or disables the mirroring mode for the preview.

getIsPreviewMirror

Determines whether the mirroring mode is enabled for the preview.

setCameraType

Switches between the front and rear cameras.

getCameraType

Obtains the current camera type, which is the front camera or the rear camera.

switchAudioOutput

Switches the audio output type. You can set the speaker or the handset as the audio output device.

getAudioOutputType

Obtains the audio output type. You can set the speaker or the handset as the audio output device.

sendCustomMessage

Sends a custom message to a user.

getRTCEngine

Obtains an underlying Real-Time Communication (RTC) engine instance.

Static members or methods

The following table lists the API operations about the static members or methods under AUIRoomEngine.

Operation

Description

registerSDK

Registers an SDK.

currrentUser

Obtains or sets the current logon user.

login

Logs on to the ApsaraVideo MediaBox SDK app.

logout

Logs off from the ApsaraVideo MediaBox SDK app.

isLogin

Specifies whether to log on to the ApsaraVideo MediaBox SDK app.

getMessageService

Obtains an interactive messaging instance.

AUIRoomEngineDelegate

AUIRoomEngineDelegate is an API of channel engine callback events. You can use the callback method to listen for the callback events that you are interested in.

Operation

Description

onJoined

The callback that is triggered when a user joins a channel.

onLeaved

The callback that is triggered when a user leaves a channel.

onReceivedRequestJoin

The callback that is triggered when an invitation to join a channel is received.

onReceivedCancelRequestJoin

The callback that is triggered when an invitation to join a channel is canceled.

onReceivedResponseJoin

The callback that is triggered when the response indicating that an invitee joins a channel is received.

onStartedPublish

The callback that is triggered when the response indicating that a user starts stream ingest is received.

onStopedPublish

The callback that is triggered when the response indicating that a user stops stream ingest is received.

onReceivedRequestPublish

The callback that is triggered when a stream ingest invitation is received.

onReceivedCancelRequestPublish

The callback that is triggered when a stream ingest invitation is canceled.

onReceivedResponsePublish

The callback that is triggered when the response indicating that an invitee ingests a stream is received.

onReceivedMicrophoneStateChanged

The callback that is triggered when a request for switching the microphone status is received.

onReceivedCameraStateChanged

The callback that is triggered when a request for switching the camera status is received.

onMicrophoneStateChanged

The callback that is triggered when an audio stream changes between the muted and unmuted states.

onCameraStateChanged

The callback that is triggered when a black video frame is sent in a video stream.

onReceivedCustomMessage

The callback that is triggered when a custom message is received.

onError

The callback that is triggered when an error occurs.

AUIRoomRenderView

The following table lists the API operations about video rendering views.

Operation

Description

style

Sets or obtains the view style. The view style is a normal view, large view, or small view.

user

Obtains the current user who ingests and pulls a stream.

displayView

Obtains the current rendering view.

renderMode

Obtains the rendering mode of the current rendering view. The rendering mode is the auto mode, stretching mode, padding mode, or cropping mode.

AUIRoomRenderViewDefaultLayout

The following table lists the API operations about a layout container that is used to manage video rendering views.

Operation

Description

dimensions

Obtains the resolution of a rendering view.

getRenderViewList

Obtains video rendering views.

createRenderView

Creates a video rendering view.

createRenderViewCallback

Creates a video rendering view by using a callback method.

willInsertRenderView

Is about to insert a rendering view into a layout container.

insertRenderView

Inserts a rendering view into a layout container.

removeRenderView

Removes a rendering view from a layout container.

willLayoutRenderViewList

Is about to implement the layout of video rendering views in a container.

layoutRenderViewList

Implements the layout of video rendering views in a container.

smallStyleRenderViewDefaultFrame

Obtains the size of a rendering view when the rendering view is set as a small view.

smallStyleRenderViewSafeEdge

Obtains the margin of a rendering view in a layout container when the rendering view is set as a small view.

AUIRoomEngine

The AUIRoomEngine API is a non-UI interface for audio and video call components. If the existing interaction does not meet your business requirements, you can use the API to encapsulate custom API operations based on your business requirements.

init: the constructor used to create and initialize a RoomEngine instance.
override public init()
destroy: releases the related objects within a RoomEngine instance.
public func destroy()
addObserver: adds the observer that listens for a channel event callback.
public func addObserver(delegate: AUIRoomEngine.AUIRoomEngineDelegate)

Parameter

Type

Description

delegate

AUIRoomEngineDelegate

The observer that you want to add.

removeObserver: removes the observer that listens for a channel event callback.
public func removeObserver(delegate: AUIRoomEngine.AUIRoomEngineDelegate)

Parameter

Type

Description

delegate

AUIRoomEngineDelegate

The observer that you want to remove.

roomUser: obtains the current channel user.
lazy public private(set) var roomUser: AUIRoomEngine.AUIRoomUser?
roomConfig: obtains channel configurations.
public private(set) var roomConfig: AUIRoomEngine.AUIRoomEngineConfig? { get }
renderViewLayout: sets or obtains video rendering views in a layout container.
public var renderViewLayout: AUIRoomEngine.AUIRoomRenderViewLayoutProtocol?
startPreview: starts the preview.
public func startPreview(completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

stopPreview: stops the preview.
public func stopPreview(completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

create: creates a channel.
public func create(completed: @escaping (_ roomId: String?, _ error: NSError?) -> Void)

Parameter

Type

Description

completed

(_ roomId: String?, _ error: NSError?) -> Void

The callback that is triggered when the operation is complete. If the operation is successful, the channel ID is returned. If the operation fails, an error is returned.

join: joins a channel.
public func join(config: AUIRoomEngine.AUIRoomEngineConfig, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

config

AUIRoomEngineConfig

The channel configurations.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

leave: leaves a channel.
public func leave(completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

isJoin: specifies whether to join a channel.
public var isJoin: Bool { get }
requestJoin: invites other users to join a channel.
public func requestJoin(roomId: String, userId: String, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

roomId

String

The channel ID.

userId

String

The invitee ID.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

cancelRequestJoin: cancels a request for inviting other users to join a channel.
public func cancelRequestJoin(roomId: String, userId: String, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

roomId

String

The channel ID.

userId

String

The ID of the user who cancels the invitation.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

responseJoin: responds to an invitation to join a channel.
public func responseJoin(roomId: String, userId: String, agree: Bool, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

roomId

String

The channel ID.

userId

String

The invitee ID.

agree

Bool

Specifies whether to agree to join the channel.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

startPublish: starts stream ingest.
public func startPublish(completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

stopPublish: stops stream ingest.
public func stopPublish(completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

isPublishing: determines whether a stream is being ingested.
public private(set) var isPublishing: Bool { get }
requestPublish: invites other users to ingest streams.
public func requestPublish(userId: String, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

userId

String

The invitee ID.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

cancelRequestPublish: cancels a request for inviting other users to ingest streams.
public func cancelRequestPublish(userId: String, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

userId

String

The ID of the user who cancels the invitation.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

responsePublish: responds to a stream ingest invitation.
public func responsePublish(userId: String, agree: Bool, extra: [AnyHashable : Any]? = nil, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

userId

String

The invitee ID.

agree

Bool

Specifies whether to agree to ingest the stream.

extra

[AnyHashable : Any]?

The extended data.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

switchCamera: enables or disables the camera.
public func switchCamera(off: Bool, userId: String, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

off

Bool

Enables or disables the camera.

userId

String

The ID of the user whose camera is enabled or disabled.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

switchMicrophone: enables or disables the microphone.
public func switchMicrophone(off: Bool, userId: String, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

off

Bool

Enables or disables the microphone.

userId

String

The ID of the user whose microphone is enabled or disabled.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

switchPreviewMirror: enables or disables the mirroring mode for the preview.
public func switchPreviewMirror(on: Bool)

Parameter

Type

Description

on

Bool

Enables or disables the mirroring mode for the preview.

getIsPreviewMirror: determines whether the mirroring mode is enabled for the preview.
public func getIsPreviewMirror() -> Bool
setCameraType: switches between the front and rear cameras.
public func setCameraType(type: AUIRoomEngine.AUIRoomEngineCameraType)

Parameter

Type

Description

type

AUIRoomEngineCameraType

The current camera type, which is the front camera or the rear camera.

getCameraType: obtains the current camera type, which is the front camera or the rear camera.
public func getCameraType() -> AUIRoomEngine.AUIRoomEngineCameraType
switchAudioOutput: switches the audio output type. You can set the speaker or the handset as the audio output device.
public func switchAudioOutput(type: AUIRoomEngine.AUIRoomEngineAudioOutputType)

Parameter

Type

Description

type

AUIRoomEngineAudioOutputType

The audio output type. You can set the speaker or the handset as the audio output device.

getAudioOutputType: obtains the audio output type. You can set the speaker or the handset as the audio output device.
public func getAudioOutputType() -> AUIRoomEngine.AUIRoomEngineAudioOutputType
sendCustomMessage: sends a custom message to a user.
public func sendCustomMessage(message: [AnyHashable : Any], roomId: String?, userId: String? = nil, skipAudit: Bool = true, completed: AUIRoomEngine.AUIRoomEngineCompleted? = nil)

Parameter

Type

Description

message

[AnyHashable : Any]

The message body.

roomId

String?

The channel ID.

userId

String?

The ID of the user who receives the message.

skipAudit

Bool

Specifies whether to skip the review.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

getRTCEngine: obtains an underlying RTC engine instance.
public func getRTCEngine() -> AnyObject?
registerSDK: registers an SDK.
public static func registerSDK(scene: String)

Parameter

Type

Description

scene

String

The scenario identification for tracking.

currrentUser: obtains or sets the current logon user.
public static var currrentUser: AUIRoomEngine.AUIRoomUser?
login: logs on to the ApsaraVideo MediaBox SDK app.
public static func login(token: String, completed: AUIRoomEngine.AUIRoomEngineCompleted?)

The following table describes the parameters in the previous syntax.

Parameter

Type

Description

token

String

The token for logon authentication.

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

logout: logs off from the ApsaraVideo MediaBox SDK app.
public static func logout(completed: AUIRoomEngine.AUIRoomEngineCompleted?)

Parameter

Type

Description

completed

AUIRoomEngineCompleted

The callback that is triggered when the operation is complete.

isLogin: specifies whether to log on to the ApsaraVideo MediaBox SDK app.
public static var isLogin: Bool { get }
getMessageService: obtains an interactive messaging instance.
public static func getMessageService() -> AUIMessageServiceProtocol

AUIRoomEngineDelegate

AUIRoomEngineDelegate is an API of channel engine callback events. You can use the callback method to listen for the callback events that you are interested in.

onJoined: the callback that is triggered when a user joins a channel.
@objc optional func onJoined(user: AUIRoomEngine.AUIRoomUser)

Parameter

Type

Description

user

AUIRoomUser

The user who joins the channel.

onLeaved: the callback that is triggered when a user leaves a channel.
@objc optional func onLeaved(user: AUIRoomEngine.AUIRoomUser)

Parameter

Type

Description

user

AUIRoomUser

The user who leaves the channel.

onReceivedRequestJoin: the callback that is triggered when an invitation to join a channel is received.
@objc optional func onReceivedRequestJoin(user: AUIRoomEngine.AUIRoomUser, roomId: String, extra: [AnyHashable : Any]?)

Parameter

Type

Description

user

AUIRoomUser

The invitee.

roomId

String

The channel ID.

extra

[AnyHashable : Any]?

The extended data.

onReceivedCancelRequestJoin: the callback that is triggered when an invitation to join a channel is canceled.
@objc optional func onReceivedCancelRequestJoin(user: AUIRoomEngine.AUIRoomUser, roomId: String, extra: [AnyHashable : Any]?)

Parameter

Type

Description

user

AUIRoomUser

The user who cancels the invitation.

roomId

String

The channel ID.

extra

[AnyHashable : Any]?

The extended data.

onReceivedResponseJoin: the callback that is triggered when the response indicating that an invitee joins a channel is received.
@objc optional func onReceivedResponseJoin(user: AUIRoomEngine.AUIRoomUser, roomId: String, agree: Bool, extra: [AnyHashable : Any]?)

Parameter

Type

Description

user

AUIRoomUser

The user who responds to the invitation.

roomId

String

The channel ID.

agree

Bool

Indicates whether to agree to join the channel.

extra

[AnyHashable : Any]?

The extended data.

onStartedPublish: the callback that is triggered when the response indicating that a user starts stream ingest is received.
@objc optional func onStartedPublish(user: AUIRoomEngine.AUIRoomUser)

Parameter

Type

Description

user

AUIRoomUser

The user who starts stream ingest.

onStopedPublish: the callback that is triggered when the response indicating that a user stops stream ingest is received.
@objc optional func onStopedPublish(user: AUIRoomEngine.AUIRoomUser)

Parameter

Type

Description

user

AUIRoomUser

The user who stops stream ingest.

onReceivedRequestPublish: the callback that is triggered when a stream ingest invitation is received.
@objc optional func onReceivedRequestPublish(user: AUIRoomEngine.AUIRoomUser, extra: [AnyHashable : Any]?, completed: @escaping (_ agree: Bool, _ extra: [AnyHashable : Any]?) -> Void)

Parameter

Type

Description

user

AUIRoomUser

The invitee.

extra

[AnyHashable : Any]?

The extended data.

completed

(_ agree: Bool, _ extra: [AnyHashable : Any]?) -> Void

Indicates whether to agree to ingest the stream.

onReceivedCancelRequestPublish: the callback that is triggered when a stream ingest invitation is canceled.
@objc optional func onReceivedCancelRequestPublish(user: AUIRoomEngine.AUIRoomUser, extra: [AnyHashable : Any]?)

Parameter

Type

Description

user

AUIRoomUser

The user who cancels the invitation.

extra

[AnyHashable : Any]?

The extended data.

onReceivedResponsePublish: the callback that is triggered when the response indicating that an invitee ingests a stream is received.
@objc optional func onReceivedResponsePublish(user: AUIRoomEngine.AUIRoomUser, agree: Bool, extra: [AnyHashable : Any]?)

Parameter

Type

Description

user

AUIRoomUser

The invitee.

agree

Bool

Indicates whether to agree to ingest the stream.

extra

[AnyHashable : Any]?

The extended data.

onReceivedMicrophoneStateChanged: the callback that is triggered when a request for switching the microphone status is received.
@objc optional func onReceivedMicrophoneStateChanged(user: AUIRoomEngine.AUIRoomUser, off: Bool)

Parameter

Type

Description

user

AUIRoomUser

The user who initiates the invitation.

off

Bool

Enables or disables the microphone.

onReceivedCameraStateChanged: the callback that is triggered when a request for switching the camera status is received.
@objc optional func onReceivedCameraStateChanged(user: AUIRoomEngine.AUIRoomUser, off: Bool)

Parameter

Type

Description

user

AUIRoomUser

The user who initiates the invitation.

off

Bool

Enables or disables the camera.

onMicrophoneStateChanged: the callback that is triggered when an audio stream changes between the muted and unmuted states.
@objc optional func onMicrophoneStateChanged(user: AUIRoomEngine.AUIRoomUser, off: Bool)

Parameter

Type

Description

user

AUIRoomUser

The user who initiates the state change.

off

Bool

Indicates whether the audio stream is muted or unmuted.

onCameraStateChanged: the callback that is triggered when a black video frame is sent in a video stream.
@objc optional func onCameraStateChanged(user: AUIRoomEngine.AUIRoomUser, off: Bool)

Parameter

Type

Description

user

AUIRoomUser

The user who initiates the state change.

off

Bool

Indicates whether a black video frame is sent in a video stream.

onReceivedCustomMessage: the callback that is triggered when a custom message is received.
@objc optional func onReceivedCustomMessage(user: AUIRoomEngine.AUIRoomUser, message: [AnyHashable : Any])

Parameter

Type

Description

user

AUIRoomUser

The user who sends the message.

message

[AnyHashable : Any]

The message body.

onError: the callback that is triggered when an error occurs.
@objc optional func onError(_ error: Error)

Parameter

Type

Description

error

Error

The error message.

AUIRoomRenderView

The section lists the API operations about video rendering views.

style: sets or obtains the view style. The view style is a normal view, large view, or small view.
open var style: AUIRoomEngine.AUIRoomRenderView.Style
user: obtains the current user who ingests and pulls a stream.
public let user: AUIRoomEngine.AUIRoomUser
displayView: obtains the current rendering view.
public let displayView: UIView
renderMode: obtains the rendering mode of the current rendering view. The rendering mode is the auto mode, stretching mode, padding mode, or cropping mode.
public var renderMode: AUIRoomEngine.AUIRoomRenderView.RenderMode

AUIRoomRenderViewDefaultLayout

The section lists the API operations about a layout container that is used to manage video rendering views.

dimensions: obtains the resolution of a rendering view.
public private(set) var dimensions: CGSize { get }
getRenderViewList: obtains video rendering views.
public func getRenderViewList() -> [AUIRoomEngine.AUIRoomRenderView]
createRenderView: creates a video rendering view.
open func createRenderView(user: AUIRoomEngine.AUIRoomUser) -> AUIRoomEngine.AUIRoomRenderView?

Parameter

Type

Description

user

AUIRoomUser

The user who wants to create the video rendering view.

createRenderViewCallback: creates a video rendering view by using a callback method.
public var createRenderViewCallback: ((_ user: AUIRoomEngine.AUIRoomUser, _ dimensions: CGSize?) -> AUIRoomEngine.AUIRoomRenderView?)?

Parameter

Type

Description

user

AUIRoomUser

The user who wants to create the video rendering view.

dimensions

CGSize?

The resolution.

willInsertRenderView: is about to insert a rendering view into a layout container.
open func willInsertRenderView(renderView: AUIRoomEngine.AUIRoomRenderView) -> Int

Parameter

Type

Description

renderView

AUIRoomRenderView

The video rendering view.

insertRenderView: inserts a rendering view into a layout container.
open func insertRenderView(renderView: AUIRoomEngine.AUIRoomRenderView)

Parameter

Type

Description

renderView

AUIRoomRenderView

The video rendering view.

removeRenderView: removes a rendering view from a layout container.
open func removeRenderView(renderView: AUIRoomEngine.AUIRoomRenderView)

Parameter

Type

Description

renderView

AUIRoomRenderView

The video rendering view that you want to remove.

willLayoutRenderViewList: is about to implement the layout of video rendering views in a container.
open func willLayoutRenderViewList()
layoutRenderViewList: implements the layout of video rendering views in a container.
open func layoutRenderViewList()
smallStyleRenderViewDefaultFrame: obtains the size of a rendering view when the rendering view is set as a small view.
open var smallStyleRenderViewDefaultFrame: CGRect { get }
smallStyleRenderViewSafeEdge: obtains the margin of a rendering view in a layout container when the rendering view is set as a small view.
open var smallStyleRenderViewSafeEdge: UIEdgeInsets { get }