You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Deep Dive/Modules/MediaSourceExtensions.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
The Media Source Extensions specification defines a set of classes which allows clients to implement their own loading, buffering, and variant switching behavior, as opposed to requiring the UA to handle same.
6
6
7
-
Clients `fetch()` media initialization segments and media segments, typically subsets of a single [fragmented MP4 file](https://www.w3.org/TR/mse-byte-stream-format-isobmff/) or [WebM file](https://www.w3.org/TR/mse-byte-stream-format-webm/), and append those segments into a SourceBuffer object, which is associated with a HTMLMediaElement through a <doc:MediaSourceExtensions#MediaSource> object.
7
+
Clients `fetch()` media initialization segments and media segments, typically subsets of a single [fragmented MP4 file](https://www.w3.org/TR/mse-byte-stream-format-isobmff/) or [WebM file](https://www.w3.org/TR/mse-byte-stream-format-webm/), and append those segments into a SourceBuffer object, which is associated with a HTMLMediaElement through a MediaSource object.
8
8
9
9
## Relevant Classes
10
10
@@ -13,12 +13,13 @@ Clients `fetch()` media initialization segments and media segments, typically su
* Associating those SourceBuffer objects with a HTMLMediaElement.
18
19
19
-
Once created, clients can create query for container and codec support via `isTypeSupported(type)`, <doc:MediaSourceExtensions#SourceBuffer> objects via `addSourceBuffer(type)`, explicitly set the MediaSource's `duration`, and signal an end of the stream via `endOfStream(error)`.
20
+
Once created, clients can create query for container and codec support via `isTypeSupported(type)`, SourceBuffer objects via `addSourceBuffer(type)`, explicitly set the MediaSource's `duration`, and signal an end of the stream via `endOfStream(error)`.
20
21
21
-
Before creating any <doc:MediaSourceExtensions#SourceBuffer> objects, the MediaSource must be associated with a HTMLMediaElement.
22
+
Before creating any SourceBuffer objects, the MediaSource must be associated with a HTMLMediaElement.
22
23
The MediaSource can be set directly as the HTMLMediaElement's `srcObject`. Alternatively, an [extension](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/Modules/mediasource/DOMURL%2BMediaSource.idl) to DOMURL allows an ObjectURL to be created from a MediaSource object, and that ObjectURL can be set as the HTMLMediaElement's `src`.
23
24
24
25
A MediaSource object will fire a `"sourceopen"` event when successfully associated with a HTMLMediaElement, and a `"sourceclose"` event when disassociated.
@@ -29,30 +30,30 @@ The state of the MediaSource object can be queried via its `readyState` property
SourceBuffer accepts buffers of initialization segments and media segments, which are then parsed into media tracks and media samples. Those samples are cached within the SourceBuffer (inside its [SourceBufferPrivate](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/SourceBufferPrivate.h) object)
32
-
and enqueued into platform-specific decoders on demand. The primary storage mechanism for these samples is a <doc:MediaSourceExtensions#SampleMap>, which orders those samples both in terms of each sample's DecodeTime and PresentationTime. These two times can differ for codecs that support frame reordering, typically MPEG video codecs such as h.264 and HEVC.
33
+
and enqueued into platform-specific decoders on demand. The primary storage mechanism for these samples is a SampleMap, which orders those samples both in terms of each sample's DecodeTime and PresentationTime. These two times can differ for codecs that support frame reordering, typically MPEG video codecs such as h.264 and HEVC.
33
34
34
35
Clients append these segments via `appendBuffer()`, which sets an internal `updating` flag, fires the `"updatestart"` event, and subsequently fires the `"updateend"` event and clears the `updating` flag once parsing is complete. The results of the append are visible by querying the `buffered` property, or by querying the `audioTracks`, `videoTracks`, and `textTracks` TrackList objects.
MediaSourcePrivate is an abstract base class which allows <doc:MediaSourceExtensions#MediaSource> to communicate through the platform boundary to a platform-specific implementation of MediaSource.
41
+
MediaSourcePrivate is an abstract base class which allows MediaSource to communicate through the platform boundary to a platform-specific implementation of MediaSource.
41
42
42
43
When the GPU Process is enabled, the MediaSourcePrivate in the WebContent process is typically a [MediaSourcePrivateRemote](https://github.com/WebKit/WebKit/blob/main/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp), which will pass commands and properties across the WebContent/GPU process boundary.
43
44
44
45
For Apple ports, the MediaSourcePrivate is typically a [MediaSourcePrivateAVFObjC](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h).
45
46
46
47
For GStreamer-based ports, the MediaSourcePrivate is typically a [MediaSourcePrivateGStreamer](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h).
47
48
48
-
When running in DumpRenderTree/WebKitTestRunner, a "mock" MediaSourcePrivate can be enabled, and a [MockMediaSourcePrivate](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h) can be created. This is useful for writing platform-independent tests which exercise the platform-independent <doc:MediaSourceExtensions#MediaSource> and <doc:MediaSourceExtensions#SourceBuffer> objects directly.
49
+
When running in DumpRenderTree/WebKitTestRunner, a "mock" MediaSourcePrivate can be enabled, and a [MockMediaSourcePrivate](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h) can be created. This is useful for writing platform-independent tests which exercise the platform-independent MediaSource and SourceBuffer objects directly.
SourceBufferPrivate is a semi-abstract base class which accepts initialization segment and media segment buffers, parse those buffers with platform-specific parsers, and enqueue the resulting samples into platform-specific decoders.
55
-
SourceBufferPrivate is also responsible for caching parsed samples in a <doc:MediaSourceExtensions#SampleMap>.
56
+
SourceBufferPrivate is also responsible for caching parsed samples in a SampleMap.
56
57
57
58
### MediaTime
58
59
@@ -72,8 +73,8 @@ MediaTime offers convenience methods to convert from (`createTimeWithDouble()`)
MediaSample is an abstract base class representing a sample parsed from a media segment. MediaSamples have `presentationTime()`, `decodeTime()`, and `duration()`, each of which are <doc:MediaSourceExtensions#MediaTime> values,
76
-
which are used to order these samples relative to one another in a <doc:MediaSourceExtensions#SampleMap>.
76
+
MediaSample is an abstract base class representing a sample parsed from a media segment. MediaSamples have `presentationTime()`, `decodeTime()`, and `duration()`, each of which are MediaTime values,
77
+
which are used to order these samples relative to one another in a SampleMap.
77
78
For codecs which support frame reordering, `presentationTime()` and `decodeTime()` for each sample may differ.
0 commit comments