This section describes how to implement the basic features of a virtual host scenario.
Refer to the flowcharts for the following functions:
Product | SDK downloads | Integration guide |
---|---|---|
Agora RTC (Real-time Communication) SDK | Agora SDK for iOS | Start a Live broadcast |
Agora RTM (Real-time Messaging) SDK | Real-time messaging SDK | Peer-to-peer or Channel Messaging |
Third-party Animoji Enhancement SDK | N/A | Refer to the integration guide of the third-party Animoji SDK. |
The following diagrams show the core APIs that the Agora Live Demo app uses to implement a multi-hosted interactive streaming scenario. Refer to them to implement the various functions in your project.
API | Function |
---|---|
initWithAppId | Creates an RTM Client object. |
loginByToken | Logs into the Agora RTM system. |
createChannelWithId | Creates an Agora RTM channel. |
joinWithCompletion | Joins the RTM channel. |
sendMessage | Sends a channel message, which can be received by all users in the channel. |
sendMessage | Sends a peer message. The host uses this method to send a co-hosting invitation to an audience member; an audience member uses this method to send a co-hosting application to the host. |
messageReceived | Occurs when receiving a channel message. |
messageReceived | Occurs when receiving a peer-to-peer message. |
leaveWithCompletion | Leaves the RTM channel. |
logoutWithCompletion | Logs out of the Agora RTM system. |
API | Function |
---|---|
sharedEngineWithAppId | Creates an RtcEngine object. |
setChannelProfile | Sets the channel profile. In multi-hosted interactive streaming, the channel profile is set as Broadcasting . |
setClientRole | Sets the user role in interactive streaming. In multi-hosted interactive streaming, use this method to switch a user between a co-host and an audience member. |
enableVideo | Enables video. |
setupLocalVideo | Sets the local video view. Call this method on the clients of the host and co-hosts to enable the host and co-hosts to see their own video view. |
joinChannelByToken | Joins the RTC channel. |
setupRemoteVideo | Sets the remote video view. Call this method on the clients of the host and co-hosts to enable the audience to see the video view of the host and co-hosts. |
leaveChannel | Leaves the channel. |
setVideoSource | Sets the video source. |
consumePixelBuffer | Uses the video information in the pixel buffer. |
startPreview | Starts the local video preview before joining a channel. |
Network quality detection
Use the reportRtcStats
callback to detect and report the network quality in real-time. Triggered once every two seconds during a live broadcast, this callback reports statistics, including the sending and receiving bitrate and packet loss rate.
In-ear monitoring
Call enableInEarMonitoring
to enable the in-ear monitor function on the host's client.
Audio mixing
After joining the channel, call startAudioMixing
on the host's client to play background music.
Agora provides an open-source sample project for Virtual Host on GitHub for you to download as a source code reference.