Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / cast_streaming / performance.js
blob0ca6d9f37166d405798d37777f91fd6ef24b438b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Run a cast v2 mirroring session for 10 seconds.
7 chrome.test.runTests([
8 function sendTestPatterns() {
9 // The receive port changes between browser_test invocations, and is passed
10 // as an query parameter in the URL.
11 var recvPort;
12 try {
13 recvPort = parseInt(window.location.search.substring("?port=".length));
14 chrome.test.assertTrue(recvPort > 0);
15 } catch (err) {
16 chrome.test.fail("Error parsing ?port=### -- " + err.message);
17 return;
20 var width = 1920;
21 var height = 1080;
22 var frameRate = 30;
24 chrome.tabCapture.capture(
25 { video: true,
26 audio: true,
27 videoConstraints: {
28 mandatory: {
29 minWidth: width,
30 minHeight: height,
31 maxWidth: width,
32 maxHeight: height,
33 maxFrameRate: frameRate,
37 function startStreamingTestPatterns(captureStream) {
38 chrome.test.assertTrue(!!captureStream);
39 chrome.cast.streaming.session.create(
40 captureStream.getAudioTracks()[0],
41 captureStream.getVideoTracks()[0],
42 function (audioId, videoId, udpId) {
43 chrome.cast.streaming.udpTransport.setDestination(
44 udpId, { address: "127.0.0.1", port: recvPort } );
45 var rtpStream = chrome.cast.streaming.rtpStream;
46 rtpStream.start(audioId,
47 rtpStream.getSupportedParams(audioId)[0]);
48 var videoParams = rtpStream.getSupportedParams(videoId)[0];
49 videoParams.payload.clockRate = frameRate;
50 rtpStream.start(videoId, videoParams);
51 setTimeout(function () {
52 chrome.test.succeed();
53 rtpStream.stop(audioId);
54 rtpStream.stop(videoId);
55 }, 20000); // 20 seconds
56 });
57 });
59 ]);