Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 98ff5ead9890f03ba261bc3405d6bf3fa19721c6
https://github.com/WebKit/WebKit/commit/98ff5ead9890f03ba261bc3405d6bf3fa19721c6
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-16 (Wed, 16 Sep 2026)
Changed paths:
A
LayoutTests/media/media-fragments/track-dimension-double-track-expected.txt
A LayoutTests/media/media-fragments/track-dimension-double-track.html
A
LayoutTests/media/media-fragments/track-dimension-invalid-track-expected.txt
A LayoutTests/media/media-fragments/track-dimension-invalid-track.html
A
LayoutTests/media/media-fragments/track-dimension-selects-audio-track-expected.txt
A LayoutTests/media/media-fragments/track-dimension-selects-audio-track.html
M Source/WebCore/html/HTMLMediaElement.cpp
M Source/WebCore/html/HTMLMediaElement.h
M Source/WebCore/html/MediaFragmentURIParser.cpp
M Source/WebCore/html/MediaFragmentURIParser.h
Log Message:
-----------
Add "track" Media Fragments URI dimension (#track=) for <audio>/<video>
https://bugs.webkit.org/show_bug.cgi?id=320349
rdar://183304887
Reviewed by Eric Carlson.
WebKit's MediaFragmentURIParser only implemented the temporal ("t=")
dimension of the Media Fragments URI spec. This adds the track
dimension [1]: a "#track=name" fragment selects the named audio or
video track by id. Unlike "t=", "track=" may be repeated and is not
last-occurrence-wins at the parser level; when more than one
occurrence matches a track of the same kind, the last match is the
one selected.
MediaFragmentURIParser now collects every "track=" value it sees
into m_trackIdentifiers, exposed via a new trackIdentifiers()
accessor, using the same parseTimeFragment() pass that already walks
the fragment list (a second pass would find the list already
cleared).
HTMLMediaElement::prepareMediaFragmentURI() stores the parsed ids and
calls a new selectTracksForFragment(), which looks up each id against
m_audioTracks/m_videoTracks by id, exclusively enables the matched
audio track (disabling every other audio track, since WebKit -
unlike video - otherwise allows multiple audio tracks enabled at
once), and selects the matched video track.
Track lists are not guaranteed to be populated yet at HAVE_METADATA
(AVFoundation and GStreamer both report tracks asynchronously), so
selectTracksForFragment() is also called from
mediaPlayerDidAddAudioTrack()/mediaPlayerDidAddVideoTrack(), making
it safe to invoke repeatedly as tracks trickle in.
[1]
https://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#naming-track
Tests: media/media-fragments/track-dimension-double-track.html
media/media-fragments/track-dimension-invalid-track.html
media/media-fragments/track-dimension-selects-audio-track.html
* LayoutTests/media/media-fragments/track-dimension-double-track-expected.txt:
Added.
* LayoutTests/media/media-fragments/track-dimension-double-track.html: Added.
* LayoutTests/media/media-fragments/track-dimension-invalid-track-expected.txt:
Added.
* LayoutTests/media/media-fragments/track-dimension-invalid-track.html: Added.
*
LayoutTests/media/media-fragments/track-dimension-selects-audio-track-expected.txt:
Added.
* LayoutTests/media/media-fragments/track-dimension-selects-audio-track.html:
Added.
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack):
(WebCore::HTMLMediaElement::mediaPlayerDidAddVideoTrack):
(WebCore::HTMLMediaElement::prepareMediaFragmentURI):
(WebCore::HTMLMediaElement::selectTracksForFragment):
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/html/MediaFragmentURIParser.cpp:
(WebCore::MediaFragmentURIParser::trackIdentifiers):
(WebCore::MediaFragmentURIParser::parseTimeFragment):
* Source/WebCore/html/MediaFragmentURIParser.h:
Canonical link: https://commits.webkit.org/321279@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications