Add ObjC API for getting native histograms.
BUG= Review-Url: https://codereview.webrtc.org/2036773003 Cr-Commit-Position: refs/heads/master@{#13064}
This commit is contained in:
@ -36,12 +36,17 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Classes/RTCDispatcher.m",
|
"objc/Framework/Classes/RTCDispatcher.m",
|
||||||
"objc/Framework/Classes/RTCFieldTrials.mm",
|
"objc/Framework/Classes/RTCFieldTrials.mm",
|
||||||
"objc/Framework/Classes/RTCLogging.mm",
|
"objc/Framework/Classes/RTCLogging.mm",
|
||||||
|
"objc/Framework/Classes/RTCMetrics.mm",
|
||||||
|
"objc/Framework/Classes/RTCMetricsSampleInfo+Private.h",
|
||||||
|
"objc/Framework/Classes/RTCMetricsSampleInfo.mm",
|
||||||
"objc/Framework/Classes/RTCSSLAdapter.mm",
|
"objc/Framework/Classes/RTCSSLAdapter.mm",
|
||||||
"objc/Framework/Classes/RTCTracing.mm",
|
"objc/Framework/Classes/RTCTracing.mm",
|
||||||
"objc/Framework/Headers/WebRTC/RTCDispatcher.h",
|
"objc/Framework/Headers/WebRTC/RTCDispatcher.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCFieldTrials.h",
|
"objc/Framework/Headers/WebRTC/RTCFieldTrials.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCLogging.h",
|
"objc/Framework/Headers/WebRTC/RTCLogging.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCMacros.h",
|
"objc/Framework/Headers/WebRTC/RTCMacros.h",
|
||||||
|
"objc/Framework/Headers/WebRTC/RTCMetrics.h",
|
||||||
|
"objc/Framework/Headers/WebRTC/RTCMetricsSampleInfo.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCSSLAdapter.h",
|
"objc/Framework/Headers/WebRTC/RTCSSLAdapter.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCTracing.h",
|
"objc/Framework/Headers/WebRTC/RTCTracing.h",
|
||||||
]
|
]
|
||||||
|
|||||||
32
webrtc/sdk/objc/Framework/Classes/RTCMetrics.mm
Normal file
32
webrtc/sdk/objc/Framework/Classes/RTCMetrics.mm
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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 "WebRTC/RTCMetrics.h"
|
||||||
|
|
||||||
|
#import "RTCMetricsSampleInfo+Private.h"
|
||||||
|
|
||||||
|
void RTCEnableMetrics() {
|
||||||
|
webrtc::metrics::Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray<RTCMetricsSampleInfo *> *RTCGetAndResetMetrics() {
|
||||||
|
std::map<std::string, std::unique_ptr<webrtc::metrics::SampleInfo>>
|
||||||
|
histograms;
|
||||||
|
webrtc::metrics::GetAndReset(&histograms);
|
||||||
|
|
||||||
|
NSMutableArray *metrics =
|
||||||
|
[NSMutableArray arrayWithCapacity:histograms.size()];
|
||||||
|
for (auto const &histogram : histograms) {
|
||||||
|
RTCMetricsSampleInfo *metric = [[RTCMetricsSampleInfo alloc]
|
||||||
|
initWithNativeSampleInfo:*histogram.second];
|
||||||
|
[metrics addObject:metric];
|
||||||
|
}
|
||||||
|
return metrics;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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 "WebRTC/RTCMetricsSampleInfo.h"
|
||||||
|
|
||||||
|
#include "webrtc/system_wrappers/include/metrics_default.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface RTCMetricsSampleInfo ()
|
||||||
|
|
||||||
|
/** Initialize an RTCMetricsSampleInfo object from native SampleInfo. */
|
||||||
|
- (instancetype)initWithNativeSampleInfo:
|
||||||
|
(const webrtc::metrics::SampleInfo &)info;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
43
webrtc/sdk/objc/Framework/Classes/RTCMetricsSampleInfo.mm
Normal file
43
webrtc/sdk/objc/Framework/Classes/RTCMetricsSampleInfo.mm
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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 "RTCMetricsSampleInfo+Private.h"
|
||||||
|
|
||||||
|
#import "NSString+StdString.h"
|
||||||
|
|
||||||
|
@implementation RTCMetricsSampleInfo
|
||||||
|
|
||||||
|
@synthesize name = _name;
|
||||||
|
@synthesize min = _min;
|
||||||
|
@synthesize max = _max;
|
||||||
|
@synthesize bucketCount = _bucketCount;
|
||||||
|
@synthesize samples = _samples;
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeSampleInfo:
|
||||||
|
(const webrtc::metrics::SampleInfo &)info {
|
||||||
|
if (self = [super init]) {
|
||||||
|
_name = [NSString stringForStdString:info.name];
|
||||||
|
_min = info.min;
|
||||||
|
_max = info.max;
|
||||||
|
_bucketCount = info.bucket_count;
|
||||||
|
|
||||||
|
NSMutableDictionary *samples =
|
||||||
|
[NSMutableDictionary dictionaryWithCapacity:info.samples.size()];
|
||||||
|
for (auto const &sample : info.samples) {
|
||||||
|
[samples setObject:@(sample.second) forKey:@(sample.first)];
|
||||||
|
}
|
||||||
|
_samples = samples;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
23
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h
Normal file
23
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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 <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <WebRTC/RTCMacros.h>
|
||||||
|
#import <WebRTC/RTCMetricsSampleInfo.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables gathering of metrics (which can be fetched with
|
||||||
|
* RTCGetAndResetMetrics). Must be called before any other call into WebRTC.
|
||||||
|
*/
|
||||||
|
RTC_EXTERN void RTCEnableMetrics();
|
||||||
|
|
||||||
|
/** Gets and clears native histograms. */
|
||||||
|
RTC_EXTERN NSArray<RTCMetricsSampleInfo *> *RTCGetAndResetMetrics();
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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 <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <WebRTC/RTCMacros.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
RTC_EXPORT
|
||||||
|
@interface RTCMetricsSampleInfo : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example of RTCMetricsSampleInfo:
|
||||||
|
* name: "WebRTC.Video.InputFramesPerSecond"
|
||||||
|
* min: 1
|
||||||
|
* max: 100
|
||||||
|
* bucketCount: 50
|
||||||
|
* samples: [29]:2 [30]:1
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** The name of the histogram. */
|
||||||
|
@property(nonatomic, readonly) NSString *name;
|
||||||
|
|
||||||
|
/** The minimum bucket value. */
|
||||||
|
@property(nonatomic, readonly) int min;
|
||||||
|
|
||||||
|
/** The maximum bucket value. */
|
||||||
|
@property(nonatomic, readonly) int max;
|
||||||
|
|
||||||
|
/** The number of buckets. */
|
||||||
|
@property(nonatomic, readonly) int bucketCount;
|
||||||
|
|
||||||
|
/** A dictionary holding the samples <value, # of events>. */
|
||||||
|
@property(nonatomic, readonly) NSDictionary<NSNumber *, NSNumber *> *samples;
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@ -25,6 +25,8 @@
|
|||||||
#import <WebRTC/RTCMediaConstraints.h>
|
#import <WebRTC/RTCMediaConstraints.h>
|
||||||
#import <WebRTC/RTCMediaStream.h>
|
#import <WebRTC/RTCMediaStream.h>
|
||||||
#import <WebRTC/RTCMediaStreamTrack.h>
|
#import <WebRTC/RTCMediaStreamTrack.h>
|
||||||
|
#import <WebRTC/RTCMetrics.h>
|
||||||
|
#import <WebRTC/RTCMetricsSampleInfo.h>
|
||||||
#import <WebRTC/RTCPeerConnection.h>
|
#import <WebRTC/RTCPeerConnection.h>
|
||||||
#import <WebRTC/RTCPeerConnectionFactory.h>
|
#import <WebRTC/RTCPeerConnectionFactory.h>
|
||||||
#import <WebRTC/RTCRtpCodecParameters.h>
|
#import <WebRTC/RTCRtpCodecParameters.h>
|
||||||
|
|||||||
@ -37,12 +37,17 @@
|
|||||||
'objc/Framework/Classes/RTCDispatcher.m',
|
'objc/Framework/Classes/RTCDispatcher.m',
|
||||||
'objc/Framework/Classes/RTCFieldTrials.mm',
|
'objc/Framework/Classes/RTCFieldTrials.mm',
|
||||||
'objc/Framework/Classes/RTCLogging.mm',
|
'objc/Framework/Classes/RTCLogging.mm',
|
||||||
|
'objc/Framework/Classes/RTCMetrics.mm',
|
||||||
|
'objc/Framework/Classes/RTCMetricsSampleInfo+Private.h',
|
||||||
|
'objc/Framework/Classes/RTCMetricsSampleInfo.mm',
|
||||||
'objc/Framework/Classes/RTCSSLAdapter.mm',
|
'objc/Framework/Classes/RTCSSLAdapter.mm',
|
||||||
'objc/Framework/Classes/RTCTracing.mm',
|
'objc/Framework/Classes/RTCTracing.mm',
|
||||||
'objc/Framework/Headers/WebRTC/RTCDispatcher.h',
|
'objc/Framework/Headers/WebRTC/RTCDispatcher.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCFieldTrials.h',
|
'objc/Framework/Headers/WebRTC/RTCFieldTrials.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCLogging.h',
|
'objc/Framework/Headers/WebRTC/RTCLogging.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCMacros.h',
|
'objc/Framework/Headers/WebRTC/RTCMacros.h',
|
||||||
|
'objc/Framework/Headers/WebRTC/RTCMetrics.h',
|
||||||
|
'objc/Framework/Headers/WebRTC/RTCMetricsSampleInfo.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCSSLAdapter.h',
|
'objc/Framework/Headers/WebRTC/RTCSSLAdapter.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCTracing.h',
|
'objc/Framework/Headers/WebRTC/RTCTracing.h',
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user