Index: chrome/test/data/webrtc/peerconnection.js |
diff --git a/chrome/test/data/webrtc/peerconnection.js b/chrome/test/data/webrtc/peerconnection.js |
index 639e0f41a8ff34624bc5be8ea6fed1aeb640b757..ec9ea0bffcd71aaeda52a4499fa318b87fe59702 100644 |
--- a/chrome/test/data/webrtc/peerconnection.js |
+++ b/chrome/test/data/webrtc/peerconnection.js |
@@ -22,6 +22,18 @@ var gIceCandidates = []; |
*/ |
var gHasSeenCryptoInSdp = 'no-crypto-seen'; |
+/** |
+ * The default video codec that should be used. |
+ * @private |
+ */ |
+var gDefaultVideoCodec = null; |
+ |
+/** |
+ * Flag to indicate if Opus Dtx should be enabled. |
+ * @private |
+ */ |
+var gOpusDtx = false; |
+ |
// Public interface to tests. These are expected to be called with |
// ExecuteJavascript invocations from the browser tests and will return answers |
// through the DOM automation controller. |
@@ -68,25 +80,45 @@ function preparePeerConnectionWithCertificate(certificate) { |
} |
/** |
+ * Sets the flag to force Opus Dtx to be used when creating an offer. |
+ */ |
+function forceOpusDtx() { |
+ gOpusDtx = true; |
+ returnToTest('ok-forced'); |
+} |
+ |
+/** |
+ * Sets the default video codec be used when creating an offer. |
+ * @param {string} videoCodec promotes the specified codec to be the default |
+ * video codec, e.g. the first one in the list on the 'm=video' SDP offer |
+ * line. |videoCodec| is the case-sensitive codec name, e.g. 'VP8' or |
+ * 'H264'. |
+ */ |
+function forceVideoCodec(videoCodec) { |
+ gDefaultVideoCodec = videoCodec; |
+ returnToTest('ok-forced'); |
+} |
+ |
+/** |
* Asks this page to create a local offer. |
* |
* Returns a string on the format ok-(JSON encoded session description). |
* |
* @param {!Object} constraints Any createOffer constraints. |
- * @param {string} videoCodec If not null, promotes the specified codec to be |
- * the default video codec, e.g. the first one in the list on the 'm=video' |
- * SDP offer line. |videoCodec| is the case-sensitive codec name, e.g. |
- * 'VP8' or 'H264'. |
*/ |
-function createLocalOffer(constraints, videoCodec = null) { |
+function createLocalOffer(constraints) { |
peerConnection_().createOffer( |
function(localOffer) { |
success('createOffer'); |
setLocalDescription(peerConnection, localOffer); |
- if (videoCodec !== null) |
- localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, videoCodec); |
- |
+ if (gDefaultVideoCodec !== null) { |
+ localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, |
+ gDefaultVideoCodec); |
+ } |
+ if (gOpusDtx) { |
+ localOffer.sdp = setOpusDtxEnabled(localOffer.sdp); |
+ } |
returnToTest('ok-' + JSON.stringify(localOffer)); |
}, |
function(error) { failure('createOffer', error); }, |
@@ -117,8 +149,14 @@ function receiveOfferFromPeer(sessionDescJson, constraints) { |
peerConnection_().createAnswer( |
function(answer) { |
+ if (gDefaultVideoCodec !== null) { |
+ verifyDefaultVideoCodec(answer.sdp, gDefaultVideoCodec); |
phoglund_chromium
2016/07/28 06:39:01
I still want to keep the verification as a separat
Ivo-OOO until feb 6
2016/07/28 12:29:31
Ok, done.
I realized that dtx verification is a b
|
+ } |
success('createAnswer'); |
setLocalDescription(peerConnection, answer); |
+ if (gOpusDtx) { |
+ answer.sdp = setOpusDtxEnabled(answer.sdp); |
+ } |
returnToTest('ok-' + JSON.stringify(answer)); |
}, |
function(error) { failure('createAnswer', error); }, |
@@ -134,13 +172,8 @@ function receiveOfferFromPeer(sessionDescJson, constraints) { |
* @param {!string} expectedVideoCodec The case-sensitive codec name, e.g. |
* 'VP8' or 'H264'. |
*/ |
-function verifyDefaultVideoCodec(sessionDescJson, expectedVideoCodec) { |
- var sessionDesc = parseJson_(sessionDescJson); |
- if (!sessionDesc.type) { |
- failure('verifyDefaultVideoCodec', |
- 'Invalid session description: ' + sessionDescJson); |
- } |
- var defaultVideoCodec = getSdpDefaultVideoCodec(sessionDesc.sdp); |
+function verifyDefaultVideoCodec(sdp, expectedVideoCodec) { |
+ var defaultVideoCodec = getSdpDefaultVideoCodec(sdp); |
if (defaultVideoCodec === null) { |
failure('verifyDefaultVideoCodec', |
'Could not determine default video codec.'); |
@@ -150,7 +183,6 @@ function verifyDefaultVideoCodec(sessionDescJson, expectedVideoCodec) { |
'Expected default video codec ' + expectedVideoCodec + |
', got ' + defaultVideoCodec + '.'); |
} |
- returnToTest('ok-verified'); |
} |
/** |