[Android] setRemoteDescription appears to hang

143 views
Skip to first unread message

Benjamin Efron

unread,
May 6, 2017, 2:32:16 PM5/6/17
to discuss-webrtc
I am new to Android and WebRTC and I have been struggling to try to get p2p video working between a native android app and a website. On my android app, it appears that setRemoteDescription either hangs or fails silently. None of the print or Log statements in the observer ever appear in the Android Monitor (if I should be looking elsewhere please tell me), and the print and log statements that I have right after setRemoteDescription() never appear either. If there is any other information that you need to help me solve this issue please tell me. The relevant code from my app is as follows:

if (receivedJson.has("sdp")) {
System.out.println("ADDING SESSION DESCRIPTION");

String sdpStr = receivedJson.getJSONObject("sdp").getString("sdp");

SessionDescription sdp = new SessionDescription(SessionDescription.Type.OFFER, sdpStr);

// System.out.println("NEW SDP");
// System.out.println(sdpStr + "\n\n");

System.out.println("Setting remote description");
peerConnection.setRemoteDescription(new CallbackObserver("SetRemoteDescription"), sdp);

// create the answer to the session description
Log.d("SDP_LISTENER","CREATING ANSWER");
System.out.println("Creating answer");
peerConnection.createAnswer(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
System.out.println("SUCCESSFULLY CREATED ANSWER");
// set the answer to our local session description
peerConnection.setLocalDescription(new CallbackObserver("SET_LOCAL_SDP"), sessionDescription);

// package the response and send it to the server
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sdp", sessionDescription.toString());
in_scope_ws.sendText(jsonObject.toString());

} catch (JSONException e) {
e.printStackTrace();
}
}

CallbackObserver class:

    private class CallbackObserver implements SdpObserver {

private String TAG;

public CallbackObserver(String TAG) {
this.TAG = TAG;
}

@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
Logging.d(TAG, "SUCCESSFULLY CREATED remote description");
Log.d(TAG, "SUCCESSFULLY CREATED remote description");
System.out.println("SUCCESSFULLY CREATED remote description");
// while (true);
}

@Override
public void onSetSuccess() {
Logging.d(TAG, "SUCCESSFULLY SET remote description");
Log.d(TAG, "SUCCESSFULLY SET remote description");
System.out.println("SUCCESSFULLY SET remote description");
// while(true);
}

@Override
public void onCreateFailure(String s) {
Logging.d(TAG, "Failed to CREATE remote description");
Log.e(TAG, "Failed to CREATE remote description");
System.out.println("Failed to CREATE remote description");
// while(true);
}

@Override
public void onSetFailure(String s) {
Logging.d(TAG, "Failed to SET remote description");
Log.e(TAG, "Failed to SET remote description");
System.out.println("Failed to SET remote description");
// while(true);
}
}

Reply all
Reply to author
Forward
0 new messages