@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 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; }
/** * 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; }
offerContent.addProperty("type", sessionDescription.type.canonicalForm()); inviteContent.add("offer", offerContent);
@CalledByNative String getTypeInCanonicalForm() { return type.canonicalForm(); } }