Here are the examples of the java api org.webrtc.IceCandidate taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
92 Examples
19
Source : PeerConnectionWrapper.java
with GNU General Public License v3.0
from XecureIT
with GNU General Public License v3.0
from XecureIT
public boolean addIceCandidate(IceCandidate candidate) {
return this.peerConnection.addIceCandidate(candidate);
}
19
Source : FancyWebRTC.java
with MIT License
from triniwiz
with MIT License
from triniwiz
public void addIceCandidate(final IceCandidate iceCandidate) {
executor.execute(new Runnable() {
@Override
public void run() {
if (connection != null && connection.getRemoteDescription() != null) {
connection.addIceCandidate(iceCandidate);
} else {
remoteIceCandidates.add(iceCandidate);
}
}
});
}
19
Source : FancyRTCIceCandidate.java
with MIT License
from triniwiz
with MIT License
from triniwiz
/**
* Created by triniwiz on 1/8/19
*/
public clreplaced FancyRTCIceCandidate {
private String candidate;
private String sdpMid;
private int sdpMLineIndex;
private String usernameFragment;
private String serverUrl;
private IceCandidate iceCandidate;
public FancyRTCIceCandidate() {
candidate = "";
sdpMid = "";
sdpMLineIndex = 0;
usernameFragment = "";
serverUrl = "";
}
public FancyRTCIceCandidate(String sdp, String sdpMid, int sdpMLineIndex) {
candidate = sdp;
this.sdpMid = sdpMid;
this.sdpMLineIndex = sdpMLineIndex;
usernameFragment = "";
serverUrl = "";
this.iceCandidate = new IceCandidate(this.sdpMid, this.sdpMLineIndex, sdp);
}
FancyRTCIceCandidate(IceCandidate candidate) {
this.candidate = candidate.sdp;
this.sdpMid = candidate.sdpMid;
this.sdpMLineIndex = candidate.sdpMLineIndex;
usernameFragment = "";
serverUrl = candidate.serverUrl;
this.iceCandidate = candidate;
}
public String getCandidate() {
return candidate;
}
public void setCandidate(String candidate) {
this.candidate = candidate;
}
public void setSdp(String sdp) {
candidate = sdp;
}
public String getSdp() {
return candidate;
}
public String getSdpMid() {
return sdpMid;
}
public void setSdpMid(String sdpMid) {
this.sdpMid = sdpMid;
}
public int getSdpMLineIndex() {
return sdpMLineIndex;
}
public void setSdpMLineIndex(int sdpMLineIndex) {
this.sdpMLineIndex = sdpMLineIndex;
}
public void setUsernameFragment(String usernameFragment) {
this.usernameFragment = usernameFragment;
}
public String getUsernameFragment() {
return usernameFragment;
}
public String getServerUrl() {
return serverUrl;
}
public String toJSON() {
Gson gson = new Gson();
return gson.toJson(this);
}
public static FancyRTCIceCandidate fromJSON(String json) {
Gson gson = new Gson();
return gson.fromJson(json, FancyRTCIceCandidate.clreplaced);
}
public IceCandidate getIceCandidate() {
return iceCandidate;
}
}
19
Source : WebRTCWrapper.java
with GNU General Public License v3.0
from snikket-im
with GNU General Public License v3.0
from snikket-im
void addIceCandidate(IceCandidate iceCandidate) {
requirePeerConnection().addIceCandidate(iceCandidate);
}
19
Source : CustomPeerConnectionObserver.java
with Apache License 2.0
from sergiopaniego
with Apache License 2.0
from sergiopaniego
@Override
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
Log.d(logTag, "onIceCandidatesRemoved() called with: iceCandidates = [" + Arrays.toString(iceCandidates) + "]");
}
19
Source : CustomPeerConnectionObserver.java
with Apache License 2.0
from sergiopaniego
with Apache License 2.0
from sergiopaniego
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
Log.d(logTag, "onIceCandidate() called with: iceCandidate = [" + iceCandidate + "]");
}
19
Source : PeerConnectionObserver.java
with GNU Affero General Public License v3.0
from RooyeKhat-Media
with GNU Affero General Public License v3.0
from RooyeKhat-Media
@Override
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
}
19
Source : PeerConnectionAdapter.java
with Apache License 2.0
from rome753
with Apache License 2.0
from rome753
@Override
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
log("onIceCandidatesRemoved " + iceCandidates);
}
19
Source : PeerConnectionAdapter.java
with Apache License 2.0
from rome753
with Apache License 2.0
from rome753
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
log("onIceCandidate " + iceCandidate);
}
19
Source : JanusUtils.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
// Converts a Java candidate to a JSONObject.
public static JSONObject convertJsonToCandidate(final IceCandidate candidate) {
JSONObject json = new JSONObject();
jsonPut(json, "candidate", candidate.sdp);
jsonPut(json, "sdpMid", candidate.sdpMid);
jsonPut(json, "sdpMLineIndex", candidate.sdpMLineIndex);
return json;
}
19
Source : ConferencePeerConnectionChannel.java
with Apache License 2.0
from open-webrtc-toolkit
with Apache License 2.0
from open-webrtc-toolkit
@Override
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
observer.onIceCandidatesRemoved(key, iceCandidates);
}
19
Source : ConferencePeerConnectionChannel.java
with Apache License 2.0
from open-webrtc-toolkit
with Apache License 2.0
from open-webrtc-toolkit
@Override
public void onIceCandidate(final IceCandidate iceCandidate) {
callbackExecutor.execute(() -> {
if (remoteSdpSet) {
observer.onIceCandidate(key, iceCandidate);
} else {
queuedLocalCandidates.add(iceCandidate);
}
});
}
19
Source : DefaultObserver.java
with GNU General Public License v3.0
from meshenger-app
with GNU General Public License v3.0
from meshenger-app
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
}
19
Source : DirectRTCClient.java
with MIT License
from lgyjg
with MIT License
from lgyjg
/**
* Send removed Ice candidates to the other participant.
*/
@Override
public void sendLocalIceCandidateRemovals(final IceCandidate[] candidates) {
executor.execute(new Runnable() {
@Override
public void run() {
JSONObject json = new JSONObject();
jsonPut(json, "type", "remove-candidates");
JSONArray jsonArray = new JSONArray();
for (final IceCandidate candidate : candidates) {
jsonArray.put(toJsonCandidate(candidate));
}
jsonPut(json, "candidates", jsonArray);
if (roomState != ConnectionState.CONNECTED) {
reportError("Sending ICE candidate removals in non connected state.");
return;
}
sendMessage(json.toString());
}
});
}
19
Source : DirectRTCClient.java
with MIT License
from lgyjg
with MIT License
from lgyjg
// -------------------------------------------------------------------
// TCPChannelClient event handlers
@Override
public void sendLocalIceCandidate(final IceCandidate candidate) {
executor.execute(new Runnable() {
@Override
public void run() {
JSONObject json = new JSONObject();
jsonPut(json, "type", "candidate");
jsonPut(json, "label", candidate.sdpMLineIndex);
jsonPut(json, "id", candidate.sdpMid);
jsonPut(json, "candidate", candidate.sdp);
if (roomState != ConnectionState.CONNECTED) {
reportError("Sending ICE candidate in non connected state.");
return;
}
sendMessage(json.toString());
}
});
}
19
Source : DirectRTCClient.java
with Apache License 2.0
from googlesamples
with Apache License 2.0
from googlesamples
@Override
public void sendLocalIceCandidate(final IceCandidate candidate) {
executor.execute(new Runnable() {
@Override
public void run() {
JSONObject json = new JSONObject();
jsonPut(json, "type", "candidate");
jsonPut(json, "label", candidate.sdpMLineIndex);
jsonPut(json, "id", candidate.sdpMid);
jsonPut(json, "candidate", candidate.sdp);
if (roomState != ConnectionState.CONNECTED) {
reportError("Sending ICE candidate in non connected state.");
return;
}
sendMessage(json.toString());
}
});
}
19
Source : IceCandidateConverter.java
with Apache License 2.0
from google
with Apache License 2.0
from google
/**
* Converts a WebRTC IceCandidate to a protocol buffer message.
*/
public static CameraApi.IceCandidate serialize(IceCandidate candidate) {
return CameraApi.IceCandidate.newBuilder().setSdpMid(candidate.sdpMid).setSdpMLineIndex(candidate.sdpMLineIndex).setSdp(candidate.sdp).build();
}
19
Source : BlockingPeerObserver.java
with Apache License 2.0
from google
with Apache License 2.0
from google
/**
* Triggered when a new ICE candidate has been found.
*/
@Override
public void onIceCandidate(IceCandidate candidate) {
Log.d(TAG, "IceCandidate: " + candidate.toString());
iceCandidates.add(candidate);
}
19
Source : MainActivity.java
with MIT License
from crossle
with MIT License
from crossle
@Override
public void onIceCandidatesRemoved(IceCandidate[] candidates) {
}
19
Source : KinesisVideoPeerConnection.java
with Apache License 2.0
from awslabs
with Apache License 2.0
from awslabs
@Override
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
Log.d(TAG, "onIceCandidatesRemoved(): iceCandidates Length = [" + iceCandidates.length + "]");
}
19
Source : KinesisVideoPeerConnection.java
with Apache License 2.0
from awslabs
with Apache License 2.0
from awslabs
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
Log.d(TAG, "onIceCandidate(): iceCandidate = [" + iceCandidate + "]");
}
18
Source : WebSocketRTCClient.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
// Send Ice candidate to the other participant.
@Override
public void sendLocalIceCandidate(final IceCandidate candidate) {
handler.post(new Runnable() {
@Override
public void run() {
JSONObject json = new JSONObject();
jsonPut(json, "type", "candidate");
jsonPut(json, "label", candidate.sdpMLineIndex);
jsonPut(json, "id", candidate.sdpMid);
jsonPut(json, "candidate", candidate.sdp);
if (initiator) {
// Call initiator sends ice candidates to GAE server.
if (roomState != ConnectionState.CONNECTED) {
reportError("Sending ICE candidate in non connected state.");
return;
}
sendPostMessage(MessageType.MESSAGE, messageUrl, json.toString());
if (connectionParameters.loopback) {
events.onRemoteIceCandidate(candidate);
}
} else {
// Call receiver sends ice candidates to websocket server.
wsClient.send(json.toString());
}
}
});
}
18
Source : WebSocketRTCClient.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
// Send removed Ice candidates to the other participant.
@Override
public void sendLocalIceCandidateRemovals(final IceCandidate[] candidates) {
handler.post(new Runnable() {
@Override
public void run() {
JSONObject json = new JSONObject();
jsonPut(json, "type", "remove-candidates");
JSONArray jsonArray = new JSONArray();
for (final IceCandidate candidate : candidates) {
jsonArray.put(toJsonCandidate(candidate));
}
jsonPut(json, "candidates", jsonArray);
if (initiator) {
// Call initiator sends ice candidates to GAE server.
if (roomState != ConnectionState.CONNECTED) {
reportError("Sending ICE candidate removals in non connected state.");
return;
}
sendPostMessage(MessageType.MESSAGE, messageUrl, json.toString());
if (connectionParameters.loopback) {
events.onRemoteIceCandidatesRemoved(candidates);
}
} else {
// Call receiver sends ice candidates to websocket server.
wsClient.send(json.toString());
}
}
});
}
18
Source : CallActivity.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
@Override
public void onIceCandidate(final IceCandidate candidate) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (appRtcClient != null) {
appRtcClient.sendLocalIceCandidate(candidate);
}
}
});
}
18
Source : CallActivity.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
@Override
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (appRtcClient != null) {
appRtcClient.sendLocalIceCandidateRemovals(candidates);
}
}
});
}
18
Source : CallActivity.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
@Override
public void onRemoteIceCandidatesRemoved(final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (peerConnectionClient == null) {
Log.e(TAG, "Received ICE candidate removals for a non-initialized peer connection.");
return;
}
peerConnectionClient.removeRemoteIceCandidates(candidates);
}
});
}
18
Source : CallActivity.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
@Override
public void onRemoteIceCandidate(final IceCandidate candidate) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (peerConnectionClient == null) {
Log.e(TAG, "Received ICE candidate for a non-initialized peer connection.");
return;
}
peerConnectionClient.addRemoteIceCandidate(candidate);
}
});
}
18
Source : EchoTestActivity.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
@Override
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (echoTestClient != null) {
// WebSocketRTCClient.sendLocalIceCandidateRemovals(candidates);
}
}
});
}
18
Source : AudioBridgeActivity.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
@Override
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (audioBridgeClient != null) {
// WebSocketRTCClient.sendLocalIceCandidateRemovals(candidates);
}
}
});
}
18
Source : P2PClient.java
with Apache License 2.0
from open-webrtc-toolkit
with Apache License 2.0
from open-webrtc-toolkit
@Override
public void onIceCandidatesRemoved(String key, IceCandidate[] candidates) {
}
18
Source : DirectRTCClientTest.java
with MIT License
from lgyjg
with MIT License
from lgyjg
// TODO(sakal): Replace isNotNull(clreplaced) with isNotNull() once Java 8 is used.
@SuppressWarnings("deprecation")
@Test
public void testDirectRTCClient() {
server.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "0.0.0.0", LOOPBACK));
try {
Thread.sleep(SERVER_WAIT);
} catch (InterruptedException e) {
fail(e.getMessage());
}
client.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "127.0.0.1", LOOPBACK));
verify(serverEvents, timeout(NETWORK_TIMEOUT)).onConnectedToRoom(any(AppRTCClient.SignalingParameters.clreplaced));
SessionDescription offerSdp = new SessionDescription(SessionDescription.Type.OFFER, DUMMY_SDP);
server.sendOfferSdp(offerSdp);
verify(clientEvents, timeout(NETWORK_TIMEOUT)).onConnectedToRoom(any(AppRTCClient.SignalingParameters.clreplaced));
SessionDescription answerSdp = new SessionDescription(SessionDescription.Type.ANSWER, DUMMY_SDP);
client.sendAnswerSdp(answerSdp);
verify(serverEvents, timeout(NETWORK_TIMEOUT)).onRemoteDescription(isNotNull(SessionDescription.clreplaced));
IceCandidate candidate = new IceCandidate(DUMMY_SDP_MID, 0, DUMMY_SDP);
server.sendLocalIceCandidate(candidate);
verify(clientEvents, timeout(NETWORK_TIMEOUT)).onRemoteIceCandidate(isNotNull(IceCandidate.clreplaced));
client.sendLocalIceCandidate(candidate);
verify(serverEvents, timeout(NETWORK_TIMEOUT)).onRemoteIceCandidate(isNotNull(IceCandidate.clreplaced));
client.disconnectFromRoom();
verify(clientEvents, timeout(NETWORK_TIMEOUT)).onChannelClose();
verify(serverEvents, timeout(NETWORK_TIMEOUT)).onChannelClose();
verifyNoMoreInteractions(clientEvents);
verifyNoMoreInteractions(serverEvents);
}
18
Source : DirectRTCClient.java
with MIT License
from lgyjg
with MIT License
from lgyjg
@Override
public void onTCPMessage(String msg) {
try {
JSONObject json = new JSONObject(msg);
String type = json.optString("type");
if (type.equals("candidate")) {
events.onRemoteIceCandidate(toJavaCandidate(json));
} else if (type.equals("remove-candidates")) {
JSONArray candidateArray = json.getJSONArray("candidates");
IceCandidate[] candidates = new IceCandidate[candidateArray.length()];
for (int i = 0; i < candidateArray.length(); ++i) {
candidates[i] = toJavaCandidate(candidateArray.getJSONObject(i));
}
events.onRemoteIceCandidatesRemoved(candidates);
} else if (type.equals("answer")) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
events.onRemoteDescription(sdp);
} else if (type.equals("offer")) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
SignalingParameters parameters = new SignalingParameters(// Ice servers are not needed for direct connections.
new LinkedList<PeerConnection.IceServer>(), // This code will only be run on the client side. So, we are not the initiator.
false, // clientId
null, // wssUrl
null, // wssPostUrl
null, // offerSdp
sdp, // iceCandidates
null);
roomState = ConnectionState.CONNECTED;
events.onConnectedToRoom(parameters);
} else {
reportError("Unexpected TCP message: " + msg);
}
} catch (JSONException e) {
reportError("TCP message JSON parsing error: " + e.toString());
}
}
18
Source : DirectRTCClient.java
with MIT License
from lgyjg
with MIT License
from lgyjg
// Converts a Java candidate to a JSONObject.
private static JSONObject toJsonCandidate(final IceCandidate candidate) {
JSONObject json = new JSONObject();
jsonPut(json, "label", candidate.sdpMLineIndex);
jsonPut(json, "id", candidate.sdpMid);
jsonPut(json, "candidate", candidate.sdp);
return json;
}
18
Source : PeerConnectionClientTest.java
with MIT License
from lgyjg
with MIT License
from lgyjg
@Override
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {
// TODO(honghaiz): Add this for tests.
}
18
Source : DirectRTCClient.java
with Apache License 2.0
from googlesamples
with Apache License 2.0
from googlesamples
@Override
public void onTCPMessage(String msg) {
try {
JSONObject json = new JSONObject(msg);
String type = json.optString("type");
if (type.equals("candidate")) {
events.onRemoteIceCandidate(toJavaCandidate(json));
} else if (type.equals("remove-candidates")) {
JSONArray candidateArray = json.getJSONArray("candidates");
IceCandidate[] candidates = new IceCandidate[candidateArray.length()];
for (int i = 0; i < candidateArray.length(); ++i) {
candidates[i] = toJavaCandidate(candidateArray.getJSONObject(i));
}
events.onRemoteIceCandidatesRemoved(candidates);
} else if (type.equals("answer")) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
events.onRemoteDescription(sdp);
} else if (type.equals("offer")) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
SignalingParameters parameters = new SignalingParameters(// Ice servers are not needed for direct connections.
new ArrayList<>(), // This code will only be run on the client side. So, we are not the initiator.
false, // clientId
null, // wssUrl
null, // wssPostUrl
null, // offerSdp
sdp, // iceCandidates
null);
roomState = ConnectionState.CONNECTED;
events.onConnectedToRoom(parameters);
} else {
reportError("Unexpected TCP message: " + msg);
}
} catch (JSONException e) {
reportError("TCP message JSON parsing error: " + e.toString());
}
}
18
Source : Peer.java
with MIT License
from ddssingsong
with MIT License
from ddssingsong
@Override
public void onIceCandidate(IceCandidate candidate) {
// 发送IceCandidate
mEvent.onSendIceCandidate(mUserId, candidate);
}
18
Source : Peer.java
with MIT License
from ddssingsong
with MIT License
from ddssingsong
// 移除RemoteIceCandidates
public void removeRemoteIceCandidates(final IceCandidate[] candidates) {
if (pc == null) {
return;
}
drainCandidates();
pc.removeIceCandidates(candidates);
}
18
Source : Peer.java
with MIT License
from ddssingsong
with MIT License
from ddssingsong
@Override
public void onIceCandidatesRemoved(IceCandidate[] candidates) {
Log.i(TAG, "onIceCandidatesRemoved:");
}
18
Source : MainActivity.java
with MIT License
from crossle
with MIT License
from crossle
@Override
public void onIceCandidate(IceCandidate candidate, BigInteger handleId) {
Log.e(TAG, "=========onIceCandidate========");
if (candidate != null) {
mWebSocketChannel.trickleCandidate(handleId, candidate);
} else {
mWebSocketChannel.trickleCandidateComplete(handleId);
}
}
17
Source : CallActivity.java
with Apache License 2.0
from sokunmin
with Apache License 2.0
from sokunmin
@Override
public void onIceCandidate(final IceCandidate candidate) {
runOnUiThread(() -> {
if (appRtcClient != null) {
appRtcClient.sendLocalIceCandidate(candidate);
}
});
}
17
Source : CallActivity.java
with Apache License 2.0
from sokunmin
with Apache License 2.0
from sokunmin
@Override
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {
runOnUiThread(() -> {
if (appRtcClient != null) {
appRtcClient.sendLocalIceCandidateRemovals(candidates);
}
});
}
17
Source : PeerConnectionObserver.java
with GNU Affero General Public License v3.0
from RooyeKhat-Media
with GNU Affero General Public License v3.0
from RooyeKhat-Media
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
Log.i("WWW", "WebRtc onIceCandidate : " + iceCandidate.toString());
new RequestSignalingCandidate().signalingCandidate(iceCandidate.sdpMid, iceCandidate.sdpMLineIndex, iceCandidate.sdp);
}
17
Source : SignalingClient.java
with Apache License 2.0
from rome753
with Apache License 2.0
from rome753
public void sendIceCandidate(IceCandidate iceCandidate, String to) {
JSONObject jo = new JSONObject();
try {
jo.put("type", "candidate");
jo.put("label", iceCandidate.sdpMLineIndex);
jo.put("id", iceCandidate.sdpMid);
jo.put("candidate", iceCandidate.sdp);
jo.put("from", socket.id());
jo.put("to", to);
socket.emit("message", jo);
} catch (JSONException e) {
e.printStackTrace();
}
}
17
Source : SignalingClient.java
with Apache License 2.0
from rome753
with Apache License 2.0
from rome753
public void sendIceCandidate(IceCandidate iceCandidate) {
JSONObject jo = new JSONObject();
try {
jo.put("type", "candidate");
jo.put("label", iceCandidate.sdpMLineIndex);
jo.put("id", iceCandidate.sdpMid);
jo.put("candidate", iceCandidate.sdp);
socket.emit("message", jo);
} catch (JSONException e) {
e.printStackTrace();
}
}
17
Source : WebSocketRTCClient.java
with GNU Lesser General Public License v2.1
from Peter-St
with GNU Lesser General Public License v2.1
from Peter-St
// --------------------------------------------------------------------
// WebSocketChannelEvents interface implementation.
// All events are called by WebSocketChannelClient on a local looper thread
// (preplaceded to WebSocket client constructor).
@Override
public void onWebSocketMessage(final String msg) {
if (wsClient.getState() != WebSocketConnectionState.REGISTERED) {
Log.e(TAG, "Got WebSocket message in non registered state.");
return;
}
try {
JSONObject json = new JSONObject(msg);
String msgText = json.getString("msg");
String errorText = json.optString("error");
if (msgText.length() > 0) {
json = new JSONObject(msgText);
String type = json.optString("type");
if (type.equals("candidate")) {
events.onRemoteIceCandidate(toJavaCandidate(json));
} else if (type.equals("remove-candidates")) {
JSONArray candidateArray = json.getJSONArray("candidates");
IceCandidate[] candidates = new IceCandidate[candidateArray.length()];
for (int i = 0; i < candidateArray.length(); ++i) {
candidates[i] = toJavaCandidate(candidateArray.getJSONObject(i));
}
events.onRemoteIceCandidatesRemoved(candidates);
} else if (type.equals("answer")) {
if (initiator) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
events.onRemoteDescription(sdp);
} else {
reportError("Received answer for call initiator: " + msg);
}
} else if (type.equals("offer")) {
if (!initiator) {
SessionDescription sdp = new SessionDescription(SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp"));
events.onRemoteDescription(sdp);
} else {
reportError("Received offer for call receiver: " + msg);
}
} else if (type.equals("bye")) {
events.onChannelClose();
} else {
reportError("Unexpected WebSocket message: " + msg);
}
} else {
if (errorText != null && errorText.length() > 0) {
reportError("WebSocket error message: " + errorText);
} else {
reportError("Unexpected WebSocket message: " + msg);
}
}
} catch (JSONException e) {
reportError("WebSocket message JSON parsing error: " + e.toString());
}
}
17
Source : VideoRoomClient.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
public void trickleCandidate(final BigInteger handleId, final IceCandidate iceCandidate) {
handler.post(new Runnable() {
@Override
public void run() {
trickle(handleId, iceCandidate);
}
});
}
17
Source : VideoRoomActivity.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
@Override
public void onIceCandidatesRemoved(final BigInteger handleId, final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (videoRoomClient != null) {
// WebSocketRTCClient.sendLocalIceCandidateRemovals(candidates);
}
}
});
}
17
Source : VideoLiveActivity.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
@Override
public void onIceCandidatesRemoved(final BigInteger handleId, final IceCandidate[] candidates) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (videoLiveClient != null) {
// WebSocketRTCClient.sendLocalIceCandidateRemovals(candidates);
}
}
});
}
17
Source : EchoTestClient.java
with MIT License
from pcgpcgpcg
with MIT License
from pcgpcgpcg
public void trickleCandidate(final BigInteger handleId, final IceCandidate iceCandidate) {
handler.post(new Runnable() {
@Override
public void run() {
String transactionID = AppRTCUtils.randomString(12);
Log.d(TAG, "trickleCandidate" + " transactionID: " + transactionID);
JSONObject candidate = new JSONObject();
JSONObject message = new JSONObject();
try {
candidate.putOpt("candidate", iceCandidate.sdp);
candidate.putOpt("sdpMid", iceCandidate.sdpMid);
candidate.putOpt("sdpMLineIndex", iceCandidate.sdpMLineIndex);
message.putOpt("jreplaced", "trickle");
message.putOpt("candidate", candidate);
message.putOpt("transaction", transactionID);
message.putOpt("session_id", sessionId);
message.putOpt("handle_id", handleId);
} catch (JSONException e) {
e.printStackTrace();
}
Log.d(TAG, "C->WSS: " + message.toString());
wsClient.send(message.toString());
}
});
}
17
Source : P2PPeerConnectionChannel.java
with Apache License 2.0
from open-webrtc-toolkit
with Apache License 2.0
from open-webrtc-toolkit
@Override
public void onIceCandidate(final IceCandidate iceCandidate) {
callbackExecutor.execute(() -> {
Log.d(LOG_TAG, "onIceCandidate");
observer.onIceCandidate(key, iceCandidate);
});
}
See More Examples