WebVTT served via HLS never results in cues
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2018 05:55:55 +0000 (05:55 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2018 05:55:55 +0000 (05:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181773

Reviewed by Eric Carlson.

Source/WebCore:

Test: http/tests/media/hls/hls-webvtt-tracks.html

Three independant errors conspired to keep in-band WebVTT samples from parsing:

- The definition of ISOWebVTTCue::boxTypeName() was incorrect.
- ISOWebVTTCue::parse() didn't call it's superclass's parse() method (leading to an incorrect size and offset).
- Use String::fromUTF8() rather than String.adopt(StringVector&&).

* platform/graphics/iso/ISOVTTCue.cpp:
(WebCore::ISOWebVTTCue::parse):
* platform/graphics/iso/ISOVTTCue.h:
(WebCore::ISOWebVTTCue::boxTypeName):

LayoutTests:

* http/tests/media/hls/hls-webvtt-tracks-expected.txt: Added.
* http/tests/media/hls/hls-webvtt-tracks.html: Added.
* http/tests/media/resources/hls/subtitles/fileSequence0.webvtt: Added.
* http/tests/media/resources/hls/subtitles/prog_index.m3u8: Added.
* http/tests/media/resources/hls/test-webvtt.m3u8: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/media/hls/hls-webvtt-tracks-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/hls/hls-webvtt-tracks.html [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/subtitles/fileSequence0.webvtt [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/subtitles/prog_index.m3u8 [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/test-webvtt.m3u8 [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/iso/ISOVTTCue.cpp
Source/WebCore/platform/graphics/iso/ISOVTTCue.h

index 01fb939..09e3d17 100644 (file)
@@ -1,3 +1,16 @@
+2018-01-17  Jer Noble  <jer.noble@apple.com>
+
+        WebVTT served via HLS never results in cues
+        https://bugs.webkit.org/show_bug.cgi?id=181773
+
+        Reviewed by Eric Carlson.
+
+        * http/tests/media/hls/hls-webvtt-tracks-expected.txt: Added.
+        * http/tests/media/hls/hls-webvtt-tracks.html: Added.
+        * http/tests/media/resources/hls/subtitles/fileSequence0.webvtt: Added.
+        * http/tests/media/resources/hls/subtitles/prog_index.m3u8: Added.
+        * http/tests/media/resources/hls/test-webvtt.m3u8: Added.
+
 2018-01-17  John Wilander  <wilander@apple.com>
 
         Resource Load Statistics: Block cookies for prevalent resources without user interaction
diff --git a/LayoutTests/http/tests/media/hls/hls-webvtt-tracks-expected.txt b/LayoutTests/http/tests/media/hls/hls-webvtt-tracks-expected.txt
new file mode 100644 (file)
index 0000000..3ac1a15
--- /dev/null
@@ -0,0 +1,9 @@
+
+EVENT(addtrack)
+EXPECTED (video.textTracks.length == '1') OK
+RUN(video.textTracks[0].mode = 'showing')
+EVENT(cuechange)
+EXPECTED (video.textTracks[0].activeCues.length == '1') OK
+EXPECTED (video.textTracks[0].activeCues[0].text == 'Subtitle Test') OK
+END OF TEST
+
diff --git a/LayoutTests/http/tests/media/hls/hls-webvtt-tracks.html b/LayoutTests/http/tests/media/hls/hls-webvtt-tracks.html
new file mode 100644 (file)
index 0000000..ee86192
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=../../media-resources/video-test.js></script>
+    <script src=../../media-resources/media-controls.js></script>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function start() {
+            video = document.getElementById('video');
+            video.src = "../resources/hls/test-webvtt.m3u8";
+            video.play();
+            waitForEventOnceOn(video.textTracks, 'addtrack', trackAdded);
+        }
+
+        function trackAdded() {
+            testExpected("video.textTracks.length", "1");
+            run("video.textTracks[0].mode = 'showing'");
+            waitForEventOnceOn(video.textTracks[0], 'cuechange', cueChanged);
+        }
+
+        function cueChanged() {
+            testExpected("video.textTracks[0].activeCues.length", "1");
+            testExpected("video.textTracks[0].activeCues[0].text", "Subtitle Test");
+            endTest();
+        }
+    </script>
+</head>
+<body onload="start()">
+    <video id="video"></video>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/media/resources/hls/subtitles/fileSequence0.webvtt b/LayoutTests/http/tests/media/resources/hls/subtitles/fileSequence0.webvtt
new file mode 100644 (file)
index 0000000..a2f3f8f
--- /dev/null
@@ -0,0 +1,5 @@
+WEBVTT
+X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000
+
+00:00:00.000 --> 00:00:10.000
+Subtitle Test
diff --git a/LayoutTests/http/tests/media/resources/hls/subtitles/prog_index.m3u8 b/LayoutTests/http/tests/media/resources/hls/subtitles/prog_index.m3u8
new file mode 100644 (file)
index 0000000..730b9bf
--- /dev/null
@@ -0,0 +1,8 @@
+#EXTM3U
+#EXT-X-TARGETDURATION:30
+#EXT-X-VERSION:3
+#EXT-X-MEDIA-SEQUENCE:0
+#EXT-X-PLAYLIST-TYPE:VOD
+#EXTINF:10,
+fileSequence0.webvtt
+#EXT-X-ENDLIST
diff --git a/LayoutTests/http/tests/media/resources/hls/test-webvtt.m3u8 b/LayoutTests/http/tests/media/resources/hls/test-webvtt.m3u8
new file mode 100644 (file)
index 0000000..e8f5f2c
--- /dev/null
@@ -0,0 +1,6 @@
+#EXTM3U
+
+#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles",LANGUAGE="en-US"NAME="English",AUTOSELECT=YES,DEFAULT=YES,URI="subtitles/prog_index.m3u8"
+
+#EXT-X-STREAM-INF:BANDWIDTH=634451,CODECS="mp4a.40.2, avc1.4d401e",RESOLUTION=640x480,SUBTITLES="subtitles"
+bipbop/prog_index.m3u8
index ae7dde8..f9e2919 100644 (file)
@@ -1,3 +1,23 @@
+2018-01-17  Jer Noble  <jer.noble@apple.com>
+
+        WebVTT served via HLS never results in cues
+        https://bugs.webkit.org/show_bug.cgi?id=181773
+
+        Reviewed by Eric Carlson.
+
+        Test: http/tests/media/hls/hls-webvtt-tracks.html
+
+        Three independant errors conspired to keep in-band WebVTT samples from parsing:
+
+        - The definition of ISOWebVTTCue::boxTypeName() was incorrect.
+        - ISOWebVTTCue::parse() didn't call it's superclass's parse() method (leading to an incorrect size and offset).
+        - Use String::fromUTF8() rather than String.adopt(StringVector&&).
+
+        * platform/graphics/iso/ISOVTTCue.cpp:
+        (WebCore::ISOWebVTTCue::parse):
+        * platform/graphics/iso/ISOVTTCue.h:
+        (WebCore::ISOWebVTTCue::boxTypeName):
+
 2018-01-17  John Wilander  <wilander@apple.com>
 
         Resource Load Statistics: Block cookies for prevalent resources without user interaction
index 91ad417..3e85e63 100644 (file)
@@ -58,7 +58,7 @@ protected:
             return true;
         }
 
-        StringVector<LChar> characters;
+        Vector<LChar> characters;
         characters.reserveInitialCapacity((size_t)characterCount);
         while (characterCount--) {
             int8_t character = 0;
@@ -67,7 +67,7 @@ protected:
             characters.uncheckedAppend(character);
         }
 
-        m_contents.adopt(WTFMove(characters));
+        m_contents = String::fromUTF8(characters);
         offset = localOffset;
         return true;
     }
@@ -88,6 +88,9 @@ ISOWebVTTCue::ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& d
 
 bool ISOWebVTTCue::parse(DataView& view, unsigned& offset)
 {
+    if (!ISOBox::parse(view, offset))
+        return false;
+
     ISOStringBox stringBox;
 
     while (stringBox.read(view, offset)) {
index eda868f..a6160b6 100644 (file)
@@ -42,7 +42,7 @@ class ISOWebVTTCue : public ISOBox {
 public:
     ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& duration);
 
-    static FourCC boxTypeName() { return "vtcc"; }
+    static FourCC boxTypeName() { return "vttc"; }
 
     const MediaTime& presentationTime() const { return m_presentationTime; }
     const MediaTime& duration() const { return m_duration; }