This article introduces some best practices for calling an API or setting a parameter while implementing video streaming use cases.
The video streaming use case is built on the Agora RTC SDK, Agora RTM SDK, and the third-party image enhancement SDK.
Refer to the following
In scenarios with high security requirements, such as online education, Agora recommends every teacher and student test their network and device before a class begins. For details, see Pre-call Tests。
Different use cases require different channel profiles. For interactive video streaming use cases, call setChannelProfile
and set profile
as LIVE_BROADCASTING
.
A user can take the role of either broadcaster or audience. A broadcaster sends and recieves streams, while an audience member only recieves streams.
Before joining the channel, call setClientRole
to set the intial user role. During the live streaming, you can also call setClientRole
to switch the user role, in case an audience member wants to become a co-host.
To enhance communication security, Agora recommends authenticating your users with dynamic tokens and setting the expiration timestamp to a reasonable duration. For how to get and use dynamic tokens, see Set up authentication.
For most video streaming scenarios, you can use the default audio profile.
When calling setVideoEncoderConfiguration
to set the video resolution, frame rate, and bitrate, Agora recommends setting them to a reasonable value. High resolution puts pressure on the codec CPU and leads to video freeze, particularly on lower-end devices. On the other hand, high bitrate compromises the uplink and downlink bandwidth. Therefore, under the premise that video quality can be guaranteed, we suggest setting a lower video resolution and bitrate to alleviate resource consumption and the downlink bandwidth.
For recommended video resolution, frame rate, and bitrate, refer to Set the Video Profile.
In scenarios involving rotating the video, you can use the setVideoEncoderConfiguration
method. For details, see Set the Video Profile.
In video scenarios with multiple users, Agora recommends using the dual-stream feature of the RTC SDK. To enable this function, call enableDualStreamMode
from all clients that publish streams, and setRemoteVideoStreamType
from all clients that receive streams. For details, see Video for Multiple Users。
Under limited network conditions where guaranteeing both audio and video is not possible, you can call setLocalPublishFallbackOption
and setRemoteSubscribeFallbackOption
to enable the stream fallback function. For details, see Stream fallback。
To ensure user experience, you can monitor the network quality during the class, and report the statistics of the local or remote network quality in the user interface. For details, see In-call stats。
If a user fails to join the channel within 10 seconds, check whether the network environment has a firewall that restricts network access. If so, refer to Firewall Requirements to add firewall whitelist or use Agora cloud proxy.