| Index: chrome/test/data/extensions/api_test/cast_streaming/performance.js
|
| diff --git a/chrome/test/data/extensions/api_test/cast_streaming/performance.js b/chrome/test/data/extensions/api_test/cast_streaming/performance.js
|
| index 0ca6d9f37166d405798d37777f91fd6ef24b438b..a2935ecea258a5f79aa85c28397513c59ed96660 100644
|
| --- a/chrome/test/data/extensions/api_test/cast_streaming/performance.js
|
| +++ b/chrome/test/data/extensions/api_test/cast_streaming/performance.js
|
| @@ -8,51 +8,83 @@ chrome.test.runTests([
|
| function sendTestPatterns() {
|
| // The receive port changes between browser_test invocations, and is passed
|
| // as an query parameter in the URL.
|
| - var recvPort;
|
| + let recvPort;
|
| + let autoThrottling;
|
| + let aesKey;
|
| + let aesIvMask;
|
| try {
|
| - recvPort = parseInt(window.location.search.substring("?port=".length));
|
| + const params = window.location.search;
|
| + recvPort = parseInt(params.match(/(\?|&)port=(\d+)/)[2]);
|
| chrome.test.assertTrue(recvPort > 0);
|
| + autoThrottling = (params.match(/(\?|&)autoThrottling=(true|false)/)[2] ==
|
| + 'true');
|
| + aesKey = params.match(/(\?|&)aesKey=([0-9A-F]{32})/)[2];
|
| + aesIvMask = params.match(/(\?|&)aesIvMask=([0-9A-F]{32})/)[2];
|
| } catch (err) {
|
| - chrome.test.fail("Error parsing ?port=### -- " + err.message);
|
| + chrome.test.fail("Error parsing params -- " + err.message);
|
| return;
|
| }
|
|
|
| - var width = 1920;
|
| - var height = 1080;
|
| - var frameRate = 30;
|
| -
|
| + const kMaxFrameRate = 30;
|
| chrome.tabCapture.capture(
|
| { video: true,
|
| audio: true,
|
| videoConstraints: {
|
| - mandatory: {
|
| - minWidth: width,
|
| - minHeight: height,
|
| - maxWidth: width,
|
| - maxHeight: height,
|
| - maxFrameRate: frameRate,
|
| - }
|
| + mandatory: autoThrottling ? ({
|
| + minWidth: 320,
|
| + minHeight: 180,
|
| + maxWidth: 1920,
|
| + maxHeight: 1080,
|
| + maxFrameRate: kMaxFrameRate,
|
| + enableAutoThrottling: true
|
| + }) : ({
|
| + minWidth: 1920,
|
| + minHeight: 1080,
|
| + maxWidth: 1920,
|
| + maxHeight: 1080,
|
| + maxFrameRate: kMaxFrameRate,
|
| + })
|
| }
|
| },
|
| - function startStreamingTestPatterns(captureStream) {
|
| - chrome.test.assertTrue(!!captureStream);
|
| + captureStream => {
|
| + if (!captureStream) {
|
| + chrome.test.fail(chrome.runtime.lastError.message || 'null stream');
|
| + return;
|
| + }
|
| +
|
| chrome.cast.streaming.session.create(
|
| captureStream.getAudioTracks()[0],
|
| captureStream.getVideoTracks()[0],
|
| - function (audioId, videoId, udpId) {
|
| + (audioId, videoId, udpId) => {
|
| chrome.cast.streaming.udpTransport.setDestination(
|
| udpId, { address: "127.0.0.1", port: recvPort } );
|
| - var rtpStream = chrome.cast.streaming.rtpStream;
|
| - rtpStream.start(audioId,
|
| - rtpStream.getSupportedParams(audioId)[0]);
|
| - var videoParams = rtpStream.getSupportedParams(videoId)[0];
|
| - videoParams.payload.clockRate = frameRate;
|
| + const rtpStream = chrome.cast.streaming.rtpStream;
|
| + rtpStream.onError.addListener(() => {
|
| + chrome.test.fail('RTP stream error');
|
| + });
|
| + const audioParams = rtpStream.getSupportedParams(audioId)[0];
|
| + audioParams.payload.aesKey = aesKey;
|
| + audioParams.payload.aesIvMask = aesIvMask;
|
| + rtpStream.start(audioId, audioParams);
|
| + const videoParams = rtpStream.getSupportedParams(videoId)[0];
|
| + videoParams.payload.clockRate = kMaxFrameRate;
|
| + videoParams.payload.aesKey = aesKey;
|
| + videoParams.payload.aesIvMask = aesIvMask;
|
| rtpStream.start(videoId, videoParams);
|
| - setTimeout(function () {
|
| + setTimeout(() => {
|
| chrome.test.succeed();
|
| +
|
| rtpStream.stop(audioId);
|
| rtpStream.stop(videoId);
|
| - }, 20000); // 20 seconds
|
| + rtpStream.destroy(audioId);
|
| + rtpStream.destroy(videoId);
|
| +
|
| + const tracks = captureStream.getTracks();
|
| + for (let i = 0; i < tracks.length; ++i) {
|
| + tracks[i].stop();
|
| + }
|
| + chrome.test.assertFalse(captureStream.active);
|
| + }, 15000); // 15 seconds
|
| });
|
| });
|
| }
|
|
|