Last active
February 15, 2017 00:51
-
-
Save ktoraskartwilio/adf6e3ba2eac10532e6d8b435b2df32d to your computer and use it in GitHub Desktop.
Twilio Programmable Video ICE Server setup - iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a Client with the access token | |
if (!self.client) { | |
self.client = [TVIVideoClient clientWithToken:self.accessToken]; | |
} | |
// Documentation related to ICE servers can be found here: | |
// https://media.twiliocdn.com/sdk/ios/video/releases/1.0.0-beta7/docs/Classes/TVIIceServer.html | |
TVIIceOptions *iceOptions = [TVIIceOptions optionsWithBlock:^(TVIIceOptionsBuilder * _Nonnull builder) { | |
builder.transportPolicy = TVIIceTransportPolicyAll; | |
builder.servers = @[[[TVIIceServer alloc] initWithURL:@"stun:foo.bar.address?transport=udp"], | |
[[TVIIceServer alloc] initWithURL:@"turn:foo.bar.address:3478?transport=udp" | |
username:@"fake" | |
password:@"pass"]]; | |
}]; | |
TVIConnectOptions *options = [TVIConnectOptions optionsWithBlock:^(TVIConnectOptionsBuilder * _Nonnull builder) { | |
builder.name = roomName; | |
builder.iceOptions = iceOptions; | |
builder.localMedia = [[TVILocalMedia alloc] init]; | |
}]; | |
// Connect to the Room using the options we provided. | |
self.room = [self.client connectWithOptions:connectOptions delegate:self]; | |
- (void)logMessage:(NSString *)msg { | |
self.messageLabel.text = msg; | |
} | |
- (void)didConnectToRoom:(TVIRoom *)room { | |
[self logMessage:[NSString stringWithFormat:@"Connected to room %@ as %@", room.name, room.localParticipant.identity]]; | |
} | |
- (void)room:(TVIRoom *)room didDisconnectWithError:(nullable NSError *)error { | |
[self logMessage:[NSString stringWithFormat:@"Disconncted from room %@, error = %@", room.name, error]]; | |
} | |
- (void)room:(TVIRoom *)room didFailToConnectWithError:(nonnull NSError *)error{ | |
[self logMessage:[NSString stringWithFormat:@"Failed to connect to room, error = %@", error]]; | |
} | |
- (void)room:(TVIRoom *)room participantDidConnect:(TVIParticipant *)participant { | |
[self logMessage:[NSString stringWithFormat:@"Room %@ participant %@ connected", room.name, participant.identity]]; | |
} | |
- (void)room:(TVIRoom *)room participantDidDisconnect:(TVIParticipant *)participant { | |
[self logMessage:[NSString stringWithFormat:@"Room %@ participant %@ disconnected", room.name, participant.identity]]; | |
} | |
- (void)participant:(TVIParticipant *)participant addedVideoTrack:(TVIVideoTrack *)videoTrack { | |
[self logMessage:[NSString stringWithFormat:@"Participant %@ added video track.", participant.identity]]; | |
} | |
- (void)participant:(TVIParticipant *)participant removedVideoTrack:(TVIVideoTrack *)videoTrack { | |
[self logMessage:[NSString stringWithFormat:@"Participant %@ removed video track.", participant.identity]]; | |
} | |
- (void)participant:(TVIParticipant *)participant addedAudioTrack:(TVIAudioTrack *)audioTrack { | |
[self logMessage:[NSString stringWithFormat:@"Participant %@ added audio track.", participant.identity]]; | |
} | |
- (void)participant:(TVIParticipant *)participant removedAudioTrack:(TVIAudioTrack *)audioTrack { | |
[self logMessage:[NSString stringWithFormat:@"Participant %@ removed audio track.", participant.identity]]; | |
} | |
- (void)participant:(TVIParticipant *)participant enabledTrack:(TVITrack *)track { | |
} | |
- (void)participant:(TVIParticipant *)participant disabledTrack:(TVITrack *)track { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment