public void execute(String peerId, JSONObject payload) throws JSONException { Log.d(TAG, "AddIceCandidateCommand"); PeerConnection pc = peers.get(peerId).pc; if (pc.getRemoteDescription() != null) { IceCandidate candidate = new IceCandidate( payload.getString("id"), payload.getInt("label"), payload.getString("candidate") ); pc.addIceCandidate(candidate); } } }
IceCandidate toJavaCandidate(JSONObject json) throws JSONException { return new IceCandidate( json.getString("id"), json.getInt("label"), json.getString("candidate")); } }
private static IceCandidate toJavaCandidate(JSONObject json) throws JSONException { return new IceCandidate( json.getString("id"), json.getInt("label"), json.getString("candidate")); } }
IceCandidate toJavaCandidate(JSONObject json) throws JSONException { return new IceCandidate( json.getString("id"), json.getInt("label"), json.getString("candidate")); } }
private void onRemoteCandidateReceived(String userId, JSONObject message) { logcatOnUI("Receive Remote Candidate ..."); try { IceCandidate remoteIceCandidate = new IceCandidate(message.getString("id"), message.getInt("label"), message.getString("candidate")); mPeerConnection.addIceCandidate(remoteIceCandidate); } catch (JSONException e) { e.printStackTrace(); } }
/** * A new Ice candidate is received * * @param candidates the channel candidates */ private void onNewCandidates(final JsonArray candidates) { Log.d(LOG_TAG, "## onNewCandidates(): call state " + getCallState() + " with candidates " + candidates); if (!CALL_STATE_CREATED.equals(getCallState()) && (null != mPeerConnection)) { List<IceCandidate> candidatesList = new ArrayList<>(); // convert the JSON to IceCandidate for (int index = 0; index < candidates.size(); index++) { JsonObject item = candidates.get(index).getAsJsonObject(); try { String candidate = item.get("candidate").getAsString(); String sdpMid = item.get("sdpMid").getAsString(); int sdpLineIndex = item.get("sdpMLineIndex").getAsInt(); candidatesList.add(new IceCandidate(sdpMid, sdpLineIndex, candidate)); } catch (Exception e) { Log.e(LOG_TAG, "## onNewCandidates(): Exception Msg=" + e.getMessage(), e); } } for (IceCandidate cand : candidatesList) { Log.d(LOG_TAG, "## onNewCandidates(): addIceCandidate " + cand); mPeerConnection.addIceCandidate(cand); } } }
SessionDescription.Type.fromCanonicalForm(messageType), message.getString("sdp")); } else if (messageType.equals("candidate")) { IceCandidate candidate = new IceCandidate( message.getString("id"), message.getInt("label"), message.getString("candidate")); iceCandidates.add(candidate);
SessionDescription.Type.fromCanonicalForm(messageType), message.getString("sdp")); } else if (messageType.equals("candidate")) { IceCandidate candidate = new IceCandidate( message.getString("id"), message.getInt("label"), message.getString("candidate")); iceCandidates.add(candidate);
} else if (message.getString("type").equals("candidate") && isStarted) { Log.d(TAG, "connectToSignallingServer: receiving candidates"); IceCandidate candidate = new IceCandidate(message.getString("id"), message.getInt("label"), message.getString("candidate")); peerConnection.addIceCandidate(candidate);