Skip to content

Commit eecdb7c

Browse files
committed
Add support for turn server username and password
1 parent 1bc3064 commit eecdb7c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

WebRTC-Sample-App/VideoViewController.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class VideoViewController: UIViewController {
5757

5858

5959
//set default stunserver or turn server
60-
//let iceServer:RTCIceServer = RTCIceServer.init(urlStrings: ["stun:stun.l.google.com:19302"], username: "", credential: "")
61-
//Config.setDefaultStunServer(server: iceServer);
60+
//Config.setDefaultStunServer(server: "stun:stun.l.google.com:19302", user:"", pass:"");
6261

6362
//self.client.setMaxVideoBps(videoBitratePerSecond: 500000)
6463

WebRTCiOSSDK/api/webrtc/Config.swift

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,37 @@ import WebRTC
1111

1212
public class Config: NSObject {
1313

14+
//You can also set the turn server address for this
1415
private static var stunServer: String = "stun:stun.l.google.com:19302"
16+
private static var username: String = ""
17+
private static var password: String = ""
18+
1519
private static let constraints: [String: String] = ["OfferToReceiveAudio": "true", "OfferToReceiveVideo": "true"]
1620
private static let defaultConstraints: [String: String] = ["DtlsSrtpKeyAgreement": "true"]
1721

1822
private static var rtcSdpSemantics = RTCSdpSemantics.unifiedPlan
1923

24+
/**
25+
* You can set the turn server as well. If you need to add username and password, please use the setDefaultStunServer(server: String, user:String, pass:String)
26+
*/
2027
public static func setDefaultStunServer(server: String) {
2128
stunServer = server
2229
}
30+
/**
31+
* You can set the turn server as well. If you need to add username and password
32+
*/
33+
public static func setDefaultStunServer(server: String, user:String, pass:String) {
34+
stunServer = server
35+
username = user
36+
password = pass
37+
}
2338

2439
public static func setSdpSemantics(sdpSemantics: RTCSdpSemantics) {
2540
rtcSdpSemantics = sdpSemantics
2641
}
2742

2843
static func defaultStunServer() -> RTCIceServer {
29-
return RTCIceServer(urlStrings: [stunServer], username: "", credential: "")
44+
return RTCIceServer(urlStrings: [stunServer], username: username, credential: password)
3045
}
3146

3247
static func createAudioVideoConstraints() -> RTCMediaConstraints {

0 commit comments

Comments
 (0)