LibWeb/EME: Implement get_supported_configuration

This commit is contained in:
stelar7 2025-07-31 13:27:32 +02:00 committed by Jelle Raaijmakers
commit 7b9d5f9fdc
Notes: github-actions[bot] 2025-08-27 07:59:21 +00:00
2 changed files with 29 additions and 1 deletions

View file

@ -372,4 +372,31 @@ Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem
return ConsentConfiguration { consent_status, accumulated_configuration };
}
// https://w3c.github.io/encrypted-media/#get-supported-configuration
Optional<ConsentConfiguration> get_supported_configuration(KeySystem const& implementation, Bindings::MediaKeySystemConfiguration const& candidate_configuration, URL::Origin const& origin)
{
// 1. Let supported configuration be ConsentDenied.
Optional<ConsentConfiguration> supported_configuration = ConsentConfiguration { ConsentStatus::ConsentDenied, {} };
// 2. Initialize restrictions to indicate that no configurations have had user consent denied.
MediaKeyRestrictions restrictions;
size_t loop_count = 0;
// 3. Repeat the following step while supported configuration is ConsentDenied:
while (supported_configuration.has_value() && supported_configuration->status == ConsentStatus::ConsentDenied) {
// 1. Let supported configuration and, if provided, restrictions be the result of executing
// the Get Supported Configuration and Consent algorithm with implementation, candidate configuration, restrictions and origin.
supported_configuration = get_supported_configuration_and_consent(implementation, candidate_configuration, restrictions, origin);
// AD-HOC: While this is being implemented, we use this to avoid a possible infinite loop
if (loop_count++ > 5) {
break;
}
}
// 4. Return supported configuration.
return supported_configuration;
}
}