Monitoring Network Quality - iOS
VideoSDK provides the onQualityLimitation event to keep your app informed whenever media quality is affected or recovers in a room.
onQualityLimitation
-
This event will be triggered when a quality limitation is detected or resolved in the room. It describes the video your device sends, such as your webcam or screen share.
-
It will pass
typeas an event callback parameter which will indicate the type of quality limitation affecting media performance. All possible types are :CPU: Quality is limited due to high CPU usage.BANDWIDTH: Quality is limited due to insufficient available bandwidth.CONGESTION: Quality is limited due to network congestion.
-
It will pass
stateas an event callback parameter which will indicate whether a quality limitation is currently active or has been resolved. All possible states are :DETECTED: The limitation is detected.RESOLVED: The limitation is resolved.
-
It will pass
timestampas an event callback parameter which will indicate the time (in milliseconds since epoch) when the event occurred. -
Implement this method of the
RoomEventListenerprotocol, and register the listener with theaddEventListener(_:)method of theRoomclass.
Example
Here is the usage of the event mentioned in this page.
- Swift
extension RoomViewController: RoomEventListener {
func onQualityLimitation(type: QualityLimitationType, state: QualityLimitationState, timestamp: Int) {
switch type {
case .CPU:
print("Quality limited due to high CPU usage: \(state) at \(timestamp)")
case .BANDWIDTH:
print("Quality limited due to low bandwidth: \(state) at \(timestamp)")
case .CONGESTION:
print("Quality limited due to network congestion: \(state) at \(timestamp)")
@unknown default:
break
}
}
}
Checking the Connection
To see how much your connection is sending and receiving, call getTransportStats() on room.localParticipant. It returns a dictionary with a send entry (outgoingBitrate in kbps and totalSentBytes) and a receive entry (incomingBitrate in kbps and totalReceivedBytes), or nil when no stats are available. It waits for a reply from the server, so avoid calling it on the main thread. Refer to the Understanding Call Quality guide for an example.
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord

