ARBroadcaster
open class ARBroadcaster : UIViewController
extension ARBroadcaster: ARSCNViewDelegate
extension ARBroadcaster: ARSessionDelegate
extension ARBroadcaster: AgoraRtcEngineDelegate
extension ARBroadcaster: RenderARDelegate
Undocumented
-
A reference to the
ARSCNView
Declaration
Swift
public var sceneView: ARSCNView!
-
The
ARWorldTrackingConfiguration
‘s setting for plane detectionDefaults to
nil
Declaration
Swift
public var planeDetection: ARWorldTrackingConfiguration.PlaneDetection?
-
Setting to enable default lighting within the ARSCNView
Declaration
Swift
open var enableDefaultLighting: Bool
-
Setting to update lighting information within the ARSCNView
Declaration
Swift
open var autoUpdateLights: Bool
-
Setting to enable light estimation within the
ARTrackingConfiguration
Declaration
Swift
open var lightEstimation: Bool
-
Debug option for the
ARTrackingConfiguration
to display render statsDeclaration
Swift
open var showStatistics: Bool
-
Debug option for the
ARTrackingConfiguration
to display debug dataDeclaration
Swift
open var arSceneDebugOptions: SCNDebugOptions
-
Undocumented
Declaration
Swift
public var channelProfile: AgoraChannelProfile
-
Undocumented
Declaration
Swift
public var frameRate: AgoraVideoFrameRate
-
Undocumented
Declaration
Swift
public var videoDimension: CGSize
-
Undocumented
Declaration
Swift
public var videoBitRate: Int
-
Undocumented
Declaration
Swift
public var videoOutputOrientationMode: AgoraVideoOutputOrientationMode
-
Undocumented
Declaration
Swift
public var audioSampleRate: UInt
-
Undocumented
Declaration
Swift
public var audioChannelsPerFrame: UInt
-
Undocumented
Declaration
Swift
public var defaultToSpeakerPhone: Bool
-
Undocumented
Declaration
Swift
public var channelName: String!
-
A
UIButton
that toggles the microphoneDeclaration
Swift
public var micBtn: UIButton!
-
Undocumented
Declaration
Swift
public var micBtnFrame: CGRect?
-
Undocumented
Declaration
Swift
public var micBtnImage: UIImage?
-
Undocumented
Declaration
Swift
public var micBtnTextLabel: String
-
Undocumented
Declaration
Swift
public var muteBtnImage: UIImage?
-
Undocumented
Declaration
Swift
public var muteBtnTextLabel: String
-
A
UIButton
that dismisses the view controller when tappedDeclaration
Swift
public var backBtn: UIButton!
-
Undocumented
Declaration
Swift
public var backBtnFrame: CGRect?
-
Undocumented
Declaration
Swift
public var backBtnImage: UIImage?
-
Undocumented
Declaration
Swift
public var backBtnTextLabel: String
-
An optional
UIImageView
that displays a watermark over part of the video.Declaration
Swift
public var watermark: UIImageView?
-
Undocumented
Declaration
Swift
public var watermarkImage: UIImage?
-
Undocumented
Declaration
Swift
public var watermarkFrame: CGRect?
-
Undocumented
Declaration
Swift
public var watermarkAlpha: CGFloat
-
Undocumented
Declaration
Swift
public var viewBackgroundColor: UIColor
-
Undocumented
Declaration
Swift
public var debug: Bool
-
Undocumented
Declaration
Swift
public var showLogs: Bool
-
AgoraARKit uses the
viewDidLoad
method to create the UI, set up the Agora engine configuration, set theARSCNViewDelegate
/ARSessionDeleagates
, set up the off screen renderer and configure the SceneView’sDeclaration
Swift
override open func viewDidLoad()
-
AgoraARKit sets up and runs the ARTracking configuration within the
viewWillAppear
Declaration
Swift
override open func viewWillAppear(_ animated: Bool)
-
AgoraARKit joins the Agora channel within the
viewDidAppear
Declaration
Swift
override open func viewDidAppear(_ animated: Bool)
-
AgoraARKit pauses the AR session within the
viewWillDisappear
Declaration
Swift
override open func viewWillDisappear(_ animated: Bool)
-
Since Apple does not provide explicit de-initializers for the ARSCN, AgoraARKit use
viewDidDisappear
to free up resources and clean up the SceneView references.Declaration
Swift
override open func viewDidDisappear(_ animated: Bool)
-
AgoraARKit hides the status bar UI
Declaration
Swift
override open var prefersStatusBarHidden: Bool { get }
-
Conencts to the Agora channel, and sets the default audio route to speakerphone
Declaration
Swift
open func joinChannel()
-
Undocumented
Declaration
Swift
open func leaveChannel()
-
Programmatically generated UI, creates the SceneView, and buttons.
Declaration
Swift
open func createUI()
-
Undocumented
Declaration
Swift
open func setARConfiguration()
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval)
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval)
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, didRenderScene scene: SCNScene, atTime time: TimeInterval)
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor)
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor)
-
Undocumented
Declaration
Swift
open func renderer(_ renderer: SCNSceneRenderer, didRemove node: SCNNode, for anchor: ARAnchor)
-
Undocumented
Declaration
Swift
open func session(_ session: ARSession, didUpdate frame: ARFrame)
-
Undocumented
Declaration
Swift
open func session(_ session: ARSession, didOutputAudioSampleBuffer audioSampleBuffer: CMSampleBuffer)
-
Undocumented
Declaration
Swift
open func session(_ session: ARSession, didFailWithError error: Error)
-
Undocumented
Declaration
Swift
open func sessionWasInterrupted(_ session: ARSession)
-
Reports a warning during the Agora SDK at runtime.
In most cases, the app can ignore the warning reported by the SDK because the SDK can usually fix the issue and resume running.
For instance, the SDK may report an AgoraWarningCodeOpenChannelTimeout(106) warning upon disconnection from the server and attempts to reconnect.
See AgoraWarningCode.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didOccurWarning warningCode: AgoraWarningCode)
Parameters
engine
AgoraRtcEngineKit object
warningCode
Warning code. Full list: AgoraWarningCode
-
Reports an error during the Agora SDK at runtime.
In most cases, the SDK cannot fix the issue and resume running. The SDK requires the app to take action or informs the user about the issue.
For example, the SDK reports an AgoraErrorCodeStartCall = 1002 error when failing to initialize a call. The app informs the user that the call initialization failed and invokes the leaveChannel method to leave the channel.
See AgoraErrorCode.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didOccurError errorCode: AgoraErrorCode)
Parameters
engine
AgoraRtcEngineKit object
errorCode
-
Occurs when a method is executed by the SDK.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didApiCallExecute error: NSInteger, api: String, result: String)
Parameters
engine
AgoraRtcEngineKit object
error
The AgoraErrorCode returned by the SDK when the method call fails. If the SDK returns 0, then the method call succeeds.
api
The method executed by the SDK.
result
The result of the method call.
-
Occurs when the local user joins a specified channel.
Same as joinSuccessBlock in the joinChannelByToken method.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinChannel channel: String, withUid uid: UInt, elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
channel
Channel name.
uid
User ID. If the
uid
is specified in thejoinChannelByToken
method, the specified user ID is returned. If theuser ID
is not specified when thejoinChannel
method is called, the server automatically assigns a uid.elapsed
The time elapsed (ms) from the local user calling Agora’s
joinChannelByToken
orsetClientRole
method, until the SDK triggers this callback. -
Occurs when the local user rejoins a channel.
If the client loses connection with the server because of network problems, the SDK automatically attempts to reconnect and then triggers this callback upon reconnection, indicating that the user rejoins the channel with the assigned channel ID and user ID.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didRejoinChannel channel: String, withUid uid: UInt, elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
channel
Channel name.
uid
User ID. If the
uid
is specified in thejoinChannelByToken
method, the specified user ID is returned. If theuser ID
is not specified when thejoinChannel
method is called, the server automatically assigns a uid.elapsed
The time elapsed (ms) from the local user calling Agora’s
joinChannelByToken
orsetClientRole
method, until the SDK triggers this callback. -
Occurs when the local user leaves a channel.
When the app calls the
leaveChannel
method, this callback notifies the app that a user leaves a channel.With this callback, the app retrieves information, such as the call duration and the statistics of the received/transmitted data reported by the
audioQualityOfUid
callback.Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didLeaveChannelWith stats: AgoraChannelStats)
Parameters
engine
AgoraRtcEngineKit object
stats
Statistics of the call:. See AgoraChannelStats for more details.
-
Occurs when the local user successfully registers a user account by calling the registerLocalUserAccount or joinChannelByUserAccount method.
This callback reports the user ID and user account of the local user.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didRegisteredLocalUser userAccount: String, withUid uid: UInt)
Parameters
engine
AgoraRtcEngineKit object
userAccount
The user account of the local user.
uid
The ID of the local user.
-
Occurs when the SDK gets the user ID and user account of the remote user.
After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (userInfo), and triggers this callback on the local client.
Declaration
Swift
open func rtceEngine(_ engine: AgoraRtcEngineKit, didUpdated userInfo: AgoraUserInfo, withUid uid: UInt)
Parameters
engine
AgoraRtcEngineKit object
userInfo
The AgoraUserInfo object that contains the user ID and user account of the remote user.
uid
The ID of the remote user.
-
Occurs when the local user role switches in a live broadcast.
The SDK triggers this callback when the local user switches the user role by calling the setClientRole method after joining the channel.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didClientRoleChanged oldRole: AgoraClientRole, newRole: AgoraClientRole)
Parameters
engine
AgoraRtcEngineKit object
oldRole
Role that the user switches from: AgoraClientRole.
newRole
Role that the user switches to: AgoraClientRole.
-
Occurs when a remote user or host joins a channel.
The SDK triggers this callback under one of the following circumstances: - A remote user/host joins the channel by calling the joinChannelByToken method. - A remote user switches the user role to the host by calling the setClientRole method after joining the channel. - A remote user/host rejoins the channel after a network interruption. - A host injects an online media stream into the channel by calling the addInjectStreamUrl method.
Note
Live-broadcast profile:- The host receives this callback when another host joins the channel.
- The audience in the channel receives this callback when a new host joins the channel.
- When a web application joins the channel, the SDK triggers this callback as long as the web application publishes streams.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinedOfUid uid: UInt, elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
channel
Channel name.
uid
ID of the remote user whose video state changes.
elapsed
The time elapsed (ms) from the local user calling Agora’s
joinChannel
method until the SDK triggers this callback. -
Occurs when a remote user (Communication)/host (Live Broadcast) leaves a channel. Same as userOfflineBlock.
There are two reasons for users to be offline:
- Leave a channel: When the user/host leaves a channel, the user/host sends a goodbye message. When the message is received, the SDK assumes that the user/host leaves a channel.
- Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the Communication profile, and more for the Live-broadcast profile), the SDK assumes that the user/host drops offline. Unreliable network connections may lead to false detections, so Agora recommends using a signaling system for more reliable offline detection.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason)
Parameters
engine
AgoraRtcEngineKit object
uid
ID of the user or host who leaves a channel or goes offline.
reason
Reason why the user goes offline, see AgoraUserOfflineReason.
-
Occurs when the network connection state changes.
The SDK triggers this callback to report on the current network connection state when it changes, and the reason of the change.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, connectionChangedTo state: AgoraConnectionStateType, reason: AgoraConnectionChangedReason)
Parameters
engine
AgoraRtcEngineKit object
state
The current network connection state, see AgoraConnectionStateType.
reason
The reason of the connection state change, see AgoraConnectionChangedReason.
-
Occurs when the local network type changes.
When the network connection is interrupted, this callback indicates whether the interruption is caused by a network type change or poor network conditions.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, networkTypeChangedTo type: AgoraNetworkType)
Parameters
engine
AgoraRtcEngineKit object
type
The network type, see AgoraNetworkType.
-
Occurs when the SDK cannot reconnect to Agora’s edge server 10 seconds after its connection to the server is interrupted.
The SDK triggers this callback when it cannot connect to the server 10 seconds after calling the joinChannelByToken method, regardless of whether it is in the channel or not.
This callback is different from rtcEngineConnectionDidInterrupted:
- The SDK triggers the rtcEngineConnectionDidInterrupted callback when it loses connection with the server for more than four seconds after it successfully joins the channel.
- The SDK triggers the rtcEngineConnectionDidLost callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not. If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora’s edge server, the SDK stops rejoining the channel.
Declaration
Swift
open func rtcEngineConnectionDidLost(_ engine: AgoraRtcEngineKit)
Parameters
engine
AgoraRtcEngineKit object
-
Occurs when the token expires in 30 seconds.
The user becomes offline if the token used in the joinChannelByToken method expires. The SDK triggers this callback 30 seconds before the token expires to remind the app to get a new token. Upon receiving this callback, generate a new token on the server and call the renewToken method to pass the new token to the SDK.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, tokenPrivilegeWillExpire token: String)
Parameters
engine
AgoraRtcEngineKit object
token
The token that expires in 30 seconds.
-
Occurs when the token expires.
After a token is specified by calling the joinChannelByToken method, if the SDK losses connection to the Agora server due to network issues, the token may expire after a certain period of time and a new token may be required to reconnect to the server.
Th SDK triggers this callback to notify the app to generate a new token. Call the renewToken method to renew the token.
Declaration
Swift
open func rtcEngineRequestToken(_ engine: AgoraRtcEngineKit)
Parameters
engine
AgoraRtcEngineKit object
-
Reports which users are speaking, the speakers’ volumes, and whether the local user is speaking.
This callback reports the IDs and volumes of the loudest speakers at the moment in the channel, and whether the local user is speaking. By default, this callback is disabled. You can enable it by calling the enableAudioVolumeIndication method. Once enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not. The SDK triggers two independent reportAudioVolumeIndicationOfSpeakers callbacks at one time, which separately report the volume information of the local user and all the remote speakers. For more information, see the detailed parameter descriptions.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, reportAudioVolumeIndicationOfSpeakers speakers: [AgoraRtcAudioVolumeInfo], totalVolume: Int)
Parameters
engine
AgoraRtcEngineKit object
speakers
AgoraRtcAudioVolumeInfo array. An empty speakers array in the callback indicates that no remote user is speaking at the moment.
- In the local user’s callback, this array contains the following members: uid = 0, volume = totalVolume, which reports the sum of the voice volume and audio-mixing volume of the local user, and vad, which reports the voice activity status of the local user.
- In the remote speakers’ callback, this array contains the following members: uid of each remote speaker, volume, which reports the sum of the voice volume and audio-mixing volume of each remote speaker, and vad = 0.
totalVolume
Total volume after audio mixing. The value range is [0,255].
- In the local user’s callback, totalVolume is the sum of the voice volume and audio-mixing volume of the local user.
- In the remote speakers’ callback, totalVolume is the sum of the voice volume and audio-mixing volume of all the remote speakers.
-
Occurs when a remote user’s audio stream is muted/unmuted.
The SDK triggers this callback when the remote user stops or resumes sending the audio stream by calling the muteLocalAudioStream method.
Note
This callback is invalid when the number of the users or broadcasters in a channel exceeds 20.Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didAudioMuted muted: Bool, byUid uid: UInt)
Parameters
engine
AgoraRtcEngineKit object
muted
Whether the remote user’s audio stream is muted/unmuted. Where
true
represets MUTED, andfalse
is UNMUTEDuid
ID of the remote user or host who’s mic was muted
-
Reports which user is the loudest speaker over a period of time.
This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling the enableAudioVolumeIndication method, this callback returns the user ID of the active speaker whose voice is detected by the audio volume detection module of the SDK.
Note
- To receive this callback, you need to call the enableAudioVolumeIndication method.
- This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, activeSpeaker speakerUid: UInt)
Parameters
engine
AgoraRtcEngineKit object
speakerUid
The user ID of the active speaker. A speakerUid of 0 represents the local user.
-
Occurs when the engine sends the first local audio frame.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, firstLocalAudioFrame elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
elapsed
Time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK triggers this callback.
-
Occurs when the engine receives the first audio frame from a specified remote user.
This callback is triggered in either of the following scenarios:
- The remote user joins the channel and sends the audio stream.
- The remote user stops sending the audio stream and re-sends it after 15 seconds. Possible reasons include:
- The remote user leaves channel.
- The remote user drops offline.
- The remote user calls muteLocalAudioStream.
- The remote user calls disableAudio.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, firstRemoteAudioFrameOfUid uid: UInt, elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
uid
User ID of the remote user.
elapsed
Time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK triggers this callback.
-
Occurs when a remote user’s video stream playback pauses/resumes.
You can also use the remoteVideoStateChangedOfUid callback with the following parameters:
AgoraVideoRemoteStateStopped(0)
andAgoraVideoRemoteStateReasonRemoteMuted(5)
.AgoraVideoRemoteStateDecoding(2)
andAgoraVideoRemoteStateReasonRemoteUnmuted(6)
.
The SDK triggers this callback when the remote user stops or resumes sending the video stream by calling the muteLocalVideoStream method.
Note
This callback is invalid when the number of users or broadcasters in a channel exceeds 20.Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didVideoMuted muted: Bool, byUid uid: UInt)
Parameters
engine
AgoraRtcEngineKit object
muted
A remote user’s video stream playback pauses/resumes. Where
true
represets PAUSE, andfalse
is RESUMEuid
ID of the remote user or host who’s video was paused/resumed
-
Occurs when the remote video state changes.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, remoteVideoStateChangedOfUid uid: UInt, state: AgoraVideoRemoteState, reason: AgoraVideoRemoteStateReason, elapsed: Int)
Parameters
engine
AgoraRtcEngineKit object
uid
ID of the remote user whose video state changes.
state
The state of the remote video. For more detail see AgoraVideoRemoteState
reason
The reason of the remote video state change. For more detail see AgoraVideoRemoteStateReason
elapsed
The time elapsed (ms) from the local user calling Agora’s
joinChannel
method until the SDK triggers this callback.
-
Occurs when the local user receives the data stream from a remote user within five seconds.
The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the sendStreamMessage method.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, receiveStreamMessageFromUid uid: UInt, streamId: Int, data: Data)
Parameters
engine
AgoraRtcEngineKit object
uid
User ID of the remote user sending the message.
streamId
Stream ID
data
Data received by the local user
-
Occurs when the local user does not receive the data stream from the remote user within five seconds.
The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the sendStreamMessage method.
Declaration
Swift
open func rtcEngine(_ engine: AgoraRtcEngineKit, didOccurStreamMessageErrorFromUid uid: UInt, streamId: Int, error: Int, missed: Int, cached: Int)
Parameters
engine
AgoraRtcEngineKit object
uid
User ID of the remote user sending the message.
streamId
Stream ID
error
Error code. See AgoraErrorCode.
missed
Number of lost messages.
cached
Number of incoming cached messages when the data stream is interrupted.
-
Declaration
Swift
open func frame(didRender buffer: CVPixelBuffer, with time: CMTime, using rawBuffer: CVPixelBuffer)