OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #import "RTCLegacyStatsReport+Private.h" |
| 12 |
| 13 #import "NSString+StdString.h" |
| 14 #import "WebRTC/RTCLogging.h" |
| 15 |
| 16 #include "webrtc/base/checks.h" |
| 17 |
| 18 @implementation RTCLegacyStatsReport |
| 19 |
| 20 @synthesize timestamp = _timestamp; |
| 21 @synthesize type = _type; |
| 22 @synthesize reportId = _reportId; |
| 23 @synthesize values = _values; |
| 24 |
| 25 - (NSString *)description { |
| 26 return [NSString stringWithFormat:@"RTCLegacyStatsReport:\n%@\n%@\n%f\n%@", |
| 27 _reportId, |
| 28 _type, |
| 29 _timestamp, |
| 30 _values]; |
| 31 } |
| 32 |
| 33 #pragma mark - Private |
| 34 |
| 35 - (instancetype)initWithNativeReport:(const webrtc::StatsReport &)nativeReport { |
| 36 if (self = [super init]) { |
| 37 _timestamp = nativeReport.timestamp(); |
| 38 _type = [NSString stringForStdString:nativeReport.TypeToString()]; |
| 39 _reportId = [NSString stringForStdString: |
| 40 nativeReport.id()->ToString()]; |
| 41 |
| 42 NSUInteger capacity = nativeReport.values().size(); |
| 43 NSMutableDictionary *values = |
| 44 [NSMutableDictionary dictionaryWithCapacity:capacity]; |
| 45 for (auto const &valuePair : nativeReport.values()) { |
| 46 NSString *key = [NSString stringForStdString: |
| 47 valuePair.second->display_name()]; |
| 48 NSString *value = [NSString stringForStdString: |
| 49 valuePair.second->ToString()]; |
| 50 |
| 51 // Not expecting duplicate keys. |
| 52 RTC_DCHECK(![values objectForKey:key]); |
| 53 [values setObject:value forKey:key]; |
| 54 } |
| 55 _values = values; |
| 56 } |
| 57 return self; |
| 58 } |
| 59 |
| 60 @end |
OLD | NEW |