Skip to content

LibWeb+LibMedia: Reject audio⇔video codec mismatches in decodingInfo() - #10888

Open
sideshowbarker wants to merge 1 commit into
LadybirdBrowser:masterfrom
sideshowbarker:media-capabilities-codec-type
Open

LibWeb+LibMedia: Reject audio⇔video codec mismatches in decodingInfo()#10888
sideshowbarker wants to merge 1 commit into
LadybirdBrowser:masterfrom
sideshowbarker:media-capabilities-codec-type

Conversation

@sideshowbarker

@sideshowbarker sideshowbarker commented Jul 27, 2026

Copy link
Copy Markdown
Member

This aligns our mediaCapabilities.decodingInfo() implementation with WPT expectations to reject an audio codec where a video codec is expected, and reject a video codec where an audio codec is expected. The spec (see w3c/media-capabilities#261) doesn’t explicitly state that requirement — but Gecko and WebKit both also reject such codec mismatches (and pass the relevant WPT subtests).

This also includes a track_type_from_codec_id() bug fix — to correctly classify Theora as a video codec, rather than incorrectly as audio. Fixes #10696.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 05968065-501f-4369-85cc-eff78b147dfa

📥 Commits

Reviewing files that changed from the base of the PR and between efb6f45 and ec1f836.

📒 Files selected for processing (7)
  • Libraries/LibMedia/CodecID.h
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h
  • Libraries/LibWeb/MimeSniff/MimeType.cpp
  • Libraries/LibWeb/MimeSniff/MimeType.h
  • Tests/LibWeb/Text/expected/wpt-import/media-capabilities/decodingInfo.any.txt
  • Tests/LibWeb/Text/input/wpt-import/media-capabilities/decodingInfo.any.js
💤 Files with no reviewable changes (1)
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h
🚧 Files skipped from review as they are similar to previous changes (6)
  • Libraries/LibWeb/MimeSniff/MimeType.h
  • Tests/LibWeb/Text/input/wpt-import/media-capabilities/decodingInfo.any.js
  • Tests/LibWeb/Text/expected/wpt-import/media-capabilities/decodingInfo.any.txt
  • Libraries/LibWeb/MimeSniff/MimeType.cpp
  • Libraries/LibMedia/CodecID.h
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp

📝 Walkthrough

Walkthrough

The PR adds RFC 6381 codec-string mapping for supported audio and video codecs. Media capability validation now strictly validates MIME strings, codec parameters, codec counts, and media/codec type matches. MIME-sniffing code gains string validation. WPT coverage and expected results are updated for the new validation behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Navigator
  participant MediaCapabilities
  participant MimeSniff
  participant CodecID
  Navigator->>MediaCapabilities: decodingInfo(configuration)
  MediaCapabilities->>MimeSniff: is_valid_mime_type_string(content_type)
  MimeSniff-->>MediaCapabilities: MIME validity
  MediaCapabilities->>CodecID: codec_id_from_rfc6381_codec_string(codec_string)
  CodecID-->>MediaCapabilities: codec ID or CodecID::Unknown
  MediaCapabilities-->>Navigator: MediaCapabilitiesInfo
Loading

Possibly related issues

  • Issue 10696 — Adds codec-family validation that rejects video codecs in audio configurations and audio codecs in video configurations.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the media codec validation changes and the Theora track classification bug fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp`:
- Around line 90-100: Update the codec validation in is_able_to_decode_media()
so an unrecognized codec ID is rejected or otherwise reported unsupported
instead of reaching the supported result. Reuse the existing
codec_id_from_rfc6381_codec_string/track_type_from_codec_id flow to detect
unknown codecs, while preserving the audio/video track-type mismatch checks.

In `@Tests/LibWeb/Text/input/wpt-import/media-capabilities/decodingInfo.any.js`:
- Around line 377-386: Update the test using videoConfigurationWithDynamicRange
to create an independent clone before overriding contentType, rather than
reusing the mutated fixture. Ensure this media-source decodingInfo test retains
the intended HDR codec configuration and remains order-independent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37c24086-ee1b-4eec-a99a-d8687e91ee95

📥 Commits

Reviewing files that changed from the base of the PR and between e94da4a and 868d146.

📒 Files selected for processing (7)
  • Libraries/LibMedia/CodecID.h
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h
  • Libraries/LibWeb/MimeSniff/MimeType.cpp
  • Libraries/LibWeb/MimeSniff/MimeType.h
  • Tests/LibWeb/Text/expected/wpt-import/media-capabilities/decodingInfo.any.txt
  • Tests/LibWeb/Text/input/wpt-import/media-capabilities/decodingInfo.any.js
💤 Files with no reviewable changes (1)
  • Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h

Comment thread Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp Outdated
@sideshowbarker
sideshowbarker force-pushed the media-capabilities-codec-type branch from 868d146 to 218cbf6 Compare July 27, 2026 06:26
Comment thread Libraries/LibWeb/MimeSniff/MimeType.cpp
Comment thread Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp Outdated
@sideshowbarker
sideshowbarker force-pushed the media-capabilities-codec-type branch 2 times, most recently from 5c69e03 to 9886057 Compare August 1, 2026 00:55
@github-actions github-actions Bot added the conflicts Pull request has merge conflicts that need resolution label Aug 9, 2026
This aligns our mediaCapabilities.decodingInfo() implementation with WPT
expectations to reject an audio codec where a video codec is expected,
and reject a video codec where an audio codec is expected. The spec (see
w3c/media-capabilities#261) doesn’t explicitly
state that requirement — but Gecko and WebKit both also reject such
codec mismatches (and pass the relevant WPT subtests).

This also includes a track_type_from_codec_id() bug fix — to correctly
classify Theora as a video codec, rather than incorrectly as audio.

Fixes LadybirdBrowser#10696
@sideshowbarker
sideshowbarker force-pushed the media-capabilities-codec-type branch from 9886057 to ec1f836 Compare August 9, 2026 22:38
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions github-actions Bot removed the conflicts Pull request has merge conflicts that need resolution label Aug 9, 2026
@LadybirdBrowser LadybirdBrowser deleted a comment from github-actions Bot Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

navigator.mediaCapabilities.decodingInfo() accepts video codecs as audio codecs and vice versa

2 participants