Index: chrome/test/data/webrtc/peerconnection.js |
diff --git a/chrome/test/data/webrtc/peerconnection.js b/chrome/test/data/webrtc/peerconnection.js |
index 16236e28d6385835d3459151d9adb36e0588a167..639e0f41a8ff34624bc5be8ea6fed1aeb640b757 100644 |
--- a/chrome/test/data/webrtc/peerconnection.js |
+++ b/chrome/test/data/webrtc/peerconnection.js |
@@ -21,18 +21,6 @@ |
* @private |
*/ |
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 |
@@ -80,45 +68,25 @@ |
} |
/** |
- * 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. |
- */ |
-function createLocalOffer(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) { |
peerConnection_().createOffer( |
function(localOffer) { |
success('createOffer'); |
setLocalDescription(peerConnection, localOffer); |
- if (gDefaultVideoCodec !== null) { |
- localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, |
- gDefaultVideoCodec); |
- } |
- if (gOpusDtx) { |
- localOffer.sdp = setOpusDtxEnabled(localOffer.sdp); |
- } |
+ if (videoCodec !== null) |
+ localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, videoCodec); |
+ |
returnToTest('ok-' + JSON.stringify(localOffer)); |
}, |
function(error) { failure('createOffer', error); }, |
@@ -151,9 +119,6 @@ |
function(answer) { |
success('createAnswer'); |
setLocalDescription(peerConnection, answer); |
- if (gOpusDtx) { |
- answer.sdp = setOpusDtxEnabled(answer.sdp); |
- } |
returnToTest('ok-' + JSON.stringify(answer)); |
}, |
function(error) { failure('createAnswer', error); }, |
@@ -161,21 +126,16 @@ |
} |
/** |
- * Verifies that the codec previously set using forceVideoCodec() is the |
- * default video codec, e.g. the first one in the list on the 'm=video' SDP |
- * answer line. If this is not the case, |failure| occurs. If no codec was |
- * previously set using forceVideoCodec(), this function will return |
- * 'ok-no-default-set'. |
+ * Verifies that the specified codec is the default video codec, e.g. the first |
+ * one in the list on the 'm=video' SDP answer line. If this is not the case, |
+ * |failure| occurs. |
* |
* @param {!string} sessionDescJson A JSON-encoded session description. |
- */ |
-function verifyDefaultVideoCodec(sessionDescJson) { |
+ * @param {!string} expectedVideoCodec The case-sensitive codec name, e.g. |
+ * 'VP8' or 'H264'. |
+ */ |
+function verifyDefaultVideoCodec(sessionDescJson, expectedVideoCodec) { |
var sessionDesc = parseJson_(sessionDescJson); |
- var defaultVideoCodec = getSdpDefaultVideoCodec(sessionDesc.sdp); |
- if (gDefaultVideoCodec === null) { |
- returnToTest('ok-no-default-set'); |
- return; |
- } |
if (!sessionDesc.type) { |
failure('verifyDefaultVideoCodec', |
'Invalid session description: ' + sessionDescJson); |
@@ -185,9 +145,9 @@ |
failure('verifyDefaultVideoCodec', |
'Could not determine default video codec.'); |
} |
- if (gDefaultVideoCodec !== defaultVideoCodec) { |
+ if (expectedVideoCodec !== defaultVideoCodec) { |
failure('verifyDefaultVideoCodec', |
- 'Expected default video codec ' + gDefaultVideoCodec + |
+ 'Expected default video codec ' + expectedVideoCodec + |
', got ' + defaultVideoCodec + '.'); |
} |
returnToTest('ok-verified'); |