Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: tools/perf/page_sets/webrtc_cases/resolution.js

Issue 2761163003: Use local pages for webrtc telemetry tests. (Closed)
Patch Set: Exclude all of webrtc_cases in PRESUBMIT.py and add a comment explaining it is because these are te… Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/page_sets/webrtc_cases/resolution.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/page_sets/webrtc_cases/resolution.js
diff --git a/tools/perf/page_sets/webrtc_cases/resolution.js b/tools/perf/page_sets/webrtc_cases/resolution.js
new file mode 100644
index 0000000000000000000000000000000000000000..4b807b0ec4264fdb16330c89bbc5f57ad8c2a1b2
--- /dev/null
+++ b/tools/perf/page_sets/webrtc_cases/resolution.js
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+'use strict';
+
+var dimensions = document.querySelector('#dimensions');
+var video = document.querySelector('video');
+var stream;
+
+var vgaButton = document.querySelector('#vga');
+var qvgaButton = document.querySelector('#qvga');
+var hdButton = document.querySelector('#hd');
+var fullHdButton = document.querySelector('#full-hd');
+
+vgaButton.onclick = function() {
+ getMedia(vgaConstraints);
+};
+
+qvgaButton.onclick = function() {
+ getMedia(qvgaConstraints);
+};
+
+hdButton.onclick = function() {
+ getMedia(hdConstraints);
+};
+
+fullHdButton.onclick = function() {
+ getMedia(fullHdConstraints);
+};
+
+var qvgaConstraints = {
+ video: {width: {exact: 320}, height: {exact: 240}}
+};
+
+var vgaConstraints = {
+ video: {width: {exact: 640}, height: {exact: 480}}
+};
+
+var hdConstraints = {
+ video: {width: {exact: 1280}, height: {exact: 720}}
+};
+
+var fullHdConstraints = {
+ video: {width: {exact: 1920}, height: {exact: 1080}}
+};
+
+function gotStream(mediaStream) {
+ window.stream = mediaStream; // stream available to console
+ video.srcObject = mediaStream;
+}
+
+function displayVideoDimensions() {
+ if (!video.videoWidth) {
+ setTimeout(displayVideoDimensions, 500);
+ }
+ dimensions.innerHTML = 'Actual video dimensions: ' + video.videoWidth +
+ 'x' + video.videoHeight + 'px.';
+}
+
+video.onloadedmetadata = displayVideoDimensions;
+
+function getMedia(constraints) {
+ if (stream) {
+ stream.getTracks().forEach(function(track) {
+ track.stop();
+ });
+ }
+
+ navigator.mediaDevices.getUserMedia(constraints)
+ .then(gotStream)
+ .catch(function(e) {
+ var message = 'getUserMedia error: ' + e.name;
+ alert(message);
+ console.log(message);
+ });
+}
« no previous file with comments | « tools/perf/page_sets/webrtc_cases/resolution.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698