Provide GetStats method in RTCPeerConnection
BUG=3144 R=fischman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12069006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5960 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#import "RTCPeerConnectionDelegate.h"
|
||||
#import "RTCPeerConnectionFactory.h"
|
||||
#import "RTCSessionDescription.h"
|
||||
#import "RTCStatsDelegate.h"
|
||||
#import "RTCVideoRenderer.h"
|
||||
#import "RTCVideoCapturer.h"
|
||||
#import "RTCVideoTrack.h"
|
||||
@@ -63,6 +64,8 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - RTCPeerConnectionDelegate
|
||||
|
||||
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
|
||||
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||
NSLog(@"PCO onError.");
|
||||
@@ -147,13 +150,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)displayLogMessage:(NSString*)message {
|
||||
[_delegate displayLogMessage:message];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface APPRTCAppDelegate ()
|
||||
@interface APPRTCAppDelegate () <RTCStatsDelegate>
|
||||
|
||||
@property(nonatomic, strong) APPRTCAppClient* client;
|
||||
@property(nonatomic, strong) PCObserver* pcObserver;
|
||||
@@ -163,7 +168,9 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation APPRTCAppDelegate
|
||||
@implementation APPRTCAppDelegate {
|
||||
NSTimer* _statsTimer;
|
||||
}
|
||||
|
||||
#pragma mark - UIApplicationDelegate methods
|
||||
|
||||
@@ -175,6 +182,12 @@
|
||||
[[APPRTCViewController alloc] initWithNibName:@"APPRTCViewController"
|
||||
bundle:nil];
|
||||
self.window.rootViewController = self.viewController;
|
||||
_statsTimer =
|
||||
[NSTimer scheduledTimerWithTimeInterval:10
|
||||
target:self
|
||||
selector:@selector(didFireStatsTimer:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
@@ -488,6 +501,16 @@
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - RTCStatsDelegate methods
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection*)peerConnection
|
||||
didGetStats:(NSArray*)stats {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString* message = [NSString stringWithFormat:@"Stats:\n %@", stats];
|
||||
[self displayLogMessage:message];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - internal methods
|
||||
|
||||
- (void)disconnect {
|
||||
@@ -531,6 +554,14 @@
|
||||
return removeBackslash;
|
||||
}
|
||||
|
||||
- (void)didFireStatsTimer:(NSTimer *)timer {
|
||||
if (self.peerConnection) {
|
||||
[self.peerConnection getStatsWithDelegate:self
|
||||
mediaStreamTrack:nil
|
||||
statsOutputLevel:RTCStatsOutputLevelDebug];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - public methods
|
||||
|
||||
- (void)closeVideoUI {
|
||||
|
Reference in New Issue
Block a user