BRTC 提供 onStatistics 回调事件,它会每隔两秒钟一次向应用层上报当前网络质量,其参数包括本地推流和远端拉流质量两个部分:
BRTCListener brtcListener = new BRTCBaseListener() { @Override public void onStatistics(BRTCStatistics statics) { Log.d(TAG, "onStatistics: " + statics.toString()); runOnUiThread(new Runnable() { @Override public void run() { appCPUText.setText("cpu:"+statics.appCpu); sendBytesText.setText("cpu:"+statics.sendBytes); receiveBytesText.setText("cpu:"+statics.receiveBytes); if (isPublish) { publisherRttText.setText(statics.rtt + "ms"); publisherLossText.setText(statics.upLoss + "%"); ArrayList<BRTCStatistics.BRTCLocalStatistics> localArray = statics.localArray; for (BRTCStatistics.BRTCLocalStatistics localStatics:localArray) { publisherResolutionText.setText(localStatics.width + "x" + localStatics.height); publisherBitrateText.setText(localStatics.videoBitrate + "kbps"); publisherFpsText.setText(localStatics.frameRate + "f/s"); publisherSampleText.setText(localStatics.audioSampleRate + "Hz"); publisherAudioBitrateText.setText(localStatics.audioBitrate + "kbps"); publisherStreamTypeText.setText(localStatics.streamType); } } if (isPlay) { playerRttText.setText(statics.rtt + "ms"); playerLossText.setText(statics.downLoss + "%"); ArrayList<BRTCStatistics.BRTCRemoteStatistics> remoteArray = statics.remoteArray; for (BRTCStatistics.BRTCRemoteStatistics remoteStatics:remoteArray) { playerResolutionText.setText(remoteStatics.width + "x" + remoteStatics.height); playerBitrateText.setText(remoteStatics.videoBitrate + "kbps"); playerFpsText.setText(remoteStatics.frameRate + "f/s"); playerDelayText.setText(remoteStatics.jitterBufferDelay + "ms"); playerLossText.setText(remoteStatics.finalLoss + "%"); playerUserIdText.setText(remoteStatics.userId); playerSampleText.setText(remoteStatics.audioSampleRate + "Hz"); playerAudioBitrateText.setText(remoteStatics.audioBitrate + "kbps"); playerStreamTypeText.setText(remoteStatics.streamType); } } } }); } };
流类型 BRTCVideoStreamType 定义如下:
通话质量检测
BRTC 提供 onStatistics 回调事件,它会每隔两秒钟一次向应用层上报当前网络质量,其参数包括本地推流和远端拉流质量两个部分:
示例代码
流类型 BRTCVideoStreamType 定义如下: