Adding GetStats APIs for senders/receivers.

Bug: webrtc:10345
Change-Id: Id9c10db91d94323ffe8b9e4e540411837d56aaa4
Reviewed-on: https://webrtc-review.googlesource.com/c/124493
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Peter Hanspers <peterhanspers@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26867}
This commit is contained in:
Peter Hanspers
2019-02-26 16:39:48 +01:00
committed by Commit Bot
parent 7b3f4a2035
commit e12a1c7644
2 changed files with 28 additions and 0 deletions

View File

@ -12,6 +12,8 @@
#import "RTCLegacyStatsReport+Private.h" #import "RTCLegacyStatsReport+Private.h"
#import "RTCMediaStreamTrack+Private.h" #import "RTCMediaStreamTrack+Private.h"
#import "RTCRtpReceiver+Private.h"
#import "RTCRtpSender+Private.h"
#import "RTCStatisticsReport+Private.h" #import "RTCStatisticsReport+Private.h"
#import "helpers/NSString+StdString.h" #import "helpers/NSString+StdString.h"
@ -63,6 +65,20 @@ class StatsObserverAdapter : public StatsObserver {
@implementation RTCPeerConnection (Stats) @implementation RTCPeerConnection (Stats)
- (void)statisticsForSender:(RTCRtpSender *)sender
completionHandler:(RTCStatisticsCompletionHandler)completionHandler {
rtc::scoped_refptr<webrtc::StatsCollectorCallbackAdapter> collector(
new rtc::RefCountedObject<webrtc::StatsCollectorCallbackAdapter>(completionHandler));
self.nativePeerConnection->GetStats(sender.nativeRtpSender, collector);
}
- (void)statisticsForReceiver:(RTCRtpReceiver *)receiver
completionHandler:(RTCStatisticsCompletionHandler)completionHandler {
rtc::scoped_refptr<webrtc::StatsCollectorCallbackAdapter> collector(
new rtc::RefCountedObject<webrtc::StatsCollectorCallbackAdapter>(completionHandler));
self.nativePeerConnection->GetStats(receiver.nativeRtpReceiver, collector);
}
- (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler { - (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler {
rtc::scoped_refptr<webrtc::StatsCollectorCallbackAdapter> collector( rtc::scoped_refptr<webrtc::StatsCollectorCallbackAdapter> collector(
new rtc::RefCountedObject<webrtc::StatsCollectorCallbackAdapter>(completionHandler)); new rtc::RefCountedObject<webrtc::StatsCollectorCallbackAdapter>(completionHandler));

View File

@ -331,6 +331,18 @@ typedef void (^RTCStatisticsCompletionHandler)(RTCStatisticsReport *);
/** Gather statistic through the v2 statistics API. */ /** Gather statistic through the v2 statistics API. */
- (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler; - (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 @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END