Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 12 additions & 2 deletions ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ios/RCTWebRTC/WebRTCModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static NSString *const kEventPeerConnectionOnTrack = @"peerConnectionOnTrack";
@property(nonatomic, strong) RTCPeerConnectionFactory *peerConnectionFactory;
@property(nonatomic, strong) id<RTCVideoDecoderFactory> decoderFactory;
@property(nonatomic, strong) id<RTCVideoEncoderFactory> encoderFactory;
@property(nonatomic, strong) RTCCallbackLogger* callbackLogger;

@property(nonatomic, strong) NSMutableDictionary<NSNumber *, RTCPeerConnection *> *peerConnections;
@property(nonatomic, strong) NSMutableDictionary<NSString *, RTCMediaStream *> *localStreams;
Expand Down
23 changes: 23 additions & 0 deletions ios/RCTWebRTC/WebRTCModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,29 @@ - (instancetype)init {
RCTLogInfo(@"Using video encoder factory: %@", NSStringFromClass([encoderFactory class]));
RCTLogInfo(@"Using video decoder factory: %@", NSStringFromClass([decoderFactory class]));

NSArray<RTCVideoCodecInfo *> *enc = [encoderFactory supportedCodecs];
NSArray<RTCVideoCodecInfo *> *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];
Expand Down
Loading