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 "RTCStats.h" | |
12 | |
13 #import "webrtc/api/objc/RTCStats+Private.h" | |
14 #import "webrtc/base/objc/NSString+StdString.h" | |
15 #import "webrtc/base/objc/RTCLogging.h" | |
16 | |
17 @implementation RTCStats | |
18 | |
19 @synthesize timestamp = _timestamp; | |
20 @synthesize type = _type; | |
21 @synthesize statsId = _statsId; | |
22 @synthesize values = _values; | |
23 | |
24 - (NSString *)description { | |
25 return [NSString stringWithFormat:@"RTCStats:\n%@\n%@\n%f\n%@", | |
26 _statsId, | |
27 _type, | |
28 _timestamp, | |
29 _values]; | |
30 } | |
31 | |
32 #pragma mark - Private | |
33 | |
34 - (instancetype)initWithStatsReport:(const webrtc::StatsReport &)stats { | |
35 if (self = [super init]) { | |
36 _timestamp = stats.timestamp(); | |
37 _type = [NSString stringForStdString:stats.TypeToString()]; | |
38 _statsId = [NSString stringForStdString:stats.id()->ToString()]; | |
39 | |
40 NSMutableDictionary *values = | |
41 [NSMutableDictionary dictionaryWithCapacity:stats.values().size()]; | |
42 for (auto const &valuePair : stats.values()) { | |
43 NSString *key = [NSString stringForStdString: | |
44 valuePair.second->display_name()]; | |
45 NSString *value = [NSString stringForStdString: | |
46 valuePair.second->ToString()]; | |
47 | |
48 if ([values objectForKey:key]) { | |
49 RTCLogWarning(@"The |key| already exists in this stats report: %@", | |
hjon
2016/01/06 00:39:14
tkchin@ Is this the kind of logging you had in min
| |
50 key); | |
51 } | |
52 | |
53 values[key] = value; | |
54 } | |
55 _values = [values copy]; | |
56 } | |
57 return self; | |
58 } | |
59 | |
60 @end | |
OLD | NEW |