Index: webrtc/api/objc/RTCStats.mm |
diff --git a/webrtc/api/objc/RTCStats.mm b/webrtc/api/objc/RTCStats.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cff12ee3d2933b436b8e7d461cd8f73b01ff9f98 |
--- /dev/null |
+++ b/webrtc/api/objc/RTCStats.mm |
@@ -0,0 +1,53 @@ |
+/* |
+ * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#import "RTCStats.h" |
+ |
+#import "webrtc/api/objc/RTCStats+Private.h" |
+#import "webrtc/base/objc/NSString+StdString.h" |
+ |
+@implementation RTCStats |
+ |
+@synthesize timestamp = _timestamp; |
+@synthesize type = _type; |
+@synthesize id = _id; |
+@synthesize values = _values; |
+ |
+- (NSString *)description { |
+ return [NSString stringWithFormat:@"RTCStats:\n%@\n%@\n%f\n%@", |
+ _id, |
+ _type, |
+ _timestamp, |
+ _values]; |
+} |
+ |
+#pragma mark - Private |
+ |
+- (instancetype)initWithStatsReport:(const webrtc::StatsReport &)stats { |
+ if (self = [super init]) { |
+ _timestamp = stats.timestamp(); |
+ _type = [NSString stringForStdString:stats.TypeToString()]; |
+ _id = [NSString stringForStdString:stats.id()->ToString()]; |
+ |
+ NSMutableDictionary *values = |
+ [NSMutableDictionary dictionaryWithCapacity:stats.values().size()]; |
+ for (auto const &valuePair : stats.values()) { |
+ NSString *key = [NSString stringForStdString: |
+ valuePair.second->display_name()]; |
+ NSString *value = [NSString stringForStdString: |
+ valuePair.second->ToString()]; |
+ values[key] = value; |
tkchin_webrtc
2016/01/05 20:08:17
Per other CR, there may be a problem here with rep
hjon
2016/01/06 00:39:14
Done.
|
+ } |
+ _values = [NSDictionary dictionaryWithDictionary:values]; |
+ } |
+ return self; |
+} |
+ |
+@end |