Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/ARDStatsBuilder.m

Issue 2578123002: Add QP stats to the statsview in AppRTCMobile for ios. (Closed)
Patch Set: Remove delta ivars and improve wording Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 23 matching lines...) Expand all
34 NSString *_videoEncodeMs; 34 NSString *_videoEncodeMs;
35 NSString *_videoInputFps; 35 NSString *_videoInputFps;
36 NSString *_videoInputHeight; 36 NSString *_videoInputHeight;
37 NSString *_videoInputWidth; 37 NSString *_videoInputWidth;
38 NSString *_videoSendCodec; 38 NSString *_videoSendCodec;
39 NSString *_videoSendBitrate; 39 NSString *_videoSendBitrate;
40 NSString *_videoSendFps; 40 NSString *_videoSendFps;
41 NSString *_videoSendHeight; 41 NSString *_videoSendHeight;
42 NSString *_videoSendWidth; 42 NSString *_videoSendWidth;
43 43
44 // QP stats.
45 int _videoQPSum;
46 int _framesEncoded;
47 int _oldVideoQPSum;
48 int _oldFramesEncoded;
49
44 // Video receive stats. 50 // Video receive stats.
45 NSString *_videoDecodeMs; 51 NSString *_videoDecodeMs;
46 NSString *_videoDecodedFps; 52 NSString *_videoDecodedFps;
47 NSString *_videoOutputFps; 53 NSString *_videoOutputFps;
48 NSString *_videoRecvBitrate; 54 NSString *_videoRecvBitrate;
49 NSString *_videoRecvFps; 55 NSString *_videoRecvFps;
50 NSString *_videoRecvHeight; 56 NSString *_videoRecvHeight;
51 NSString *_videoRecvWidth; 57 NSString *_videoRecvWidth;
52 58
53 // Audio send stats. 59 // Audio send stats.
(...skipping 16 matching lines...) Expand all
70 } 76 }
71 77
72 - (instancetype)init { 78 - (instancetype)init {
73 if (self = [super init]) { 79 if (self = [super init]) {
74 _audioSendBitrateTracker = [[ARDBitrateTracker alloc] init]; 80 _audioSendBitrateTracker = [[ARDBitrateTracker alloc] init];
75 _audioRecvBitrateTracker = [[ARDBitrateTracker alloc] init]; 81 _audioRecvBitrateTracker = [[ARDBitrateTracker alloc] init];
76 _connSendBitrateTracker = [[ARDBitrateTracker alloc] init]; 82 _connSendBitrateTracker = [[ARDBitrateTracker alloc] init];
77 _connRecvBitrateTracker = [[ARDBitrateTracker alloc] init]; 83 _connRecvBitrateTracker = [[ARDBitrateTracker alloc] init];
78 _videoSendBitrateTracker = [[ARDBitrateTracker alloc] init]; 84 _videoSendBitrateTracker = [[ARDBitrateTracker alloc] init];
79 _videoRecvBitrateTracker = [[ARDBitrateTracker alloc] init]; 85 _videoRecvBitrateTracker = [[ARDBitrateTracker alloc] init];
86 _videoQPSum = 0;
87 _framesEncoded = 0;
80 } 88 }
81 return self; 89 return self;
82 } 90 }
83 91
84 - (NSString *)statsString { 92 - (NSString *)statsString {
85 NSMutableString *result = [NSMutableString string]; 93 NSMutableString *result = [NSMutableString string];
86 NSString *systemStatsFormat = @"(cpu)%ld%%\n"; 94 NSString *systemStatsFormat = @"(cpu)%ld%%\n";
87 [result appendString:[NSString stringWithFormat:systemStatsFormat, 95 [result appendString:[NSString stringWithFormat:systemStatsFormat,
88 (long)ARDGetCpuUsagePercentage()]]; 96 (long)ARDGetCpuUsagePercentage()]];
89 97
90 // Connection stats. 98 // Connection stats.
91 NSString *connStatsFormat = @"CN %@ms | %@->%@/%@ | (s)%@ | (r)%@\n"; 99 NSString *connStatsFormat = @"CN %@ms | %@->%@/%@ | (s)%@ | (r)%@\n";
92 [result appendString:[NSString stringWithFormat:connStatsFormat, 100 [result appendString:[NSString stringWithFormat:connStatsFormat,
93 _connRtt, 101 _connRtt,
94 _localCandType, _remoteCandType, _transportType, 102 _localCandType, _remoteCandType, _transportType,
95 _connSendBitrate, _connRecvBitrate]]; 103 _connSendBitrate, _connRecvBitrate]];
96 104
97 // Video send stats. 105 // Video send stats.
98 NSString *videoSendFormat = @"VS (input) %@x%@@%@fps | (sent) %@x%@@%@fps\n" 106 NSString *videoSendFormat = @"VS (input) %@x%@@%@fps | (sent) %@x%@@%@fps\n"
99 "VS (enc) %@/%@ | (sent) %@/%@ | %@ms | %@\n"; 107 "VS (enc) %@/%@ | (sent) %@/%@ | %@ms | %@\n"
108 "AvgQP (past %d encoded frames) = %d\n ";
109 int avgqp = [self calculateAvgQP];
110
100 [result appendString:[NSString stringWithFormat:videoSendFormat, 111 [result appendString:[NSString stringWithFormat:videoSendFormat,
101 _videoInputWidth, _videoInputHeight, _videoInputFps, 112 _videoInputWidth, _videoInputHeight, _videoInputFps,
102 _videoSendWidth, _videoSendHeight, _videoSendFps, 113 _videoSendWidth, _videoSendHeight, _videoSendFps,
103 _actualEncBitrate, _targetEncBitrate, 114 _actualEncBitrate, _targetEncBitrate,
104 _videoSendBitrate, _availableSendBw, 115 _videoSendBitrate, _availableSendBw,
105 _videoEncodeMs, 116 _videoEncodeMs,
106 _videoSendCodec]]; 117 _videoSendCodec,
118 _framesEncoded - _oldFramesEncoded, avgqp]];
107 119
108 // Video receive stats. 120 // Video receive stats.
109 NSString *videoReceiveFormat = 121 NSString *videoReceiveFormat =
110 @"VR (recv) %@x%@@%@fps | (decoded)%@ | (output)%@fps | %@/%@ | %@ms\n"; 122 @"VR (recv) %@x%@@%@fps | (decoded)%@ | (output)%@fps | %@/%@ | %@ms\n";
111 [result appendString:[NSString stringWithFormat:videoReceiveFormat, 123 [result appendString:[NSString stringWithFormat:videoReceiveFormat,
112 _videoRecvWidth, _videoRecvHeight, _videoRecvFps, 124 _videoRecvWidth, _videoRecvHeight, _videoRecvFps,
113 _videoDecodedFps, 125 _videoDecodedFps,
114 _videoOutputFps, 126 _videoOutputFps,
115 _videoRecvBitrate, _availableRecvBw, 127 _videoRecvBitrate, _availableRecvBw,
116 _videoDecodeMs]]; 128 _videoDecodeMs]];
(...skipping 24 matching lines...) Expand all
141 } 153 }
142 } else if ([reportType isEqualToString:@"VideoBwe"]) { 154 } else if ([reportType isEqualToString:@"VideoBwe"]) {
143 [self parseBweStatsReport:statsReport]; 155 [self parseBweStatsReport:statsReport];
144 } else if ([reportType isEqualToString:@"googCandidatePair"]) { 156 } else if ([reportType isEqualToString:@"googCandidatePair"]) {
145 [self parseConnectionStatsReport:statsReport]; 157 [self parseConnectionStatsReport:statsReport];
146 } 158 }
147 } 159 }
148 160
149 #pragma mark - Private 161 #pragma mark - Private
150 162
163 - (int)calculateAvgQP {
164 int deltaFramesEncoded = _framesEncoded - _oldFramesEncoded;
165 int deltaQPSum = _videoQPSum - _oldVideoQPSum;
166
167 return deltaFramesEncoded ? deltaQPSum / deltaFramesEncoded : deltaQPSum;
magjed_webrtc 2016/12/16 12:33:17 I prefer explicit comparison with 0, i.e. 'deltaFr
magjed_webrtc 2016/12/16 12:33:17 Is deltaQPSum meaningful when deltaFramesEncoded==
daniela-webrtc 2016/12/16 13:06:19 Valid point. What would make more sense for avgQP
magjed_webrtc 2016/12/19 08:56:57 0 is also fine. I think it will be 0 with the curr
168 }
169
151 - (void)parseBweStatsReport:(RTCLegacyStatsReport *)statsReport { 170 - (void)parseBweStatsReport:(RTCLegacyStatsReport *)statsReport {
152 [statsReport.values enumerateKeysAndObjectsUsingBlock:^( 171 [statsReport.values enumerateKeysAndObjectsUsingBlock:^(
153 NSString *key, NSString *value, BOOL *stop) { 172 NSString *key, NSString *value, BOOL *stop) {
154 if ([key isEqualToString:@"googAvailableSendBandwidth"]) { 173 if ([key isEqualToString:@"googAvailableSendBandwidth"]) {
155 _availableSendBw = 174 _availableSendBw =
156 [ARDBitrateTracker bitrateStringForBitrate:value.doubleValue]; 175 [ARDBitrateTracker bitrateStringForBitrate:value.doubleValue];
157 } else if ([key isEqualToString:@"googAvailableReceiveBandwidth"]) { 176 } else if ([key isEqualToString:@"googAvailableReceiveBandwidth"]) {
158 _availableRecvBw = 177 _availableRecvBw =
159 [ARDBitrateTracker bitrateStringForBitrate:value.doubleValue]; 178 [ARDBitrateTracker bitrateStringForBitrate:value.doubleValue];
160 } else if ([key isEqualToString:@"googActualEncBitrate"]) { 179 } else if ([key isEqualToString:@"googActualEncBitrate"]) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } else if ([key isEqualToString:@"googFrameWidthSent"]) { 253 } else if ([key isEqualToString:@"googFrameWidthSent"]) {
235 _videoSendWidth = value; 254 _videoSendWidth = value;
236 } else if ([key isEqualToString:@"googFrameRateSent"]) { 255 } else if ([key isEqualToString:@"googFrameRateSent"]) {
237 _videoSendFps = value; 256 _videoSendFps = value;
238 } else if ([key isEqualToString:@"googAvgEncodeMs"]) { 257 } else if ([key isEqualToString:@"googAvgEncodeMs"]) {
239 _videoEncodeMs = value; 258 _videoEncodeMs = value;
240 } else if ([key isEqualToString:@"bytesSent"]) { 259 } else if ([key isEqualToString:@"bytesSent"]) {
241 NSInteger byteCount = value.integerValue; 260 NSInteger byteCount = value.integerValue;
242 [_videoSendBitrateTracker updateBitrateWithCurrentByteCount:byteCount]; 261 [_videoSendBitrateTracker updateBitrateWithCurrentByteCount:byteCount];
243 _videoSendBitrate = _videoSendBitrateTracker.bitrateString; 262 _videoSendBitrate = _videoSendBitrateTracker.bitrateString;
263 } else if ([key isEqualToString:@"qpSum"]) {
264 _oldVideoQPSum = _videoQPSum;
265 _videoQPSum = value.integerValue;
266 } else if ([key isEqualToString:@"framesEncoded"]) {
267 _oldFramesEncoded = _framesEncoded;
268 _framesEncoded = value.integerValue;
244 } 269 }
245 }]; 270 }];
246 } 271 }
247 272
248 - (void)parseRecvSsrcStatsReport:(RTCLegacyStatsReport *)statsReport { 273 - (void)parseRecvSsrcStatsReport:(RTCLegacyStatsReport *)statsReport {
249 NSDictionary *values = statsReport.values; 274 NSDictionary *values = statsReport.values;
250 if ([values objectForKey:@"googFrameWidthReceived"]) { 275 if ([values objectForKey:@"googFrameWidthReceived"]) {
251 // Video track. 276 // Video track.
252 [self parseVideoRecvStatsReport:statsReport]; 277 [self parseVideoRecvStatsReport:statsReport];
253 } else if ([values objectForKey:@"audioOutputLevel"]) { 278 } else if ([values objectForKey:@"audioOutputLevel"]) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } else if ([key isEqualToString:@"bytesReceived"]) { 316 } else if ([key isEqualToString:@"bytesReceived"]) {
292 NSInteger byteCount = value.integerValue; 317 NSInteger byteCount = value.integerValue;
293 [_videoRecvBitrateTracker updateBitrateWithCurrentByteCount:byteCount]; 318 [_videoRecvBitrateTracker updateBitrateWithCurrentByteCount:byteCount];
294 _videoRecvBitrate = _videoRecvBitrateTracker.bitrateString; 319 _videoRecvBitrate = _videoRecvBitrateTracker.bitrateString;
295 } 320 }
296 }]; 321 }];
297 } 322 }
298 323
299 @end 324 @end
300 325
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698