Adding AecDump functionality to AppRTCDemo for iOS
BUG=webrtc:6229 Review-Url: https://codereview.webrtc.org/2253013006 Cr-Commit-Position: refs/heads/master@{#13927}
This commit is contained in:
@ -43,6 +43,8 @@
|
||||
@property(nonatomic, strong) NSURL *webSocketRestURL;
|
||||
@property(nonatomic, readonly) BOOL isLoopback;
|
||||
@property(nonatomic, readonly) BOOL isAudioOnly;
|
||||
@property(nonatomic, readonly) BOOL shouldMakeAecDump;
|
||||
@property(nonatomic, assign) BOOL isAecDumpActive;
|
||||
|
||||
@property(nonatomic, strong)
|
||||
RTCMediaConstraints *defaultPeerConnectionConstraints;
|
||||
|
||||
@ -64,9 +64,11 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) {
|
||||
// Establishes a connection with the AppRTC servers for the given room id.
|
||||
// If |isLoopback| is true, the call will connect to itself.
|
||||
// If |isAudioOnly| is true, video will be disabled for the call.
|
||||
// If |shouldMakeAecDump| is true, an aecdump will be created for the call.
|
||||
- (void)connectToRoomWithId:(NSString *)roomId
|
||||
isLoopback:(BOOL)isLoopback
|
||||
isAudioOnly:(BOOL)isAudioOnly;
|
||||
isAudioOnly:(BOOL)isAudioOnly
|
||||
shouldMakeAecDump:(BOOL)shouldMakeAecDump;
|
||||
|
||||
// Disconnects from the AppRTC servers and any connected clients.
|
||||
- (void)disconnect;
|
||||
|
||||
@ -129,6 +129,8 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
||||
_defaultPeerConnectionConstraints;
|
||||
@synthesize isLoopback = _isLoopback;
|
||||
@synthesize isAudioOnly = _isAudioOnly;
|
||||
@synthesize shouldMakeAecDump = _shouldMakeAecDump;
|
||||
@synthesize isAecDumpActive = _isAecDumpActive;
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
@ -220,11 +222,13 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
||||
|
||||
- (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 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
||||
_hasReceivedSdp = NO;
|
||||
_messageQueue = [NSMutableArray array];
|
||||
#if defined(WEBRTC_IOS)
|
||||
if (_isAecDumpActive) {
|
||||
[_factory stopAecDump];
|
||||
_isAecDumpActive = NO;
|
||||
}
|
||||
[_peerConnection stopRtcEventLog];
|
||||
#endif
|
||||
_peerConnection = nil;
|
||||
@ -562,6 +570,22 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
didInputRoom:(NSString *)room
|
||||
isLoopback:(BOOL)isLoopback
|
||||
isAudioOnly:(BOOL)isAudioOnly
|
||||
shouldMakeAecDump:(BOOL)shouldMakeAecDump
|
||||
useManualAudio:(BOOL)useManualAudio;
|
||||
|
||||
- (void)mainViewDidToggleAudioLoop:(ARDMainView *)mainView;
|
||||
|
||||
@ -119,6 +119,8 @@ static CGFloat const kCallControlMargin = 8;
|
||||
UILabel *_callOptionsLabel;
|
||||
UISwitch *_audioOnlySwitch;
|
||||
UILabel *_audioOnlyLabel;
|
||||
UISwitch *_aecdumpSwitch;
|
||||
UILabel *_aecdumpLabel;
|
||||
UISwitch *_loopbackSwitch;
|
||||
UILabel *_loopbackLabel;
|
||||
UISwitch *_useManualAudioSwitch;
|
||||
@ -174,6 +176,17 @@ static CGFloat const kCallControlMargin = 8;
|
||||
[_loopbackLabel sizeToFit];
|
||||
[self addSubview:_loopbackLabel];
|
||||
|
||||
_aecdumpSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
[_aecdumpSwitch sizeToFit];
|
||||
[self addSubview:_aecdumpSwitch];
|
||||
|
||||
_aecdumpLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_aecdumpLabel.text = @"Create AecDump";
|
||||
_aecdumpLabel.font = controlFont;
|
||||
_aecdumpLabel.textColor = controlFontColor;
|
||||
[_aecdumpLabel sizeToFit];
|
||||
[self addSubview:_aecdumpLabel];
|
||||
|
||||
_useManualAudioSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
[_useManualAudioSwitch sizeToFit];
|
||||
_useManualAudioSwitch.on = YES;
|
||||
@ -274,8 +287,21 @@ static CGFloat const kCallControlMargin = 8;
|
||||
_loopbackLabel.center = CGPointMake(loopbackModeLabelCenterX,
|
||||
CGRectGetMidY(loopbackModeRect));
|
||||
|
||||
CGFloat useManualAudioTop =
|
||||
CGFloat aecdumpModeTop =
|
||||
CGRectGetMaxY(_loopbackSwitch.frame) + kCallControlMargin;
|
||||
CGRect aecdumpModeRect = CGRectMake(kCallControlMargin * 3,
|
||||
aecdumpModeTop,
|
||||
_aecdumpSwitch.frame.size.width,
|
||||
_aecdumpSwitch.frame.size.height);
|
||||
_aecdumpSwitch.frame = aecdumpModeRect;
|
||||
CGFloat aecdumpModeLabelCenterX = CGRectGetMaxX(aecdumpModeRect) +
|
||||
kCallControlMargin + _aecdumpLabel.frame.size.width / 2;
|
||||
_aecdumpLabel.center = CGPointMake(aecdumpModeLabelCenterX,
|
||||
CGRectGetMidY(aecdumpModeRect));
|
||||
|
||||
|
||||
CGFloat useManualAudioTop =
|
||||
CGRectGetMaxY(_aecdumpSwitch.frame) + kCallControlMargin;
|
||||
CGRect useManualAudioRect =
|
||||
CGRectMake(kCallControlMargin * 3,
|
||||
useManualAudioTop,
|
||||
@ -334,6 +360,7 @@ static CGFloat const kCallControlMargin = 8;
|
||||
didInputRoom:room
|
||||
isLoopback:_loopbackSwitch.isOn
|
||||
isAudioOnly:_audioOnlySwitch.isOn
|
||||
shouldMakeAecDump:_aecdumpSwitch.isOn
|
||||
useManualAudio:_useManualAudioSwitch.isOn];
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
didInputRoom:(NSString *)room
|
||||
isLoopback:(BOOL)isLoopback
|
||||
isAudioOnly:(BOOL)isAudioOnly
|
||||
shouldMakeAecDump:(BOOL)shouldMakeAecDump
|
||||
useManualAudio:(BOOL)useManualAudio {
|
||||
if (!room.length) {
|
||||
[self showAlertWithMessage:@"Missing room name."];
|
||||
@ -96,6 +97,7 @@
|
||||
[[ARDVideoCallViewController alloc] initForRoom:trimmedRoom
|
||||
isLoopback:isLoopback
|
||||
isAudioOnly:isAudioOnly
|
||||
shouldMakeAecDump:shouldMakeAecDump
|
||||
delegate:self];
|
||||
videoCallViewController.modalTransitionStyle =
|
||||
UIModalTransitionStyleCrossDissolve;
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
- (instancetype)initForRoom:(NSString *)room
|
||||
isLoopback:(BOOL)isLoopback
|
||||
isAudioOnly:(BOOL)isAudioOnly
|
||||
shouldMakeAecDump:(BOOL)shouldMakeAecDump
|
||||
delegate:(id<ARDVideoCallViewControllerDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
||||
@ -39,13 +39,15 @@
|
||||
- (instancetype)initForRoom:(NSString *)room
|
||||
isLoopback:(BOOL)isLoopback
|
||||
isAudioOnly:(BOOL)isAudioOnly
|
||||
shouldMakeAecDump:(BOOL)shouldMakeAecDump
|
||||
delegate:(id<ARDVideoCallViewControllerDelegate>)delegate {
|
||||
if (self = [super init]) {
|
||||
_delegate = delegate;
|
||||
_client = [[ARDAppClient alloc] initWithDelegate:self];
|
||||
[_client connectToRoomWithId:room
|
||||
isLoopback:isLoopback
|
||||
isAudioOnly:isAudioOnly];
|
||||
isAudioOnly:isAudioOnly
|
||||
shouldMakeAecDump:shouldMakeAecDump];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ static NSUInteger const kLogViewHeight = 280;
|
||||
didEnterRoomId:(NSString*)roomId {
|
||||
[_client disconnect];
|
||||
ARDAppClient *client = [[ARDAppClient alloc] initWithDelegate:self];
|
||||
[client connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO];
|
||||
[client connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO shouldMakeAecDump:NO];
|
||||
_client = client;
|
||||
}
|
||||
|
||||
|
||||
@ -283,8 +283,8 @@
|
||||
weakAnswerer = answerer;
|
||||
|
||||
// Kick off connection.
|
||||
[caller connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO];
|
||||
[answerer connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO];
|
||||
[caller connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO shouldMakeAecDump:NO];
|
||||
[answerer connectToRoomWithId:roomId isLoopback:NO isAudioOnly:NO shouldMakeAecDump:NO];
|
||||
[self waitForExpectationsWithTimeout:20 handler:^(NSError *error) {
|
||||
if (error) {
|
||||
NSLog(@"Expectations error: %@", error);
|
||||
|
||||
@ -48,6 +48,19 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)startAecDumpWithFileDescriptor:(int)fileDescriptor
|
||||
maxFileSizeInBytes:(int)maxFileSizeInBytes {
|
||||
// Pass the file to the recorder. The file ownership
|
||||
// is passed to the recorder, and the recorder
|
||||
// closes the file when needed.
|
||||
return _nativeFactory->StartAecDump(fileDescriptor, maxFileSizeInBytes);
|
||||
}
|
||||
|
||||
- (void)stopAecDump {
|
||||
// The file is closed by the call below.
|
||||
_nativeFactory->StopAecDump();
|
||||
}
|
||||
|
||||
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
|
||||
(nullable RTCMediaConstraints *)constraints {
|
||||
return [[RTCAVFoundationVideoSource alloc] initWithFactory:self
|
||||
|
||||
@ -53,6 +53,16 @@ RTC_EXPORT
|
||||
delegate:
|
||||
(nullable id<RTCPeerConnectionDelegate>)delegate;
|
||||
|
||||
/** Start an aecdump recording with a file descriptor and
|
||||
a specified maximum size limit (-1 specifies that no
|
||||
limit should be used).
|
||||
This API call will likely change in the future */
|
||||
- (BOOL)startAecDumpWithFileDescriptor:(int)fileDescriptor
|
||||
maxFileSizeInBytes:(int)maxFileSizeInBytes;
|
||||
|
||||
/* Stop an active aecdump recording */
|
||||
- (void)stopAecDump;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Reference in New Issue
Block a user