Search in sources :

Example 1 with IceCandidateFoundEvent

use of org.kurento.client.IceCandidateFoundEvent in project openmeetings by apache.

the class KUser method getEndpointForUser.

private WebRtcEndpoint getEndpointForUser(final KurentoHandler h, final KUser sender) {
    if (sender.getUid().equals(uid)) {
        log.debug("PARTICIPANT {}: configuring loopback", this.uid);
        return outgoingMedia;
    }
    log.debug("PARTICIPANT {}: receiving video from {}", this.uid, sender.getUid());
    WebRtcEndpoint incoming = incomingMedia.get(sender.getUid());
    if (incoming == null) {
        log.debug("PARTICIPANT {}: creating new endpoint for {}", this.uid, sender.getUid());
        incoming = new WebRtcEndpoint.Builder(pipeline).build();
        incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

            @Override
            public void onEvent(IceCandidateFoundEvent event) {
                JSONObject response = newKurentoMsg();
                response.put("id", "iceCandidate");
                response.put("uid", sender.getUid());
                response.put("candidate", convert(JsonUtils.toJsonObject(event.getCandidate())));
                h.sendClient(uid, response);
            }
        });
        incomingMedia.put(sender.getUid(), incoming);
    }
    log.debug("PARTICIPANT {}: obtained endpoint for {}", this.uid, sender.getUid());
    sender.getOutgoingWebRtcPeer().connect(incoming);
    return incoming;
}
Also used : WebRtcEndpoint(org.kurento.client.WebRtcEndpoint) JSONObject(com.github.openjson.JSONObject) IceCandidateFoundEvent(org.kurento.client.IceCandidateFoundEvent)

Aggregations

JSONObject (com.github.openjson.JSONObject)1 IceCandidateFoundEvent (org.kurento.client.IceCandidateFoundEvent)1 WebRtcEndpoint (org.kurento.client.WebRtcEndpoint)1