use of im.actor.runtime.webrtc.WebRTCPeerConnectionCallback in project actor-platform by actorapp.
the class AndroidPeerConnection method close.
@Override
public void close() {
AndroidWebRTCRuntimeProvider.postToHandler(() -> {
while (!ownStreams.isEmpty()) {
CountedReference<WebRTCMediaStream> stream = ownStreams.remove(0);
peerConnection.removeStream(((AndroidMediaStream) stream.get()).getStream());
stream.release();
}
for (MediaStream stream : streams.keySet()) {
AndroidMediaStream stream1 = streams.get(stream);
if (stream1 != null) {
for (WebRTCPeerConnectionCallback c : callbacks) {
c.onStreamRemoved(stream1);
}
}
}
peerConnection.dispose();
});
}
use of im.actor.runtime.webrtc.WebRTCPeerConnectionCallback 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() {
// if (sessionId != -1) {
// callback.onNegotiationNeeded(sessionId);
// }
}
@Override
public void onStreamAdded(WebRTCMediaStream addedStream) {
// by parent actor
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