@Override public void onCreateSuccess(final SessionDescription sdp) { // TODO: modify sdp to use pcParams prefered codecs try { JSONObject payload = new JSONObject(); payload.put("type", sdp.type.canonicalForm()); payload.put("sdp", sdp.description); sendMessage(id, sdp.type.canonicalForm(), payload); pc.setLocalDescription(Peer.this, sdp); } catch (JSONException e) { e.printStackTrace(); } }
public void execute(String peerId, JSONObject payload) throws JSONException { Log.d(TAG, "CreateAnswerCommand"); Peer peer = peers.get(peerId); SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(payload.getString("type")), payload.getString("sdp") ); peer.pc.setRemoteDescription(peer, sdp); peer.pc.createAnswer(peer, pcConstraints); } }
if (messageType.equals("offer")) { offerSdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(messageType), message.getString("sdp")); } else if (messageType.equals("candidate")) { IceCandidate candidate = new IceCandidate(
if (messageType.equals("offer")) { offerSdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(messageType), message.getString("sdp")); } else if (messageType.equals("candidate")) { IceCandidate candidate = new IceCandidate(
offerContent.addProperty("type", sessionDescription.type.canonicalForm()); inviteContent.add("offer", offerContent);
if (initiator) { SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp")); events.onRemoteDescription(sdp); } else { if (!initiator) { SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp")); events.onRemoteDescription(sdp); } else {
if (initiator) { SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp")); events.onRemoteDescription(sdp); } else { if (!initiator) { SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(type), json.getString("sdp")); events.onRemoteDescription(sdp); } else {
} 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"));
String type = sdp.type.toString(); jsep.put("type",type.toLowerCase()); jsep.put("sdp",sdp.description);
/** * Send the answer event * * @param sessionDescription the session description */ private void sendAnswer(final SessionDescription sessionDescription) { // check if the call has not been killed if (isCallEnded()) { Log.d(LOG_TAG, "sendAnswer isCallEnded"); return; } Log.d(LOG_TAG, "sendAnswer"); // build the invitation event JsonObject answerContent = new JsonObject(); answerContent.addProperty("version", 0); answerContent.addProperty("call_id", mCallId); answerContent.addProperty("lifetime", CALL_TIMEOUT_MS); JsonObject offerContent = new JsonObject(); offerContent.addProperty("sdp", sessionDescription.description); offerContent.addProperty("type", sessionDescription.type.canonicalForm()); answerContent.add("answer", offerContent); Event event = new Event(Event.EVENT_TYPE_CALL_ANSWER, answerContent, mSession.getCredentials().userId, mCallSignalingRoom.getRoomId()); mPendingEvents.add(event); sendNextEvent(); mIsAnswered = true; }
@Override public void run() { if (roomState != ConnectionState.CONNECTED) { reportError("Sending offer SDP in non connected state."); return; } JSONObject json = new JSONObject(); jsonPut(json, "sdp", sdp.description); jsonPut(json, "type", "offer"); sendPostMessage(MessageType.MESSAGE, messageUrl, json.toString()); if (connectionParameters.loopback) { // In loopback mode rename this offer to answer and route it back. SessionDescription sdpAnswer = new SessionDescription( SessionDescription.Type.fromCanonicalForm("answer"), sdp.description); events.onRemoteDescription(sdpAnswer); } } });
@Override public void sendOfferSdp(final SessionDescription sdp) { handler.post(() -> { if (roomState != ConnectionState.CONNECTED) { reportError("Sending offer SDP in non connected state."); return; } JSONObject json = new JSONObject(); jsonPut(json, "sdp", sdp.description); jsonPut(json, "type", "offer"); sendPostMessage(MessageType.MESSAGE, messageUrl, json.toString()); if (connectionParameters.loopback) { // In loopback mode rename this offer to answer and route it back. SessionDescription sdpAnswer = new SessionDescription( SessionDescription.Type.fromCanonicalForm("answer"), sdp.description); events.onRemoteDescription(sdpAnswer); } }); }
public String canonicalForm() { return name().toLowerCase(); }
public static JSONObject sdpToJSON(SessionDescription sdp) { JSONObject data = new JSONObject(); try { data.put("type",sdp.type.canonicalForm()); data.put("sdp",sdp.description); } catch (JSONException e) { e.printStackTrace(); } return data; }
public String canonicalForm() { return name().toLowerCase(Locale.US); }
@CalledByNative String getTypeInCanonicalForm() { return type.canonicalForm(); } }
@CalledByNative("Type") public static Type fromCanonicalForm(String canonical) { return Type.valueOf(Type.class, canonical.toUpperCase(Locale.US)); } }
public static Type fromCanonicalForm(String canonical) { return Type.valueOf(Type.class, canonical.toUpperCase()); } }
public void execute(String peerId, JSONObject payload) throws JSONException { Log.d(TAG, "SetRemoteSDPCommand"); Peer peer = peers.get(peerId); SessionDescription sdp = new SessionDescription( SessionDescription.Type.fromCanonicalForm(payload.getString("type")), payload.getString("sdp") ); peer.pc.setRemoteDescription(peer, sdp); } }