1<!doctype html>
2<html>
3 <head>
4 <meta charset="utf-8">
5 <title>Testing H264 baseline and high profile</title>
6 <script src="../resources/testharness.js"></script>
7 <script src="../resources/testharnessreport.js"></script>
8 </head>
9 <body>
10 <video id="video" autoplay=""></video>
11 <canvas id="canvas" width="640" height="480"></canvas>
12 <script src ="routines.js"></script>
13 <script>
14function grabFrameData(x, y, w, h)
15{
16 canvas.width = video.videoWidth;
17 canvas.height = video.videoHeight;
18
19 canvas.getContext('2d').drawImage(video, x, y, w, h, x, y, w, h);
20 return canvas.getContext('2d').getImageData(x, y, w, h).data;
21}
22
23function testImage()
24{
25 const data = grabFrameData(10, 325, 250, 1);
26
27 var index = 20;
28 assert_true(data[index] < 100);
29 assert_true(data[index + 1] < 100);
30 assert_true(data[index + 2] < 100);
31
32 index = 80;
33 assert_true(data[index] > 200);
34 assert_true(data[index + 1] > 200);
35 assert_true(data[index + 2] > 200);
36
37 index += 80;
38 assert_true(data[index] > 200);
39 assert_true(data[index + 1] > 200);
40 assert_true(data[index + 2] < 100);
41}
42
43promise_test(async (test) => {
44 if (window.testRunner)
45 testRunner.setUserMediaPermission(true);
46
47 const localStream = await navigator.mediaDevices.getUserMedia({video: true});
48 const stream = await new Promise((resolve, reject) => {
49 createConnections((firstConnection) => {
50 firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
51 }, (secondConnection) => {
52 secondConnection.ontrack = (trackEvent) => {
53 resolve(trackEvent.streams[0]);
54 };
55 }, { observeOffer : (offer) => {
56 offer.sdp = offer.sdp.replace("640c1f", "42e01f");
57 return offer;
58 }
59 });
60 setTimeout(() => reject("Test timed out"), 5000);
61 });
62
63 video.srcObject = stream;
64 await video.play();
65
66 testImage();
67}, "Baseline H264");
68
69promise_test(async (test) => {
70 if (window.testRunner)
71 testRunner.setUserMediaPermission(true);
72
73 const localStream = await navigator.mediaDevices.getUserMedia({video: true});
74 const stream = await new Promise((resolve, reject) => {
75 createConnections((firstConnection) => {
76 firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
77 }, (secondConnection) => {
78 secondConnection.ontrack = (trackEvent) => {
79 resolve(trackEvent.streams[0]);
80 };
81 }, { observeOffer : (offer) => {
82 offer.sdp = offer.sdp.replace("42e01f", "640c1f");
83 return offer;
84 }
85 });
86 setTimeout(() => reject("Test timed out"), 5000);
87 });
88
89 video.srcObject = stream;
90 await video.play();
91
92 testImage();
93}, "High H264");
94 </script>
95 </body>
96</html>