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

Unified Diff: tools/perf/page_sets/webrtc_cases/getusermedia_files/main.js

Issue 2761163003: Use local pages for webrtc telemetry tests. (Closed)
Patch Set: 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
Index: tools/perf/page_sets/webrtc_cases/getusermedia_files/main.js
diff --git a/tools/perf/page_sets/webrtc_cases/getusermedia_files/main.js b/tools/perf/page_sets/webrtc_cases/getusermedia_files/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..048b682e0ef7e6e6be7fbc3420569f4194d4f3ee
--- /dev/null
+++ b/tools/perf/page_sets/webrtc_cases/getusermedia_files/main.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+
+'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);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698