Index: content/test/data/media/peerconnection-call.html |
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html |
index 7581b729947e8f3370b4d4aa4652e232c6090185..39b01b5a5f0a926c0e4d9e58fdd904bdb98cd6c2 100644 |
--- a/content/test/data/media/peerconnection-call.html |
+++ b/content/test/data/media/peerconnection-call.html |
@@ -1,28 +1,22 @@ |
<html> |
<head> |
+ <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
<script type="text/javascript"> |
$ = function(id) { |
return document.getElementById(id); |
}; |
- // These must match with how the video and canvas tags are declared in html. |
- const VIDEO_TAG_WIDTH = 320; |
- const VIDEO_TAG_HEIGHT = 240; |
- |
var gFirstConnection = null; |
var gSecondConnection = null; |
var gTestWithoutMsidAndBundle = false; |
- // Number of test events to occur before the test pass. When the test pass, |
- // the document title change to OK. |
- var gNumberOfExpectedEvents = 0; |
- |
- // Number of events that currently have occured. |
- var gNumberOfEvents = 0; |
- |
var gLocalStream = null; |
var gSentTones = ''; |
+ setAllEventsOccuredHandler(function() { |
+ document.title = 'OK'; |
+ }); |
+ |
// Test that we can setup call with an audio and video track. |
function call(constraints) { |
createConnections(null); |
@@ -109,6 +103,16 @@ |
// Do the DTMF test after we have received video. |
detectVideoIn('remote-view-2', onCallEstablished); |
} |
+ |
+ // Test call with a new Video MediaStream that has been created based on a |
+ // stream generated by getUserMedia. |
+ function callWithNewVideoMediaStream() { |
+ createConnections(null); |
+ navigator.webkitGetUserMedia({audio:true, video:true}, |
+ createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); |
+ waitForVideo('remote-view-1'); |
+ waitForVideo('remote-view-2'); |
+ } |
// This function is used for setting up a test that: |
// 1. Creates a data channel on |gFirstConnection| and sends data to |
@@ -155,7 +159,7 @@ |
secondDataChannel.send(sendDataString); |
} |
} |
- } |
+ } |
function onToneChange(tone) { |
gSentTones += tone.tone; |
@@ -203,6 +207,15 @@ |
gFirstConnection.addStream(localStream); |
negotiate(); |
} |
+ |
+ // Called if getUserMedia succeeds when we want to send a modified |
+ // MediaStream. A new MediaStream is created and the video track from |
+ // |localStream| is added. |
+ function createNewVideoStreamAndAddToBothConnections(localStream) { |
+ var new_stream = new webkitMediaStream(); |
+ new_stream.addTrack(localStream.getVideoTracks()[0]); |
+ addStreamToBothConnectionsAndNegotiate(new_stream); |
+ } |
function negotiate() { |
gFirstConnection.createOffer(onOfferCreated); |
@@ -275,66 +288,7 @@ |
var remoteVideo = $(target); |
remoteVideo.src = remoteStreamUrl; |
} |
- |
- // TODO(phoglund): perhaps use the video detector in chrome/test/data/webrtc/? |
- function detectVideoIn(videoElementName, callback) { |
- var width = VIDEO_TAG_WIDTH; |
- var height = VIDEO_TAG_HEIGHT; |
- var videoElement = $(videoElementName); |
- var canvas = $(videoElementName + '-canvas'); |
- var waitVideo = setInterval(function() { |
- var context = canvas.getContext('2d'); |
- context.drawImage(videoElement, 0, 0, width, height); |
- var pixels = context.getImageData(0, 0, width, height).data; |
- |
- if (isVideoPlaying(pixels, width, height)) { |
- clearInterval(waitVideo); |
- callback(); |
- } |
- }, 100); |
- } |
- |
- function waitForVideo(videoElement) { |
- document.title = 'Waiting for video...'; |
- addExpectedEvent(); |
- detectVideoIn(videoElement, function () { eventOccured(); }); |
- } |
- |
- // This very basic video verification algorithm will be satisfied if any |
- // pixels are nonzero in a small sample area in the middle. It relies on the |
- // assumption that a video element with null source just presents zeroes. |
- function isVideoPlaying(pixels, width, height) { |
- // Sample somewhere near the middle of the image. |
- var middle = width * height / 2; |
- for (var i = 0; i < 20; i++) { |
- if (pixels[middle + i] > 0) { |
- return true; |
- } |
- } |
- return false; |
- } |
- |
- |
- // This function matches |left| and |right| and throws an exception if the |
- // values don't match. |
- function expectEquals(left, right) { |
- if (left != right) { |
- var s = "expectEquals failed left: " + left + " right: " + right; |
- document.title = s; |
- throw s; |
- } |
- } |
- |
- function addExpectedEvent() { |
- ++gNumberOfExpectedEvents; |
- } |
- |
- function eventOccured() { |
- ++gNumberOfEvents; |
- if (gNumberOfEvents == gNumberOfExpectedEvents) { |
- document.title = 'OK'; |
- } |
- } |
+ |
</script> |
</head> |
<body> |