This article describes how to implement the basic features of multi-hosted interactive streaming.
Refer to the flowcharts for the following functions:
- Joins and leaves the room.
- Controls host seats.
Integrate the SDK
Refer to the following table to integrate the SDKs into your project:
Core API call sequence
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.
The host joins the room and starts the interactive streaming.
The host invites the audience for co-hosting, stops co-hosting, mutes and unmutes a co-host, and closes and reopens a host seat.
The audience applies for co-hosting and switches back to an audience member.
Core API reference
- Agora RTM SDK
|createInstance||Creates an RTM Client object.|
|login||Logs into the Agora RTM system.|
|createChannel||Creates an Agora RTM channel.|
|join||Joins the RTM channel.|
|sendMessage||Sends a channel message, which can be received by all users in the channel.|
|sendMessageToPeer||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.|
|onMessageReceived||Occurs when receiving a peer-to-peer message.|
|leave||Leaves the RTM channel.|
|logout||Logs out of the Agora RTM system.|
- Agora RTC SDK
|create||Creates an RtcEngine object.|
|setChannelProfile||Sets the channel profile. In multi-hosted interactive streaming, the channel profile is set as
|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.|
|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.|
|joinChannel||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.|
|muteLocalAudioStream||Stops or resumes sending the local audio stream. Use this method with
|muteLocalVideoStream||Stops or resumes sending the local video stream. Use this method with
|leaveChannel||Leaves the channel.|
The Agora Live Demo app uses a third-party SDK for image enhancement. You can refer to the source code in the faceunity file to implement the function.
Network quality detection
onRtcStats 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.
enableInEarMonitoring to enable the in-ear monitor function on the host's client.
After joining the channel, call
startAudioMixing on the host's client to play background music.
Open-source sample project
Agora provides an open-source sample project for Multi-hosted Interactive Streaming on GitHub for you to download as a source code reference.