LibMedia+LibWeb: Align Media::Track more to the web spec

...giving tracks a kind attribute, and renaming name to label.

Demuxers will need to determine the kind attribute, since the spec for
sourcing tracks requires us to select based on info we don't expose.
This commit is contained in:
Zaggy1024
2026-03-25 15:48:00 -05:00
committed by Gregory Bertilson
parent 9664c11c15
commit b4db8f11c5
Notes: github-actions[bot] 2026-04-01 07:58:37 +00:00
6 changed files with 65 additions and 26 deletions

View File

@@ -1377,18 +1377,6 @@ void HTMLMediaElement::on_audio_track_added(Media::Track const& track)
if (enable == TriState::True)
audio_track->set_enabled(true);
// NB: According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within
// the specified formats.
// WebM:
// - "main": the FlagDefault element is set on the track
// - "translation": not first audio (video) track
// MP4:
// - "main": first audio (video) track
// - "translation": not first audio (video) track
// Though the behavior for WebM is not clear if its first track is not marked with FlagDefault, the idea here seems to be that the preferred
// track should be marked as "main", and the rest should be marked as "translation".
audio_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
// 7. Fire an event named addtrack at this AudioTrackList object, using TrackEvent, with the track attribute initialized to the new AudioTrack object.
TrackEventInit event_init {};
event_init.track = GC::make_root(audio_track);
@@ -1432,9 +1420,6 @@ void HTMLMediaElement::on_video_track_added(Media::Track const& track)
if (enable == TriState::True)
video_track->set_selected(true);
// NB: See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/.
video_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
// 7. Fire an event named addtrack at this VideoTrackList object, using TrackEvent, with the track attribute initialized to the new VideoTrack object.
TrackEventInit event_init {};
event_init.track = GC::make_root(video_track);