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
|
<!doctype html>
<meta charset=utf-8>
<title>Media Source Extensions IDL tests</title>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<script type=text/plain class=untested>
interface EventTarget {
void addEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
boolean dispatchEvent(Event event);
};
interface EventHandler {};
interface URL {};
interface HTMLVideoElement {};
interface AudioTrack {};
interface AudioTrackList {};
interface VideoTrack {};
interface VideoTrackList {};
interface TextTrack {};
interface TextTrackList {};
interface TimeRanges {};
typedef double DOMHighResTimeStamp;
</script>
<script type=text/plain>
[Constructor]
interface MediaSource : EventTarget {
readonly attribute SourceBufferList sourceBuffers;
readonly attribute SourceBufferList activeSourceBuffers;
readonly attribute ReadyState readyState;
attribute unrestricted double duration;
attribute EventHandler onsourceopen;
attribute EventHandler onsourceended;
attribute EventHandler onsourceclose;
SourceBuffer addSourceBuffer(DOMString type);
void removeSourceBuffer(SourceBuffer sourceBuffer);
void endOfStream(optional EndOfStreamError error);
void setLiveSeekableRange(double start, double end);
void clearLiveSeekableRange();
static boolean isTypeSupported(DOMString type);
};
interface SourceBuffer : EventTarget {
attribute AppendMode mode;
readonly attribute boolean updating;
readonly attribute TimeRanges buffered;
attribute double timestampOffset;
readonly attribute AudioTrackList audioTracks;
readonly attribute VideoTrackList videoTracks;
readonly attribute TextTrackList textTracks;
attribute double appendWindowStart;
attribute unrestricted double appendWindowEnd;
attribute EventHandler onupdatestart;
attribute EventHandler onupdate;
attribute EventHandler onupdateend;
attribute EventHandler onerror;
attribute EventHandler onabort;
void appendBuffer(BufferSource data);
void abort();
void remove(double start, unrestricted double end);
};
interface SourceBufferList : EventTarget {
readonly attribute unsigned long length;
attribute EventHandler onaddsourcebuffer;
attribute EventHandler onremovesourcebuffer;
getter SourceBuffer (unsigned long index);
};
[Exposed=Window,DedicatedWorker,SharedWorker]
partial interface URL {
static DOMString createObjectURL(MediaSource mediaSource);
};
partial interface AudioTrack {
readonly attribute SourceBuffer? sourceBuffer;
};
partial interface VideoTrack {
readonly attribute SourceBuffer? sourceBuffer;
};
partial interface TextTrack {
readonly attribute SourceBuffer? sourceBuffer;
};
enum EndOfStreamError {
"network",
"decode"
};
enum AppendMode {
"segments",
"sequence"
};
enum ReadyState {
"closed",
"open",
"ended"
};
</script>
<script>
"use strict";
setup({ explicit_done: true });
var mediaSource;
var sourceBuffer;
var video = document.createElement("video");
var idlCheck = function() {
var idlArray = new IdlArray();
[].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
if (node.className == "untested") {
idlArray.add_untested_idls(node.textContent);
} else {
idlArray.add_idls(node.textContent);
}
});
idlArray.add_objects({
MediaSource: ['mediaSource'],
SourceBuffer: ['sourceBuffer'],
SourceBufferList: ['mediaSource.sourceBuffers']
});
idlArray.test();
done();
}
mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener("sourceopen", function () {
var defaultType ='video/webm;codecs="vp8,vorbis"';
if (video.canPlayType(defaultType)) {
sourceBuffer = mediaSource.addSourceBuffer(defaultType);
} else {
sourceBuffer = mediaSource.addSourceBuffer('video/mp4');
}
sourceBuffer.addEventListener("updateend", function (e) {
mediaSource.endOfStream();
idlCheck();
});
sourceBuffer.appendBuffer(new ArrayBuffer());
});
</script>
|