S028: merge s022-mse-proto (MSE: S022, S026-S028) into main
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
80977fa836
892 changed files with 118656 additions and 58 deletions
|
|
@ -72,7 +72,9 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
|
|||
| `tools/smoke.sh tests/smoke/settings.txt` (+ `SMOKE_SIZE=1280x1100`) | every settings section and sub-page dark and light, search results (`nacre://settings/?search=…`), narrow width; `settings-write.txt` (hidden, `SMOKE_SIZE=1280x1100`, fresh outdir) taps controls with selftest `tap x y`, then check `home/.config/nacre-servo/Default/settings.json` (expected values in its header) | now (S019) |
|
||||
| `SMOKE_SIZE=1280x1600 tools/smoke.sh tests/smoke/sliders.txt` | controls hold still (R1-21): Interface size drag (value label while held, applied on release), Contrast live, Style chip pick; `SMOKE_VISIBLE=1 tools/smoke.sh tests/smoke/sliders-visible.txt` the same plus scrolling for the user's window (~772 px). Selftest `press`/`drag`/`release`, `scroll x y dy`; read the PNGs | now (R1-21) |
|
||||
| `python3 tests/smoke/net/server.py &` + `tools/smoke.sh tests/smoke/net-{privacy,adblock,downloads}.txt` | network pass, offline: secure DNS through a local DoH stub (`*.nacre.test` → 127.0.0.1), HTTPS-only + certificate warning, tracking params, ad blocker with a local list, downloads + download manager stubs; the server's `/log` has requests, DNS names, Range headers, manager calls. `cache-restart.txt` with `SMOKE_HOME=<cache.txt outdir>/home`: disk cache. `net-real.txt` needs internet. `@HOME@` in scripts = the throwaway home | now (S007) |
|
||||
| `tools/smoke.sh tests/smoke/mse.txt` | MSE: MediaSource + one SourceBuffer plays chunk-appended fMP4 and WebM (offline); passes only on a build with the MSE patches (branch `s022-mse-proto`, see docs/engine/mse-spike.md) | S022 prototype |
|
||||
| `SMOKE_TIMEOUT=400 tools/smoke.sh tests/smoke/mse.txt` + `tests/smoke/mse-leak-check.sh <outdir>` | MSE: chunk-appended fMP4, WebM and split A/V play; `mse-spec.html` spec cases (attach/detach, duration, buffered/seekable, remove, removeSourceBuffer, changeType, abort, reopen, sequence, leak); the leak check reads nacre.log (offline). `NACRE_DOM_MEDIA_SOURCE_ENABLED=0 tools/smoke.sh tests/smoke/mse-off.txt`: the switch. `SMOKE_TIMEOUT=400 tools/smoke.sh tests/smoke/mse-player.txt`: player integration (attach without blocking, seeks, rate, ended, decode error, garbage append, script-thread gaps < 1 s; `?only=<case>` in the page URL for one case). `tools/gst-mse.sh test`: patched gst_mse + C tests. DESIGN.md "Media and Media Source Extensions" | S022, S027, S028 |
|
||||
| `tools/gst-mse.sh [test]` | builds Nacre's patched gst_mse library and `mse` plugin (vendor/gst-mse) into `target/gst-mse/` (needed before running a build that uses MSE); `test` also runs the C tests in `tests/gst-mse/` | now (S026, branch s022-mse-proto) |
|
||||
| `tools/wpt-mse.sh [outdir] [file ...]` | WPT media-source subset (60 files) in a hidden run; first run sparse-clones WPT at a pinned commit into `target/wpt` (needs internet once); prints subtest pass counts, results in `<outdir>/wpt/results.json`; ~45 min | S027 |
|
||||
| `tools/smoke.sh tests/smoke/privacy-mode.txt` (+ `SMOKE_ARGS=--incognito … privacy-incognito.txt`) | privacy mode: `pages/fingerprint.html` read off/on, `fp-off.json`/`fp-on.json` + shots (offline); `privacy-net.txt` (needs `tests/smoke/net/server.py`) frame cookies, per-site pause, Accept-Language; `SMOKE_TIMEOUT=700 … coveryourtracks.txt` EFF's test off/on (internet, direct). Selftest `save <name> <js>` writes a JS string result to `<name>.json`; `SMOKE_ARGS` passes browser arguments | now (S024) |
|
||||
| `python tools/icons.py` | rebuilds the icon font subset and `src/ui/icons.rs` from `tools/icons.txt` (needs fontTools and Arch's ttf-material-symbols-variable) | now (S015) |
|
||||
| appimagetool, wine + Inno Setup, VM "Windows 10" | packaging and Windows checks | see the user's global CLAUDE.md "Building" |
|
||||
|
|
|
|||
32
Cargo.lock
generated
32
Cargo.lock
generated
|
|
@ -3260,6 +3260,29 @@ dependencies = [
|
|||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-mse"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7ca9904b80a0688047407ee2ef6373645e0ecf1f8b6a185b55fce6aec106a97"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gstreamer",
|
||||
"gstreamer-mse-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-mse-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38a61799981f19ed14d3761dc88896f824834d8a2560fa746d219777b20e5f86"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-play"
|
||||
version = "0.25.0"
|
||||
|
|
@ -8180,8 +8203,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cb3ee4f036fb8fd88384808d59bc9ae1e0f2231871907d646aea5f446c67fe5"
|
||||
dependencies = [
|
||||
"servo-base",
|
||||
"servo-media-audio",
|
||||
|
|
@ -8246,8 +8267,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81d297e26348b43aaea9cc09cafe125ae95b4a2fb1e943b5badd748694b22db6"
|
||||
dependencies = [
|
||||
"byte-slice-cast",
|
||||
"data-url",
|
||||
|
|
@ -8257,6 +8276,7 @@ dependencies = [
|
|||
"gstreamer-app",
|
||||
"gstreamer-audio",
|
||||
"gstreamer-base",
|
||||
"gstreamer-mse",
|
||||
"gstreamer-play",
|
||||
"gstreamer-sdp",
|
||||
"gstreamer-sys",
|
||||
|
|
@ -8343,8 +8363,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-player"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "730258a7bf65bf70fb857869fdf97872a8f5bf7a0484c3924ea364c23527e426"
|
||||
dependencies = [
|
||||
"malloc_size_of_derive",
|
||||
"serde",
|
||||
|
|
@ -8818,8 +8836,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-script-bindings"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b850dc804d54cd052dbc5cd63b2772a74d9472f12871d5a5ef3b4fae5194dfbd"
|
||||
dependencies = [
|
||||
"atomic_refcell",
|
||||
"bitflags 2.13.2",
|
||||
|
|
|
|||
|
|
@ -106,3 +106,7 @@ opt-level = 2
|
|||
epaint = { path = "vendor/epaint" }
|
||||
servo-net = { path = "vendor/servo-net" }
|
||||
servo-script = { path = "vendor/servo-script" }
|
||||
servo-script-bindings = { path = "vendor/servo-script-bindings" }
|
||||
servo-media = { path = "vendor/servo-media" }
|
||||
servo-media-player = { path = "vendor/servo-media-player" }
|
||||
servo-media-gstreamer = { path = "vendor/servo-media-gstreamer" }
|
||||
|
|
|
|||
|
|
@ -20,15 +20,15 @@ work happens on main.
|
|||
- `docs/DESIGN.md` media section and "Engine limits"
|
||||
|
||||
## Steps
|
||||
- [ ] `git merge main` into the branch; build; mse smoke green
|
||||
- [ ] Attach without blocking the script thread: setup for `StreamType::MediaSource` returns at once; readiness
|
||||
- [x] `git merge main` into the branch; build; mse smoke green
|
||||
- [x] Attach without blocking the script thread: setup for `StreamType::MediaSource` returns at once; readiness
|
||||
arrives as a player event; test: a page appends while the player starts and the `js` probe answers in <1 s
|
||||
- [ ] Seeking: `currentTime =` inside and outside buffered ranges (waits for an append, then `seeked`); playback
|
||||
- [x] Seeking: `currentTime =` inside and outside buffered ranges (waits for an append, then `seeked`); playback
|
||||
rate; `ended` after endOfStream; smoke asserts each
|
||||
- [ ] Errors: decode error → `MediaError` + `sourceended`/error events; append of garbage → SourceBuffer `error`
|
||||
- [ ] Codec table: `isTypeSupported` consistent with `canPlayType` (registry scanner learns opus/webm, vp09.*, av01
|
||||
- [x] Errors: decode error → `MediaError` + `sourceended`/error events; append of garbage → SourceBuffer `error`
|
||||
- [x] Codec table: `isTypeSupported` consistent with `canPlayType` (registry scanner learns opus/webm, vp09.*, av01
|
||||
when dav1d is installed); unit test for the mime/codec mapping
|
||||
- [ ] Full smoke set green on the branch (launch, basics, input, chrome, keys, mse, settings; heavy-web where
|
||||
- [x] Full smoke set green on the branch (launch, basics, input, chrome, keys, mse, settings; heavy-web where
|
||||
the network allows) and `nice cargo test --release -j 2`
|
||||
- [ ] Merge `s022-mse-proto` into main; build main; mse smoke green on main; remove the worktree
|
||||
- [ ] DESIGN.md: media section (MSE path, vendored crates, patched gst_mse); "Engine limits": drop the MSE line,
|
||||
|
|
|
|||
8
build.rs
Normal file
8
build.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Nacre's patched libgstmse-1.0.so.0 (tools/gst-mse.sh) must win over the system copy: the binary's RUNPATH
|
||||
// looks next to it first (`lib/`, the release layout), then in a dev tree's `target/gst-mse/lib`.
|
||||
fn main() {
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("linux") {
|
||||
println!("cargo:rustc-link-arg-bins=-Wl,-rpath,$ORIGIN/lib:$ORIGIN/../gst-mse/lib");
|
||||
}
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
|
@ -139,8 +139,6 @@ picture-in-picture, extensions, password capture, printing.
|
|||
- Chrome extensions: not possible. Replaced by user scripts and user styles (Apps -> Scripts).
|
||||
- Hardware acceleration switch: Servo needs GL; "Off" selects software GL (LIBGL_ALWAYS_SOFTWARE) on next start.
|
||||
- Printing: "Save page as PDF/PNG" through a full-page screenshot.
|
||||
- Media Source Extensions: Servo 0.7 has no `MediaSource`, so YouTube's player says "Your browser can't play this
|
||||
video" (and PiP finds no video). Plain `<video>` files (WebM, MP4 through GStreamer) play.
|
||||
- Inline `<svg>` is painted from its own markup, so `currentColor` misses the CSS colour; `SVG_COLOR_JS`
|
||||
(`inject.rs`) copies each icon's computed colour into its `color` attribute (hover colours not followed).
|
||||
- Fingerprinting: Servo has no IndexedDB, plugins list, WebRTC or DynamicsCompressorNode, and its user agent is a
|
||||
|
|
@ -173,6 +171,7 @@ picture-in-picture, extensions, password capture, printing.
|
|||
| File, function | What and why | Re-check |
|
||||
|---|---|---|
|
||||
| `event_loop/timers.rs` `OneshotTimers::fire_timer`, `JsTimerTask::invoke` | due timers wait in a `RootedTraceableBox<VecDeque>` instead of a plain `Vec`, and the running timer's callback is rooted: a GC inside one callback swept the functions of the timers still waiting (SIGSEGV in `GlobalScope::from_object`, R5-01) | `crash-adblock.txt` |
|
||||
| `dom/media/`, `dom/html/embedded_content/htmlmediaelement.rs`, `dom/globalscope`, `dom/url` and more | Media Source Extensions (S022-S028), see "Media and Media Source Extensions" below; `grep -rn "Nacre" vendor/servo-script` lists them | `mse.txt`, `mse-player.txt` |
|
||||
|
||||
Third-party rule (S023): a request is third-party when its host's site (registrable domain, eTLD+1; an IP address
|
||||
or a single-label host stands for itself) differs from the top-level site of its webview. Scheme and port don't
|
||||
|
|
@ -184,6 +183,22 @@ checked like any subresource. `document.cookie` and the Cookie Store API in a th
|
|||
webview id (servo-script isn't vendored); Nacre's `FRAME_COOKIE_JS` (`inject.rs`, S024) empties them in a frame
|
||||
whose top page is another site.
|
||||
|
||||
## Media and Media Source Extensions (S022-S028)
|
||||
|
||||
Plain `<video>`/`<audio>` play through servo-media's GStreamer backend (playbin3 via GstPlay). Servo 0.7 has no
|
||||
`MediaSource`; Nacre adds it in vendored crates (`[patch.crates-io]`, every change marked `Nacre patch`):
|
||||
|
||||
| Crate | What |
|
||||
|---|---|
|
||||
| `vendor/servo-script-bindings` | `MediaSource`, `SourceBuffer`, `SourceBufferList` WebIDL; `buffered` is `[Throws]` (`GetBuffered`, `cx` in Bindings.conf) |
|
||||
| `vendor/servo-script` `dom/media/` | the DOM objects to spec: attach/detach, events through tasks, buffered/seekable, abort, changeType, sequence mode, object URLs per global. Ready state under MSE comes from buffered ranges vs. current time (`buffered_ready_state`), metadata (`loadedmetadata`) once every SourceBuffer has an init segment; player-driven HAVE_ENOUGH bumps are skipped |
|
||||
| `vendor/servo-media-player` `mse.rs` | backend traits, `MseEvent`, pure helpers (ready state, track counts from codecs, type parsing) with unit tests |
|
||||
| `vendor/servo-media-gstreamer` | `mse.rs` backend over gst_mse; `ByteStreamCheck` walks MP4 boxes / WebM EBML to find init segments and reject garbage (gst_mse only reports an init segment once frames arrive). `player.rs` setup returns at once for a MediaSource (never blocks the script thread); msesrc `ready-state` -> `MseEvent::Metadata`. `registry_scanner.rs` codec table (`isTypeSupported` = `canPlayType`) |
|
||||
| `vendor/gst-mse` | patched gst-plugins-bad 1.28.9 MSE library + msesrc, built by `tools/gst-mse.sh` into `target/gst-mse`, loaded ahead of the system copy; patches in `docs/engine/gst-mse-patches.md`, diff in `nacre.patch` |
|
||||
|
||||
Checks: `mse.txt` (spec cases + leak check), `mse-player.txt` (attach, seeks, rate, ended, errors, script-thread
|
||||
gaps), `tools/gst-mse.sh test` (C tests), `tools/wpt-mse.sh` (WPT media-source). Background: `docs/engine/mse-spike.md`.
|
||||
|
||||
## Cookies at rest (S025)
|
||||
|
||||
`store::cookies` keeps Servo's public cookie jar in `<data>/cookies.bin`: the jar's JSON (Servo's own
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ Media button (when playing/always/never), player flyout (art, seek, controls, mu
|
|||
buttons, paused state): verified S009 (integ-discord.txt + integ-discord-check.sh, fake IPC server): handshake with the Settings app ID, SET_ACTIVITY with title, artist, progress bar, button, paused state and a browsing activity; the media state comes from the page's Media Session. Fixed R4-09: the large image falls back to the origin's /favicon.ico when the page's favicon is data:, http: or long. Not checked: real Discord, per-site IDs, display type, the media flyout, visualizer, mute, PiP (S005). Picture in picture (own always-on-top window; reloads the page in a web view
|
||||
of its own and seeks the video, page state lost, D-008): verified on Xvfb (S005). Protected content (Widevine): engine
|
||||
limit, shown as unavailable.
|
||||
Media Source Extensions (`MediaSource`, `SourceBuffer`; YouTube-style players): S026-S028, vendored crates and patched
|
||||
gst_mse (DESIGN.md "Media and Media Source Extensions"); verified S028 (mse.txt, mse-player.txt: attach without
|
||||
blocking, seek inside/outside buffered, rate, ended, decode error, garbage append; WPT media-source, see PROGRESS).
|
||||
|
||||
## Passwords and autofill
|
||||
Encrypted vault (device key or master password, auto-lock, re-ask before showing), save prompt, autofill, strong
|
||||
|
|
|
|||
|
|
@ -329,6 +329,12 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
|
|||
- Reruns (resumed session): crash-adblock 3/3, net-adblock, launch green (visible); heavy-web ×2 no SIGSEGV and no core, both reach `status done`; their failed asserts are YouTube search/playback/PiP (main has no MSE, S028). `cargo test` 70 green.
|
||||
- S028 merge: the MSE branch also vendors `vendor/servo-script`; take the branch's files and re-apply the two `Nacre patch (S031)` hunks in `event_loop/timers.rs` (the branch's timers.rs is the pristine 0.7.0 file).
|
||||
|
||||
## S028 — MSE player integration (WIP, stopped for the weekly limit, 2026-11-12, branch s022-mse-proto)
|
||||
- Done: main merged in (mse smoke green). Attach doesn't block the script thread (max stall 35 ms, was ~1 s). loadedmetadata after the init segment (own MP4/WebM byte-stream check; gst_mse reports it only with frames), readyState from buffered at currentTime, byte-stream append errors (garbage / media before init), `buffered` throws once removed, failure steps detach the MediaSource, codec table (vp09, Opus/fLaC, vorbis, hevc). New `tests/smoke/mse-player.txt`: 7/9 cases.
|
||||
- Next: two gst_mse C fixes: (1) msesrc sends no EOS after endOfStream (S027's abort patch dropped it), so no `ended`: set EOS on the track buffers at end of stream, clear on reopen; (2) `on_duration_changed` shrinks a page-set duration (breaks seek past buffered): only raise it. Then cargo test (new unit tests never run), WPT rerun (baseline 239/407), full smoke set, DESIGN/FEATURES, merge.
|
||||
- Merge note: main vendors servo-script too (S031, 0ecfd0f): take the branch's servo-script files and re-apply the two `Nacre patch (S031)` hunks in event_loop/timers.rs.
|
||||
- State (stopped by orchestrator, 2026-11-12): gst_mse patches 10-11 (EOS at endOfStream, duration only grows) committed; mse-player 9/9, cargo test 70 + media crate tests 11 green; DESIGN/FEATURES/CLAUDE docs done; plan boxes 1-5 ticked. origin/main merged into the branch (servo-script = branch files + main's S031 timers.rs), merge NOT built. Smokes on the pre-merge binary: launch, basics, input, chrome, keys green; mse.txt fails `reopen` (mse-spec.html, regression from patch 10's clear-EOS on reopen? check first); settings, mse-player rerun, heavy-web, WPT not run. Next: fix `reopen`, build the merged branch, rerun smokes + crash-adblock + WPT, then merge into main.
|
||||
|
||||
## Later
|
||||
- Turnstile widget paints as a black half-disc (Servo painting of its iframe/shadow DOM, S006 site doctor).
|
||||
- Google sign-in past the email step: press Next with a real account, by the user (S006).
|
||||
|
|
|
|||
40
docs/S027-handoff.md
Normal file
40
docs/S027-handoff.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# S027 hand-over (MSE DOM to spec) — 2026-11-12
|
||||
|
||||
Branch `s022-mse-proto`, worktree ~/Projects/Nacre-s022 (own target/). Plan: Plans/05 Engine/S027-mse-dom-spec.md (on main).
|
||||
|
||||
## Done (committed on the branch)
|
||||
- DOM rewrite: vendor/servo-script/dom/media/{mediasource,sourcebuffer,sourcebufferlist}.rs. DOM owns spec state; all events
|
||||
queued as media element tasks; attach/detach (htmlmediaelement.rs step 7.3, resource_fetch_algorithm), duration change
|
||||
(element duration from the MediaSource), HTMLMediaElement.buffered/seekable from MediaSource (pure fns + 5 tests in
|
||||
vendor/servo-media-player/mse.rs), activeSourceBuffers from gst active list, removeSourceBuffer, abort, changeType (same
|
||||
container only), sequence mode, live seekable range, endOfStream(error) -> element error steps.
|
||||
- Object URLs: per-global map GlobalScope::media_source_urls, revoke removes one task later, cleared on unload.
|
||||
- Weak event sink: thread-local id -> WeakRef<MediaSource> (MediaSource weakReferenceable). Debug counter: nacre.log
|
||||
"MSE: MediaSource <id> created/freed".
|
||||
- Pref: [Func="MediaSource::enabled"] reads NACRE_DOM_MEDIA_SOURCE_ENABLED (D-017 on main explains why not servo-config).
|
||||
- isTypeSupported: servo_media_player::mse::is_type_well_formed (registry rules) before gst + decoder check.
|
||||
- gst_mse patches 5-9 (vendor/gst-mse, nacre.patch regenerated, docs/engine/gst-mse-patches.md): remove() real, abort()
|
||||
resets parser, reset drops old appsinks (crash), track_feeds keyed by id, appendWindowStart check inverted.
|
||||
C tests tests/gst-mse/mse-fixes.c 5/5 (tools/gst-mse.sh test).
|
||||
- Smoke: tests/smoke/mse.txt (+ pages/mse-spec.html, 11 cases) green; tests/smoke/mse-leak-check.sh ok (MS freed in run);
|
||||
tests/smoke/mse-off.txt green with NACRE_DOM_MEDIA_SOURCE_ENABLED=0. Run mse.txt with SMOKE_TIMEOUT=400.
|
||||
- WPT runner: tools/wpt-mse.sh (+ tests/wpt-mse/), pinned WPT in target/wpt.
|
||||
|
||||
## WPT
|
||||
- Run 1 (before validator/endOfStream error): 246/407 subtests in 60 files.
|
||||
- Run 2 (current build) was running at hand-over; output: /tmp/claude-1000/-home-astar76-Projects-Nacre/9e6752f4-4824-467b-b5b7-80b90b1ca98b/scratchpad/wpt4.out, results /tmp/claude-1000/-home-astar76-Projects-Nacre/9e6752f4-4824-467b-b5b7-80b90b1ca98b/scratchpad/wpt4/wpt/results.json.
|
||||
If gone, rerun: tools/wpt-mse.sh (~45 min). Target in plan: >= 293.
|
||||
|
||||
## Not done / next steps
|
||||
1. Get run-2 count; record in PROGRESS (main). Tick plan box 7 (smoke) and 8 (PROGRESS, INDEX, push) + tracker S027.
|
||||
2. Biggest remaining WPT gaps are player integration (S028): loadedmetadata/HAVE_METADATA after init segment only
|
||||
(duration-boundaryconditions 0/13 time out, play/seek tests 0/1), changetype across containers (gst can't, 1/19 x3),
|
||||
errors before init segment, buffered after removeSourceBuffer should throw ([Throws] attr), same TimeRanges object.
|
||||
3. Opus/fLaC in mp4 unsupported (gst/decoder), 4 WPT subtests.
|
||||
|
||||
## Gotchas
|
||||
- weakReferenceable structs can't impl Drop (codegen does); counter lives in a LiveCount field.
|
||||
- Servo runs no FinalizationRegistry callbacks / WeakRef clearing: leak check must use the log.
|
||||
- WPT tests call alert() on 404s: tests/wpt-mse/testharnessreport.js stubs it; WPT media/ dir needed.
|
||||
- After abort/changeType the next append must start with an init segment (gst reset forgets it).
|
||||
- Negative timestampOffset clamps to 0 (GstClockTime).
|
||||
177
docs/engine/gst-mse-patches.md
Normal file
177
docs/engine/gst-mse-patches.md
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
# gst_mse patches (S026)
|
||||
|
||||
Nacre carries its own build of GStreamer's MSE library (`libgstmse-1.0`) and plugin (`mse`, element `msesrc`) from
|
||||
gst-plugins-bad **1.28.9** (`vendor/gst-mse/`, LGPL-2.1, `COPYING` kept). Every change is marked `Nacre patch` in the
|
||||
source; `vendor/gst-mse/nacre.patch` is the whole diff against the Debian 1.28.9-1 sources. This page is the write-up
|
||||
for upstream. **No merge request has been opened** (that needs the user's OK).
|
||||
|
||||
Build and test: `tools/gst-mse.sh` (library and plugin into `target/gst-mse/`), `tools/gst-mse.sh test` (C tests in
|
||||
`tests/gst-mse/mse-fixes.c`). Every test passes on the patched build; the tests for 1–3 fail on the system 1.28.9
|
||||
(`LD_LIBRARY_PATH=/usr/lib`, no `GST_PLUGIN_PATH`).
|
||||
|
||||
## 1. update-end fires before the append is parsed
|
||||
|
||||
**What.** `append_to_buffer_task_func` (gstsourcebuffer.c) calls `gst_append_pipeline_append()` and signals
|
||||
`on-update` / `on-update-end` right after. `gst_append_pipeline_append()` only queues the buffer and an
|
||||
`end-of-append` event in appsrc. The samples reach the track buffers later, when the append pipeline's background
|
||||
task handles the `end-of-append` bus message (`consume_all_samples`).
|
||||
|
||||
**Why it matters.** Players read `SourceBuffer.buffered` at `updateend` to decide what to fetch next. With 1.28.9 it
|
||||
is still empty (or one append behind), so a player either fetches the same range again or stalls. Spec: the
|
||||
"segment parser loop" runs the coded frame processing before "the buffer append" algorithm fires `update` and
|
||||
`updateend`.
|
||||
|
||||
**Fix.** `GstAppendPipeline` counts appends sent and appends done (`appends_sent`, `appends_done`, a mutex and a
|
||||
cond). `gst_append_pipeline_append()` takes a ticket and waits until the background task has handled that append's
|
||||
`end-of-append` (after `consume_all_samples`), or the pipeline shut down, aborted or failed (`finish_appends(all)`),
|
||||
or 10 s passed (a warning; a stuck parser must not leave the buffer updating forever). The append task drops the
|
||||
source buffer's object lock while it waits, because the new-sample callback takes that lock; `updating` stays set, so
|
||||
no second append can start, and the task re-checks `is_removed` after re-locking.
|
||||
|
||||
**Test.** `/mse/update-end-after-parse`: append a whole WebM clip (init + media) in one call; at the first
|
||||
update-end, `gst_source_buffer_get_buffered()` must be non-empty. System 1.28.9: 0 ranges.
|
||||
|
||||
## 2. update / update-end every second while idle
|
||||
|
||||
**What.** The append task waits for pending data with a 1 s timeout. On timeout it took the "no pending data" branch
|
||||
and called `append_successful_unlocked()`, which schedules `on-update` and `on-update-end`.
|
||||
|
||||
**Why it matters.** A page sees `update`/`updateend` without having appended anything, every second. Players that
|
||||
chain the next append on `updateend` append twice, or hit `InvalidStateError` because they think the buffer is free.
|
||||
|
||||
**Fix.** The "no pending data" branch returns without signalling.
|
||||
|
||||
**Test.** `/mse/no-idle-updates`: no signals during 3 s idle; one append gives exactly one `update` and one
|
||||
`update-end`; 3 s more idle add none. System 1.28.9: 3 updates in the first 3 s.
|
||||
|
||||
## 3. msesrc exposes streams before every SourceBuffer has an init segment
|
||||
|
||||
**What.** `gst_mse_src_emit_streams()` (gstmsesrc.c) runs on every SourceBuffer's first init segment and exposes the
|
||||
tracks it knows right away. `update_ready_state_for_init_segment()` checks whether every buffer has an init segment,
|
||||
but only to set HAVE_METADATA, and its "not yet" path returned with `media_source_lock` still held.
|
||||
|
||||
**Why it matters.** Sites with separate audio and video SourceBuffers (YouTube always) append one init segment before
|
||||
the other. msesrc exposed the first buffer's track alone, playbin prerolled on it and never took the second, so the
|
||||
element stayed at HAVE_NOTHING. The leaked mutex then deadlocked the ready-state task and every later caller of
|
||||
`MEDIA_SOURCE_LOCK` (attach, detach, seek). Spec: "init segment received" step 5 moves to HAVE_METADATA only once
|
||||
every SourceBuffer in `activeSourceBuffers` has received one; WebKit's GStreamer MSE also waits for all of them.
|
||||
|
||||
**Fix.** `update_ready_state_for_init_segment()` returns whether every buffer has its init segment (TRUE once past
|
||||
HAVE_NOTHING, or when detached), always unlocks, and releases the buffer list it was leaking. `emit_streams()`
|
||||
returns early, exposing nothing, until it is TRUE. Each call passes all tracks of all buffers, so the last init
|
||||
segment exposes every stream at once with one stream collection.
|
||||
|
||||
**Test.** `/mse/split-audio-video`: playbin3 on `mse://`, a video-only WebM (VP9) SourceBuffer and an audio-only
|
||||
fMP4 (AAC) SourceBuffer; the video clip is appended, then 2 s later the audio. During those 2 s msesrc has
|
||||
`n-video = n-audio = 0` and `ready-state = HAVE_NOTHING`; after the audio append both are 1, and playback passes
|
||||
1 s. System 1.28.9: `n-video = 1` after the video append alone.
|
||||
|
||||
## 4. msesrc pad task gives up when its peer is not active yet
|
||||
|
||||
**What.** `pad_task` (gstmsesrc.c) waits until its pad is linked, pops a sample from the track and pushes it. Under
|
||||
playbin3, urisourcebin links each new msesrc pad to a fresh typefind element and only then activates that element,
|
||||
and linking resumes the pad task. A push in that gap returns `GST_FLOW_FLUSHING`; the task treated it as a flush,
|
||||
paused for good, and the popped sample was lost. That stream never started, playbin3 waited for it, and the element
|
||||
stayed at HAVE_NOTHING. Which stream lost depends on the order of the streams hash table and on timing: about one
|
||||
start in four in Nacre's split smoke page, one in eight of the C test under CPU load, none when idle.
|
||||
|
||||
**Why it matters.** It hits every multi-stream MediaSource, but split audio/video (patch 3, YouTube) makes it common,
|
||||
because both pads appear at once.
|
||||
|
||||
**Fix.** Before taking data from the track, the task checks whether the peer pad is still flushing (not activated);
|
||||
if so it sleeps 10 ms and returns, so the task loops until the peer is ready. Sticky events pushed meanwhile stay
|
||||
on the pad and go out with the first buffer.
|
||||
|
||||
**Test.** `/mse/split-audio-video` runs its scenario in `SPLIT_ROUNDS` fresh processes (default 4) with playbin3 set up
|
||||
like Servo's player (appsink sinks, `download` flag, 500 MiB `buffer-size`). The race needs load to show there (2 of
|
||||
15 runs failed while a smoke loop ran, 0 of 30 on an idle machine), so the evidence is Nacre's
|
||||
`tests/smoke/mse.txt` `?split` page: 10 of 10 played with the patch, against 6 stalls in 23 runs before it.
|
||||
|
||||
## 5. remove() is a stub (S027)
|
||||
|
||||
**What.** `gst_source_buffer_remove()` returned TRUE and removed nothing, so `buffered` never shrank and players that
|
||||
trim old media (YouTube does, to stay under quota) kept growing the buffer until eviction.
|
||||
|
||||
**Fix.** It removes, synchronously, every coded frame group (key frame to key frame) that lies inside `[start, end)`
|
||||
from every track buffer (`gst_media_source_track_buffer_remove_range`, the helper eviction already uses), then
|
||||
recomputes the size. A group that only overlaps the range stays, so no kept frame loses its key frame; the spec removes
|
||||
partial groups up to the next random access point, so Nacre keeps slightly more than a spec browser. Nacre's backend
|
||||
still reports `update`/`updateend` itself (the library signals nothing for a removal). **Test:** `/mse/remove`.
|
||||
|
||||
## 6. abort() breaks the source buffer (S027)
|
||||
|
||||
**What.** `gst_source_buffer_abort()` sent end-of-stream into the append pipeline's appsrc. Every later append then
|
||||
failed, so a page that aborted (on a seek, a quality switch, `changeType`) could never append again.
|
||||
|
||||
**Fix.** abort drops the pending data; if an append is inside the pipeline it waits for it (new `appending` /
|
||||
`abort_requested` flags and `append_done_cond`; the append task discards that append's result and signals nothing)
|
||||
and then runs the spec's "reset parser state" (`reset_parser_state_unlocked`, as the append error path does) and
|
||||
clears `updating`. The next append must start with an initialization segment (the reset forgets the old one; the spec
|
||||
keeps it). **Test:** `/mse/abort-then-append`.
|
||||
|
||||
## 7. Parser reset leaves the old appsinks in the append pipeline (S027)
|
||||
|
||||
**What.** `gst_append_pipeline_reset()` emptied its track list but left the tracks' appsinks in the bin. The next
|
||||
initialization segment named its appsink `video-0` again, `gst_bin_add()` refused the duplicate and freed it, and
|
||||
`add_track()` used the freed element: a crash on the first append after any reset (abort, changeType, append error).
|
||||
|
||||
**Fix.** The reset sets each old appsink to NULL and removes it from the bin first. **Test:** `/mse/abort-then-append`
|
||||
(abort after the init segment was parsed, then append; crashed before).
|
||||
|
||||
## 8. Track feeds keyed by object, not by track id (S027)
|
||||
|
||||
**What.** After a reset, the new initialization segment brings new `GstMediaSourceTrack` objects with the same ids.
|
||||
`track_buffers` is keyed by id and finds the existing buffer, but `track_feeds` used `g_direct_hash`, so the new
|
||||
samples hit `get_track_feed_unlocked: assertion ... failed` (fatal in the tests).
|
||||
|
||||
**Fix.** `track_feeds` uses the same id hash and equality as `track_buffers`, so samples after a reset reach the
|
||||
existing feeds and msesrc's streams. **Test:** `/mse/abort-then-append`.
|
||||
|
||||
## 9. appendWindowStart refuses every valid value (S027)
|
||||
|
||||
**What.** `gst_source_buffer_set_append_window_start()` failed when `start <= append_window_end`, the inverse of the
|
||||
spec's check, so any start below the end (all valid ones) gave a TYPE error. `SourceBuffer.abort()` resets the window
|
||||
to `0..+inf`, so it failed too.
|
||||
|
||||
**Fix.** The check is `start >= append_window_end` (an end of `GST_CLOCK_TIME_NONE` is +infinity in the unsigned
|
||||
compare). **Test:** `/mse/remove` sets the window.
|
||||
|
||||
## 10. endOfStream never reaches msesrc (S028)
|
||||
|
||||
**What.** Upstream `gst_media_source_end_of_stream()` relied on `abort_all_source_buffers()` pushing EOS into each
|
||||
appsrc, which then reached the track buffers and msesrc. Patch 6 made abort drop data instead, so after
|
||||
`endOfStream()` msesrc never sent EOS and the element never fired `ended`.
|
||||
|
||||
**Fix.** End of stream (no error) marks every track buffer of every source buffer EOS (`gst_source_buffer_set_eos`,
|
||||
under TRACKS_LOCK); `gst_media_source_open()` clears it again when the state was ENDED (a new append reopens the
|
||||
source; new `gst_media_source_track_buffer_clear_eos`). `gst_source_buffer_append_buffer()` drops its own TRACKS_LOCK
|
||||
around that reopen (it held it, and the clear takes it again: a deadlock that hung the script thread). **Test:**
|
||||
mse-player smoke case `ended`; C test `/mse/reopen-append`.
|
||||
|
||||
## 11. Coded frames shrink a duration the page set (S028)
|
||||
|
||||
**What.** `on_duration_changed()` set the duration to the highest buffered end whenever buffers arrived, so a page
|
||||
that set `duration = 5` and appended the first second got its duration cut back to 1.0; the element then clamped a
|
||||
seek to 3.5 back to 1.0. The spec only raises the duration from coded frames.
|
||||
|
||||
**Fix.** The handler returns when the current duration is valid and not below the new maximum. **Test:** mse-player
|
||||
smoke case `seekUnbuffered`.
|
||||
|
||||
## 12. Coded frames don't raise the duration (S028)
|
||||
|
||||
**What.** `on_duration_changed()` took only the append pipeline's (demuxer's) duration. For fragmented MP4 with an
|
||||
empty `moov` that is 0 or the first fragment's length, so after appending a 5 s clip `MediaSource.duration` read 1.0
|
||||
(Chromium: 5.08), and nothing re-ran the handler after later fragments.
|
||||
|
||||
**Fix.** The handler also takes each source buffer's highest buffered end, and every successful append calls it
|
||||
(outside the source buffer's object lock, before update-end). **Test:** C test `/mse/duration-from-frames`.
|
||||
**Seen:** `/mse/split-audio-video` failed its final ready-state check (HAVE_METADATA after playing past 1 s) 2 times
|
||||
in ~70 rounds after this patch, 0 in 24 before (not conclusive). msesrc reads its position from a pad's
|
||||
`segment.position` (the feed's push position, not playback); Nacre's DOM computes readyState itself.
|
||||
|
||||
## Found, not fixed here
|
||||
|
||||
- `gst_source_buffer_change_content_type()` always fails (NotSupported). Nacre's backend accepts a change within the
|
||||
same container (parser reset, the next init segment may bring other codecs) and refuses another container.
|
||||
- `timestampOffset` is a `GstClockTime` in the API: negative offsets clamp to 0.
|
||||
- Duration: `gst_media_source_end_of_stream()` doesn't apply the spec's duration change; Nacre's DOM does.
|
||||
29
src/main.rs
29
src/main.rs
|
|
@ -99,6 +99,34 @@ fn choose_gl(settings: &store::settings::Settings) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Points GStreamer at Nacre's patched MSE plugin (`msesrc`, docs/engine/gst-mse-patches.md) ahead of the
|
||||
/// system one. The matching library, libgstmse-1.0.so.0, is found through the binary's RUNPATH (build.rs).
|
||||
/// Release layout: `<exe dir>/lib/gstreamer-1.0`; a dev build: `target/gst-mse/gstreamer-1.0` (tools/gst-mse.sh).
|
||||
fn use_own_gst_mse() {
|
||||
let Some(dir) = std::env::current_exe().ok().and_then(|exe| exe.parent().map(|dir| dir.to_path_buf())) else {
|
||||
return;
|
||||
};
|
||||
let Some(plugins) = [dir.join("lib/gstreamer-1.0"), dir.join("../gst-mse/gstreamer-1.0")]
|
||||
.into_iter()
|
||||
.find(|plugins| plugins.join(if cfg!(windows) { "gstmse.dll" } else { "libgstmse.so" }).is_file())
|
||||
else {
|
||||
eprintln!("nacre: gst-mse: no patched mse plugin next to the binary, using the system one");
|
||||
return;
|
||||
};
|
||||
let mut paths = vec![plugins.clone()];
|
||||
paths.extend(std::env::var_os("GST_PLUGIN_PATH").iter().flat_map(std::env::split_paths));
|
||||
if let Ok(value) = std::env::join_paths(paths) {
|
||||
// SAFETY: called on the main thread before any other thread exists.
|
||||
unsafe { std::env::set_var("GST_PLUGIN_PATH", value) };
|
||||
}
|
||||
let library = std::fs::read_to_string("/proc/self/maps")
|
||||
.unwrap_or_default()
|
||||
.lines()
|
||||
.find_map(|line| line.split_whitespace().nth(5).filter(|path| path.contains("libgstmse-1.0")).map(str::to_owned))
|
||||
.unwrap_or_else(|| "not loaded".into());
|
||||
eprintln!("nacre: gst-mse: plugin {}, library {library}", plugins.display());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let launch = match parse_args() {
|
||||
Ok(launch) => launch,
|
||||
|
|
@ -113,6 +141,7 @@ fn main() {
|
|||
return;
|
||||
}
|
||||
choose_gl(&store::settings::Settings::load(&paths.settings()));
|
||||
use_own_gst_mse();
|
||||
let event_loop = match EventLoop::<AppEvent>::with_user_event().build() {
|
||||
Ok(event_loop) => event_loop,
|
||||
Err(error) => {
|
||||
|
|
|
|||
BIN
tests/gst-mse/data/audio-aac.mp4
Normal file
BIN
tests/gst-mse/data/audio-aac.mp4
Normal file
Binary file not shown.
BIN
tests/gst-mse/data/video-vp9.webm
Normal file
BIN
tests/gst-mse/data/video-vp9.webm
Normal file
Binary file not shown.
572
tests/gst-mse/mse-fixes.c
Normal file
572
tests/gst-mse/mse-fixes.c
Normal file
|
|
@ -0,0 +1,572 @@
|
|||
/* Regression tests for Nacre's gst_mse patches (docs/engine/gst-mse-patches.md), one per defect of
|
||||
* gst-plugins-bad 1.28.9's MSE library:
|
||||
* /mse/update-end-after-parse bug 1: `buffered` is current at the first update-end of an append
|
||||
* /mse/no-idle-updates bug 2: no update / update-end while nothing is appended
|
||||
* /mse/split-audio-video bug 3: separate audio and video SourceBuffers, video appended 2 s
|
||||
* before audio, expose no stream until both have an init segment, then play;
|
||||
* SPLIT_ROUNDS times (default 4), each in a fresh process, with playbin3 set
|
||||
* up like Servo's player: the stream whose pad task started before
|
||||
* urisourcebin activated its typefind hung in about one fresh process of
|
||||
* eight (msesrc pad task, patch 4)
|
||||
*
|
||||
* /mse/remove remove() drops the coded frame groups inside the range (a stub in 1.28.9);
|
||||
* set_append_window_start() takes a start below the end (refused all)
|
||||
* /mse/abort-then-append abort() mid-append resets the parser; the next append works (1.28.9 sent
|
||||
* end-of-stream into the append pipeline, so every later append failed);
|
||||
* again after the init segment was parsed (the reset left the old appsinks
|
||||
* in the pipeline and the next one crashed on a name clash)
|
||||
* /mse/reopen-append an append after endOfStream() reopens the source and completes (patch 10's
|
||||
* reopen took the appending buffer's tracks lock twice: a deadlock)
|
||||
* /mse/duration-from-frames appended coded frames raise the duration to the buffered end (1.28.9 took
|
||||
* only the demuxer's duration: 0 or the first fragment's for fragmented MP4);
|
||||
* end of stream keeps the duration the page set
|
||||
*
|
||||
* Built and run by `tools/gst-mse.sh test` against target/gst-mse (GST_PLUGIN_PATH, own registry).
|
||||
* Clips in data/ (TESTS_DATA_DIR), made with ffmpeg:
|
||||
* video-vp9.webm testsrc2 320x180 30 fps 5 s, libvpx-vp9, no audio
|
||||
* audio-aac.mp4 sine 440 Hz 5 s, aac 64k, fragmented (frag_keyframe+empty_moov+default_base_moof, 1 s)
|
||||
* Running the binary with LD_LIBRARY_PATH=/usr/lib and GST_PLUGIN_PATH unset tests the system copy instead
|
||||
* (all of them fail there).
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/mse/mse.h>
|
||||
|
||||
#define VIDEO_TYPE "video/webm; codecs=\"vp9\""
|
||||
#define AUDIO_TYPE "audio/mp4; codecs=\"mp4a.40.2\""
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GMutex lock;
|
||||
GCond cond;
|
||||
gint updates;
|
||||
gint update_ends;
|
||||
gint errors;
|
||||
/* buffered ranges seen at each update-end */
|
||||
GArray *buffered_at_end;
|
||||
} Counter;
|
||||
|
||||
static void
|
||||
counter_init (Counter * c)
|
||||
{
|
||||
g_mutex_init (&c->lock);
|
||||
g_cond_init (&c->cond);
|
||||
c->updates = c->update_ends = c->errors = 0;
|
||||
c->buffered_at_end = g_array_new (FALSE, TRUE, sizeof (guint));
|
||||
}
|
||||
|
||||
static void
|
||||
counter_clear (Counter * c)
|
||||
{
|
||||
g_array_unref (c->buffered_at_end);
|
||||
g_mutex_clear (&c->lock);
|
||||
g_cond_clear (&c->cond);
|
||||
}
|
||||
|
||||
static void
|
||||
on_update (GstSourceBuffer * buffer, Counter * c)
|
||||
{
|
||||
g_mutex_lock (&c->lock);
|
||||
c->updates++;
|
||||
g_mutex_unlock (&c->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
on_update_end (GstSourceBuffer * buffer, Counter * c)
|
||||
{
|
||||
GArray *ranges = gst_source_buffer_get_buffered (buffer, NULL);
|
||||
guint n = ranges ? ranges->len : 0;
|
||||
g_clear_pointer (&ranges, g_array_unref);
|
||||
g_mutex_lock (&c->lock);
|
||||
c->update_ends++;
|
||||
g_array_append_val (c->buffered_at_end, n);
|
||||
g_cond_broadcast (&c->cond);
|
||||
g_mutex_unlock (&c->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
on_error (GstSourceBuffer * buffer, Counter * c)
|
||||
{
|
||||
g_mutex_lock (&c->lock);
|
||||
c->errors++;
|
||||
g_cond_broadcast (&c->cond);
|
||||
g_mutex_unlock (&c->lock);
|
||||
}
|
||||
|
||||
/* Waits up to @seconds for @n update-ends in total; returns whether they came. */
|
||||
static gboolean
|
||||
wait_update_ends (Counter * c, gint n, gint seconds)
|
||||
{
|
||||
gint64 deadline = g_get_monotonic_time () + seconds * G_TIME_SPAN_SECOND;
|
||||
gboolean ok = TRUE;
|
||||
g_mutex_lock (&c->lock);
|
||||
while (c->update_ends < n && ok) {
|
||||
ok = g_cond_wait_until (&c->cond, &c->lock, deadline);
|
||||
}
|
||||
ok = c->update_ends >= n;
|
||||
g_mutex_unlock (&c->lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void
|
||||
watch (GstSourceBuffer * buffer, Counter * c)
|
||||
{
|
||||
g_signal_connect (buffer, "on-update", G_CALLBACK (on_update), c);
|
||||
g_signal_connect (buffer, "on-update-end", G_CALLBACK (on_update_end), c);
|
||||
g_signal_connect (buffer, "on-error", G_CALLBACK (on_error), c);
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
clip (const gchar * name)
|
||||
{
|
||||
gchar *path = g_build_filename (g_getenv ("TESTS_DATA_DIR"), name, NULL);
|
||||
gchar *data;
|
||||
gsize size;
|
||||
GError *error = NULL;
|
||||
g_file_get_contents (path, &data, &size, &error);
|
||||
g_assert_no_error (error);
|
||||
g_free (path);
|
||||
return gst_buffer_new_wrapped (data, size);
|
||||
}
|
||||
|
||||
static void
|
||||
sleep_seconds (gdouble seconds)
|
||||
{
|
||||
g_usleep ((gulong) (seconds * G_USEC_PER_SEC));
|
||||
}
|
||||
|
||||
/* A MediaSource attached to a lone msesrc (no pipeline), opened, with one SourceBuffer. */
|
||||
typedef struct
|
||||
{
|
||||
GstElement *src;
|
||||
GstMediaSource *source;
|
||||
GstSourceBuffer *buffer;
|
||||
} Lone;
|
||||
|
||||
static void
|
||||
lone_setup (Lone * lone, const gchar * type)
|
||||
{
|
||||
lone->src = gst_element_factory_make ("msesrc", NULL);
|
||||
g_assert_nonnull (lone->src);
|
||||
gst_object_ref_sink (lone->src);
|
||||
lone->source = gst_media_source_new ();
|
||||
gst_media_source_attach (lone->source, GST_MSE_SRC (lone->src));
|
||||
g_assert_cmpint (gst_media_source_get_ready_state (lone->source), ==,
|
||||
GST_MEDIA_SOURCE_READY_STATE_OPEN);
|
||||
GError *error = NULL;
|
||||
lone->buffer = gst_media_source_add_source_buffer (lone->source, type, &error);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
static void
|
||||
lone_teardown (Lone * lone)
|
||||
{
|
||||
gst_media_source_detach (lone->source);
|
||||
gst_clear_object (&lone->buffer);
|
||||
gst_clear_object (&lone->source);
|
||||
gst_clear_object (&lone->src);
|
||||
}
|
||||
|
||||
static void
|
||||
test_update_end_after_parse (void)
|
||||
{
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, VIDEO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
clip ("video-vp9.webm"), NULL));
|
||||
g_assert_true (wait_update_ends (&c, 1, 10));
|
||||
g_assert_cmpint (c.errors, ==, 0);
|
||||
/* The whole clip (init segment and media) was in that append. */
|
||||
g_assert_cmpuint (g_array_index (c.buffered_at_end, guint, 0), >, 0);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
static void
|
||||
test_no_idle_updates (void)
|
||||
{
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, AUDIO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
sleep_seconds (3);
|
||||
g_assert_cmpint (c.updates, ==, 0);
|
||||
g_assert_cmpint (c.update_ends, ==, 0);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
clip ("audio-aac.mp4"), NULL));
|
||||
g_assert_true (wait_update_ends (&c, 1, 10));
|
||||
sleep_seconds (3);
|
||||
g_assert_cmpint (c.updates, ==, 1);
|
||||
g_assert_cmpint (c.update_ends, ==, 1);
|
||||
g_assert_cmpint (c.errors, ==, 0);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
/* Seconds buffered from the start of the first range to the end of the last one, 0 if none. */
|
||||
static gdouble
|
||||
buffered_span (GstSourceBuffer * buffer, guint * n_ranges)
|
||||
{
|
||||
GArray *ranges = gst_source_buffer_get_buffered (buffer, NULL);
|
||||
gdouble span = 0;
|
||||
*n_ranges = ranges ? ranges->len : 0;
|
||||
if (*n_ranges > 0) {
|
||||
GstMediaSourceRange *first = &g_array_index (ranges, GstMediaSourceRange, 0);
|
||||
GstMediaSourceRange *last =
|
||||
&g_array_index (ranges, GstMediaSourceRange, ranges->len - 1);
|
||||
span = (gdouble) (last->end - first->start) / GST_SECOND;
|
||||
}
|
||||
g_clear_pointer (&ranges, g_array_unref);
|
||||
return span;
|
||||
}
|
||||
|
||||
static void
|
||||
test_remove (void)
|
||||
{
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, AUDIO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
clip ("audio-aac.mp4"), NULL));
|
||||
g_assert_true (wait_update_ends (&c, 1, 10));
|
||||
guint n;
|
||||
gdouble before = buffered_span (lone.buffer, &n);
|
||||
g_assert_cmpfloat (before, >, 4.0);
|
||||
|
||||
GError *error = NULL;
|
||||
g_assert_true (gst_source_buffer_remove (lone.buffer, 0, 3 * GST_SECOND,
|
||||
&error));
|
||||
g_assert_no_error (error);
|
||||
gdouble after = buffered_span (lone.buffer, &n);
|
||||
g_assert_cmpuint (n, >, 0);
|
||||
g_assert_cmpfloat (after, <, before - 1.5);
|
||||
|
||||
/* The append window setters (start was refused for every value below the end). */
|
||||
g_assert_true (gst_source_buffer_set_append_window_start (lone.buffer,
|
||||
GST_SECOND, &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (gst_source_buffer_set_append_window_end (lone.buffer,
|
||||
10 * GST_SECOND, &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_false (gst_source_buffer_set_append_window_start (lone.buffer,
|
||||
20 * GST_SECOND, NULL));
|
||||
g_assert_true (gst_source_buffer_set_append_window_start (lone.buffer, 0,
|
||||
&error));
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert_true (gst_source_buffer_remove (lone.buffer, 0,
|
||||
GST_CLOCK_TIME_NONE, &error));
|
||||
g_assert_no_error (error);
|
||||
buffered_span (lone.buffer, &n);
|
||||
g_assert_cmpuint (n, ==, 0);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
static void
|
||||
test_abort_then_append (void)
|
||||
{
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, VIDEO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
/* Half the clip, then abort while that append may still be in the parser. */
|
||||
GstBuffer *whole = clip ("video-vp9.webm");
|
||||
gsize size = gst_buffer_get_size (whole);
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
gst_buffer_copy_region (whole, GST_BUFFER_COPY_ALL, 0, size / 2),
|
||||
NULL));
|
||||
GError *error = NULL;
|
||||
g_assert_true (gst_source_buffer_abort (lone.buffer, &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_false (gst_source_buffer_get_updating (lone.buffer));
|
||||
|
||||
gint ends = c.update_ends;
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
gst_buffer_ref (whole), &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (wait_update_ends (&c, ends + 1, 10));
|
||||
g_assert_cmpint (c.errors, ==, 0);
|
||||
guint n;
|
||||
g_assert_cmpfloat (buffered_span (lone.buffer, &n), >, 4.0);
|
||||
|
||||
/* Abort with the init segment parsed (tracks exist), then append again: the
|
||||
* reset must drop the old appsinks (crashed before, name clash). */
|
||||
g_assert_true (gst_source_buffer_abort (lone.buffer, &error));
|
||||
g_assert_no_error (error);
|
||||
ends = c.update_ends;
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer, whole, &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (wait_update_ends (&c, ends + 1, 10));
|
||||
g_assert_cmpint (c.errors, ==, 0);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
/* playbin3 on mse:// set up like Servo's player (vendor/servo-media-gstreamer/player.rs): appsink
|
||||
* sinks, the download flag, a 500 MiB buffer-size. */
|
||||
typedef struct
|
||||
{
|
||||
GstElement *playbin;
|
||||
GstMediaSource *source;
|
||||
GstElement *src;
|
||||
GMutex lock;
|
||||
GCond cond;
|
||||
gboolean opened;
|
||||
} Player;
|
||||
|
||||
static void
|
||||
on_source_setup (GstElement * playbin, GstElement * src, Player * p)
|
||||
{
|
||||
g_mutex_lock (&p->lock);
|
||||
p->src = gst_object_ref (src);
|
||||
g_mutex_unlock (&p->lock);
|
||||
gst_media_source_attach (p->source, GST_MSE_SRC (src));
|
||||
}
|
||||
|
||||
static void
|
||||
on_source_open (GstMediaSource * source, Player * p)
|
||||
{
|
||||
g_mutex_lock (&p->lock);
|
||||
p->opened = TRUE;
|
||||
g_cond_broadcast (&p->cond);
|
||||
g_mutex_unlock (&p->lock);
|
||||
}
|
||||
|
||||
static GstClockTime
|
||||
position (GstElement * playbin)
|
||||
{
|
||||
gint64 pos = -1;
|
||||
if (!gst_element_query_position (playbin, GST_FORMAT_TIME, &pos))
|
||||
return GST_CLOCK_TIME_NONE;
|
||||
return pos;
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
new_appsink (void)
|
||||
{
|
||||
GstElement *sink = gst_element_factory_make ("appsink", NULL);
|
||||
g_object_set (sink, "sync", TRUE, "drop", TRUE, "max-buffers", 2, NULL);
|
||||
return sink;
|
||||
}
|
||||
|
||||
static void
|
||||
split_audio_video_round (void)
|
||||
{
|
||||
Player p = { 0 };
|
||||
g_mutex_init (&p.lock);
|
||||
g_cond_init (&p.cond);
|
||||
p.source = gst_media_source_new ();
|
||||
g_signal_connect (p.source, "on-source-open", G_CALLBACK (on_source_open), &p);
|
||||
p.playbin = gst_element_factory_make ("playbin3", NULL);
|
||||
g_assert_nonnull (p.playbin);
|
||||
guint flags;
|
||||
g_object_get (p.playbin, "flags", &flags, NULL);
|
||||
g_object_set (p.playbin, "uri", "mse://test", "video-sink", new_appsink (),
|
||||
"audio-sink", new_appsink (), "buffer-size", 500 * 1024 * 1024,
|
||||
"flags", flags | 0x80 /* download */ , NULL);
|
||||
g_signal_connect (p.playbin, "source-setup", G_CALLBACK (on_source_setup), &p);
|
||||
|
||||
gst_element_set_state (p.playbin, GST_STATE_PAUSED);
|
||||
gint64 deadline = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
|
||||
g_mutex_lock (&p.lock);
|
||||
while (!p.opened && g_cond_wait_until (&p.cond, &p.lock, deadline));
|
||||
g_assert_true (p.opened);
|
||||
g_mutex_unlock (&p.lock);
|
||||
|
||||
GError *error = NULL;
|
||||
Counter cv, ca;
|
||||
counter_init (&cv);
|
||||
counter_init (&ca);
|
||||
GstSourceBuffer *video =
|
||||
gst_media_source_add_source_buffer (p.source, VIDEO_TYPE, &error);
|
||||
g_assert_no_error (error);
|
||||
GstSourceBuffer *audio =
|
||||
gst_media_source_add_source_buffer (p.source, AUDIO_TYPE, &error);
|
||||
g_assert_no_error (error);
|
||||
watch (video, &cv);
|
||||
watch (audio, &ca);
|
||||
|
||||
/* Video first, then 2 s with only one init segment, like YouTube's separate buffers. */
|
||||
g_assert_true (gst_source_buffer_append_buffer (video, clip ("video-vp9.webm"),
|
||||
NULL));
|
||||
g_assert_true (wait_update_ends (&cv, 1, 10));
|
||||
sleep_seconds (2);
|
||||
guint n_video = 0, n_audio = 0;
|
||||
GstMseSrcReadyState ready;
|
||||
g_object_get (p.src, "n-video", &n_video, "n-audio", &n_audio, "ready-state",
|
||||
&ready, NULL);
|
||||
g_assert_cmpuint (n_video, ==, 0);
|
||||
g_assert_cmpuint (n_audio, ==, 0);
|
||||
g_assert_cmpint (ready, ==, GST_MSE_SRC_READY_STATE_HAVE_NOTHING);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (audio, clip ("audio-aac.mp4"),
|
||||
NULL));
|
||||
g_assert_true (wait_update_ends (&ca, 1, 10));
|
||||
g_assert_true (gst_media_source_end_of_stream (p.source,
|
||||
GST_MEDIA_SOURCE_EOS_ERROR_NONE, &error));
|
||||
g_assert_no_error (error);
|
||||
g_object_get (p.src, "n-video", &n_video, "n-audio", &n_audio, NULL);
|
||||
g_assert_cmpuint (n_video, ==, 1);
|
||||
g_assert_cmpuint (n_audio, ==, 1);
|
||||
|
||||
gst_element_set_state (p.playbin, GST_STATE_PLAYING);
|
||||
GstClockTime pos = GST_CLOCK_TIME_NONE;
|
||||
for (gint i = 0; i < 100; i++) {
|
||||
sleep_seconds (0.1);
|
||||
pos = position (p.playbin);
|
||||
if (GST_CLOCK_TIME_IS_VALID (pos) && pos > GST_SECOND)
|
||||
break;
|
||||
}
|
||||
g_test_message ("position after play: %" GST_TIME_FORMAT, GST_TIME_ARGS (pos));
|
||||
g_assert_true (GST_CLOCK_TIME_IS_VALID (pos) && pos > GST_SECOND);
|
||||
g_object_get (p.src, "ready-state", &ready, NULL);
|
||||
gint64 src_pos = -1;
|
||||
gst_element_query_position (p.src, GST_FORMAT_TIME, &src_pos);
|
||||
g_test_message ("ready state %d, msesrc position %" GST_TIME_FORMAT
|
||||
", duration %" GST_TIME_FORMAT, ready, GST_TIME_ARGS (src_pos),
|
||||
GST_TIME_ARGS (gst_media_source_get_duration (p.source)));
|
||||
g_assert_cmpint (ready, >=, GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA);
|
||||
g_assert_cmpint (cv.errors + ca.errors, ==, 0);
|
||||
|
||||
gst_element_set_state (p.playbin, GST_STATE_NULL);
|
||||
gst_clear_object (&video);
|
||||
gst_clear_object (&audio);
|
||||
gst_clear_object (&p.src);
|
||||
gst_clear_object (&p.playbin);
|
||||
gst_clear_object (&p.source);
|
||||
counter_clear (&cv);
|
||||
counter_clear (&ca);
|
||||
g_mutex_clear (&p.lock);
|
||||
g_cond_clear (&p.cond);
|
||||
}
|
||||
|
||||
static void
|
||||
test_split_audio_video (void)
|
||||
{
|
||||
if (g_test_subprocess ()) {
|
||||
split_audio_video_round ();
|
||||
return;
|
||||
}
|
||||
const gchar *env = g_getenv ("SPLIT_ROUNDS");
|
||||
gint rounds = env ? atoi (env) : 4;
|
||||
for (gint i = 0; i < rounds; i++) {
|
||||
g_test_trap_subprocess (NULL, 30 * G_USEC_PER_SEC,
|
||||
G_TEST_SUBPROCESS_INHERIT_STDERR);
|
||||
g_test_message ("round %d: %s", i + 1,
|
||||
g_test_trap_has_passed ()? "played" : "failed");
|
||||
g_test_trap_assert_passed ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_reopen_append (void)
|
||||
{
|
||||
if (!g_test_subprocess ()) {
|
||||
/* A deadlock would hang the test: run it in a child with a time limit. */
|
||||
g_test_trap_subprocess (NULL, 20 * G_USEC_PER_SEC,
|
||||
G_TEST_SUBPROCESS_INHERIT_STDERR);
|
||||
g_test_trap_assert_passed ();
|
||||
return;
|
||||
}
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, AUDIO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
GstBuffer *whole = clip ("audio-aac.mp4");
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
gst_buffer_copy_region (whole, GST_BUFFER_COPY_ALL, 0,
|
||||
gst_buffer_get_size (whole) / 2), NULL));
|
||||
g_assert_true (wait_update_ends (&c, 1, 10));
|
||||
guint n;
|
||||
gdouble half = buffered_span (lone.buffer, &n);
|
||||
GError *error = NULL;
|
||||
g_assert_true (gst_media_source_end_of_stream (lone.source,
|
||||
GST_MEDIA_SOURCE_EOS_ERROR_NONE, &error));
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (gst_media_source_get_ready_state (lone.source), ==,
|
||||
GST_MEDIA_SOURCE_READY_STATE_ENDED);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer, whole, NULL));
|
||||
g_assert_cmpint (gst_media_source_get_ready_state (lone.source), ==,
|
||||
GST_MEDIA_SOURCE_READY_STATE_OPEN);
|
||||
g_assert_true (wait_update_ends (&c, 2, 10));
|
||||
g_assert_cmpint (c.errors, ==, 0);
|
||||
/* The rest of the clip is buffered too. */
|
||||
gdouble full = buffered_span (lone.buffer, &n);
|
||||
g_test_message ("buffered after half %.2f s, after reopen %.2f s", half, full);
|
||||
g_assert_cmpfloat (full, >, half + 1);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
static void
|
||||
test_duration_from_frames (void)
|
||||
{
|
||||
Lone lone;
|
||||
Counter c;
|
||||
counter_init (&c);
|
||||
lone_setup (&lone, AUDIO_TYPE);
|
||||
watch (lone.buffer, &c);
|
||||
|
||||
g_assert_true (gst_source_buffer_append_buffer (lone.buffer,
|
||||
clip ("audio-aac.mp4"), NULL));
|
||||
g_assert_true (wait_update_ends (&c, 1, 10));
|
||||
guint n;
|
||||
gdouble span = buffered_span (lone.buffer, &n);
|
||||
GstClockTime duration = gst_media_source_get_duration (lone.source);
|
||||
g_test_message ("buffered %.3f s, duration %" GST_TIME_FORMAT, span,
|
||||
GST_TIME_ARGS (duration));
|
||||
/* Coded frames raise the duration to the highest end timestamp. */
|
||||
g_assert_true (GST_CLOCK_TIME_IS_VALID (duration));
|
||||
g_assert_cmpfloat ((gdouble) duration / GST_SECOND, >=, span - 0.001);
|
||||
|
||||
/* End of stream keeps the duration the page set (the buffered end). */
|
||||
GstClockTime end = (GstClockTime) (span * GST_SECOND);
|
||||
g_assert_true (gst_media_source_set_duration (lone.source, end, NULL));
|
||||
GError *error = NULL;
|
||||
g_assert_true (gst_media_source_end_of_stream (lone.source,
|
||||
GST_MEDIA_SOURCE_EOS_ERROR_NONE, &error));
|
||||
g_assert_no_error (error);
|
||||
duration = gst_media_source_get_duration (lone.source);
|
||||
g_test_message ("after end of stream %" GST_TIME_FORMAT, GST_TIME_ARGS (duration));
|
||||
g_assert_cmpuint (duration, ==, end);
|
||||
|
||||
lone_teardown (&lone);
|
||||
counter_clear (&c);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
gst_init (&argc, &argv);
|
||||
g_test_add_func ("/mse/update-end-after-parse", test_update_end_after_parse);
|
||||
g_test_add_func ("/mse/no-idle-updates", test_no_idle_updates);
|
||||
g_test_add_func ("/mse/remove", test_remove);
|
||||
g_test_add_func ("/mse/abort-then-append", test_abort_then_append);
|
||||
g_test_add_func ("/mse/reopen-append", test_reopen_append);
|
||||
g_test_add_func ("/mse/duration-from-frames", test_duration_from_frames);
|
||||
g_test_add_func ("/mse/split-audio-video", test_split_audio_video);
|
||||
return g_test_run ();
|
||||
}
|
||||
17
tests/smoke/mse-leak-check.sh
Executable file
17
tests/smoke/mse-leak-check.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
# Leak check for tests/smoke/mse.txt (S027): in <outdir>/nacre.log, the leak case's MediaSource (the second-to-last
|
||||
# "MSE: MediaSource <id> created") must be freed before the page's sentinel (the last one created) is created, i.e.
|
||||
# collected during the run after the page dropped it, not at shutdown. Usage: tests/smoke/mse-leak-check.sh <outdir>
|
||||
set -eu
|
||||
log=$1/nacre.log
|
||||
mapfile -t created < <(grep -n '^MSE: MediaSource [0-9]* created' "$log" | tail -2)
|
||||
[ ${#created[@]} -eq 2 ] || { echo "mse-leak-check: fewer than two MediaSources created"; exit 1; }
|
||||
leak=$(sed -E 's/^[0-9]+:MSE: MediaSource ([0-9]+) .*/\1/' <<<"${created[0]}")
|
||||
sentinel_line=${created[1]%%:*}
|
||||
freed_line=$(grep -n "^MSE: MediaSource $leak freed" "$log" | head -1 | cut -d: -f1)
|
||||
if [ -n "$freed_line" ] && [ "$freed_line" -lt "$sentinel_line" ]; then
|
||||
echo "mse-leak-check: ok, MediaSource $leak freed during the run ($(sed -n "${freed_line}p" "$log"))"
|
||||
else
|
||||
echo "mse-leak-check: FAILED, MediaSource $leak not freed before the sentinel was created"
|
||||
exit 1
|
||||
fi
|
||||
9
tests/smoke/mse-off.txt
Normal file
9
tests/smoke/mse-off.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# dom_media_source_enabled off (S027): with NACRE_DOM_MEDIA_SOURCE_ENABLED=0 in the environment, MediaSource,
|
||||
# SourceBuffer and SourceBufferList are absent. Offline. Run: NACRE_DOM_MEDIA_SOURCE_ENABLED=0 tools/smoke.sh tests/smoke/mse-off.txt
|
||||
wait 3
|
||||
open @PAGES@/mse-basic.html
|
||||
waitload 30
|
||||
assert typeof MediaSource === 'undefined' && typeof SourceBuffer === 'undefined' && typeof SourceBufferList === 'undefined'
|
||||
assert window.mse.stage === 'no MediaSource'
|
||||
status done
|
||||
quit
|
||||
24
tests/smoke/mse-player.txt
Normal file
24
tests/smoke/mse-player.txt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# MSE player integration (S028): mse-player.html runs attach, metadata after the init segment, seeking inside and
|
||||
# outside the buffered range, playback rate, ended, decode error and garbage appends (see its header); each case
|
||||
# must report true. The js probe right after the page starts the first player must answer within 1 s (the script
|
||||
# thread never blocks on attach), and the page's own 20 ms timer must never stall for 1 s. Offline.
|
||||
# Run: SMOKE_TIMEOUT=400 tools/smoke.sh tests/smoke/mse-player.txt
|
||||
wait 3
|
||||
open @PAGES@/mse-player.html
|
||||
waitload 30
|
||||
waitfor 1 document.readyState === "complete"
|
||||
waitfor 180 window.player && window.player.done
|
||||
shot mse-player
|
||||
js JSON.stringify(window.player)
|
||||
assert window.player.results.attach === true
|
||||
assert window.player.results.metadata === true
|
||||
assert window.player.results.seekBuffered === true
|
||||
assert window.player.results.seekUnbuffered === true
|
||||
assert window.player.results.rate === true
|
||||
assert window.player.results.ended === true
|
||||
assert window.player.results.decodeError === true
|
||||
assert window.player.results.garbage === true
|
||||
assert window.player.results.garbageFirst === true
|
||||
assert window.player.maxGap < 1000
|
||||
status done
|
||||
quit
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
# Media Source Extensions (S022 prototype, branch s022-mse-proto): mse-basic.html appends a clip to one
|
||||
# SourceBuffer in 32 KiB chunks, ends the stream and plays. Passes when MediaSource exists, every chunk is
|
||||
# appended, and currentTime advances. Offline. Run with tools/smoke.sh (needs a build with the MSE patch).
|
||||
# Media Source Extensions (branch s022-mse-proto): mse-basic.html appends a clip to one SourceBuffer in 32 KiB
|
||||
# chunks, ends the stream and plays; ?split (S026) uses separate video and audio SourceBuffers. Passes when
|
||||
# MediaSource exists, every chunk is appended, and currentTime advances. Then mse-spec.html (S027) runs the spec
|
||||
# cases one by one (see its header); each must report true. Afterwards run tests/smoke/mse-leak-check.sh <outdir>:
|
||||
# the leak case's MediaSource must be freed during the run ("MSE: MediaSource <id> freed" in nacre.log). Offline. Run with tools/smoke.sh (needs a build with the
|
||||
# MSE patches). mse-off.txt checks the dom_media_source_enabled switch.
|
||||
wait 3
|
||||
open @PAGES@/mse-basic.html
|
||||
waitload 30
|
||||
|
|
@ -17,5 +20,33 @@ waitfor 20 window.mse.time > 1.5
|
|||
shot mse-webm
|
||||
assert window.mse.errors.length === 0
|
||||
js JSON.stringify(window.mse)
|
||||
# S026: separate video and audio SourceBuffers (video appended 2 s before audio), as YouTube does
|
||||
open @PAGES@/mse-basic.html?split
|
||||
waitload 30
|
||||
assert window.mse.supported === true
|
||||
waitfor 30 window.mse && window.mse.stage === 'ended'
|
||||
waitfor 20 window.mse.time > 1.5
|
||||
assert window.mse.videoWidth > 0
|
||||
shot mse-split
|
||||
assert window.mse.errors.length === 0
|
||||
js JSON.stringify(window.mse)
|
||||
# S027: spec cases
|
||||
open @PAGES@/mse-spec.html
|
||||
waitload 30
|
||||
waitfor 120 window.spec && window.spec.done
|
||||
shot mse-spec
|
||||
js JSON.stringify(window.spec.results)
|
||||
assert window.spec.results.attach === true
|
||||
assert window.spec.results.duration === true
|
||||
assert window.spec.results.ranges === true
|
||||
assert window.spec.results.remove === true
|
||||
assert window.spec.results.removeSourceBuffer === true
|
||||
assert window.spec.results.changeType === true
|
||||
assert window.spec.results.abort === true
|
||||
assert window.spec.results.reopen === true
|
||||
assert window.spec.results.sequence === true
|
||||
assert window.spec.results.detach === true
|
||||
assert window.spec.results.leak === true
|
||||
# then: tests/smoke/mse-leak-check.sh <outdir>
|
||||
status done
|
||||
quit
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<!-- MSE test (S022): a MediaSource with one SourceBuffer, fed mse-clip-mp4.js (fMP4, H.264 + AAC) or, with
|
||||
?webm, mse-clip-webm.js (VP9 + Opus) in 32 KiB appendBuffer chunks. The clips are base64 scripts because
|
||||
Servo refuses fetch() and XHR of file:// URLs. window.mse holds the state for
|
||||
smoke asserts: stage, chunks appended, buffered end, currentTime, errors. -->
|
||||
?webm, mse-clip-webm.js (VP9 + Opus) in 32 KiB appendBuffer chunks. With ?split (S026) it uses two
|
||||
SourceBuffers like YouTube: mse-clip-video.js (VP9 WebM, video only) is appended first, then after 2 s
|
||||
mse-clip-audio.js (AAC fMP4, audio only). The clips are base64 scripts because Servo refuses fetch() and
|
||||
XHR of file:// URLs. window.mse holds the state for smoke asserts: stage, chunks appended, buffered end
|
||||
(the smallest over the buffers), currentTime, readyState, videoWidth, errors. -->
|
||||
<head><meta charset="utf-8"><title>MSE basic</title>
|
||||
<style>
|
||||
body { margin: 0; background: #1d3b2a; color: #fff; font: 20px sans-serif; text-align: center; }
|
||||
|
|
@ -16,8 +18,12 @@
|
|||
<div id="log"></div>
|
||||
<script>
|
||||
const webm = location.search.includes('webm');
|
||||
const file = webm ? 'mse-clip-webm.js' : 'mse-clip-mp4.js';
|
||||
const mime = webm ? 'video/webm; codecs="vp9, opus"' : 'video/mp4; codecs="avc1.4d401f, mp4a.40.2"';
|
||||
const split = location.search.includes('split');
|
||||
const tracks = split
|
||||
? [{ file: 'mse-clip-video.js', mime: 'video/webm; codecs="vp9"' },
|
||||
{ file: 'mse-clip-audio.js', mime: 'audio/mp4; codecs="mp4a.40.2"', delay: 2000 }]
|
||||
: [{ file: webm ? 'mse-clip-webm.js' : 'mse-clip-mp4.js',
|
||||
mime: webm ? 'video/webm; codecs="vp9, opus"' : 'video/mp4; codecs="avc1.4d401f, mp4a.40.2"' }];
|
||||
const mse = window.mse = { stage: 'start', chunks: 0, buffered: 0, time: 0, errors: [] };
|
||||
const log = (line) => { document.getElementById('log').textContent += line + '\n'; };
|
||||
const fail = (what) => { mse.errors.push(String(what)); log('ERROR ' + what); };
|
||||
|
|
@ -36,31 +42,20 @@ function update() {
|
|||
const v = document.getElementById('v');
|
||||
mse.time = v.currentTime;
|
||||
mse.readyState = v.readyState;
|
||||
mse.videoWidth = v.videoWidth;
|
||||
document.getElementById('head').textContent =
|
||||
'MSE ' + mse.stage + ' chunks ' + mse.chunks + ' buffered ' + mse.buffered.toFixed(2) +
|
||||
' time ' + mse.time.toFixed(2);
|
||||
}
|
||||
|
||||
async function run() {
|
||||
if (!window.MediaSource) { mse.stage = 'no MediaSource'; return; }
|
||||
mse.supported = MediaSource.isTypeSupported(mime);
|
||||
log('isTypeSupported ' + mse.supported + ' ' + mime);
|
||||
const data = await load(file);
|
||||
const v = document.getElementById('v');
|
||||
const ms = new MediaSource();
|
||||
ms.addEventListener('sourceopen', () => {
|
||||
mse.stage = 'open';
|
||||
log('sourceopen readyState ' + ms.readyState);
|
||||
let sb;
|
||||
try { sb = ms.addSourceBuffer(mime); } catch (e) { fail(e); return; }
|
||||
// Appends data to sb in 32 KiB chunks, one per updateend; resolves when all of it is in.
|
||||
function append(sb, data) {
|
||||
return new Promise((resolve) => {
|
||||
let offset = 0;
|
||||
const next = () => {
|
||||
if (sb.buffered.length) mse.buffered = sb.buffered.end(sb.buffered.length - 1);
|
||||
if (offset >= data.byteLength) {
|
||||
ms.endOfStream();
|
||||
mse.stage = 'ended';
|
||||
log('endOfStream buffered ' + mse.buffered + ' duration ' + ms.duration);
|
||||
v.play().then(() => log('playing'), fail);
|
||||
sb.removeEventListener('updateend', next);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
sb.appendBuffer(data.slice(offset, offset + 32768));
|
||||
|
|
@ -68,9 +63,42 @@ async function run() {
|
|||
mse.chunks++;
|
||||
};
|
||||
sb.addEventListener('updateend', next);
|
||||
sb.addEventListener('error', () => fail('SourceBuffer error'));
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
const bufferedEnd = (sb) => (sb.buffered.length ? sb.buffered.end(sb.buffered.length - 1) : 0);
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
async function run() {
|
||||
if (!window.MediaSource) { mse.stage = 'no MediaSource'; return; }
|
||||
mse.supported = tracks.every((t) => MediaSource.isTypeSupported(t.mime));
|
||||
for (const t of tracks) log('isTypeSupported ' + MediaSource.isTypeSupported(t.mime) + ' ' + t.mime);
|
||||
for (const t of tracks) t.data = await load(t.file);
|
||||
const v = document.getElementById('v');
|
||||
const ms = new MediaSource();
|
||||
ms.addEventListener('sourceopen', async () => {
|
||||
mse.stage = 'open';
|
||||
log('sourceopen readyState ' + ms.readyState);
|
||||
try {
|
||||
for (const t of tracks) {
|
||||
t.sb = ms.addSourceBuffer(t.mime);
|
||||
t.sb.addEventListener('error', () => fail('SourceBuffer error ' + t.mime));
|
||||
}
|
||||
} catch (e) { fail(e); return; }
|
||||
for (const t of tracks) {
|
||||
if (t.delay) {
|
||||
await sleep(t.delay);
|
||||
log('before ' + t.mime + ': readyState ' + v.readyState);
|
||||
}
|
||||
await append(t.sb, t.data);
|
||||
}
|
||||
mse.buffered = Math.min(...tracks.map((t) => bufferedEnd(t.sb)));
|
||||
ms.endOfStream();
|
||||
mse.stage = 'ended';
|
||||
log('endOfStream buffered ' + mse.buffered + ' duration ' + ms.duration);
|
||||
v.play().then(() => log('playing'), fail);
|
||||
});
|
||||
ms.addEventListener('sourceended', () => log('sourceended'));
|
||||
v.addEventListener('error', () => fail('video error ' + (v.error && v.error.message)));
|
||||
v.src = URL.createObjectURL(ms);
|
||||
|
|
|
|||
2
tests/smoke/pages/mse-clip-audio.js
Normal file
2
tests/smoke/pages/mse-clip-audio.js
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue