forked from w3c/media-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-source.js
576 lines (508 loc) · 40 KB
/
media-source.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
(function() {
var MSE_spec_url = "http://www.w3.org/TR/media-source/";
var HTML5_spec_url = "https://www.w3.org/TR/html51/semantics-embedded-content.html";
var HTML5_infrastructure_spec_url = "https://www.w3.org/TR/html51/infrastructure.html";
var HTML5_browsers_spec_url = "https://www.w3.org/TR/html51/browsers.html";
var HTML5_webappapis_spec_url = "https://www.w3.org/TR/html51/webappapis.html";
var DOM_spec_url = "https://dom.spec.whatwg.org/";
var HRTIME_spec_url = "https://www.w3.org/TR/hr-time/";
var W3C_STREAMS_spec_url = "https://www.w3.org/TR/streams-api/"; // Make sure this matches the localBiblio entry.
var WHATWG_STREAMS_spec_url = "https://streams.spec.whatwg.org/"; // Make sure this matches the localBiblio entry.
var FILE_spec_url = "https://www.w3.org/TR/FileAPI/";
var WEBIDL_spec_url = "https://www.w3.org/TR/WebIDL-1/";
function url_helper(doc, url) {
if (url[0] == "#" && doc.mseDefGroupName != window.respecConfig.mseDefGroupName) {
return groupBaseURLs[doc.mseDefGroupName] + url;
}
return url;
}
function eventdfn_helper(doc, df, id, text) {
df.appendChild($("<dfn/>").attr({id: 'dom-evt-' + text.toLowerCase()}).wrapInner($("<code/>").text(text))[0]);
}
function idlref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: url_helper(doc, "#" + id)}).text(text))[0]);
}
function eventref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: url_helper(doc, "#dom-evt-" + id)}).text(text))[0]);
}
function videoref_helper(doc, df, id, text) {
link_helper(doc, df, HTML5_spec_url + '#' + id, text);
}
function code_videoref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: HTML5_spec_url + "#" + id}).text(text))[0]);
}
function fileapi_helper(doc, df, id, text) {
link_helper(doc, df, FILE_spec_url + '#' + id, text);
}
function hrtime_helper(doc, df, id, text) {
link_helper(doc, df, HRTIME_spec_url + '#' + id, text);
}
function webappapis_helper(doc, df, id, text) {
link_helper(doc, df, HTML5_webappapis_spec_url + '#' + id, text);
}
function infrastructure_helper(doc, df, id, text) {
link_helper(doc, df, HTML5_infrastructure_spec_url + '#' + id, text);
}
function browsers_helper(doc, df, id, text) {
link_helper(doc, df, HTML5_browsers_spec_url + '#' + id, text);
}
function term_helper(doc, df, id, text) {
link_helper(doc, df, url_helper(doc, '#' + id), text);
}
function var_helper(doc, df, id, text) {
df.appendChild($("<var/>").wrapInner($("<a/>").attr({href: url_helper(doc, id)}).text(text))[0]);
}
function link_helper(doc, df, id, text) {
df.appendChild($("<a/>").attr({href: url_helper(doc, id)}).text(text)[0]);
}
function exception_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: WEBIDL_spec_url + '#' + id}).text(text))[0]);
}
function typeerror_helper(doc, df, id, text) {
df.appendChild($("<code/>").text(text)[0]);
}
function webmref_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.webmproject.org/code/specs/container/#' + id, text);
}
function whatwg_streams_helper(doc, df, id, text) {
link_helper(doc, df, WHATWG_STREAMS_spec_url + '#' + id, text);
}
function queue_and_fire_helper(doc, df, id, text) {
webappapis_helper(doc, df, 'queuing', text);
df.appendChild(doc.createTextNode(' to '));
infrastructure_helper(doc, df, 'fire', 'fire a simple event');
df.appendChild(doc.createTextNode(' named'));
}
function queue_and_fire_track_event_helper_with_track_attr_initialized_to(doc, df, id, text) {
webappapis_helper(doc, df, 'queuing', 'queue a task');
df.appendChild(doc.createTextNode(' to fire a '));
infrastructure_helper(doc, df, 'trusted', 'trusted event');
df.appendChild(doc.createTextNode(' named '));
code_videoref_helper(doc, df, 'dom-' + id + 'tracklist-on' + text, text);
df.appendChild(doc.createTextNode(', that does not bubble and is not cancelable, and that uses the '));
code_videoref_helper(doc, df, 'trackevent-trackevent', 'TrackEvent');
df.appendChild(doc.createTextNode(' interface, with the '));
code_videoref_helper(doc, df, 'dom-trackevent-track', 'track');
df.appendChild(doc.createTextNode(' attribute initialized to '));
}
function fragment_helper(doc, df, id, text) {
var f = doc.createElement('span')
f.innerHTML = text;
df.appendChild(f);
}
function contributors_helper(doc, df, id, text) {
var contributors = window.respecConfig.mseContributors;
contributors.sort();
var str = "";
for (var i = 0; i < contributors.length - 1; ++i) {
if (i > 0)
str += ", ";
str += contributors[i];
}
str += ", and ";
str += contributors[contributors.length - 1];
df.appendChild(doc.createTextNode(str));
}
function append_error_helper(doc, df, id, text) {
link_helper(doc, df, id, 'append error algorithm');
df.appendChild(doc.createTextNode(' with the '));
df.appendChild($("<var/>").text('decode error')[0]);
df.appendChild(doc.createTextNode(' parameter set to ' + text));
}
var mseDefinitions = {
'mse-spec': { func: link_helper, fragment: '#', link_text: 'Media Source Extensions', },
'live-seekable-range': { func: var_helper, fragment: '#live-seekable-range', link_text: 'live seekable range', },
'sourceBuffers': { func: idlref_helper, fragment: 'widl-MediaSource-sourceBuffers', link_text: 'sourceBuffers', },
'activeSourceBuffers': { func: idlref_helper, fragment: 'widl-MediaSource-activeSourceBuffers', link_text: 'activeSourceBuffers', },
'addSourceBuffer': { func: idlref_helper, fragment: 'widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type', link_text: 'addSourceBuffer()', },
'endOfStream': { func: idlref_helper, fragment: 'widl-MediaSource-endOfStream-void-EndOfStreamError-error', link_text: 'endOfStream()', },
'readyState': { func: idlref_helper, fragment: 'widl-MediaSource-readyState', link_text: 'readyState', },
'duration': { func: idlref_helper, fragment: 'widl-MediaSource-duration', link_text: 'duration', },
'setLiveSeekableRange': { func: idlref_helper, fragment: 'widl-MediaSource-setLiveSeekableRange-void-double-start-double-end', link_text: 'setLiveSeekableRange()', },
'clearLiveSeekableRange': { func: idlref_helper, fragment: 'widl-MediaSource-clearLiveSeekableRange-void', link_text: 'clearLiveSeekableRange()', },
'isTypeSupported': { func: idlref_helper, fragment: 'widl-MediaSource-isTypeSupported-boolean-DOMString-type', link_text: 'isTypeSupported()', },
'appendBuffer': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data', link_text: 'appendBuffer()', },
'appendStream': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendStream-void-ReadableStream-stream-unsigned-long-long-maxSize', link_text: 'appendStream()', },
'abort': { func: idlref_helper, fragment: 'widl-SourceBuffer-abort-void', link_text: 'abort()', },
'remove': { func: idlref_helper, fragment: 'widl-SourceBuffer-remove-void-double-start-unrestricted-double-end', link_text: 'remove()', },
'updating': { func: idlref_helper, fragment: 'widl-SourceBuffer-updating', link_text: 'updating', },
'sourcebuffer-audioTracks': { func: idlref_helper, fragment: 'widl-SourceBuffer-audioTracks', link_text: 'audioTracks', },
'sourcebuffer-videoTracks': { func: idlref_helper, fragment: 'widl-SourceBuffer-videoTracks', link_text: 'videoTracks', },
'sourcebuffer-textTracks': { func: idlref_helper, fragment: 'widl-SourceBuffer-textTracks', link_text: 'textTracks', },
'buffered': { func: idlref_helper, fragment: 'widl-SourceBuffer-buffered', link_text: 'buffered', },
'timestampOffset': { func: idlref_helper, fragment: 'widl-SourceBuffer-timestampOffset', link_text: 'timestampOffset', },
'appendWindowStart': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendWindowStart', link_text: 'appendWindowStart', },
'appendWindowEnd': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendWindowEnd', link_text: 'appendWindowEnd', },
'AppendMode-segments': { func: idlref_helper, fragment: 'idl-def-AppendMode.segments', link_text: '"segments"', },
'AppendMode-sequence': { func: idlref_helper, fragment: 'idl-def-AppendMode.sequence', link_text: '"sequence"', },
'mode': { func: idlref_helper, fragment: 'widl-SourceBuffer-mode', link_text: 'mode', },
'trackDefaults': { func: idlref_helper, fragment: 'widl-SourceBuffer-trackDefaults', link_text: 'trackDefaults', },
'TrackDefaultList-length': { func: idlref_helper, fragment: 'widl-TrackDefaultList-length', link_text: 'length', },
'SourceBufferList-length': { func: idlref_helper, fragment: 'widl-SourceBufferList-length', link_text: 'length', },
'creationTime': { func: idlref_helper, fragment: 'widl-VideoPlaybackQuality-creationTime', link_text: 'creationTime', },
'totalVideoFrames': { func: idlref_helper, fragment: 'widl-VideoPlaybackQuality-totalVideoFrames', link_text: 'totalVideoFrames', },
'droppedVideoFrames': { func: idlref_helper, fragment: 'widl-VideoPlaybackQuality-droppedVideoFrames', link_text: 'droppedVideoFrames', },
'corruptedVideoFrames': { func: idlref_helper, fragment: 'widl-VideoPlaybackQuality-corruptedVideoFrames', link_text: 'corruptedVideoFrames', },
'totalFrameDelay': { func: idlref_helper, fragment: 'widl-VideoPlaybackQuality-totalFrameDelay', link_text: 'totalFrameDelay', },
'createObjectURL': { func: idlref_helper, fragment: 'widl-URL-createObjectURL-DOMString-MediaSource-mediaSource', link_text: 'createObjectURL()', },
'open': { func: idlref_helper, fragment: 'idl-def-ReadyState.open', link_text: '"open"', },
'closed': { func: idlref_helper, fragment: 'idl-def-ReadyState.closed', link_text: '"closed"', },
'ended': { func: idlref_helper, fragment: 'idl-def-ReadyState.ended', link_text: '"ended"', },
'network': { func: idlref_helper, fragment: 'idl-def-EndOfStreamError.network', link_text: '"network"', },
'decode': { func: idlref_helper, fragment: 'idl-def-EndOfStreamError.decode', link_text: '"decode"', },
'updatestart': { func: eventref_helper, fragment: 'updatestart', link_text: 'updatestart', },
'update': { func: eventref_helper, fragment: 'update', link_text: 'update', },
'updateend': { func: eventref_helper, fragment: 'updateend', link_text: 'updateend', },
'updateerror': { func: eventref_helper, fragment: 'error', link_text: 'error', },
'updateabort': { func: eventref_helper, fragment: 'abort', link_text: 'abort', },
'sourceopen': { func: eventref_helper, fragment: 'sourceopen', link_text: 'sourceopen', },
'sourceended': { func: eventref_helper, fragment: 'sourceended', link_text: 'sourceended', },
'sourceclose': { func: eventref_helper, fragment: 'sourceclose', link_text: 'sourceclose', },
'addsourcebuffer': { func: eventref_helper, fragment: 'addsourcebuffer', link_text: 'addsourcebuffer', },
'removesourcebuffer': { func: eventref_helper, fragment: 'removesourcebuffer', link_text: 'removesourcebuffer', },
'init-segment': { func: term_helper, fragment: 'init-segment', link_text: 'initialization segment', },
'init-segments': { func: term_helper, fragment: 'init-segment', link_text: 'initialization segments', },
'media-segment': { func: term_helper, fragment: 'media-segment', link_text: 'media segment', },
'media-segments': { func: term_helper, fragment: 'media-segment', link_text: 'media segments', },
'presentation-start-time': { func: term_helper, fragment: 'presentation-start-time', link_text: 'presentation start time', },
'random-access-point': { func: term_helper, fragment: 'random-access-point', link_text: 'random access point', },
'random-access-points': { func: term_helper, fragment: 'random-access-point', link_text: 'random access points', },
'track-id': { func: term_helper, fragment: 'track-id', link_text: 'Track ID', },
'track-ids': { func: term_helper, fragment: 'track-id', link_text: 'Track IDs', },
'track-description': { func: term_helper, fragment: 'track-description', link_text: 'track description', },
'track-descriptions': { func: term_helper, fragment: 'track-description', link_text: 'track descriptions', },
'coded-frame': { func: term_helper, fragment: 'coded-frame', link_text: 'coded frame', },
'coded-frames': { func: term_helper, fragment: 'coded-frame', link_text: 'coded frames', },
'coded-frame-duration': { func: term_helper, fragment: 'coded-frame-duration', link_text: 'coded frame duration', },
'coded-frames-duration': { func: term_helper, fragment: 'coded-frame-duration', link_text: 'coded frame\'s duration', },
'coded-frame-end-timestamp': { func: term_helper, fragment: 'coded-frame-end-timestamp', link_text: 'coded frame end timestamp', },
'parent-media-source': { func: term_helper, fragment: 'parent-media-source', link_text: 'parent media source', },
'coded-frame-group': { func: term_helper, fragment: 'coded-frame-group', link_text: 'coded frame group', },
'decode-timestamp': { func: term_helper, fragment: 'decode-timestamp', link_text: 'decode timestamp', },
'decode-timestamps': { func: term_helper, fragment: 'decode-timestamp', link_text: 'decode timestamps', },
'displayed-frame-delay': { func: term_helper, fragment: 'displayed-frame-delay', link_text: 'displayed frame delay', },
'displayed-frame-delays': { func: term_helper, fragment: 'displayed-frame-delay', link_text: 'displayed frame delays', },
'presentation-interval': { func: term_helper, fragment: 'presentation-interval', link_text: 'presentation interval', },
'presentation-order': { func: term_helper, fragment: 'presentation-order', link_text: 'presentation order', },
'presentation-timestamp': { func: term_helper, fragment: 'presentation-timestamp', link_text: 'presentation timestamp', },
'presentation-timestamps': { func: term_helper, fragment: 'presentation-timestamp', link_text: 'presentation timestamps', },
'append-window': { func: term_helper, fragment: 'append-window', link_text: 'append window', },
'enough-data': { func: term_helper, fragment: 'enough-data', link_text: 'enough data to ensure uninterrupted playback', },
'active-track-buffers': { func: term_helper, fragment: 'active-track-buffers', link_text: 'active track buffers', },
'duration-change-algorithm': { func: link_helper, fragment: '#duration-change-algorithm', link_text: 'duration change algorithm', },
'end-of-stream-algorithm': { func: link_helper, fragment: '#end-of-stream-algorithm', link_text: 'end of stream algorithm', },
'segment-parser-loop': { func: link_helper, fragment: '#sourcebuffer-segment-parser-loop', link_text: 'segment parser loop', },
'append-state': { func: var_helper, fragment: '#sourcebuffer-append-state', link_text: 'append state', },
'waiting-for-segment': { func: link_helper, fragment: '#sourcebuffer-waiting-for-segment', link_text: 'WAITING_FOR_SEGMENT', },
'parsing-init-segment': { func: link_helper, fragment: '#sourcebuffer-parsing-init-segment', link_text: 'PARSING_INIT_SEGMENT', },
'parsing-media-segment': { func: link_helper, fragment: '#sourcebuffer-parsing-media-segment', link_text: 'PARSING_MEDIA_SEGMENT', },
'byte-stream-formats-section': { func: link_helper, fragment: '#byte-stream-formats', link_text: 'byte stream formats section', },
'byte-stream-format-spec': { func: link_helper, fragment: '#byte-stream-format-specs', link_text: 'byte stream format specification', },
'byte-stream-format-specs': { func: link_helper, fragment: '#byte-stream-format-specs', link_text: 'byte stream format specifications', },
'sourcebuffer-byte-stream-format-spec': { func: link_helper, fragment: '#sourcebuffer-byte-stream-format-spec', link_text: 'SourceBuffer byte stream format specification', },
'sourcebuffer-configuration': { func: link_helper, fragment: '#sourcebuffer-configuration', link_text: 'SourceBuffer configuration', },
'append-error-algorithm': { func: append_error_helper, fragment: '#sourcebuffer-append-error', link_text: 'false', },
'append-decode-error-algorithm': { func: append_error_helper, fragment: '#sourcebuffer-append-error', link_text: 'true', },
'reset-parser-state-algorithm': { func: link_helper, fragment: '#sourcebuffer-reset-parser-state', link_text: 'reset parser state algorithm', },
'stream-append-loop': { func: link_helper, fragment: '#sourcebuffer-stream-append-loop', link_text: 'stream append loop', },
'prepare-append': { func: link_helper, fragment: '#sourcebuffer-prepare-append', link_text: 'prepare append', },
'buffer-append': { func: link_helper, fragment: '#sourcebuffer-buffer-append', link_text: 'buffer append', },
'range-removal': { func: link_helper, fragment: '#sourcebuffer-range-removal', link_text: 'range removal', },
'init-segment-received-algorithm': { func: link_helper, fragment: '#sourcebuffer-init-segment-received', link_text: 'initialization segment received algorithm', },
'coded-frame-processing-algorithm': { func: link_helper, fragment: '#sourcebuffer-coded-frame-processing', link_text: 'coded frame processing algorithm', },
'coded-frame-removal-algorithm': { func: link_helper, fragment: '#sourcebuffer-coded-frame-removal', link_text: 'coded frame removal algorithm', },
'coded-frame-eviction-algorithm': { func: link_helper, fragment: '#sourcebuffer-coded-frame-eviction', link_text: 'coded frame eviction algorithm', },
'audio-splice-frame-algorithm': { func: link_helper, fragment: '#sourcebuffer-audio-splice-frame-algorithm', link_text: 'audio splice frame algorithm', },
'audio-splice-rendering-algorithm': { func: link_helper, fragment: '#sourcebuffer-audio-splice-rendering-algorithm', link_text: 'audio splice rendering algorithm', },
'text-splice-frame-algorithm': { func: link_helper, fragment: '#sourcebuffer-text-splice-frame-algorithm', link_text: 'text splice frame algorithm', },
'default-track-language-algorithm': { func: link_helper, fragment: '#sourcebuffer-default-track-language', link_text: 'default track language algorithm', },
'default-track-label-algorithm': { func: link_helper, fragment: '#sourcebuffer-default-track-label', link_text: 'default track label algorithm', },
'default-track-kinds-algorithm': { func: link_helper, fragment: '#sourcebuffer-default-track-kinds', link_text: 'default track kinds algorithm', },
'input-buffer': { func: var_helper, fragment: '#sourcebuffer-input-buffer', link_text: 'input buffer', },
'buffer-full-flag': { func: var_helper, fragment: '#sourcebuffer-buffer-full-flag', link_text: 'buffer full flag', },
'group-start-timestamp': { func: var_helper, fragment: '#sourcebuffer-group-start-timestamp', link_text: 'group start timestamp', },
'group-end-timestamp': { func: var_helper, fragment: '#sourcebuffer-group-end-timestamp', link_text: 'group end timestamp', },
'generate-timestamps-flag': { func: var_helper, fragment: '#sourcebuffer-generate-timestamps-flag', link_text: 'generate timestamps flag', },
'MediaSource-object-URL': { func: link_helper, fragment: '#mediasource-object-url', link_text: 'MediaSource object URL', },
'first-init-segment-received-flag': { func: var_helper, fragment: '#first-init-segment-received-flag', link_text: 'first initialization segment received flag', },
'track-buffer': { func: term_helper, fragment: 'track-buffer', link_text: 'track buffer', },
'track-buffers': { func: term_helper, fragment: 'track-buffer', link_text: 'track buffers', },
'track-buffer-ranges': { func: term_helper, fragment: 'track-buffer-ranges', link_text: 'track buffer ranges', },
'last-decode-timestamp': { func: var_helper, fragment: '#last-decode-timestamp', link_text: 'last decode timestamp', },
'last-frame-duration': { func: var_helper, fragment: '#last-frame-duration', link_text: 'last frame duration', },
'highest-end-timestamp': { func: var_helper, fragment: '#highest-end-timestamp', link_text: 'highest end timestamp', },
'need-RAP-flag': { func: var_helper, fragment: '#need-RAP-flag', link_text: 'need random access point flag', },
'TrackDefaultType-audio': { func: idlref_helper, fragment: 'idl-def-TrackDefaultType.audio', link_text: '"audio"', },
'TrackDefaultType-video': { func: idlref_helper, fragment: 'idl-def-TrackDefaultType.video', link_text: '"video"', },
'TrackDefaultType-text': { func: idlref_helper, fragment: 'idl-def-TrackDefaultType.text', link_text: '"text"', },
'TrackDefault-type': { func: idlref_helper, fragment: 'widl-TrackDefault-type', link_text: 'type', },
'TrackDefault-byteStreamTrackID': { func: idlref_helper, fragment: 'widl-TrackDefault-byteStreamTrackID', link_text: 'byteStreamTrackID', },
'TrackDefault-language': { func: idlref_helper, fragment: 'widl-TrackDefault-language', link_text: 'language', },
'TrackDefault-label': { func: idlref_helper, fragment: 'widl-TrackDefault-label', link_text: 'label', },
'TrackDefault-getkinds': { func: idlref_helper, fragment: 'widl-TrackDefault-getKinds-sequence-DOMString', link_text: 'getKinds', },
'blob-uri': { func: fileapi_helper, fragment: 'url', link_text: 'Blob URI', },
'File': { func: fileapi_helper, fragment: 'dfn-file', link_text: 'File', },
'Blob': { func: fileapi_helper, fragment: 'dfn-Blob', link_text: 'Blob', },
'URL': { func: fileapi_helper, fragment: 'URL-object', link_text: 'URL', },
'file-createObjectURL': { func: fileapi_helper, fragment: 'dfn-createObjectURL', link_text: 'createObjectURL()', },
'file-revokeObjectURL': { func: fileapi_helper, fragment: 'dfn-revokeObjectURL', link_text: 'revokeObjectURL()', },
'eventdfn': { func: eventdfn_helper, fragment: '', link_text: '', },
'videoref': { func: videoref_helper, fragment: '', link_text: '', },
'media-timeline': { func: videoref_helper, fragment: 'media-timeline', link_text: 'media timeline', },
'media-element-load-algorithm': { func: videoref_helper, fragment: 'media-element-load-algorithm', link_text: 'media element load algorithm', },
'mediatracklist-change': { func: code_videoref_helper, fragment: 'dom-mediatracklist-onchange', link_text: 'change', },
'resource-fetch-algorithm': { func: videoref_helper, fragment: 'resource-fetch-algorithm', link_text: 'resource fetch algorithm', },
'delaying-the-load-event-flag': {func: videoref_helper, fragment: 'delaying-the-load-event-flag', link_text: 'delaying-the-load-event-flag', },
'intrinsic-width-and-height': { func: videoref_helper, fragment: 'video-intrinsic-width', link_text: 'intrinsic width and height', },
'normalized-timeranges-object': { func: videoref_helper, fragment: 'normalized-timeranges-object', link_text: 'normalized TimeRanges object', },
'current-playback-position': { func: videoref_helper, fragment: 'current-position', link_text: 'current playback position', },
'media-data-is-corrupted': { func: videoref_helper, fragment: 'fatal-decode-error', link_text: 'media data is corrupted', },
'preload': { func: code_videoref_helper, fragment: 'element-attrdef-media-preload', link_text: 'preload', },
'preload-none': {func: code_videoref_helper, fragment: 'valdef-htmlmediaelement-preload-none', link_text: 'none', },
'media-src': { func: code_videoref_helper, fragment: 'element-attrdef-media-src', link_text: 'src', },
'timerange': { func: code_videoref_helper, fragment: 'timeranges-timeranges', link_text: 'TimeRange', },
'timeranges': { func: code_videoref_helper, fragment: 'timeranges-timeranges', link_text: 'TimeRanges', },
'video-track': { func: code_videoref_helper, fragment: 'videotrack-videotrack', link_text: 'VideoTrack', },
'video-track-list': { func: code_videoref_helper, fragment: 'videotracklist-videotracklist', link_text: 'VideoTrackList', },
'videotrack-id': { func: code_videoref_helper, fragment: 'dom-videotrack-id', link_text: 'id', },
'videotrack-kind': { func: code_videoref_helper, fragment: 'dom-videotrack-kind', link_text: 'kind', },
'videotrack-label': { func: code_videoref_helper, fragment: 'dom-videotrack-label', link_text: 'label', },
'videotrack-language': { func: code_videoref_helper, fragment: 'dom-videotrack-language', link_text: 'language', },
'videotrack-selected': { func: code_videoref_helper, fragment: 'dom-videotrack-selected', link_text: 'selected', },
'videotrack-sourceBuffer': { func: idlref_helper, fragment: 'widl-VideoTrack-sourceBuffer', link_text: 'sourceBuffer', },
'videotracklist-length': { func: code_videoref_helper, fragment: 'dom-videotracklist-length', link_text: 'length', },
'videotracks': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-videotracks', link_text: 'videoTracks', },
'audio-track': { func: code_videoref_helper, fragment: 'audiotrack-audiotrack', link_text: 'AudioTrack', },
'audio-track-list': { func: code_videoref_helper, fragment: 'audiotracklist-audiotracklist', link_text: 'AudioTrackList', },
'audiotracklist-length': { func: code_videoref_helper, fragment: 'dom-audiotracklist-length', link_text: 'length', },
'audiotracks': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-audiotracks', link_text: 'audioTracks', },
'audiotrack-id': { func: code_videoref_helper, fragment: 'dom-audiotrack-id', link_text: 'id', },
'audiotrack-kind': { func: code_videoref_helper, fragment: 'dom-audiotrack-kind', link_text: 'kind', },
'audiotrack-label': { func: code_videoref_helper, fragment: 'dom-audiotrack-label', link_text: 'label', },
'audiotrack-language': { func: code_videoref_helper, fragment: 'dom-audiotrack-language', link_text: 'language', },
'audiotrack-enabled': { func: code_videoref_helper, fragment: 'dom-audiotrack-enabled', link_text: 'enabled', },
'audiotrack-sourceBuffer': { func: idlref_helper, fragment: 'widl-AudioTrack-sourceBuffer', link_text: 'sourceBuffer', },
'av-kind-categories-table': { func: code_videoref_helper, fragment: 'dom-TrackList-getKind-categories', link_text: 'kind categories table', },
'text-track-kind-list': { func: code_videoref_helper, fragment: 'kind-of-track', link_text: 'text track kind list', },
'text-track': { func: code_videoref_helper, fragment: 'texttrack-texttrack', link_text: 'TextTrack', },
'text-track-list': { func: code_videoref_helper, fragment: 'texttracklist-texttracklist', link_text: 'TextTrackList', },
'texttracks': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-texttracks', link_text: 'textTracks', },
'texttrack-mode': { func: code_videoref_helper, fragment: 'dom-texttrack-mode', link_text: 'mode', },
'texttrack-id': { func: code_videoref_helper, fragment: 'dom-texttrack-id', link_text: 'id', },
'texttrack-kind': { func: code_videoref_helper, fragment: 'dom-texttrack-kind', link_text: 'kind', },
'texttrack-label': { func: code_videoref_helper, fragment: 'dom-texttrack-label', link_text: 'label', },
'texttrack-language': { func: code_videoref_helper, fragment: 'dom-texttrack-language', link_text: 'language', },
'texttracklist-change': { func: code_videoref_helper, fragment: 'dom-texttracklist-onchange', link_text: 'change', },
'texttrackmode-showing': { func: code_videoref_helper, fragment: 'dom-texttrackmode-showing', link_text: '"showing"', },
'texttrackmode-hidden': { func: code_videoref_helper, fragment: 'dom-texttrackmode-hidden', link_text: '"hidden"', },
'texttrackmode-disabled': { func: code_videoref_helper, fragment: 'dom-texttrackmode-disabled', link_text: '"disabled"', },
'texttrack-sourceBuffer': { func: idlref_helper, fragment: 'widl-TextTrack-sourceBuffer', link_text: 'sourceBuffer', },
'ready-state': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-readystate', link_text: 'HTMLMediaElement.readyState', },
'ready-states' : { func: code_videoref_helper, fragment: 'ready-states', link_text: 'HTMLMediaElement ready states', },
'have-nothing': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-have_nothing', link_text: 'HAVE_NOTHING', },
'have-metadata': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-have_metadata', link_text: 'HAVE_METADATA', },
'have-current-data': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-have_current_data', link_text: 'HAVE_CURRENT_DATA', },
'have-future-data': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-have_future_data', link_text: 'HAVE_FUTURE_DATA', },
'have-enough-data': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-have_enough_data', link_text: 'HAVE_ENOUGH_DATA', },
'loadedmetadata': { func: code_videoref_helper, fragment: 'eventdef-media-loadedmetadata', link_text: 'loadedmetadata', },
'htmlmediaelement': { func: code_videoref_helper, fragment: 'htmlmediaelement-htmlmediaelement', link_text: 'HTMLMediaElement', },
'hme-duration': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-duration', link_text: 'media duration', },
'hme-buffered': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-buffered', link_text: 'HTMLMediaElement.buffered', },
'hme-error': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-error', link_text: 'HTMLMediaElement.error', },
'hme-seekable': { func: code_videoref_helper, fragment: 'dom-htmlmediaelement-seekable', link_text: 'HTMLMediaElement.seekable', },
'hme-seek-algorithm': { func: videoref_helper, fragment: 'seek', link_text: 'seek algorithm', },
'hme-duration-change-algorithm': { func: videoref_helper, fragment: 'durationChange', link_text: 'HTMLMediaElement duration change algorithm', },
'htmlvideoelement': { func: code_videoref_helper, fragment: 'htmlvideoelement-htmlvideoelement', link_text: 'HTMLVideoElement', },
'total-video-frame-count': { func: var_helper, fragment: '#total-video-frame-count', link_text: 'total video frame count', },
'dropped-video-frame-count': { func: var_helper, fragment: '#dropped-video-frame-count', link_text: 'dropped video frame count', },
'corrupted-video-frame-count': { func: var_helper, fragment: '#corrupted-video-frame-count', link_text: 'corrupted video frame count', },
'displayed-frame-delay-sum': { func: var_helper, fragment: '#displayed-frame-delay-sum', link_text: 'displayed frame delay sum', },
'invalid-access-error': { func: exception_helper, fragment: 'invalidaccesserror', link_text: 'InvalidAccessError', },
'invalid-state-error': { func: exception_helper, fragment: 'invalidstateerror', link_text: 'InvalidStateError', },
'not-found-error': { func: exception_helper, fragment: 'notfounderror', link_text: 'NotFoundError', },
'not-supported-error': { func: exception_helper, fragment: 'notsupportederror', link_text: 'NotSupportedError', },
'quota-exceeded-error': { func: exception_helper, fragment: 'quotaexceedederror', link_text: 'QuotaExceededError', },
'type-error': { func: typeerror_helper, fragment: '', link_text: 'TypeError', },
'queue-a-task-to-fire-an-event-named': { func: queue_and_fire_helper, fragment: '', link_text: 'queue a task', },
'Queue-a-task-to-fire-an-event-named': { func: queue_and_fire_helper, fragment: '', link_text: 'Queue a task', },
'queue-and-fire-media-addtrack-with-track-attr-initialized-to': { func: queue_and_fire_track_event_helper_with_track_attr_initialized_to, fragment: 'media', link_text: 'addtrack', },
'queue-and-fire-text-addtrack-with-track-attr-initialized-to': { func: queue_and_fire_track_event_helper_with_track_attr_initialized_to, fragment: 'text', link_text: 'addtrack', },
'queue-and-fire-media-removetrack-with-track-attr-initialized-to': { func: queue_and_fire_track_event_helper_with_track_attr_initialized_to, fragment: 'media', link_text: 'removetrack', },
'queue-and-fire-text-removetrack-with-track-attr-initialized-to': { func: queue_and_fire_track_event_helper_with_track_attr_initialized_to, fragment: 'text', link_text: 'removetrack', },
'provide-a-stable-state': { func: webappapis_helper, fragment: 'provide-a-stable-state', link_text: 'provide a stable state', },
'origin': { func: browsers_helper, fragment: 'origin', link_text: 'origin', },
'relevant-settings-object': { func: webappapis_helper, fragment: 'relevant-settings-object', link_text: 'relevant settings object', },
'media-data-cannot-be-fetched': { func: fragment_helper, fragment: '', link_text: '"<i>If the media data cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource</i>"', },
'perform-potentially-cors-enabled-fetch': { func: fragment_helper, fragment: '', link_text: '"<i>Perform a potentially CORS-enabled fetch</i>"', },
'contributors': { func: contributors_helper, fragment: '', link_text: '', },
'performance-now': { func: hrtime_helper, fragment: 'dom-performance-now', link_text: 'Performance.now()', },
'ReadableStream-read': { func: whatwg_streams_helper, fragment: 'rs-read', link_text:'read()', },
'ReadableStream-ready': { func: whatwg_streams_helper, fragment: 'rs-ready', link_text:'ready', },
'ReadableStream-closed': { func: whatwg_streams_helper, fragment: 'rs-closed', link_text:'closed', },
'ReadableStream-state-waiting': { func: whatwg_streams_helper, fragment: 'rs-state', link_text:'"waiting"', },
'ReadableStream-state-readable': { func: whatwg_streams_helper, fragment: 'rs-state', link_text:'"readable"', },
'ReadableStream-state-closed': { func: whatwg_streams_helper, fragment: 'rs-state', link_text:'"closed"', },
'ReadableStream-state-errored': { func: whatwg_streams_helper, fragment: 'rs-state', link_text:'"errored"', },
};
var definitionInfo = {};
var groupBaseURLs = {};
var helperTypes = {
'link' : link_helper,
'var' : var_helper,
};
function mediaSourceAddDefinitionInfo(groupName, groupBaseURL, definitions) {
groupBaseURLs[groupName] = groupBaseURL;
for (var def_id in definitions) {
if (definitionInfo[def_id]) {
console.log("Overriding previous definition of def-id '" + def_id + "'.");
}
var info = definitions[def_id];
info.groupName = groupName;
if (!info.func) {
var helper_type = info.helper_type || "link";
info.func = helperTypes[helper_type];
}
definitionInfo[def_id] = info;
}
}
function mediaSourcePreProcessor() {
for (var x in groupBaseURLs) {
if (groupBaseURLs[x] == MSE_spec_url && window.respecConfig.specStatus == "ED") {
MSE_spec_url = "index.html";
groupBaseURLs[x] = MSE_spec_url;
break;
}
}
$("a[def-id]").each(function () {
$(this).addClass('externalDFN');
});
if (window.respecConfig.localBiblio) {
var tmp = window.respecConfig.localBiblio["W3C-STREAMS-API"]
if (tmp && tmp.indexOf(W3C_STREAMS_spec_url) == -1) {
console.log("W3C_STREAMS_spec_url is out of sync with the localBiblio entry");
}
var tmp = window.respecConfig.localBiblio["WHATWG-STREAMS-API"]
if (tmp && tmp.indexOf(WHATWG_STREAMS_spec_url) == -1) {
console.log("WHATWG_STREAMS_spec_url is out of sync with the localBiblio entry");
}
}
}
function mediaSourcePostProcessor() {
var doc = document;
doc.normalize();
var usedMap = {};
$("a[def-id]").each(function () {
var $ant = $(this);
var def_id = $ant.attr('def-id');
var info = definitionInfo[def_id];
if (info) {
if (!usedMap[def_id]) {
usedMap[def_id] = 1;
} else {
usedMap[def_id]++;
}
var id = info.fragment;
var text = info.link_text;
if ($ant.attr('name')) {
id = $ant.attr('name');
}
var element_text = this.innerHTML;
if (element_text) {
text = element_text;
}
var df = doc.createDocumentFragment();
doc.mseDefGroupName = info.groupName;
info.func(doc, df, id, text);
doc.mseDefGroupName = "";
this.parentNode.replaceChild(df, this);
} else {
console.log("Found def-id '" + def_id + "' but it does not correspond to anything");
}
});
// Update links to external type definitions.
var externalClassInfo = {
'ReadableStream': { spec: 'whatwg-streams-api', fragment: 'rs-class-definition' },
'SourceBuffer': { spec: 'mse', fragment: 'idl-def-SourceBuffer' },
'AudioTrackList': {spec: 'html5', fragment: 'audiotracklist-audiotracklist' },
'TextTrackList': {spec: 'html5', fragment: 'texttracklist-texttracklist' },
'TimeRanges': { spec: 'html5', fragment: 'timeranges-timeranges' },
'VideoTrackList': {spec: 'html5', fragment: 'videotracklist-videotracklist' },
'EventHandler' : { spec: 'html5-webappapis', fragment: 'typedefdef-eventhandlernonnull-eventhandler' },
'EventTarget': { spec: 'dom', fragment: 'eventtarget' },
'DOMString': { spec: 'webidl', fragment: 'idl-DOMString' },
'boolean': { spec: 'webidl', fragment: 'idl-boolean' },
'double': { spec: 'webidl', fragment: 'idl-double' },
'unrestricted double': { spec: 'webidl', fragment: 'idl-unrestricted-double' },
'unsigned long': { spec: 'webidl', fragment: 'idl-unsigned-long' },
'unsigned long long': { spec: 'webidl', fragment: 'idl-unsigned-long-long' },
'void': { spec: 'webidl', fragment: 'idl-void' },
'ArrayBuffer': { spec: 'typed-array', fragment: 'ArrayBuffer' },
'ArrayBufferView': { spec: 'typed-array', fragment: 'ArrayBufferView' },
'DOMHighResTimeStamp': { spec: 'hr-time', fragment: 'dom-domhighrestimestamp'},
};
$("a:not([href])").each(function () {
var $ant = $(this);
var className = this.innerHTML;
var info = externalClassInfo[className];
if (info) {
var id = info.fragment;
var df = doc.createDocumentFragment();
var baseURL = null;
if (info.spec == 'w3c-streams-api') {
baseURL = W3C_STREAMS_spec_url;
} else if (info.spec == 'whatwg-streams-api') {
baseURL = WHATWG_STREAMS_spec_url;
} else if (info.spec == 'html5') {
baseURL = HTML5_spec_url;
} else if (info.spec == 'html5-webappapis') {
baseURL = HTML5_webappapis_spec_url;
} else if (info.spec == 'dom') {
baseURL = DOM_spec_url;
} else if (info.spec == 'webidl') {
baseURL = WEBIDL_spec_url;
} else if (info.spec == 'typed-array') {
baseURL = "http://www.khronos.org/registry/typedarray/specs/latest/";
} else if (info.spec == 'hr-time') {
baseURL = HRTIME_spec_url;
} else if (info.spec == 'mse') {
baseURL = MSE_spec_url;
}
if (baseURL) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: baseURL + "#" + id, 'class': 'idlType'}).text(className))[0]);
this.parentNode.replaceChild(df, this);
}
}
});
// Move algorithm text after method parameter & return value information.
$("ol.method-algorithm").each(function() {
var parent = this.parentNode;
parent.removeChild(this);
parent.appendChild($("<p/>").text("When this method is invoked, the user agent must run the following steps:")[0]);
parent.appendChild(this);
});
// Validate that all defined def-ids are actually used.
var excludeList = window.respecConfig.mseUnusedGroupNameExcludeList || [];
for (var k in definitionInfo) {
var defGroupName = definitionInfo[k].groupName;
if (!usedMap[k] && !(excludeList.indexOf(defGroupName) != -1)) {
console.log("def-id '" + k + "' from groupName '" + defGroupName + "' never used.");
}
}
$("a[href]").each(function () {
var link = $(this);
var href = link.attr('href');
var matched = /^#(.+)$/.exec(href);
if (matched) {
var id = matched[1];
if (!document.getElementById(id)) {
console.log("Internal link to an id '" + id + "' which does not exist");
}
}
});
return;
}
mediaSourceAddDefinitionInfo("media-source", MSE_spec_url, mseDefinitions);
window.mediaSourceAddDefinitionInfo = mediaSourceAddDefinitionInfo;
window.mediaSourcePreProcessor = mediaSourcePreProcessor;
window.mediaSourcePostProcessor = mediaSourcePostProcessor;
})();