The last post this week covers what Parley, Savor and Wayline needed underneath: calls, encryption and a backend you can trust with real data. These are features you’d usually assemble from three vendors and a few weekends of glue code.
Voice and video calls with WebRTC
com.codename1.webrtc
carries live audio and video directly between two devices, encrypted on the way, with a TURN relay when there’s no direct path. On Android it’s Google’s WebRTC library, on iOS the Apple build of the same library, and in the browser it’s the browser’s own WebRTC. Referencing the package is what adds the native library to a build, so apps that don’t make calls don’t pay for it.
WebRtc.openUserMedia(true, true, true).ready(media -> {
PeerConnectionConfig config = new PeerConnectionConfig()
.addIceServer(IceServer.stun("stun:stun.example.com:3478"));
pc = WebRtc.createPeerConnection(config, new PeerConnection.Listener() {
public void iceCandidate(PeerConnection connection, IceCandidate candidate) {
signalling.send(candidate);
}
public void stateChanged(PeerConnection connection, String state) {
}
public void remoteTrack(PeerConnection connection, MediaTrack track) {
if (track.isVideo()) {
form.add(BorderLayout.CENTER, new VideoView(track, false));
form.revalidate();
}
}
});
pc.addTrack(media.getAudio());
pc.addTrack(media.getVideo());
pc.createOffer().ready(offer -> pc.setLocalDescription(offer)
.ready(done -> signalling.send(offer)));
});
Signaling is yours on…