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:
parent
ddbb8a2c24
commit
19b1be159e
@ -42,6 +42,9 @@
|
|||||||
+ (RTCSignalingState)convertSignalingStateToObjC:
|
+ (RTCSignalingState)convertSignalingStateToObjC:
|
||||||
(webrtc::PeerConnectionInterface::SignalingState)nativeState;
|
(webrtc::PeerConnectionInterface::SignalingState)nativeState;
|
||||||
|
|
||||||
|
+ (webrtc::PeerConnectionInterface::StatsOutputLevel)
|
||||||
|
convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel;
|
||||||
|
|
||||||
+ (RTCSourceState)convertSourceStateToObjC:
|
+ (RTCSourceState)convertSourceStateToObjC:
|
||||||
(webrtc::MediaSourceInterface::SourceState)nativeState;
|
(webrtc::MediaSourceInterface::SourceState)nativeState;
|
||||||
|
|
||||||
|
@ -81,6 +81,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (webrtc::PeerConnectionInterface::StatsOutputLevel)
|
||||||
|
convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel {
|
||||||
|
switch (statsOutputLevel) {
|
||||||
|
case RTCStatsOutputLevelStandard:
|
||||||
|
return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard;
|
||||||
|
case RTCStatsOutputLevelDebug:
|
||||||
|
return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+ (RTCSourceState)convertSourceStateToObjC:
|
+ (RTCSourceState)convertSourceStateToObjC:
|
||||||
(webrtc::MediaSourceInterface::SourceState)nativeState {
|
(webrtc::MediaSourceInterface::SourceState)nativeState {
|
||||||
switch (nativeState) {
|
switch (nativeState) {
|
||||||
|
@ -40,4 +40,8 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString*)description {
|
||||||
|
return [NSString stringWithFormat:@"%@: %@", _key, _value];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -36,9 +36,12 @@
|
|||||||
#import "RTCICEServer+Internal.h"
|
#import "RTCICEServer+Internal.h"
|
||||||
#import "RTCMediaConstraints+Internal.h"
|
#import "RTCMediaConstraints+Internal.h"
|
||||||
#import "RTCMediaStream+Internal.h"
|
#import "RTCMediaStream+Internal.h"
|
||||||
|
#import "RTCMediaStreamTrack+Internal.h"
|
||||||
#import "RTCSessionDescription+Internal.h"
|
#import "RTCSessionDescription+Internal.h"
|
||||||
#import "RTCSessionDescriptionDelegate.h"
|
#import "RTCSessionDescriptionDelegate.h"
|
||||||
#import "RTCSessionDescription.h"
|
#import "RTCSessionDescription.h"
|
||||||
|
#import "RTCStatsDelegate.h"
|
||||||
|
#import "RTCStatsReport+Internal.h"
|
||||||
|
|
||||||
#include "talk/app/webrtc/jsep.h"
|
#include "talk/app/webrtc/jsep.h"
|
||||||
|
|
||||||
@ -108,6 +111,30 @@ class RTCSetSessionDescriptionObserver : public SetSessionDescriptionObserver {
|
|||||||
id<RTCSessionDescriptionDelegate> _delegate;
|
id<RTCSessionDescriptionDelegate> _delegate;
|
||||||
RTCPeerConnection* _peerConnection;
|
RTCPeerConnection* _peerConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RTCStatsObserver : public StatsObserver {
|
||||||
|
public:
|
||||||
|
RTCStatsObserver(id<RTCStatsDelegate> delegate,
|
||||||
|
RTCPeerConnection* peerConnection) {
|
||||||
|
_delegate = delegate;
|
||||||
|
_peerConnection = peerConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnComplete(const std::vector<StatsReport>& reports) OVERRIDE {
|
||||||
|
NSMutableArray* stats = [NSMutableArray arrayWithCapacity:reports.size()];
|
||||||
|
std::vector<StatsReport>::const_iterator it = reports.begin();
|
||||||
|
for (; it != reports.end(); ++it) {
|
||||||
|
RTCStatsReport* statsReport =
|
||||||
|
[[RTCStatsReport alloc] initWithStatsReport:*it];
|
||||||
|
[stats addObject:statsReport];
|
||||||
|
}
|
||||||
|
[_delegate peerConnection:_peerConnection didGetStats:stats];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
id<RTCStatsDelegate> _delegate;
|
||||||
|
RTCPeerConnection* _peerConnection;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation RTCPeerConnection {
|
@implementation RTCPeerConnection {
|
||||||
@ -220,6 +247,18 @@ class RTCSetSessionDescriptionObserver : public SetSessionDescriptionObserver {
|
|||||||
self.peerConnection->Close();
|
self.peerConnection->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
|
||||||
|
mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
|
||||||
|
statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel {
|
||||||
|
talk_base::scoped_refptr<webrtc::RTCStatsObserver> observer(
|
||||||
|
new talk_base::RefCountedObject<webrtc::RTCStatsObserver>(delegate,
|
||||||
|
self));
|
||||||
|
webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel =
|
||||||
|
[RTCEnumConverter convertStatsOutputLevelToNative:statsOutputLevel];
|
||||||
|
return self.peerConnection->GetStats(
|
||||||
|
observer, mediaStreamTrack.mediaTrack, nativeOutputLevel);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RTCPeerConnection (Internal)
|
@implementation RTCPeerConnection (Internal)
|
||||||
|
36
talk/app/webrtc/objc/RTCStatsReport+Internal.h
Normal file
36
talk/app/webrtc/objc/RTCStatsReport+Internal.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* libjingle
|
||||||
|
* Copyright 2014, Google Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "RTCStatsReport.h"
|
||||||
|
|
||||||
|
#include "talk/app/webrtc/statstypes.h"
|
||||||
|
|
||||||
|
@interface RTCStatsReport (Internal)
|
||||||
|
|
||||||
|
- (instancetype)initWithStatsReport:(const webrtc::StatsReport&)statsReport;
|
||||||
|
|
||||||
|
@end
|
69
talk/app/webrtc/objc/RTCStatsReport.mm
Normal file
69
talk/app/webrtc/objc/RTCStatsReport.mm
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* libjingle
|
||||||
|
* Copyright 2014, Google Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||||
|
#error "This file requires ARC support."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "RTCStatsReport+Internal.h"
|
||||||
|
|
||||||
|
#import "RTCPair.h"
|
||||||
|
|
||||||
|
@implementation RTCStatsReport
|
||||||
|
|
||||||
|
- (NSString*)description {
|
||||||
|
NSString* format = @"id: %@, type: %@, timestamp: %f, values: %@";
|
||||||
|
return [NSString stringWithFormat:format,
|
||||||
|
self.reportId,
|
||||||
|
self.type,
|
||||||
|
self.timestamp,
|
||||||
|
self.values];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation RTCStatsReport (Internal)
|
||||||
|
|
||||||
|
- (instancetype)initWithStatsReport:(const webrtc::StatsReport&)statsReport {
|
||||||
|
if (self = [super init]) {
|
||||||
|
_reportId = @(statsReport.id.c_str());
|
||||||
|
_type = @(statsReport.type.c_str());
|
||||||
|
_timestamp = statsReport.timestamp;
|
||||||
|
NSMutableArray* values =
|
||||||
|
[NSMutableArray arrayWithCapacity:statsReport.values.size()];
|
||||||
|
webrtc::StatsReport::Values::const_iterator it = statsReport.values.begin();
|
||||||
|
for (; it != statsReport.values.end(); ++it) {
|
||||||
|
RTCPair* pair = [[RTCPair alloc] initWithKey:@(it->name.c_str())
|
||||||
|
value:@(it->value.c_str())];
|
||||||
|
[values addObject:pair];
|
||||||
|
}
|
||||||
|
_values = values;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -31,8 +31,10 @@
|
|||||||
@class RTCICEServers;
|
@class RTCICEServers;
|
||||||
@class RTCMediaConstraints;
|
@class RTCMediaConstraints;
|
||||||
@class RTCMediaStream;
|
@class RTCMediaStream;
|
||||||
|
@class RTCMediaStreamTrack;
|
||||||
@class RTCSessionDescription;
|
@class RTCSessionDescription;
|
||||||
@protocol RTCSessionDescriptionDelegate;
|
@protocol RTCSessionDescriptionDelegate;
|
||||||
|
@protocol RTCStatsDelegate;
|
||||||
|
|
||||||
// RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection
|
// RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection
|
||||||
// object. See the documentation in talk/app/webrtc/peerconnectioninterface.h.
|
// object. See the documentation in talk/app/webrtc/peerconnectioninterface.h.
|
||||||
@ -99,7 +101,12 @@
|
|||||||
// Terminates all media and closes the transport.
|
// Terminates all media and closes the transport.
|
||||||
- (void)close;
|
- (void)close;
|
||||||
|
|
||||||
// TODO(hughv): Implement GetStats.
|
// Gets statistics for the media track. If |mediaStreamTrack| is nil statistics
|
||||||
|
// are gathered for all tracks.
|
||||||
|
// Statistics information will be reported via RTCStatsDelegate.
|
||||||
|
- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
|
||||||
|
mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
|
||||||
|
statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel;
|
||||||
|
|
||||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||||
// Disallow init and don't add to documentation
|
// Disallow init and don't add to documentation
|
||||||
|
39
talk/app/webrtc/objc/public/RTCStatsDelegate.h
Normal file
39
talk/app/webrtc/objc/public/RTCStatsDelegate.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* libjingle
|
||||||
|
* Copyright 2014, Google Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@class RTCPeerConnection;
|
||||||
|
|
||||||
|
// RTCSessionDescriptionDelegate is a protocol for receiving statistic
|
||||||
|
// reports from RTCPeerConnection.
|
||||||
|
@protocol RTCStatsDelegate<NSObject>
|
||||||
|
|
||||||
|
- (void)peerConnection:(RTCPeerConnection*)peerConnection
|
||||||
|
didGetStats:(NSArray*)stats; // NSArray of RTCStatsReport*.
|
||||||
|
|
||||||
|
@end
|
45
talk/app/webrtc/objc/public/RTCStatsReport.h
Normal file
45
talk/app/webrtc/objc/public/RTCStatsReport.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* libjingle
|
||||||
|
* Copyright 2014, Google Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
// ObjectiveC friendly wrapper around a StatsReport object.
|
||||||
|
// See talk/app/webrtc/statsypes.h
|
||||||
|
@interface RTCStatsReport : NSObject
|
||||||
|
|
||||||
|
@property(nonatomic, readonly) NSString* reportId;
|
||||||
|
@property(nonatomic, readonly) NSString* type;
|
||||||
|
@property(nonatomic, readonly) CFTimeInterval timestamp;
|
||||||
|
@property(nonatomic, readonly) NSArray* values; // NSArray of RTCPair*.
|
||||||
|
|
||||||
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||||
|
// Disallow init and don't add to documentation
|
||||||
|
- (id)init __attribute__((
|
||||||
|
unavailable("init is not a supported initializer for this class.")));
|
||||||
|
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||||
|
|
||||||
|
@end
|
@ -55,6 +55,12 @@ typedef enum {
|
|||||||
RTCSignalingClosed,
|
RTCSignalingClosed,
|
||||||
} RTCSignalingState;
|
} RTCSignalingState;
|
||||||
|
|
||||||
|
// RTCStatsOutputLevel correspond to webrtc::StatsOutputLevel
|
||||||
|
typedef enum {
|
||||||
|
RTCStatsOutputLevelStandard,
|
||||||
|
RTCStatsOutputLevelDebug,
|
||||||
|
} RTCStatsOutputLevel;
|
||||||
|
|
||||||
// RTCSourceState corresponds to the states in webrtc::SourceState.
|
// RTCSourceState corresponds to the states in webrtc::SourceState.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RTCSourceStateInitializing,
|
RTCSourceStateInitializing,
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#import "RTCPeerConnectionDelegate.h"
|
#import "RTCPeerConnectionDelegate.h"
|
||||||
#import "RTCPeerConnectionFactory.h"
|
#import "RTCPeerConnectionFactory.h"
|
||||||
#import "RTCSessionDescription.h"
|
#import "RTCSessionDescription.h"
|
||||||
|
#import "RTCStatsDelegate.h"
|
||||||
#import "RTCVideoRenderer.h"
|
#import "RTCVideoRenderer.h"
|
||||||
#import "RTCVideoCapturer.h"
|
#import "RTCVideoCapturer.h"
|
||||||
#import "RTCVideoTrack.h"
|
#import "RTCVideoTrack.h"
|
||||||
@ -63,6 +64,8 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - RTCPeerConnectionDelegate
|
||||||
|
|
||||||
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
|
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||||
NSLog(@"PCO onError.");
|
NSLog(@"PCO onError.");
|
||||||
@ -147,13 +150,15 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
- (void)displayLogMessage:(NSString*)message {
|
- (void)displayLogMessage:(NSString*)message {
|
||||||
[_delegate displayLogMessage:message];
|
[_delegate displayLogMessage:message];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface APPRTCAppDelegate ()
|
@interface APPRTCAppDelegate () <RTCStatsDelegate>
|
||||||
|
|
||||||
@property(nonatomic, strong) APPRTCAppClient* client;
|
@property(nonatomic, strong) APPRTCAppClient* client;
|
||||||
@property(nonatomic, strong) PCObserver* pcObserver;
|
@property(nonatomic, strong) PCObserver* pcObserver;
|
||||||
@ -163,7 +168,9 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation APPRTCAppDelegate
|
@implementation APPRTCAppDelegate {
|
||||||
|
NSTimer* _statsTimer;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - UIApplicationDelegate methods
|
#pragma mark - UIApplicationDelegate methods
|
||||||
|
|
||||||
@ -175,6 +182,12 @@
|
|||||||
[[APPRTCViewController alloc] initWithNibName:@"APPRTCViewController"
|
[[APPRTCViewController alloc] initWithNibName:@"APPRTCViewController"
|
||||||
bundle:nil];
|
bundle:nil];
|
||||||
self.window.rootViewController = self.viewController;
|
self.window.rootViewController = self.viewController;
|
||||||
|
_statsTimer =
|
||||||
|
[NSTimer scheduledTimerWithTimeInterval:10
|
||||||
|
target:self
|
||||||
|
selector:@selector(didFireStatsTimer:)
|
||||||
|
userInfo:nil
|
||||||
|
repeats:YES];
|
||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
return YES;
|
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
|
#pragma mark - internal methods
|
||||||
|
|
||||||
- (void)disconnect {
|
- (void)disconnect {
|
||||||
@ -531,6 +554,14 @@
|
|||||||
return removeBackslash;
|
return removeBackslash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)didFireStatsTimer:(NSTimer *)timer {
|
||||||
|
if (self.peerConnection) {
|
||||||
|
[self.peerConnection getStatsWithDelegate:self
|
||||||
|
mediaStreamTrack:nil
|
||||||
|
statsOutputLevel:RTCStatsOutputLevelDebug];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - public methods
|
#pragma mark - public methods
|
||||||
|
|
||||||
- (void)closeVideoUI {
|
- (void)closeVideoUI {
|
||||||
|
@ -193,6 +193,8 @@
|
|||||||
'app/webrtc/objc/RTCPeerConnectionObserver.mm',
|
'app/webrtc/objc/RTCPeerConnectionObserver.mm',
|
||||||
'app/webrtc/objc/RTCSessionDescription+Internal.h',
|
'app/webrtc/objc/RTCSessionDescription+Internal.h',
|
||||||
'app/webrtc/objc/RTCSessionDescription.mm',
|
'app/webrtc/objc/RTCSessionDescription.mm',
|
||||||
|
'app/webrtc/objc/RTCStatsReport+Internal.h',
|
||||||
|
'app/webrtc/objc/RTCStatsReport.mm',
|
||||||
'app/webrtc/objc/RTCVideoCapturer+Internal.h',
|
'app/webrtc/objc/RTCVideoCapturer+Internal.h',
|
||||||
'app/webrtc/objc/RTCVideoCapturer.mm',
|
'app/webrtc/objc/RTCVideoCapturer.mm',
|
||||||
'app/webrtc/objc/RTCVideoRenderer+Internal.h',
|
'app/webrtc/objc/RTCVideoRenderer+Internal.h',
|
||||||
@ -216,6 +218,8 @@
|
|||||||
'app/webrtc/objc/public/RTCPeerConnectionFactory.h',
|
'app/webrtc/objc/public/RTCPeerConnectionFactory.h',
|
||||||
'app/webrtc/objc/public/RTCSessionDescription.h',
|
'app/webrtc/objc/public/RTCSessionDescription.h',
|
||||||
'app/webrtc/objc/public/RTCSessionDescriptionDelegate.h',
|
'app/webrtc/objc/public/RTCSessionDescriptionDelegate.h',
|
||||||
|
'app/webrtc/objc/public/RTCStatsDelegate.h',
|
||||||
|
'app/webrtc/objc/public/RTCStatsReport.h',
|
||||||
'app/webrtc/objc/public/RTCTypes.h',
|
'app/webrtc/objc/public/RTCTypes.h',
|
||||||
'app/webrtc/objc/public/RTCVideoCapturer.h',
|
'app/webrtc/objc/public/RTCVideoCapturer.h',
|
||||||
'app/webrtc/objc/public/RTCVideoRenderer.h',
|
'app/webrtc/objc/public/RTCVideoRenderer.h',
|
||||||
@ -241,6 +245,9 @@
|
|||||||
},
|
},
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'CLANG_ENABLE_OBJC_ARC': 'YES',
|
'CLANG_ENABLE_OBJC_ARC': 'YES',
|
||||||
|
# common.gypi enables this for mac but we want this to be disabled
|
||||||
|
# like it is for ios.
|
||||||
|
'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO',
|
||||||
},
|
},
|
||||||
}, # target libjingle_peerconnection_objc
|
}, # target libjingle_peerconnection_objc
|
||||||
],
|
],
|
||||||
|
@ -508,6 +508,9 @@
|
|||||||
],
|
],
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'CLANG_ENABLE_OBJC_ARC': 'YES',
|
'CLANG_ENABLE_OBJC_ARC': 'YES',
|
||||||
|
# common.gypi enables this for mac but we want this to be disabled
|
||||||
|
# like it is for ios.
|
||||||
|
'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO',
|
||||||
'INFOPLIST_FILE': '<(infoplist_file)',
|
'INFOPLIST_FILE': '<(infoplist_file)',
|
||||||
},
|
},
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user