OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> | 4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> |
5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
6 | 6 |
7 function cubemapFaces(gl) { | 7 function cubemapFaces(gl) { |
8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, | 8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, |
9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, | 9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, |
10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, | 10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, |
(...skipping 18 matching lines...) Expand all Loading... |
29 detectVideoInLocalView1(stream, function() { | 29 detectVideoInLocalView1(stream, function() { |
30 testVideoToImageBitmap('local-view-1', function() { | 30 testVideoToImageBitmap('local-view-1', function() { |
31 stream.getVideoTracks()[0].stop(); | 31 stream.getVideoTracks()[0].stop(); |
32 waitForVideoToStop('local-view-1'); | 32 waitForVideoToStop('local-view-1'); |
33 }, failedCallback); | 33 }, failedCallback); |
34 }); | 34 }); |
35 }, | 35 }, |
36 failedCallback); | 36 failedCallback); |
37 } | 37 } |
38 | 38 |
| 39 function testGetStreamByVideoKindConstraint(constraint, kind) { |
| 40 return new Promise(function(resolve, reject) { |
| 41 getStreamOfVideoKind(constraint).then(function(stream) { |
| 42 if (stream.getVideoTracks().length != 1) { |
| 43 return reject("Expected one " + kind + " track, got " + |
| 44 stream.getVideoTracks().length + |
| 45 " when using constraint " + JSON.stringify(constraint)); |
| 46 } |
| 47 var track = stream.getVideoTracks()[0]; |
| 48 if (track.getSettings().videoKind != kind) { |
| 49 return reject("Expected " + kind + " track, got " + |
| 50 track.getSettings().videoKind + |
| 51 " when using constraint " + JSON.stringify(constraint)); |
| 52 } |
| 53 return resolve(); |
| 54 }, |
| 55 failedCallback); |
| 56 }); |
| 57 } |
| 58 |
| 59 function getStreamsByVideoKind() { |
| 60 console.log('Calling getStreamsByVideoKind'); |
| 61 var cases = [{constraint: {exact: "depth"}, kind: "depth"}, |
| 62 {constraint: {exact: "color"}, kind: "color"}]; |
| 63 var tests = []; |
| 64 for (var i in cases) { |
| 65 var test_case = cases[i]; |
| 66 tests.push(testGetStreamByVideoKindConstraint(test_case.constraint, |
| 67 test_case.kind)); |
| 68 } |
| 69 Promise.all(tests).then(reportTestSuccess, reason => { |
| 70 failedCallback({name: reason}); |
| 71 }); |
| 72 } |
| 73 |
| 74 function getStreamsByVideoKindNoDepth() { |
| 75 console.log('Calling getStreamsByVideoKindNoDepth'); |
| 76 testGetStreamByVideoKindConstraint({exact: "color"}, "color") |
| 77 .then(function() { |
| 78 // Getting a depth stream should fail. |
| 79 getStreamOfVideoKind({exact: "depth"}).then(function(stream) { |
| 80 return failedCallback({name: "Expected to fail, got depth instead."}); |
| 81 }, function() { |
| 82 // Getting a random stream should fail. |
| 83 getStreamOfVideoKind({exact: "fisheye"}).then(function(stream) { |
| 84 return failedCallback( |
| 85 {name: "Expected to fail, got fisheye instead."}); |
| 86 }, reportTestSuccess); |
| 87 }); |
| 88 }, reason => { |
| 89 failedCallback({name: reason}); |
| 90 }); |
| 91 } |
| 92 |
39 function depthStreamToRGBAUint8Texture() { | 93 function depthStreamToRGBAUint8Texture() { |
40 console.log('Calling depthStreamToRGBAUint8Texture'); | 94 console.log('Calling depthStreamToRGBAUint8Texture'); |
41 getFake16bitStream().then(function(stream) { | 95 getFake16bitStream().then(function(stream) { |
42 detectVideoInLocalView1(stream, function() { | 96 detectVideoInLocalView1(stream, function() { |
43 testVideoToRGBA8Texture('local-view-1', function() { | 97 testVideoToRGBA8Texture('local-view-1', function() { |
44 stream.getVideoTracks()[0].stop(); | 98 stream.getVideoTracks()[0].stop(); |
45 waitForVideoToStop('local-view-1'); | 99 waitForVideoToStop('local-view-1'); |
46 }, failedCallback); | 100 }, failedCallback); |
47 }); | 101 }); |
48 }, | 102 }, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 <tr> | 390 <tr> |
337 <td><video id="local-view-1" width="96" height="96" autoplay | 391 <td><video id="local-view-1" width="96" height="96" autoplay |
338 style="display:none"></video></td> | 392 style="display:none"></video></td> |
339 <!-- The canvas is used to detect when video starts and stops. --> | 393 <!-- The canvas is used to detect when video starts and stops. --> |
340 <td><canvas id="local-view-1-canvas" width="96" height="96" | 394 <td><canvas id="local-view-1-canvas" width="96" height="96" |
341 style="display:none"></canvas></td> | 395 style="display:none"></canvas></td> |
342 </tr> | 396 </tr> |
343 </table> | 397 </table> |
344 </body> | 398 </body> |
345 </html> | 399 </html> |
OLD | NEW |