字段 | 含义 | 含义说明 |
success | 是否成功 | 本次测试是否成功 |
errMsg | 错误信息 | 带宽测试的详细错误信息 |
ip | 服务器 IP | 测速服务器的 IP |
网络质量评分 | 通过评估算法测算出的网络质量,loss 越低,rtt 越小,得分也就越高 | |
upLostRate | 上行丢包率 | 范围是[0 - 1.0],例如0.3代表每向服务器发送10个数据包,可能有3个会在中途丢失 |
downLostRate | 下行丢包率 | 范围是[0 - 1.0],例如0.2代表从服务器每收取10个数据包,可能有2个会在中途丢失 |
rtt | 网络延时 | 代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好,正常数值在 10ms - 100ms 之间 |
availableUpBandwidth | 上行带宽 | 预测的上行带宽,单位为kbps, -1表示无效值 |
availableDownBandwidth | 下行带宽 | 预测的下行带宽,单位为kbps, -1表示无效值 |
startSpeedTest
启动测速功能,测速结果将会通过回调函数返回。// 启动网络测速的示例代码, 需要 sdkAppId 和 UserSig,(获取方式参考基本功能)// 这里以登录后开始测试为例- (void)onLogin:(NSString *)userId userSig:(NSString *)userSid{TRTCSpeedTestParams *params;// sdkAppID 为控制台中获取的实际应用的 AppIDparams.sdkAppID = sdkAppId;params.userID = userId;params.userSig = userSig;// 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)params.expectedUpBandwidth = 5000;// 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)params.expectedDownBandwidth = 5000;[trtcCloud startSpeedTest:params];}- (void)onSpeedTestResult:(TRTCSpeedTestResult *)result {// 测速完成后,返回测速结果}
//启动网络测速的示例代码, 需要 sdkAppId 和 UserSig,(获取方式参考基本功能)// 这里以登录后开始测试为例public void onLogin(String userId, String userSig){TRTCCloudDef.TRTCSpeedTestParams params = new TRTCCloudDef.TRTCSpeedTestParams();params.sdkAppId = GenerateTestUserSig.SDKAPPID;params.userId = mEtUserId.getText().toString();params.userSig = GenerateTestUserSig.genTestUserSig(params.userId);params.expectedUpBandwidth = Integer.parseInt(expectUpBandwidthStr);params.expectedDownBandwidth = Integer.parseInt(expectDownBandwidthStr);// sdkAppID 为控制台中获取的实际应用的 AppIDtrtcCloud.startSpeedTest(params);}// 监听测速结果,继承 TRTCCloudListener 并实现如下方法void onSpeedTestResult(TRTCCloudDef.TRTCSpeedTestResult result){// 测速完成后,会回调出测速结果}
// 启动网络测速的示例代码, 需要 sdkAppId 和 UserSig,(获取方式参考基本功能)// 这里以登录后开始测试为例void onLogin(const char* userId, const char* userSig){TRTCSpeedTestParams params;// sdkAppID 为控制台中获取的实际应用的 AppIDparams.sdkAppID = sdkAppId;params.userId = userid;param.userSig = userSig;// 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)param.expectedUpBandwidth = 5000;// 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)param.expectedDownBandwidth = 5000;trtcCloud->startSpeedTest(params);}// 监听测速结果void TRTCCloudCallbackImpl::onSpeedTestResult(const TRTCSpeedTestResult& result){// 测速完成后,会回调出测速结果}
// 启动网络测速的示例代码, 需要 sdkAppId 和 UserSig,(获取方式参考基本功能)// 这里以登录后开始测试为例private void onLogin(string userId, string userSig){TRTCSpeedTestParams params;// sdkAppID 为控制台中获取的实际应用的 AppIDparams.sdkAppID = sdkAppId;params.userId = userid;param.userSig = userSig;// 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)param.expectedUpBandwidth = 5000;// 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)param.expectedDownBandwidth = 5000;mTRTCCloud.startSpeedTest(params);}// 监听测速结果public void onSpeedTestResult(TRTCSpeedTestResult result){// 测速完成后,会回调出测速结果}
指标 | 含义 |
WiFi Quality | Wi-Fi 信号质量 |
DNS RTT | 腾讯云的测速域名解析耗时 |
MTR | MTR 是一款网络测试工具,能探测客户端到 TRTC 节点的丢包率与延时,还可以查看路由中每一跳的具体信息 |
UDP Loss | 客户端到 TRTC 节点的 UDP 丢包率 |
UDP RTT | 客户端到 TRTC 节点的 UDP 延时 |
Local RTT | 客户端到本地网关的延时 |
Upload | 上行预估带宽 |
Download | 下行预估带宽 |
onNetworkQuality
的回调事件,它会每隔两秒钟一次向您汇报当前的网络质量,其参数包括 localQuality 和 remoteQuality 两个部分:Quality | 名称 | 说明 |
0 | Unknown | 未感知到 |
1 | Excellent | 当前网络非常好 |
2 | Good | 当前网络比较好 |
3 | Poor | 当前网络一般 |
4 | Bad | 当前网络较差,可能会出现明显的卡顿和通话延迟 |
5 | VeryBad | 当前网络很差,TRTC 只能勉强保持连接,但无法保证通讯质量 |
6 | Down | 当前网络不满足 TRTC 的最低要求,无法进行正常的音视频通话 |
onNetworkQuality
进行监听并在界面上做相应地提示即可:// 监听 onNetworkQuality 回调并感知当前网络状态的变化@Overridepublic void onNetworkQuality(TRTCCloudDef.TRTCQuality localQuality,ArrayList<trtcclouddef.trtcquality> remoteQuality){// Get your local network qualityswitch(localQuality) {case TRTCQuality_Unknown:Log.d(TAG, "SDK has not yet sensed the current network quality.");break;case TRTCQuality_Excellent:Log.d(TAG, "The current network is very good.");break;case TRTCQuality_Good:Log.d(TAG, "The current network is good.");break;case TRTCQuality_Poor:Log.d(TAG, "The current network quality barely meets the demand.");break;case TRTCQuality_Bad:Log.d(TAG, "The current network is poor, and there may be significant freezes and call delays.");break;case TRTCQuality_VeryBad:Log.d(TAG, "The current network is very poor, the communication quality cannot be guaranteed");break;case TRTCQuality_Down:Log.d(TAG, "The current network does not meet the minimum requirements.");break;default:break;}// Get the network quality of remote usersfor (TRTCCloudDef.TRTCQuality info : arrayList) {Log.d(TAG, "remote user : = " + info.userId + ", quality = " + info.quality);}}
// 监听 onNetworkQuality 回调并感知当前网络状态的变化 - (void)onNetworkQuality:(TRTCQualityInfo *)localQuality remoteQuality:(NSArray<trtcqualityinfo *=""> *)remoteQuality { // Get your local network quality switch(localQuality.quality) { case TRTCQuality_Unknown: NSLog(@"SDK has not yet sensed the current network quality."); break; case TRTCQuality_Excellent: NSLog(@"The current network is very good."); break; case TRTCQuality_Good: NSLog(@"The current network is good."); break; case TRTCQuality_Poor: NSLog(@"The current network quality barely meets the demand."); break; case TRTCQuality_Bad: NSLog(@"The current network is poor, and there may be significant freezes and call delays."); break; case TRTCQuality_VeryBad: NSLog(@"The current network is very poor, the communication quality cannot be guaranteed"); break; case TRTCQuality_Down: NSLog(@"The current network does not meet the minimum requirements."); break; default: break; } // Get the network quality of remote users for (TRTCQualityInfo *info in arrayList) { NSLog(@"remote user : = %@, quality = %@", info.userId, @(info.quality)); } }
// 监听 onNetworkQuality 回调并感知当前网络状态的变化 void onNetworkQuality(liteav::TRTCQualityInfo local_quality, liteav::TRTCQualityInfo* remote_quality, uint32_t remote_quality_count) { // Get your local network quality switch (local_quality.quality) { case TRTCQuality_Unknown: printf("SDK has not yet sensed the current network quality."); break; case TRTCQuality_Excellent: printf("The current network is very good."); break; case TRTCQuality_Good: printf("The current network is good."); break; case TRTCQuality_Poor: printf("The current network quality barely meets the demand."); break; case TRTCQuality_Bad: printf("The current network is poor, and there may be significant freezes and call delays."); break; case TRTCQuality_Vbad: printf("The current network is very poor, the communication quality cannot be guaranteed"); break; case TRTCQuality_Down: printf("The current network does not meet the minimum requirements."); break; default: break; } // Get the network quality of remote users for (int i = 0; i < remote_quality_count; ++i) { printf("remote user : = %s, quality = %d", remote_quality[i].userId, remote_quality[i].quality); } }
本页内容是否解决了您的问题?