use of im.actor.runtime.webrtc.WebRTCIceServer in project actor-platform by actorapp.
the class PeerConnectionActor method preStart.
@Override
public void preStart() {
isReady = false;
WebRTCIceServer[] rtcIceServers = ManagedList.of(iceServers).map(apiICEServer -> new WebRTCIceServer(apiICEServer.getUrl(), apiICEServer.getUsername(), apiICEServer.getCredential())).toArray(new WebRTCIceServer[0]);
WebRTCSettings settings = new WebRTCSettings(false, false, config().isVideoCallsEnabled());
WebRTC.createPeerConnection(rtcIceServers, settings).then(webRTCPeerConnection -> {
PeerConnectionActor.this.peerConnection = webRTCPeerConnection;
PeerConnectionActor.this.peerConnection.addOwnStream(userMedia);
PeerConnectionActor.this.peerConnection.addCallback(new WebRTCPeerConnectionCallback() {
@Override
public void onCandidate(int label, String id, String candidate) {
if (sessionId != -1) {
callback.onCandidate(sessionId, label, id, candidate);
}
}
@Override
public void onRenegotiationNeeded() {
}
@Override
public void onStreamAdded(WebRTCMediaStream addedStream) {
for (WebRTCMediaTrack track : addedStream.getAudioTracks()) {
track.setEnabled(false);
}
for (WebRTCMediaTrack track : addedStream.getVideoTracks()) {
track.setEnabled(false);
}
callback.onStreamAdded(addedStream);
}
@Override
public void onStreamRemoved(WebRTCMediaStream removedStream) {
callback.onStreamRemoved(removedStream);
}
@Override
public void onDisposed() {
}
});
state = PeerConnectionState.WAITING_HANDSHAKE;
onReady();
}).failure(e -> {
Log.d(TAG, "preStart:error");
e.printStackTrace();
onHandshakeFailure();
});
}
Aggregations