media: add MediaStreamTrack getSettings / onEnded / muted surface (W3C)#41
Merged
Conversation
MediaStreamTrack was a bare interface — no getSettings(), no ended/mute events, and stop() was fire-and-forget. Add the read-only W3C surface: - `MediaTrackSettings` snapshot + `getSettings()` (base returns an empty snapshot; AVF capture tracks override with real device width/height/ frameRate or sampleRate/channelCount + deviceId). - `onEnded` (fires once), `muted` + `onMute`/`onUnmute`, with the event machinery + state living on the abstract base so subclasses get them for free via `notifyEnded()` / `setMuted()` hooks. - AVF capture tracks fire `onEnded` from stop() and surface their settings. The constraints surface (getCapabilities / getConstraints / applyConstraints) stays in BACKLOG — it requires reconfiguring the live capture source, a much larger capture-backend change. Tested via an in-memory track (a real capture track is macOS-only): onEnded once + stop idempotency, mute/unmute + muted-vs-enabled, and getSettings. dart analyze clean; full unit suite passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partially addresses the W3C MediaStreamTrack gap from the RFC/W3C divergence audit — the read-only settings + lifecycle-event surface.
Problem
MediaStreamTrackwas a bare interface: nogetSettings(), noended/mute/unmuteevents, andstop()was fire-and-forget.Change
media_stream_track.dart:
MediaTrackSettingssnapshot +getSettings()— base returns an empty snapshot; capture tracks override with real device values. Mirrors the existing flatMediaTrackConstraintsshape.onEnded(fires once),muted+onMute/onUnmute, with the event machinery + state on the abstract base so subclasses get them for free vianotifyEnded()/setMuted()hooks.mutedis the W3C source-driven state, distinct from the app-controlledenabled.avf_capture_track.dart: macOS capture tracks fire
onEndedfromstop()and surface their configureddeviceId/resolution/frameRate (video) or sampleRate/channelCount (audio).Scope
The constraints surface (
getCapabilities/getConstraints/applyConstraints) stays in BACKLOG — it requires reconfiguring the live capture source mid-stream, a much larger capture-backend change.Tests
A real capture track is macOS-only (AVFoundation FFI), so the shared base behaviour is covered via an in-memory track (media_stream_track_test.dart):
onEndedfires once +stop()idempotency, mute/unmute +muted-vs-enabledindependence, andgetSettings.dart analyzeclean; full unit suite (650) passes. Reviewed with/simplify.🤖 Generated with Claude Code