I have used getStats(RTCStatsCollectorCallback callback) API to get 'Bitrate Sent' and 'Bitrate Received' values.
I am facing 2 issues:
1). When only 1 user is present in conference, sometimes 'Bitrate Sent' value is coming very big(in mbps).
2). When only 2(or more) users are present in conference and one user(not host) shared his screen, the returned values fluctuate too much (means sometimes it's very less and sometimes it's very big(in mbps)).
peerConnection.getStats(new RTCStatsCollectorCallback() {
@Override
public void onStatsDelivered(RTCStatsReport rtcStatsReport) {
for (Map.Entry<String, RTCStats> e : rtcStatsReport.getStatsMap().entrySet()) {
if (e.getKey().startsWith("RTCInboundRTPAudioStream") ||
e.getKey().startsWith("RTCInboundRTPVideoStream")) {
String receivedBitrate = null;
if (e.getValue().getMembers().get("bytesReceived") != null) {
receivedBitrate = ("" +
e.getValue().getMembers().get("bytesReceived"));
}
}
if (e.getKey().startsWith("RTCOutboundRTPAudioStream") ||
e.getKey().startsWith("RTCOutboundRTPVideoStream")) {
String sentBitrate = null;
if (e.getValue().getMembers().get("bytesSent") != null) {
sentBitrate = ("" +
e.getValue().getMembers().get("bytesSent"));
}
}
}
}
}
I think I am missing something in consuming data from new getStats() API. Any help or guidance will be well appreciated.