ISBX / apprtc-ios

A native iOS video chat app based on WebRTC
BSD 3-Clause "New" or "Revised" License
1.34k stars 411 forks source link

Is it possible to connect to stun server ? #24

Open ghost opened 8 years ago

ghost commented 8 years ago

Is it possible to connect with stun server and not turn server ?

a-athaullah commented 8 years ago

Yes its posible you can change this code in ARDAppClient.m ((void)connectToRoomWithId:(NSString *)roomId options:(NSDictionary *)options)

NSURL *turnRequestURL = [NSURL URLWithString:kARDTurnRequestUrl];
[self requestTURNServersWithURL:turnRequestURL completionHandler:^(NSArray *turnServers) {
    ARDAppClient *strongSelf = weakSelf;
    [strongSelf.iceServers addObjectsFromArray:turnServers];
    strongSelf.isTurnComplete = YES;
    [strongSelf startSignalingIfReady];
}];

to:

NSArray *uris = @[
                      @"your_stun_url1",
                      @"your_stun_url2"
                      ];
NSString *username = @"";
NSString *password = @"";
NSMutableArray *servers = [NSMutableArray arrayWithCapacity:uris.count];
for (NSString *uri in uris) {
        RTCICEServer *server =
        [[RTCICEServer alloc] initWithURI:[NSURL URLWithString:uri]
                                 username:username
                                 password:password];
        [servers addObject:server];
}
ARDAppClient *strongSelf = weakSelf;
[strongSelf.iceServers addObjectsFromArray:servers];
strongSelf.isTurnComplete = YES;
[strongSelf startSignalingIfReady];