功能描述
QttAudio支持报告频道中用户的网络情况。QttAudio会每隔2秒进行一次网络情况统计,包括用户网络的网络质量等级、RTT、上下行丢包率、抖动等统计。
其中网络质量等级分为6类:
typedef NS_ENUM(NSInteger, QttQualityType) { QUALITY_UNKNOWN = 0, //网络质量未知 QUALITY_VGOOD = 1, //网络质量好,通话流畅 QUALITY_GOOD = 2, //网络质量较好,偶有卡顿 QUALITY_POOR = 3, //网络质量差,但不影响沟通 QUALITY_BAD = 4, //网络质量比较差,勉强能沟通 QUALITY_VBAD = 5 //网络质量非常差,基本不能沟通 };
|
接口描述
@interface QttRtcStat : NSObject @property (nonatomic, assign) unsigned int mUpLossRate; //上行丢包率 @property (nonatomic, assign) unsigned int mDownLossRate; //下行丢包率 @property (nonatomic, assign) unsigned int mRttAverage; //平均Rtt @property (nonatomic, assign) unsigned int mJitter; //抖动 @end
@protocol QttChannelEngineDelegate <NSObject> @optional /** * 当前通话网络统计回调,通话中每两秒触发一次 * @param uid 用户ID。表示该ID的用户的网络质量,如果为0,表示本地用户的网络质量 * @param txQuality 该用户的上行网络质量 * @param rxQuality 该用户的下行网络质量 * @param stat 通话相关的统计信息 */ - (void)onNetworkStats:(NSUInteger)uid txQuality:(QttQualityType)txQuality rxQuality:(QttQualityType)rxQuality stat:(QttRtcStat*)stat; @end
|
示例代码
@interface QttChannelEngineDelegateImpl : NSObject<QttChannelEngineDelegate> - (void)onNetworkStats:(NSUInteger)uid txQuality:(QttQualityType)txQuality rxQuality:(QttQualityType)rxQuality stat:(QttRtcStat*)stat; @end
@implementation QttChannelEngineDelegateImpl - (void)onNetworkStats:(NSUInteger)uid txQuality:(QttQualityType)txQuality rxQuality:(QttQualityType)rxQuality stat:(QttRtcStat*)stat { if (uid == 0) { NSLog(@"自己网络情况:上行质量%d 下行质量%d 上行丢包%d 下行丢包%d 端到端时延%d 抖动%d", (int)txQuality, (int)rxQuality, stat.mUpLossRate, stat.mDownLossRate, stat.mRttAverage, stat.mJitter); //todo 这里实现自己网络情况统计的逻辑 } else { NSLog(@"uid %ld 网络情况:上行质量%d 下行质量%d 上行丢包%d 下行丢包%d 端到端时延%d 抖动%d", (long)uid, (int)txQuality, (int)rxQuality, stat.mUpLossRate, stat.mDownLossRate, stat.mRttAverage, stat.mJitter); //todo 这里实现他人网络情况统计的逻辑 } } @end
id<QttChannelEngineDelegate> delegate = [[QttChannelEngineDelegateImpl alloc] init]; QttChannelEngine* engine = [QttChannelEngine GetEngineInstance:@"your AppKey" delegate:delegate];
|