objc: Export RTCStatistics and RTCStatisticsReport
These two types need to be exported in order to access the stats report from an ObjC / Swift codebase. Bug: webrtc:11158 Change-Id: Ibb2f81f289b56f824f02df70971c28accd5a1350 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174900 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31257}
This commit is contained in:
parent
475006d4a3
commit
87a6e5ab4d
@ -28,7 +28,8 @@ class StatsCollectorCallbackAdapter : public RTCStatsCollectorCallback {
|
||||
|
||||
void OnStatsDelivered(const rtc::scoped_refptr<const RTCStatsReport> &report) override {
|
||||
RTC_DCHECK(completion_handler_);
|
||||
RTCStatisticsReport *statisticsReport = [[RTCStatisticsReport alloc] initWithReport:*report];
|
||||
RTC_OBJC_TYPE(RTCStatisticsReport) *statisticsReport =
|
||||
[[RTC_OBJC_TYPE(RTCStatisticsReport) alloc] initWithReport:*report];
|
||||
completion_handler_(statisticsReport);
|
||||
completion_handler_ = nil;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
@class RTC_OBJC_TYPE(RTCRtpTransceiver);
|
||||
@class RTC_OBJC_TYPE(RTCRtpTransceiverInit);
|
||||
@class RTC_OBJC_TYPE(RTCSessionDescription);
|
||||
@class RTCStatisticsReport;
|
||||
@class RTC_OBJC_TYPE(RTCStatisticsReport);
|
||||
@class RTC_OBJC_TYPE(RTCLegacyStatsReport);
|
||||
|
||||
typedef NS_ENUM(NSInteger, RTCRtpMediaType);
|
||||
@ -341,7 +341,7 @@ RTC_OBJC_EXPORT
|
||||
|
||||
@end
|
||||
|
||||
typedef void (^RTCStatisticsCompletionHandler)(RTCStatisticsReport *);
|
||||
typedef void (^RTCStatisticsCompletionHandler)(RTC_OBJC_TYPE(RTCStatisticsReport) *);
|
||||
|
||||
@interface RTC_OBJC_TYPE (RTCPeerConnection)
|
||||
(Stats)
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
#include "api/stats/rtc_stats_report.h"
|
||||
|
||||
@interface RTCStatisticsReport (Private)
|
||||
@interface RTC_OBJC_TYPE (RTCStatisticsReport) (Private)
|
||||
|
||||
- (instancetype)initWithReport:(const webrtc::RTCStatsReport &)report;
|
||||
- (instancetype)initWithReport : (const webrtc::RTCStatsReport &)report;
|
||||
|
||||
@end
|
||||
|
||||
@ -10,25 +10,29 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class RTCStatistics;
|
||||
#import "RTCMacros.h"
|
||||
|
||||
@class RTC_OBJC_TYPE(RTCStatistics);
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** A statistics report. Encapsulates a number of RTCStatistics objects. */
|
||||
@interface RTCStatisticsReport : NSObject
|
||||
RTC_OBJC_EXPORT
|
||||
@interface RTC_OBJC_TYPE (RTCStatisticsReport) : NSObject
|
||||
|
||||
/** The timestamp of the report in microseconds since 1970-01-01T00:00:00Z. */
|
||||
@property(nonatomic, readonly) CFTimeInterval timestamp_us;
|
||||
|
||||
/** RTCStatistics objects by id. */
|
||||
@property(nonatomic, readonly) NSDictionary<NSString *, RTCStatistics *> *statistics;
|
||||
@property(nonatomic, readonly) NSDictionary<NSString *, RTC_OBJC_TYPE(RTCStatistics) *> *statistics;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
/** A part of a report (a subreport) covering a certain area. */
|
||||
@interface RTCStatistics : NSObject
|
||||
RTC_OBJC_EXPORT
|
||||
@interface RTC_OBJC_TYPE (RTCStatistics) : NSObject
|
||||
|
||||
/** The id of this subreport, e.g. "RTCMediaStreamTrack_receiver_2". */
|
||||
@property(nonatomic, readonly) NSString *id;
|
||||
|
||||
@ -100,7 +100,7 @@ NSObject *ValueFromStatsMember(const RTCStatsMemberInterface *member) {
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
@implementation RTCStatistics
|
||||
@implementation RTC_OBJC_TYPE (RTCStatistics)
|
||||
|
||||
@synthesize id = _id;
|
||||
@synthesize timestamp_us = _timestamp_us;
|
||||
@ -139,7 +139,7 @@ NSObject *ValueFromStatsMember(const RTCStatsMemberInterface *member) {
|
||||
|
||||
@end
|
||||
|
||||
@implementation RTCStatisticsReport
|
||||
@implementation RTC_OBJC_TYPE (RTCStatisticsReport)
|
||||
|
||||
@synthesize timestamp_us = _timestamp_us;
|
||||
@synthesize statistics = _statistics;
|
||||
@ -151,16 +151,17 @@ NSObject *ValueFromStatsMember(const RTCStatsMemberInterface *member) {
|
||||
|
||||
@end
|
||||
|
||||
@implementation RTCStatisticsReport (Private)
|
||||
@implementation RTC_OBJC_TYPE (RTCStatisticsReport) (Private)
|
||||
|
||||
- (instancetype)initWithReport:(const webrtc::RTCStatsReport &)report {
|
||||
- (instancetype)initWithReport : (const webrtc::RTCStatsReport &)report {
|
||||
if (self = [super init]) {
|
||||
_timestamp_us = report.timestamp_us();
|
||||
|
||||
NSMutableDictionary *statisticsById =
|
||||
[NSMutableDictionary dictionaryWithCapacity:report.size()];
|
||||
for (const auto &stat : report) {
|
||||
RTCStatistics *statistics = [[RTCStatistics alloc] initWithStatistics:stat];
|
||||
RTC_OBJC_TYPE(RTCStatistics) *statistics =
|
||||
[[RTC_OBJC_TYPE(RTCStatistics) alloc] initWithStatistics:stat];
|
||||
statisticsById[statistics.id] = statistics;
|
||||
}
|
||||
_statistics = [statisticsById copy];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user