diff --git a/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m b/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m index e636f290c..6c859521a 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m @@ -8,14 +8,30 @@ @implementation WebRTCModule (RTCAudioSession) RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(unlockPeerClosing) { + CFAbsoluteTime start = CFAbsoluteTimeGetCurrent(); + WebRTCAudioSession* session = [WebRTCAudioSession shared]; [session setAudioSessionEnabled:NO]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"dev_menu_logs" object:@{ + @"append": @YES, + @"log": [NSString stringWithFormat:@"unlockPeerClosing: time %.3f ms", (CFAbsoluteTimeGetCurrent() - start) * 1000], + @"key": @"Call End Time Elapsed" + }]; return nil; } RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(lockPeerClosing) { + CFAbsoluteTime start = CFAbsoluteTimeGetCurrent(); + WebRTCAudioSession* session = [WebRTCAudioSession shared]; [session setAudioSessionEnabled:YES]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"dev_menu_logs" object:@{ + @"append": @YES, + @"log": [NSString stringWithFormat:@"lockPeerClosing: time %.3f ms", (CFAbsoluteTimeGetCurrent() - start) * 1000], + @"key": @"Call End Time Elapsed" + }]; return nil; } diff --git a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m index 0e636251a..5b5955eeb 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m @@ -350,13 +350,23 @@ - (void)checkAudioLevel { [peerConnection addIceCandidate:candidate completionHandler:handler]; } -RCT_EXPORT_METHOD(peerConnectionClose : (nonnull NSNumber *)objectID) { +RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionClose : (nonnull NSNumber *)objectID) { + CFAbsoluteTime start = CFAbsoluteTimeGetCurrent(); + RTCPeerConnection *peerConnection = self.peerConnections[objectID]; if (!peerConnection) { - return; + return nil; } [peerConnection close]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"dev_menu_logs" object:@{ + @"append": @YES, + @"log": [NSString stringWithFormat:@"peerConnectionClose: time %.3f ms", (CFAbsoluteTimeGetCurrent() - start) * 1000], + @"key": @"Call End Time Elapsed" + }]; + + return nil; } RCT_EXPORT_METHOD(peerConnectionDispose : (nonnull NSNumber *)objectID) { diff --git a/ios/RCTWebRTC/WebRTCModule.h b/ios/RCTWebRTC/WebRTCModule.h index cba5eb7df..6f6cb13c0 100644 --- a/ios/RCTWebRTC/WebRTCModule.h +++ b/ios/RCTWebRTC/WebRTCModule.h @@ -33,6 +33,7 @@ static NSString *const kEventPeerConnectionOnTrack = @"peerConnectionOnTrack"; @property(nonatomic, strong) RTCPeerConnectionFactory *peerConnectionFactory; @property(nonatomic, strong) id decoderFactory; @property(nonatomic, strong) id encoderFactory; +@property(nonatomic, strong) RTCCallbackLogger* callbackLogger; @property(nonatomic, strong) NSMutableDictionary *peerConnections; @property(nonatomic, strong) NSMutableDictionary *localStreams; diff --git a/ios/RCTWebRTC/WebRTCModule.m b/ios/RCTWebRTC/WebRTCModule.m index 1bc5fc665..10d3985ac 100644 --- a/ios/RCTWebRTC/WebRTCModule.m +++ b/ios/RCTWebRTC/WebRTCModule.m @@ -69,6 +69,29 @@ - (instancetype)init { RCTLogInfo(@"Using video encoder factory: %@", NSStringFromClass([encoderFactory class])); RCTLogInfo(@"Using video decoder factory: %@", NSStringFromClass([decoderFactory class])); + NSArray *enc = [encoderFactory supportedCodecs]; + NSArray *dec = [decoderFactory supportedCodecs]; + NSMutableArray *encNames = [NSMutableArray array]; + for (RTCVideoCodecInfo *c in enc) { [encNames addObject:c.name ?: @""]; } + NSMutableArray *decNames = [NSMutableArray array]; + for (RTCVideoCodecInfo *c in dec) { [decNames addObject:c.name ?: @""]; } + + [[NSNotificationCenter defaultCenter] postNotificationName:@"dev_menu_logs" object:@{ + @"append": @YES, + @"log": [NSString stringWithFormat:@"Video Encoders: %@; Decoders: %@", encNames, decNames], + @"key": @"WebRTC" + }]; + + _callbackLogger = [RTCCallbackLogger new]; + _callbackLogger.severity = loggingSeverity; + [_callbackLogger startWithMessageAndSeverityHandler:^(NSString *message, RTCLoggingSeverity severity) { + [[NSNotificationCenter defaultCenter] postNotificationName:@"dev_menu_logs" object:@{ + @"append": @YES, + @"log": [NSString stringWithFormat:@"[RTC %ld] %@", (long)severity, message ?: @""], + @"key": @"WebRTC" + }]; + }]; + _peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithEncoderFactory:encoderFactory decoderFactory:decoderFactory audioDevice:audioDevice];