Add iOS tracing.
BUG=
Review URL: https://codereview.webrtc.org/1650993004
Cr-Commit-Position: refs/heads/master@{#11469}
diff --git a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
index 33e00ed..47252be 100644
--- a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -11,6 +11,7 @@
#import "ARDAppClient+Internal.h"
#if defined(WEBRTC_IOS)
+#import "webrtc/base/objc/RTCTracing.h"
#import "RTCAVFoundationVideoSource.h"
#endif
#import "RTCFileLogger.h"
@@ -48,6 +49,12 @@
static NSInteger const kARDAppClientErrorInvalidClient = -5;
static NSInteger const kARDAppClientErrorInvalidRoom = -6;
+// TODO(tkchin): Remove guard once rtc_base_objc compiles on Mac.
+#if defined(WEBRTC_IOS)
+// TODO(tkchin): Add this as a UI option.
+static BOOL const kARDAppClientEnableTracing = NO;
+#endif
+
// We need a proxy to NSTimer because it causes a strong retain cycle. When
// using the proxy, |invalidate| must be called before it properly deallocs.
@interface ARDTimerProxy : NSObject
@@ -209,6 +216,17 @@
_isAudioOnly = isAudioOnly;
self.state = kARDAppClientStateConnecting;
+#if defined(WEBRTC_IOS)
+ if (kARDAppClientEnableTracing) {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(
+ NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirPath = paths.firstObject;
+ NSString *filePath =
+ [documentsDirPath stringByAppendingPathComponent:@"webrtc-trace.txt"];
+ RTCStartInternalCapture(filePath);
+ }
+#endif
+
// Request TURN.
__weak ARDAppClient *weakSelf = self;
[_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers,
@@ -285,6 +303,9 @@
_messageQueue = [NSMutableArray array];
_peerConnection = nil;
self.state = kARDAppClientStateDisconnected;
+#if defined(WEBRTC_IOS)
+ RTCStopInternalCapture();
+#endif
}
#pragma mark - ARDSignalingChannelDelegate