Skip to content

[GStreamer] Auto-detect USAC support via GStreamer registry#1654

Open
asurdej-comcast wants to merge 1 commit intoWebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:usac_fallback
Open

[GStreamer] Auto-detect USAC support via GStreamer registry#1654
asurdej-comcast wants to merge 1 commit intoWebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:usac_fallback

Conversation

@asurdej-comcast
Copy link
Copy Markdown

@asurdej-comcast asurdej-comcast commented May 5, 2026

Add a fallback check for USAC (xHE-AAC) codec support by probing the GStreamer registry for a decoder matching
"audio/mpeg, mpegversion=(int)4, stream-format=(string)usac".

The stream-format=usac caps field is not part of the standard GStreamer audio/mpeg caps definition, but some custom audio sinks advertise it, so it can be used as an indicator of USAC decoding capability.

The WEBKIT_GST_CAN_PLAY_USAC environment variable still takes precedence as a manual override.
d8522c2

Build-Tests Layout-Tests
loading 🛠 wpe-246-amd64-build ✅ 🧪 wpe-246-amd64-layout
✅ 🛠 wpe-246-arm32-build loading 🧪 wpe-246-arm32-layout

@asurdej-comcast
Copy link
Copy Markdown
Author

@ntrrgc Follow up on #1641
I'm integrating the latest wpe-2.46 changes. Using WEBKIT_GST_CAN_PLAY_USAC is not the best option for us because we still need to set it based on audio sink caps reported. Moving this up to integration code can be tricky because it requires gst registry. Webkit's gst registry scanner is perfect place for doing that.
We would like to avoid custom changes on our side so maybe we can keep it here as a fallback. Env approach takes precedence still and that change should be harmless for other audio sinks that don't report stream-format(usac) in their caps.

Add a fallback check for USAC (xHE-AAC) codec support by probing
the GStreamer registry for a decoder matching
"audio/mpeg, mpegversion=(int)4, stream-format=(string)usac".

The stream-format=usac caps field is not part of the standard GStreamer
audio/mpeg caps definition, but some custom audio sinks advertise it, so it can
be used as an indicator of USAC decoding capability.

The WEBKIT_GST_CAN_PLAY_USAC environment variable still takes
precedence as a manual override.
@asurdej-comcast asurdej-comcast changed the title GStreamerRegistryScanner: Auto-detect USAC support via GStreamer regi… [GStreamer] Auto-detect USAC support via GStreamer registry May 5, 2026
Copy link
Copy Markdown

@ntrrgc ntrrgc left a comment

Choose a reason for hiding this comment

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

LGTM

bool canPlayUsac = value && (!g_strcmp0(value, "true") || !g_strcmp0(value, "1"));
if (!value) {
// Env is not set. Fall back to gst elements query
canPlayUsac = factories.hasElementForMediaType(ElementFactories::Type::AudioDecoder, "audio/mpeg, mpegversion=(int)4, stream-format=(string)usac"_s).isSupported;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What element is this?

I think a change like this can be upstreamed, but given the unusual -- and likely problematic -- value for stream-format, I think it's best if we leave a comment mentioning it by name, so that next time we know why this check is there and don't accidentally remove it.

I also noticed that in previous messages, and in the commit message you said "audio sinks" but the check is for an audio decoder. Was that a mistake or does the element in question happen to be both a decoder a sink element (which is possible, depending how the hardware platform API works)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is Amlogic "amlhalasink" element that is both decoder and sink. The commit message is misleading indeed

amlhalasink:   Long-name                AmlHalAsink
amlhalasink:   Klass                    Decoder/Sink/Audio
...
amlhalasink: Pad Templates:
amlhalasink:   SINK template: 'sink'
amlhalasink:     Availability: Always
amlhalasink:     Capabilities:
...
amlhalasink:       audio/x-ac4
amlhalasink:       audio/mpeg
amlhalasink:             mpegversion: 4
amlhalasink:           stream-format: { (string)loas, (string)usac }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the same with MediaTek audio sink "mtkaudiosink" which is also decoder and sink at once

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the same with MediaTek

So both amlhalasink and mtkaudiosink report support for stream-format=usac?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, they both do that actually but it's not a coincidence because mtk had been adjusted for our needs based on amlogic version kind of. So possibly that's why they use the same approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants