diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm b/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm index e035caa2d5..e2965ebab7 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm @@ -12,6 +12,8 @@ #import "RTCLegacyStatsReport+Private.h" #import "RTCMediaStreamTrack+Private.h" +#import "RTCRtpReceiver+Private.h" +#import "RTCRtpSender+Private.h" #import "RTCStatisticsReport+Private.h" #import "helpers/NSString+StdString.h" @@ -63,6 +65,20 @@ class StatsObserverAdapter : public StatsObserver { @implementation RTCPeerConnection (Stats) +- (void)statisticsForSender:(RTCRtpSender *)sender + completionHandler:(RTCStatisticsCompletionHandler)completionHandler { + rtc::scoped_refptr collector( + new rtc::RefCountedObject(completionHandler)); + self.nativePeerConnection->GetStats(sender.nativeRtpSender, collector); +} + +- (void)statisticsForReceiver:(RTCRtpReceiver *)receiver + completionHandler:(RTCStatisticsCompletionHandler)completionHandler { + rtc::scoped_refptr collector( + new rtc::RefCountedObject(completionHandler)); + self.nativePeerConnection->GetStats(receiver.nativeRtpReceiver, collector); +} + - (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler { rtc::scoped_refptr collector( new rtc::RefCountedObject(completionHandler)); diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.h b/sdk/objc/api/peerconnection/RTCPeerConnection.h index 500a7ceaf5..c641fdd545 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.h @@ -331,6 +331,18 @@ typedef void (^RTCStatisticsCompletionHandler)(RTCStatisticsReport *); /** Gather statistic through the v2 statistics API. */ - (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler; +/** Spec-compliant getStats() performing the stats selection algorithm with the + * sender. + */ +- (void)statisticsForSender:(RTCRtpSender *)sender + completionHandler:(RTCStatisticsCompletionHandler)completionHandler; + +/** Spec-compliant getStats() performing the stats selection algorithm with the + * receiver. + */ +- (void)statisticsForReceiver:(RTCRtpReceiver *)receiver + completionHandler:(RTCStatisticsCompletionHandler)completionHandler; + @end NS_ASSUME_NONNULL_END