diff options
author | jansson@chromium.org <jansson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 12:43:02 +0000 |
---|---|---|
committer | jansson@chromium.org <jansson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 12:43:02 +0000 |
commit | 239eb634ef441b4fe64ce129b3abec0a0ed83051 (patch) | |
tree | ae6ee71e9d9b70d9cf8375eebcd56fb126b3a249 /chrome/test/data/webrtc | |
parent | c9c202894089d45ddc81c24e7392cce6a3f59b5b (diff) | |
download | chromium_src-239eb634ef441b4fe64ce129b3abec0a0ed83051.zip chromium_src-239eb634ef441b4fe64ce129b3abec0a0ed83051.tar.gz chromium_src-239eb634ef441b4fe64ce129b3abec0a0ed83051.tar.bz2 |
Added peerconnection constraint checkboxes + text field.
Moved googCpuOveruseDetection constraint from gUM to peerconnection.
Minor tiding of the HTML structure, bigger overhaul needed.
NOTE: This is WebRTC test page used for manual testing of WebRTC API
JavaScript in Chrome.
BUG=355525
TEST=Manually tested P2P call with and without constraints
NOTRY=TRUE
Review URL: https://codereview.chromium.org/325683004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/webrtc')
-rw-r--r-- | chrome/test/data/webrtc/manual/peerconnection.html | 22 | ||||
-rw-r--r-- | chrome/test/data/webrtc/manual/peerconnection_manual.js | 37 |
2 files changed, 40 insertions, 19 deletions
diff --git a/chrome/test/data/webrtc/manual/peerconnection.html b/chrome/test/data/webrtc/manual/peerconnection.html index 76d8b44..84fe164 100644 --- a/chrome/test/data/webrtc/manual/peerconnection.html +++ b/chrome/test/data/webrtc/manual/peerconnection.html @@ -74,16 +74,21 @@ value="http://localhost:8888"/> Peer ID: <input type="text" id="peer-id" size="10" /> <button id="connect" onclick="connectFromHere();">Connect</button><br/> - PeerConnection <a href="http://goo.gl/xVi12">createOffer MediaConstraints: - </a><br/> + PeerConnection Constraints: + CPU overuse <input type="checkbox" id="cpuoveruse-detection" + onclick="setPeerConnectionConstraints();" checked="true"/> + RTP <input type="checkbox" id="data-channel-type-rtp" + onclick="setPeerConnectionConstraints();"><br/> + <input type="text" id="pc-constraints" size="80" value="{}"><br/> + PeerConnection <a href="http://goo.gl/xVi12"> + createOffer MediaConstraints:</a><br/> <input type="text" id="pc-createoffer-constraints" rows="7" cols="40" - value="{}"/> - <br/> - PeerConnection <a href="http://goo.gl/0TjfX">createAnswer - MediaConstraints:</a><br/> + value="{}"/><br/> + PeerConnection <a href="http://goo.gl/0TjfX"> + createAnswer MediaConstraints:</a><br/> <input type="text" id="pc-createanswer-constraints" rows="7" cols="40" - value="{}"/> - <br/> + value="{}"/><br/> + Call: <button onclick="negotiateCallFromHere();">Negotiate</button> <button onclick="hangUpFromHere();">Hang up</button><br/> @@ -98,7 +103,6 @@ <button onclick="toggleRemoteAudioFromHere();">Toggle Audio</button><br/> Data Channel: <button onclick="createDataChannelFromHere();">Create</button> - RTP <input type="checkbox" id="data-channel-type-rtp"/> <button onclick="closeDataChannelFromHere();">Close</button> status: <input type="text" id="data-channel-status" size="10" value="not created" diff --git a/chrome/test/data/webrtc/manual/peerconnection_manual.js b/chrome/test/data/webrtc/manual/peerconnection_manual.js index 2ee156c..67ea62c 100644 --- a/chrome/test/data/webrtc/manual/peerconnection_manual.js +++ b/chrome/test/data/webrtc/manual/peerconnection_manual.js @@ -54,6 +54,7 @@ window.onload = function() { updateGetUserMediaConstraints(); setupLocalStorageFieldValues(); acceptIncomingCalls(); + setPeerConnectionConstraints(); if ($('get-devices-onload').checked == true) { getDevices(); } @@ -66,7 +67,8 @@ window.onbeforeunload = function() { disconnect_(); }; -/** TODO Add element.id as a parameter and call this function instead? +/** TODO (jansson) Fix the event assigment to allow the elements to have more + * than one event assigned to it (currently replaces existing events). * A list of element id's to be registered for local storage. */ function setupLocalStorageFieldValues() { @@ -74,7 +76,6 @@ function setupLocalStorageFieldValues() { registerLocalStorage_('pc-createanswer-constraints'); registerLocalStorage_('pc-createoffer-constraints'); registerLocalStorage_('get-devices-onload'); - registerLocalStorage_('data-channel-type-rtp'); } // Public HTML functions @@ -221,7 +222,6 @@ function updateGetUserMediaConstraints() { // Default optional constraints placed here. constraints.video = {optional: [{minWidth: $('video-width').value}, {minHeight: $('video-height').value}, - {googCpuOveruseDetection: true}, {googLeakyBucket: true}] }; if (devices.videoId != null) { @@ -450,11 +450,30 @@ function handleMessage(peerConnection, message) { error_('unknown message received'); } -function createPeerConnection(stun_server, useRtpDataChannels) { +/** + * Sets the peerConnection constraints based on checkboxes. + * TODO (jansson) Make it possible to use the text field for constraints like + * for getUserMedia. + */ +function setPeerConnectionConstraints() { + // Only added optional for now. + global.pcConstraints = { + optional: [] + }; + + global.pcConstraints.optional.push( + {googCpuOveruseDetection: $('cpuoveruse-detection').checked}); + + global.pcConstraints.optional.push( + {RtpDataChannels: $('data-channel-type-rtp').checked}); + + $('pc-constraints').value = JSON.stringify(global.pcConstraints, null, ' '); +} + +function createPeerConnection(stun_server) { servers = {iceServers: [{url: 'stun:' + stun_server}]}; try { - var constraints = { optional: [{ RtpDataChannels: useRtpDataChannels }]}; - peerConnection = new RTCPeerConnection(servers, constraints); + peerConnection = new RTCPeerConnection(servers, global.pcConstraints); } catch (exception) { error_('Failed to create peer connection: ' + exception); } @@ -552,8 +571,7 @@ function preparePeerConnection() { if (global.peerConnection != null) error_('creating peer connection, but we already have one.'); - global.peerConnection = createPeerConnection(STUN_SERVER, - $('data-channel-type-rtp').checked); + global.peerConnection = createPeerConnection(STUN_SERVER); print_('ok-peerconnection-created'); } @@ -1336,8 +1354,7 @@ function handlePeerMessage_(peerId, message) { // The other side is calling us. print_('We are being called: answer...'); - global.peerConnection = createPeerConnection(STUN_SERVER, - $('data-channel-type-rtp').checked); + global.peerConnection = createPeerConnection(STUN_SERVER); if ($('auto-add-stream-oncall') && obtainGetUserMediaResult_() == 'ok-got-stream') { |