diff options
author | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-04 21:40:46 +0000 |
---|---|---|
committer | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-04 21:40:46 +0000 |
commit | 4625b101b8d2b67c5a9076d213acae1204eaf2b6 (patch) | |
tree | 945cb7680c87075835ec145bcf1f12847eddcdce /examples | |
parent | c47d0d933f5c12781b4be695de79a709255bc8af (diff) | |
download | talk-4625b101b8d2b67c5a9076d213acae1204eaf2b6.tar.gz |
AppRTCDemo(android): fix a couple of SDP-related regressions.
- r5834 made it so that empty fields are a fatal SDP parsing error, exposing
opportunities for improvement in the preferISAC; changed split/join to use
\r\n instead of \n and now omitting the trailing space on the m=audio line
that triggered the new failure.
- DTLS requires a different role for each endpoint so conflicts with loopback
calling. apprtc.py suppresses DTLS for that reason in loopback calls, so the
android demo app now only enables DTLS by default if it is not suppressed by a
constraint (matching Chrome).
BUG=3164,3165,2507
R=mallinath@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/11229004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5847 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'examples')
-rw-r--r-- | examples/android/src/org/appspot/apprtc/AppRTCClient.java | 21 | ||||
-rw-r--r-- | examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java | 10 |
2 files changed, 25 insertions, 6 deletions
diff --git a/examples/android/src/org/appspot/apprtc/AppRTCClient.java b/examples/android/src/org/appspot/apprtc/AppRTCClient.java index fc34777..86460bc 100644 --- a/examples/android/src/org/appspot/apprtc/AppRTCClient.java +++ b/examples/android/src/org/appspot/apprtc/AppRTCClient.java @@ -273,6 +273,7 @@ public class AppRTCClient { MediaConstraints pcConstraints = constraintsFromJSON( getVarValue(roomHtml, "pcConstraints", false)); + addDTLSConstraintIfMissing(pcConstraints); Log.d(TAG, "pcConstraints: " + pcConstraints); MediaConstraints videoConstraints = constraintsFromJSON( getAVConstraints("video", @@ -288,6 +289,26 @@ public class AppRTCClient { pcConstraints, videoConstraints, audioConstraints); } + // Mimic Chrome and set DtlsSrtpKeyAgreement to true if not set to false by + // the web-app. + private void addDTLSConstraintIfMissing( + MediaConstraints pcConstraints) { + for (MediaConstraints.KeyValuePair pair : pcConstraints.mandatory) { + if (pair.getKey().equals("DtlsSrtpKeyAgreement")) { + return; + } + } + for (MediaConstraints.KeyValuePair pair : pcConstraints.optional) { + if (pair.getKey().equals("DtlsSrtpKeyAgreement")) { + return; + } + } + // DTLS isn't being suppressed (e.g. for debug=loopback calls), so enable + // it by default. + pcConstraints.optional.add( + new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); + } + // Return the constraints specified for |type| of "audio" or "video" in // |mediaConstraintsString|. private String getAVConstraints( diff --git a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java index 7d92a36..3cf05d8 100644 --- a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java +++ b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java @@ -189,8 +189,6 @@ public class AppRTCDemoActivity extends Activity factory = new PeerConnectionFactory(); MediaConstraints pcConstraints = appRtcClient.pcConstraints(); - pcConstraints.mandatory.add( - new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); pcConstraints.optional.add( new MediaConstraints.KeyValuePair("RtpDataChannels", "true")); pc = factory.createPeerConnection(iceServers, pcConstraints, pcObserver); @@ -314,7 +312,7 @@ public class AppRTCDemoActivity extends Activity // Mangle SDP to prefer ISAC/16000 over any other audio codec. private String preferISAC(String sdpDescription) { - String[] lines = sdpDescription.split("\n"); + String[] lines = sdpDescription.split("\r\n"); int mLineIndex = -1; String isac16kRtpMap = null; Pattern isac16kPattern = @@ -347,16 +345,16 @@ public class AppRTCDemoActivity extends Activity newMLine.append(origMLineParts[origPartIndex++]).append(" "); newMLine.append(origMLineParts[origPartIndex++]).append(" "); newMLine.append(origMLineParts[origPartIndex++]).append(" "); - newMLine.append(isac16kRtpMap).append(" "); + newMLine.append(isac16kRtpMap); for (; origPartIndex < origMLineParts.length; ++origPartIndex) { if (!origMLineParts[origPartIndex].equals(isac16kRtpMap)) { - newMLine.append(origMLineParts[origPartIndex]).append(" "); + newMLine.append(" ").append(origMLineParts[origPartIndex]); } } lines[mLineIndex] = newMLine.toString(); StringBuilder newSdpDescription = new StringBuilder(); for (String line : lines) { - newSdpDescription.append(line).append("\n"); + newSdpDescription.append(line).append("\r\n"); } return newSdpDescription.toString(); } |