From b6c456b7721529cea59078273bba365d64548825 Mon Sep 17 00:00:00 2001 From: denicija Date: Mon, 19 Dec 2016 02:14:08 -0800 Subject: [PATCH] Add QP stats to the statsview in AppRTCMobile for ios. The following QP stats are added: *avgQP for the current polling interval as a fraction of the current delta sum over the current delta of encoded frames *total QPSum *total number of encoded frames BUG=NONE Review-Url: https://codereview.webrtc.org/2578123002 Cr-Commit-Position: refs/heads/master@{#15669} --- .../objc/AppRTCMobile/ARDStatsBuilder.m | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/webrtc/examples/objc/AppRTCMobile/ARDStatsBuilder.m b/webrtc/examples/objc/AppRTCMobile/ARDStatsBuilder.m index 0643b42827..370b72e867 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDStatsBuilder.m +++ b/webrtc/examples/objc/AppRTCMobile/ARDStatsBuilder.m @@ -41,6 +41,12 @@ NSString *_videoSendHeight; NSString *_videoSendWidth; + // QP stats. + int _videoQPSum; + int _framesEncoded; + int _oldVideoQPSum; + int _oldFramesEncoded; + // Video receive stats. NSString *_videoDecodeMs; NSString *_videoDecodedFps; @@ -77,6 +83,8 @@ _connRecvBitrateTracker = [[ARDBitrateTracker alloc] init]; _videoSendBitrateTracker = [[ARDBitrateTracker alloc] init]; _videoRecvBitrateTracker = [[ARDBitrateTracker alloc] init]; + _videoQPSum = 0; + _framesEncoded = 0; } return self; } @@ -96,14 +104,18 @@ // Video send stats. NSString *videoSendFormat = @"VS (input) %@x%@@%@fps | (sent) %@x%@@%@fps\n" - "VS (enc) %@/%@ | (sent) %@/%@ | %@ms | %@\n"; + "VS (enc) %@/%@ | (sent) %@/%@ | %@ms | %@\n" + "AvgQP (past %d encoded frames) = %d\n "; + int avgqp = [self calculateAvgQP]; + [result appendString:[NSString stringWithFormat:videoSendFormat, _videoInputWidth, _videoInputHeight, _videoInputFps, _videoSendWidth, _videoSendHeight, _videoSendFps, _actualEncBitrate, _targetEncBitrate, _videoSendBitrate, _availableSendBw, _videoEncodeMs, - _videoSendCodec]]; + _videoSendCodec, + _framesEncoded - _oldFramesEncoded, avgqp]]; // Video receive stats. NSString *videoReceiveFormat = @@ -148,6 +160,13 @@ #pragma mark - Private +- (int)calculateAvgQP { + int deltaFramesEncoded = _framesEncoded - _oldFramesEncoded; + int deltaQPSum = _videoQPSum - _oldVideoQPSum; + + return deltaFramesEncoded != 0 ? deltaQPSum / deltaFramesEncoded : 0; +} + - (void)parseBweStatsReport:(RTCLegacyStatsReport *)statsReport { [statsReport.values enumerateKeysAndObjectsUsingBlock:^( NSString *key, NSString *value, BOOL *stop) { @@ -241,6 +260,12 @@ NSInteger byteCount = value.integerValue; [_videoSendBitrateTracker updateBitrateWithCurrentByteCount:byteCount]; _videoSendBitrate = _videoSendBitrateTracker.bitrateString; + } else if ([key isEqualToString:@"qpSum"]) { + _oldVideoQPSum = _videoQPSum; + _videoQPSum = value.integerValue; + } else if ([key isEqualToString:@"framesEncoded"]) { + _oldFramesEncoded = _framesEncoded; + _framesEncoded = value.integerValue; } }]; }