Live quality management
When users participate in a live event, network connection may fluctuate throughout the event, affecting the streaming quality. In such case, you might want to notify users of their network quality, rather than having the event interrupted without any alert.
Sendbird Live provides functionalities to configure the quality of video streaming during a live event, and to notify the users whenever the connection quality changes throughout the event.
Video streaming settings
When streaming video content as hosts, it is essential to consider the fluctuations in network conditions that may occur during the stream. You can allow hosts to set and adjust their video quality settings through mediaOptions.videoQualityConstraints
.
Note: The video quality settings are needed only when the live event's
type
is set tovideo
. Each host in the event can configure their own settings according to their preference.
While WebRTC automatically adjusts the media quality based on the available network capacity, there are instances where fine-tuning specific properties becomes necessary to align with the purpose and requirements of the event.
For example, in conference event streams, emphasis may be placed on video resolutions to ensure clear visuals, while in sport event streams, the focus might be on maintaining a higher video frame rate to capture fast-paced action accurately.
Specify videoQualityConstraints
When starting the stream as hosts, set the following three parameters in videoQualityConstraints
.
List of the videoQualityConstraints parameters
Parameter | Description |
---|---|
resolution | Specifies the video resolution that the WebRTC stream uses. |
fps | Specifies the frames per second for the WebRTC Video stream. |
degradationPreference | Specifies a degradation preference to prioritize a specific aspect of the stream. |
Note: Before setting thess parameters, check the supported
resolution
orfps
on your device. If you set aresolution
orfps
value that is not supported by the device, or don't set either of the two, the system will automatically set an approximate value.
Adjust the settings during streaming
While the initial configuration sets the video quality constraints, it's important to note that WebRTC's adaptive nature adjusts the media quality based on network conditions as well.
However, if you find the need to make real-time adjustments to the video quality during the live event, use the updateVideoQualityConstraints()
function.
This function allows you to modify the current resolution, FPS, or other quality parameters on the fly to better adapt to changing network conditions or specific event requirements. By dynamically adjusting these constraints, you can ensure a smooth streaming experience for the audience.
Connection quality indicator
You can notify both hosts and participants whenever there is a change in their network connection status during the live event. To do so, listen to events related to the connection quality change through ConnectionQualityListener
and create an indicator to inform the status to the users.
Set ConnectionQualityListener
To detect changes in connection quality, use the ConnectionQualityMonitor
class. Set its ConnectionQualityListener
and select a ConnectionQualityMonitoringMode
value: either FREQUENCY
or CONNECTION_QUALITY_CHANGE
. Whenever there is a change in connection quality, the onConnectionQualityUpdated()
method will be called according to the specified mode.
List of the monitoring modes
Mode | Description |
---|---|
FREQUENCY | Monitors the connection quality every three seconds after the |
CONNECTION_QUALITY_CHANGE | Monitors the changes in connection quality level which can call the |
Remove the ConnectionQualityListener settings
When the listener is no longer needed, set the listener to null
to remove its previous configuration.
Connection metrics
The connection quality data can vary by each host and participant in a live event, and this can be quantified and analyzed by ConnectionMetrics
.
While you have flexibility to define connection quality value ranges that correspond to different quality levels, here’s a general guideline for interpreting these ranges and setting up the corresponding enumeration values.
How to read ConnectionMetrics
Quality level | Packet Lost Rate | Round Trip Time |
---|---|---|
Excellent | 0%-0.5% | 0ms - 150ms |
Good | 0.5%-1% | 150ms-200ms |
Fair | 1%-2.5% | 200ms-250ms |
Poor | 2.5%-5% | 250ms-300ms |
Very Poor | > 5% | > 300ms |
Based on the ConnectionQuality
enum, you can assess the current quality of the streaming and implement appropriate actions to improve it. For example, you might display a quality degradation alert to the user if the connection quality drops below average.