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@5847 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		| @@ -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( | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 fischman@webrtc.org
					fischman@webrtc.org