[webvtt] Where should "headers" go relative to the `WEBVTT` magic string? (#485)

icbaker has just created a new issue for https://github.com/w3c/webvtt:

== Where should "headers" go relative to the `WEBVTT` magic string? ==
We're implementing a WebVTT parser that also handles the `X-TIMESTAMP-MAP` header specified by [Section 3.5 of HLS RFC 8216](https://tools.ietf.org/html/rfc8216#section-3.5).

A [question](https://github.com/google/ExoPlayer/issues/7462) has come up about where headers should be in a WebVTT file. The spec seems to only mention "headers" in [6.1 WebVTT file parsing](https://www.w3.org/TR/webvtt1/#webvtt-parser-algorithm), and by my interpretation of steps 6 - 11 they must be on lines directly beneath `WEBVTT` (i.e. no blank lines in between). It seems step 6 allows for additional text after `WEBVTT` but then ignores/skips it in step 7. Then step 9 advances to the next line and step 11 parses any headers.

It seems by this algorithm this would be a valid file:
```
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

00:00:46.582 --> 00:00:48.305
  First cue
```

However [4.1 WebVTT file structure](https://www.w3.org/TR/webvtt1/#file-structure) seems to require one or more blank lines directly underneath `WEBVTT` (step 4) and doesn't mention headers at all. It does allow text immediately after `WEBVTT` on the first line (i.e. the same text that is skipped by the parsing algorithm) (step 3).

So by that interpretation, my example file above is invalid, and the only place to add 'extra' info to the start of the file is directly after `WEBVTT`, e.g.:
```
WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

00:00:46.582 --> 00:00:48.305
  First cue
```

But the `X-TIMESTAMP-MAP` data is now in the section that's skipped by step 7 of the algorithm in 6.1 WebVTT file parsing.

So I guess there's two questions:
* Do 4.1 and 6.1 in the spec disagree about what lines can follow `WEBVTT`?
* Should headers be directly beneath `WEBVTT` or on the same line, or is either valid?

Please view or discuss this issue at https://github.com/w3c/webvtt/issues/485 using your GitHub account

Received on Friday, 5 June 2020 08:21:34 UTC