Skip to content

Instantly share code, notes, and snippets.

@ktoraskartwilio
Last active February 15, 2017 00:12
Show Gist options
  • Save ktoraskartwilio/187af2eba9d838a70f3183d0eff7cb2c to your computer and use it in GitHub Desktop.
Save ktoraskartwilio/187af2eba9d838a70f3183d0eff7cb2c to your computer and use it in GitHub Desktop.
TwilioProgVideo_ICE_Server_Setup
VideoClient videoClient = new VideoClient(this, VIDEO_ACCESS_TOKEN);
/*
* Documentation related to ICE servers can be found here:
* https://media.twiliocdn.com/sdk/android/video/releases/1.0.0-beta8/docs/com/twilio/video/IceServer.html
*/
Set<IceServer> iceServers = new HashSet<>();
iceServers.add(new IceServer("stun:foo.bar.address?transport=udp"));
iceServers.add(new IceServer("turn:foo.bar.address:3478?transport=udp", "fake", "pass"));
// Configure IceOptions to specify the custom ICE servers
IceOptions iceOptions = new IceOptions.Builder()
.iceServers(iceServers)
.iceTransportPolicy(IceTransportPolicy.ALL)
.build();
// Provide the IceOptions in the ConnectOptions builder
ConnectOptions connectOptions = new ConnectOptions.Builder()
.roomName("myRoom")
.iceOptions(iceOptions)
.build();
Room myRoom = videoClient.connect(connectOptions, new Room.Listener() {
@Override
public void onConnected(Room room) {
}
@Override
public void onConnectFailure(Room room, TwilioException e) {
}
@Override
public void onDisconnected(Room room, TwilioException e) {
}
@Override
public void onParticipantConnected(Room room, Participant participant) {
}
@Override
public void onParticipantDisconnected(Room room, Participant participant) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment