Skip to content

[MediaCapabilities][GStreamer] Check audio codecs support isConfigurationSupported() - #60871

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
eocanha:310195
Mar 25, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
eocanha:310195

Conversation

@eocanha

@eocanha eocanha commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

e89e1a0

[MediaCapabilities][GStreamer] Check audio codecs support isConfigurationSupported()
https://bugs.webkit.org/show_bug.cgi?id=310195

Reviewed by Xabier Rodriguez-Calvar.

Currently, isConfigurationSupported() only validates video codecs
against the registered decoder/encoder map. Audio codecs from the audio
configuration were never checked, so unsupported audio codecs could
incorrectly be reported as supported.

See: WebPlatformForEmbedded/WPEWebKit#1640

Fix this by collecting codec strings from both the video and audio
ContentType objects into a single vector and running the software codec
support checks once on the combined list at the end of the function.

Audio hardware accelerated decoding doesn't save much CPU power compared
to video accelerated decoding, and we don't want to reject a video+audio
codec combination just because the audio part isn't accelerated. That's
why the hardware accelerated decoding support checks are only run on the
video codecs.

A new platform-specific layout test has been added to check that common
audio formats and codecs are properly detected (but without
power-efficient decoding, that is, without hardware decoding), while an
unexistent "fictional" codec is rejected.

Co-authored by: Andrzej Surdej (https://github.com/asurdej-comcast)

* LayoutTests/platform/glib/media/mediacapabilities/audio-decoding-info-expected.txt: Added.
* LayoutTests/platform/glib/media/mediacapabilities/audio-decoding-info.html: Added.
* Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
(WebCore::GStreamerRegistryScanner::isConfigurationSupported const): Collect audio codecs and run the codec checks.

Canonical link: https://commits.webkit.org/309939@main

7cfa03d

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug   🧪 wpe-wk2   🧪 win-tests
✅ 🧪 webkitperl   🧪 ios-wk2   🧪 api-mac ✅ 🧪 api-wpe
  🧪 ios-wk2-wpt   🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
  🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
  🛠 ios-safer-cpp   🧪 mac-wk2   🧪 gtk-wk2
✅ 🛠 vision   🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress   🛠 playstation
✅ 🧪 vision-wk2   🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
  🛠 tv-sim
✅ 🛠 watch
  🛠 watch-sim

@eocanha
eocanha requested a review from philn as a code owner March 18, 2026 17:57
@eocanha eocanha self-assigned this Mar 18, 2026
@eocanha eocanha added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Mar 18, 2026

@calvaris calvaris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This implies a behavioral change as it forces to have a hardware audio codec that is also hardware accerelated to consider something to be power efficient. Other browsers and ports consider only video for power efficiency and it is what we should do. Even when the spec allows this, I don't think we should have this behavioral change, at least by default upstream.

@eocanha

eocanha commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

This implies a behavioral change as it forces to have a hardware audio codec that is also hardware accerelated to consider something to be power efficient. Other browsers and ports consider only video for power efficiency and it is what we should do. Even when the spec allows this, I don't think we should have this behavioral change, at least by default upstream.

Hmmm... you have a point, yes. It would be unreasonable to flag "H264 video + mpeg audio" as "not hardware accelerated" in a case where there's no hardware accelerated mpeg audio decoder but there's an accelerated H264 decoder. Doing this might lead to a worse video encoding format final choice by the webpage.

I'm going to remove the audio part from the "hardware acelerated" flagging.

@calvaris calvaris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you should also write a test for this.

Comment on lines +1069 to +1070
allCodecs.appendVector(contentType.codecs());
videoCodecs.appendVector(contentType.codecs());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please cache the codecs() result to not parse them more than once.

if (!allCodecs.isEmpty()) {
if (!areAllCodecsSupported(configuration, allCodecs, false))
return { false, false, nullptr };
isUsingHardware = areAllCodecsSupported(configuration, videoCodecs, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
isUsingHardware = areAllCodecsSupported(configuration, videoCodecs, true);
isUsingHardware = !videoCodecs.isEmpty() && areAllCodecsSupported(configuration, videoCodecs, true);

areAllCodecsSupported returns true if the vector is empty and we don't want that here.

@calvaris calvaris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please, try the test crossplatform and if it works, it's preferred.

isUsingHardware = areAllCodecsSupported(configuration, codecs, true);
}
allCodecs.appendVector(codecs);
videoCodecs.appendVector(codecs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you WTF::move in the second call, you save a vector copy.

@eocanha

eocanha commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Please, try the test crossplatform and if it works, it's preferred.

No, it doesn't. Mac doesn't support audio/mp3, nor audio/mpeg, nor smooth playback of audio/mp4; codecs="mp4a.40.2", while WebKitGTK/GStreamer does. I'm applying the WTF::move() suggestion and correcting a minor indentation mismatch and landing the patch.

@eocanha eocanha added the merge-queue Applied to send a pull request to merge-queue label Mar 25, 2026
…tionSupported()

https://bugs.webkit.org/show_bug.cgi?id=310195

Reviewed by Xabier Rodriguez-Calvar.

Currently, isConfigurationSupported() only validates video codecs
against the registered decoder/encoder map. Audio codecs from the audio
configuration were never checked, so unsupported audio codecs could
incorrectly be reported as supported.

See: WebPlatformForEmbedded/WPEWebKit#1640

Fix this by collecting codec strings from both the video and audio
ContentType objects into a single vector and running the software codec
support checks once on the combined list at the end of the function.

Audio hardware accelerated decoding doesn't save much CPU power compared
to video accelerated decoding, and we don't want to reject a video+audio
codec combination just because the audio part isn't accelerated. That's
why the hardware accelerated decoding support checks are only run on the
video codecs.

A new platform-specific layout test has been added to check that common
audio formats and codecs are properly detected (but without
power-efficient decoding, that is, without hardware decoding), while an
unexistent "fictional" codec is rejected.

Co-authored by: Andrzej Surdej (https://github.com/asurdej-comcast)

* LayoutTests/platform/glib/media/mediacapabilities/audio-decoding-info-expected.txt: Added.
* LayoutTests/platform/glib/media/mediacapabilities/audio-decoding-info.html: Added.
* Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
(WebCore::GStreamerRegistryScanner::isConfigurationSupported const): Collect audio codecs and run the codec checks.

Canonical link: https://commits.webkit.org/309939@main
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 309939@main (e89e1a0): https://commits.webkit.org/309939@main

Reviewed commits have been landed. Closing PR #60871 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit e89e1a0 into WebKit:main Mar 25, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants