Adding AecDump functionality to AppRTCDemo for iOS
BUG=webrtc:6229
Review-Url: https://codereview.webrtc.org/2253013006
Cr-Commit-Position: refs/heads/master@{#13927}
diff --git a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
index 43eb6f4..a9dd8b1 100644
--- a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -129,6 +129,8 @@
_defaultPeerConnectionConstraints;
@synthesize isLoopback = _isLoopback;
@synthesize isAudioOnly = _isAudioOnly;
+@synthesize shouldMakeAecDump = _shouldMakeAecDump;
+@synthesize isAecDumpActive = _isAecDumpActive;
- (instancetype)init {
if (self = [super init]) {
@@ -220,11 +222,13 @@
- (void)connectToRoomWithId:(NSString *)roomId
isLoopback:(BOOL)isLoopback
- isAudioOnly:(BOOL)isAudioOnly {
+ isAudioOnly:(BOOL)isAudioOnly
+ shouldMakeAecDump:(BOOL)shouldMakeAecDump {
NSParameterAssert(roomId.length);
NSParameterAssert(_state == kARDAppClientStateDisconnected);
_isLoopback = isLoopback;
_isAudioOnly = isAudioOnly;
+ _shouldMakeAecDump = shouldMakeAecDump;
self.state = kARDAppClientStateConnecting;
#if defined(WEBRTC_IOS)
@@ -309,6 +313,10 @@
_hasReceivedSdp = NO;
_messageQueue = [NSMutableArray array];
#if defined(WEBRTC_IOS)
+ if (_isAecDumpActive) {
+ [_factory stopAecDump];
+ _isAecDumpActive = NO;
+ }
[_peerConnection stopRtcEventLog];
#endif
_peerConnection = nil;
@@ -562,6 +570,22 @@
RTCLogError(@"Failed to start event logging.");
}
}
+
+ // Start aecdump diagnostic recording.
+ if (_shouldMakeAecDump) {
+ _isAecDumpActive = YES;
+ NSString *filePath = [self documentsFilePathForFileName:@"audio.aecdump"];
+ int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ RTCLogError(@"Failed to create the aecdump file!");
+ _isAecDumpActive = NO;
+ } else {
+ if (![_factory startAecDumpWithFileDescriptor:fd maxFileSizeInBytes:-1]) {
+ RTCLogError(@"Failed to create aecdump.");
+ _isAecDumpActive = NO;
+ }
+ }
+ }
#endif
}