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

Unified Diff: chrome/test/data/webrtc_rendering/loopback_peerconnection.html

Issue 1254023003: Telemetry Test for WebRTC Rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added rendering_lenth_error and normalized drift_time and smoothness_score Created 5 years, 4 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: chrome/test/data/webrtc_rendering/loopback_peerconnection.html
diff --git a/chrome/test/data/webrtc_rendering/loopback_peerconnection.html b/chrome/test/data/webrtc_rendering/loopback_peerconnection.html
new file mode 100644
index 0000000000000000000000000000000000000000..b22353d2636cbcc13026c686eb273984f1cb84ad
--- /dev/null
+++ b/chrome/test/data/webrtc_rendering/loopback_peerconnection.html
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html>
+<head><title>Loopback test</title></head>
+<body>
+ <video id="localVideo" width="1280" height="720" autoplay muted></video>
+ <video id="remoteVideo" width="1280" height="720" autoplay muted></video>
+<script>
+
nednguyen 2015/09/04 15:46:40 Add: 'use strict';
cpaulin (no longer in chrome) 2015/09/16 22:57:04 Acknowledged.
+durationMS = 30000;
phoglund_chromium 2015/09/02 11:27:45 Style guide: Use NAMES_LIKE_THIS for constant valu
cpaulin (no longer in chrome) 2015/09/16 22:57:04 Acknowledged.
+testProgress = 0;
phoglund_chromium 2015/09/02 11:27:45 This variable is badly named - a better name would
cpaulin (no longer in chrome) 2015/09/16 22:57:04 Acknowledged.
+
+// Starts the test.
+function testCamera(resolution) {
+ var test = new CameraTest(resolution);
+ test.run();
+}
+
+
+// Actual test object.
+function CameraTest(resolutionArray) {
+ this.resolution = resolutionArray;
+ this.localStream = null;
+ this.remoteStream = null;
+ this.remoteVideo = document.getElementById("remoteVideo");
+ this.localVideo = document.getElementById("localVideo");
+ this.localVideo.width = this.resolution[0].toString();
+ this.localVideo.height = this.resolution[1].toString();
+ this.remoteVideo.width = this.resolution[0].toString();
+ this.remoteVideo.height = this.resolution[1].toString();
+}
+
+
+CameraTest.prototype = {
+ run: function() {
+ setTimeout(function() {testProgress = 1}, durationMS);
+ this.triggerGetUserMedia(this.resolution);
+ },
+
+ triggerGetUserMedia: function(resolution) {
+ var constraints = {
+ audio: false,
+ video: {
+ mandatory: {
+ minWidth: resolution[0],
+ minHeight: resolution[1],
+ maxWidth: resolution[0],
+ maxHeight: resolution[1]
+ }
+ }
+ };
+ try {
+ this.doGetUserMedia(constraints, this.gotLocalStream.bind(this),
+ this.onGetUserMediaError.bind(this));
+ } catch (exception) {
+ console.log('Unexpected exception: ', exception);
+ this.reportError('gUM', 'doGetUserMedia failed: ' + exception);
+ }
+ },
+
+ reportError: function(errorType, message) {
+ console.log(errorType, message);
+ },
+
+ doGetUserMedia: function(constraints, onSuccess, onFail) {
+ navigator.getUserMedia = navigator.getUserMedia ||
+ navigator.webkitGetUserMedia;
+ navigator.getUserMedia(constraints, onSuccess, onFail);
+ },
+
+ gotLocalStream: function(stream) {
+ this.localStream = stream;
+ var servers = null;
+
+ this.localPeerConnection = new webkitRTCPeerConnection(servers);
+ this.localPeerConnection.onicecandidate = this.gotLocalIceCandidate.bind(
+ this);
+
+ this.remotePeerConnection = new webkitRTCPeerConnection(servers);
+ this.remotePeerConnection.onicecandidate = this.gotRemoteIceCandidate.bind(
+ this);
+ this.remotePeerConnection.onaddstream = this.gotRemoteStream.bind(this);
+
+ this.localPeerConnection.addStream(this.localStream);
+ this.localPeerConnection.createOffer(this.gotLocalDescription.bind(this));
+ this.localVideo.src = URL.createObjectURL(stream);
+ },
+
+ onGetUserMediaError: function(stream) {
+ this.reportError('gUM', 'gUM call failed');
+ },
+
+ gotRemoteStream: function(event) {
+ this.remoteVideo.src = URL.createObjectURL(event.stream);
+ },
+
+ gotLocalDescription: function(description) {
+ this.localPeerConnection.setLocalDescription(description);
+ this.remotePeerConnection.setRemoteDescription(description);
+ this.remotePeerConnection.createAnswer(this.gotRemoteDescription.bind(
+ this));
+ },
+
+ gotRemoteDescription: function(description) {
+ this.remotePeerConnection.setLocalDescription(description);
+ this.localPeerConnection.setRemoteDescription(description);
+ },
+
+ gotLocalIceCandidate: function(event) {
+ if (event.candidate)
+ this.remotePeerConnection.addIceCandidate(
+ new RTCIceCandidate(event.candidate));
+ },
+
+ gotRemoteIceCandidate: function(event) {
+ if (event.candidate)
+ this.localPeerConnection.addIceCandidate(
+ new RTCIceCandidate(event.candidate));
+ },
+}
+
+window.onload = testCamera([1280, 720]);
+window.onerror = function (message, filename, lineno, colno, error) {
+ console.log("Something went wrong, here is the stack trace --> %s",
+ error.stack);
+};
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | tools/perf/benchmarks/webrtc_rendering.py » ('j') | tools/perf/measurements/webrtc_rendering.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698