AppRTCDemo(android): send the created SDP, not the local description after setting it

This is required to allow explicit filtering of ICE candidates.

BUG=3288
R=mallinath@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/15419004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6038 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2014-05-01 19:06:18 +00:00
parent 560dce5d48
commit dd92feb6dd

View File

@ -315,7 +315,7 @@ public class AppRTCDemoActivity extends Activity
} }
// Mangle SDP to prefer ISAC/16000 over any other audio codec. // Mangle SDP to prefer ISAC/16000 over any other audio codec.
private String preferISAC(String sdpDescription) { private static String preferISAC(String sdpDescription) {
String[] lines = sdpDescription.split("\r\n"); String[] lines = sdpDescription.split("\r\n");
int mLineIndex = -1; int mLineIndex = -1;
String isac16kRtpMap = null; String isac16kRtpMap = null;
@ -439,24 +439,30 @@ public class AppRTCDemoActivity extends Activity
// Implementation detail: handle offer creation/signaling and answer setting, // Implementation detail: handle offer creation/signaling and answer setting,
// as well as adding remote ICE candidates once the answer SDP is set. // as well as adding remote ICE candidates once the answer SDP is set.
private class SDPObserver implements SdpObserver { private class SDPObserver implements SdpObserver {
private SessionDescription localSdp;
@Override public void onCreateSuccess(final SessionDescription origSdp) { @Override public void onCreateSuccess(final SessionDescription origSdp) {
abortUnless(localSdp == null, "multiple SDP create?!?");
final SessionDescription sdp = new SessionDescription(
origSdp.type, preferISAC(origSdp.description));
localSdp = sdp;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
SessionDescription sdp = new SessionDescription(
origSdp.type, preferISAC(origSdp.description));
pc.setLocalDescription(sdpObserver, sdp); pc.setLocalDescription(sdpObserver, sdp);
} }
}); });
} }
// Helper for sending local SDP (offer or answer, depending on role) to the // Helper for sending local SDP (offer or answer, depending on role) to the
// other participant. // other participant. Note that it is important to send the output of
private void sendLocalDescription(PeerConnection pc) { // create{Offer,Answer} and not merely the current value of
SessionDescription sdp = pc.getLocalDescription(); // getLocalDescription() because the latter may include ICE candidates that
logAndToast("Sending " + sdp.type); // we might want to filter elsewhere.
private void sendLocalDescription() {
logAndToast("Sending " + localSdp.type);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
jsonPut(json, "type", sdp.type.canonicalForm()); jsonPut(json, "type", localSdp.type.canonicalForm());
jsonPut(json, "sdp", sdp.description); jsonPut(json, "sdp", localSdp.description);
sendMessage(json); sendMessage(json);
} }
@ -470,7 +476,7 @@ public class AppRTCDemoActivity extends Activity
drainRemoteCandidates(); drainRemoteCandidates();
} else { } else {
// We've just set our local description so time to send it. // We've just set our local description so time to send it.
sendLocalDescription(pc); sendLocalDescription();
} }
} else { } else {
if (pc.getLocalDescription() == null) { if (pc.getLocalDescription() == null) {
@ -480,7 +486,7 @@ public class AppRTCDemoActivity extends Activity
} else { } else {
// Answer now set as local description; send it and drain // Answer now set as local description; send it and drain
// candidates. // candidates.
sendLocalDescription(pc); sendLocalDescription();
drainRemoteCandidates(); drainRemoteCandidates();
} }
} }