[MSE][Mac] Support painting MSE video-element to canvas
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 09:41:23 +0000 (09:41 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 09:41:23 +0000 (09:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125157
<rdar://problem/23062016>

Reviewed by Eric Carlson.

* media/media-source/content/test-fragmented.mp4: Add a 'edts' atom to move the presentation time for the
    first sample to 0:00.
* media/media-source/media-source-paint-to-canvas-expected.txt: Added.
* media/media-source/media-source-paint-to-canvas.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217111 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-paint-to-canvas-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-paint-to-canvas.html [new file with mode: 0644]

index c0098d6..00cd6a2 100644 (file)
@@ -1,3 +1,16 @@
+2017-04-11  Jer Noble  <jer.noble@apple.com>
+
+        [MSE][Mac] Support painting MSE video-element to canvas
+        https://bugs.webkit.org/show_bug.cgi?id=125157
+        <rdar://problem/23062016>
+
+        Reviewed by Eric Carlson.
+
+        * media/media-source/content/test-fragmented.mp4: Add a 'edts' atom to move the presentation time for the
+            first sample to 0:00.
+        * media/media-source/media-source-paint-to-canvas-expected.txt: Added.
+        * media/media-source/media-source-paint-to-canvas.html: Added.
+
 2017-05-19  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK+ gardening.
diff --git a/LayoutTests/media/media-source/media-source-paint-to-canvas-expected.txt b/LayoutTests/media/media-source/media-source-paint-to-canvas-expected.txt
new file mode 100644 (file)
index 0000000..61fb833
--- /dev/null
@@ -0,0 +1,12 @@
+EVENT(sourceopen)
+EVENT(update)
+EVENT(canplay)
+EXPECTED (canvas.getContext("2d").getImageData(250, 130, 1, 1).data[0] != '0') OK
+RUN(video.currentTime += 1.001 / 24)
+EVENT(seeked)
+EXPECTED (canvas.getContext("2d").getImageData(250, 130, 1, 1).data[0] != '0') OK
+RUN(video.currentTime += 1.001 / 24)
+EVENT(seeked)
+EXPECTED (canvas.getContext("2d").getImageData(250, 130, 1, 1).data[0] != '0') OK
+END OF TEST
+
diff --git a/LayoutTests/media/media-source/media-source-paint-to-canvas.html b/LayoutTests/media/media-source/media-source-paint-to-canvas.html
new file mode 100644 (file)
index 0000000..78d0705
--- /dev/null
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-stalled-holds-sleep-assertion</title>
+    <script src="media-source-loader.js"></script>
+    <script src="../video-test.js"></script>
+    <script>
+
+    var canvas;
+    var loader;
+    var source;
+    var sourceBuffer;
+
+    function runTest() {
+        mediaElement = video = document.createElement('video');
+
+        loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
+        loader.onload = mediaDataLoaded;
+        loader.onerror = mediaDataLoadingFailed;
+    }
+
+    function mediaDataLoadingFailed() {
+        failTest('Media data loading failed');
+    }
+
+    function mediaDataLoaded() {
+        source = new MediaSource();
+        waitForEvent('sourceopen', sourceOpen, false, false, source);
+        video.src = URL.createObjectURL(source);
+    }
+
+    function sourceOpen() {
+        source.duration = loader.duration();
+        sourceBuffer = source.addSourceBuffer(loader.type());
+        waitForEventOn(sourceBuffer, 'update', sourceInitialized, false, true);
+        sourceBuffer.appendBuffer(loader.initSegment());
+    }
+
+    function sourceInitialized() {
+        waitForEvent('canplay', canPlay, false, true);
+        sourceBuffer.appendBuffer(loader.mediaSegment(0));
+    }
+
+    function paint() {
+        canvas = document.createElement('canvas');
+        canvas.width = video.videoWidth / 2;
+        canvas.height = video.videoHeight / 2;
+        canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
+        document.getElementById('canvases').appendChild(canvas);
+        testExpected('canvas.getContext("2d").getImageData(250, 130, 1, 1).data[0]', '0', '!=');
+    }
+
+    function canPlay() {
+        paint();
+        waitForEvent('seeked', seeked1, false, true);
+        run('video.currentTime += 1.001 / 24');
+    }
+
+    function seeked1() {
+        paint();
+        waitForEvent('seeked', seeked2, false, true);
+        run('video.currentTime += 1.001 / 24');
+    }
+
+    function seeked2() {
+        paint();
+        endTest();
+    }
+    </script>
+</head>
+<body onload="runTest()">
+    <div id="canvases"></canvas>
+</body>
+</html>
\ No newline at end of file