mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 17:29:01 +00:00
LibWeb/EME: Implement MediaKeySystemAccess
This commit is contained in:
parent
cc50b30399
commit
b1c1e33bae
Notes:
github-actions[bot]
2025-08-27 07:59:52 +00:00
Author: https://github.com/stelar7
Commit: b1c1e33bae
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5665
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
11 changed files with 147 additions and 13 deletions
|
@ -329,6 +329,7 @@ set(SOURCES
|
||||||
Encoding/TextEncoder.cpp
|
Encoding/TextEncoder.cpp
|
||||||
Encoding/TextEncoderCommon.cpp
|
Encoding/TextEncoderCommon.cpp
|
||||||
Encoding/TextEncoderStream.cpp
|
Encoding/TextEncoderStream.cpp
|
||||||
|
EncryptedMediaExtensions/MediaKeySystemAccess.cpp
|
||||||
EntriesAPI/FileSystemEntry.cpp
|
EntriesAPI/FileSystemEntry.cpp
|
||||||
EventTiming/PerformanceEventTiming.cpp
|
EventTiming/PerformanceEventTiming.cpp
|
||||||
Fetch/Body.cpp
|
Fetch/Body.cpp
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2025, Psychpsyo <psychpsyo@gmail.com>
|
* Copyright (c) 2025, Psychpsyo <psychpsyo@gmail.com>
|
||||||
|
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -7,14 +8,35 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
#include <LibWeb/Bindings/MediaKeySystemAccessPrototype.h>
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
// https://w3c.github.io/encrypted-media/#dom-mediakeysrequirement
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemmediacapability
|
||||||
enum class MediaKeysRequirement : u8 {
|
struct MediaKeySystemMediaCapability {
|
||||||
Required,
|
Utf16String content_type;
|
||||||
Optional,
|
Optional<Utf16String> encryption_scheme;
|
||||||
NotAllowed
|
Utf16String robustness;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemconfiguration
|
||||||
|
struct MediaKeySystemConfiguration {
|
||||||
|
Utf16String label;
|
||||||
|
Vector<Utf16String> init_data_types;
|
||||||
|
Vector<MediaKeySystemMediaCapability> audio_capabilities;
|
||||||
|
Vector<MediaKeySystemMediaCapability> video_capabilities;
|
||||||
|
Bindings::MediaKeysRequirement distinctive_identifier { Bindings::MediaKeysRequirement::Optional };
|
||||||
|
Bindings::MediaKeysRequirement persistent_state { Bindings::MediaKeysRequirement::Optional };
|
||||||
|
Optional<Vector<Utf16String>> session_types;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Web::EncryptedMediaExtensions {
|
||||||
|
|
||||||
|
struct MediaKeyRestrictions {
|
||||||
|
bool distinctive_identifiers { true };
|
||||||
|
bool persist_state { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// https://w3c.github.io/encrypted-media/#dom-mediakeysrequirement
|
|
||||||
enum MediaKeysRequirement {
|
|
||||||
"required",
|
|
||||||
"optional",
|
|
||||||
"not-allowed"
|
|
||||||
};
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Bindings/MediaKeySystemAccessPrototype.h>
|
||||||
|
#include <LibWeb/EncryptedMediaExtensions/MediaKeySystemAccess.h>
|
||||||
|
|
||||||
|
namespace Web::EncryptedMediaExtensions {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(MediaKeySystemAccess);
|
||||||
|
|
||||||
|
MediaKeySystemAccess::~MediaKeySystemAccess() = default;
|
||||||
|
|
||||||
|
MediaKeySystemAccess::MediaKeySystemAccess(JS::Realm& realm, Utf16String const& key_system, Bindings::MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
, m_key_system(key_system)
|
||||||
|
, m_configuration(move(configuration))
|
||||||
|
, m_cdm_implementation(move(cdm_implementation))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GC::Ref<MediaKeySystemAccess> MediaKeySystemAccess::create(JS::Realm& realm, Utf16String const& key_system, Bindings::MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||||
|
{
|
||||||
|
return realm.create<MediaKeySystemAccess>(realm, key_system, configuration, move(cdm_implementation));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaKeySystemAccess::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(MediaKeySystemAccess);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/RefPtr.h>
|
||||||
|
#include <LibGC/Heap.h>
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/EncryptedMediaExtensions/EncryptedMediaExtensions.h>
|
||||||
|
#include <LibWeb/EncryptedMediaExtensions/KeySystem.h>
|
||||||
|
|
||||||
|
namespace Web::EncryptedMediaExtensions {
|
||||||
|
|
||||||
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemaccess
|
||||||
|
class MediaKeySystemAccess : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(MediaKeySystemAccess, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(MediaKeySystemAccess);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~MediaKeySystemAccess() override;
|
||||||
|
[[nodiscard]] static GC::Ref<MediaKeySystemAccess> create(JS::Realm&, Utf16String const&, Bindings::MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||||
|
|
||||||
|
[[nodiscard]] Utf16String key_system() const { return m_key_system; }
|
||||||
|
[[nodiscard]] Bindings::MediaKeySystemConfiguration get_configuration() const { return m_configuration; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit MediaKeySystemAccess(JS::Realm&, Utf16String const&, Bindings::MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf16String m_key_system;
|
||||||
|
|
||||||
|
Bindings::MediaKeySystemConfiguration m_configuration;
|
||||||
|
NonnullOwnPtr<KeySystem> m_cdm_implementation;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
// https://w3c.github.io/encrypted-media/#mediakeysystemaccess-interface
|
||||||
|
[Exposed=Window, SecureContext]
|
||||||
|
interface MediaKeySystemAccess {
|
||||||
|
readonly attribute Utf16DOMString keySystem;
|
||||||
|
MediaKeySystemConfiguration getConfiguration();
|
||||||
|
[FIXME] Promise<MediaKeys> createMediaKeys();
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysrequirement
|
||||||
|
enum MediaKeysRequirement {
|
||||||
|
"required",
|
||||||
|
"optional",
|
||||||
|
"not-allowed"
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemconfiguration
|
||||||
|
dictionary MediaKeySystemConfiguration {
|
||||||
|
Utf16DOMString label = "";
|
||||||
|
sequence<Utf16DOMString> initDataTypes = [];
|
||||||
|
sequence<MediaKeySystemMediaCapability> audioCapabilities = [];
|
||||||
|
sequence<MediaKeySystemMediaCapability> videoCapabilities = [];
|
||||||
|
MediaKeysRequirement distinctiveIdentifier = "optional";
|
||||||
|
MediaKeysRequirement persistentState = "optional";
|
||||||
|
sequence<Utf16DOMString> sessionTypes;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemmediacapability
|
||||||
|
dictionary MediaKeySystemMediaCapability {
|
||||||
|
Utf16DOMString contentType = "";
|
||||||
|
Utf16DOMString? encryptionScheme = null;
|
||||||
|
Utf16DOMString robustness = "";
|
||||||
|
};
|
|
@ -87,7 +87,6 @@ enum class HdrMetadataType : u8;
|
||||||
enum class ImageSmoothingQuality : u8;
|
enum class ImageSmoothingQuality : u8;
|
||||||
enum class MediaDecodingType : u8;
|
enum class MediaDecodingType : u8;
|
||||||
enum class MediaEncodingType : u8;
|
enum class MediaEncodingType : u8;
|
||||||
enum class MediaKeysRequirement : u8;
|
|
||||||
enum class OffscreenRenderingContextId : u8;
|
enum class OffscreenRenderingContextId : u8;
|
||||||
enum class ReadableStreamReaderMode : u8;
|
enum class ReadableStreamReaderMode : u8;
|
||||||
enum class ReferrerPolicy : u8;
|
enum class ReferrerPolicy : u8;
|
||||||
|
@ -465,6 +464,12 @@ struct TextEncoderEncodeIntoResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::EncryptedMediaExtensions {
|
||||||
|
|
||||||
|
class MediaKeySystemAccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace Web::EntriesAPI {
|
namespace Web::EntriesAPI {
|
||||||
|
|
||||||
class FileSystemEntry;
|
class FileSystemEntry;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#import <EncryptedMediaExtensions/EncryptedMediaExtensions.idl>
|
#import <EncryptedMediaExtensions/MediaKeySystemAccess.idl>
|
||||||
|
|
||||||
// https://w3c.github.io/media-capabilities/#mediaconfiguration
|
// https://w3c.github.io/media-capabilities/#mediaconfiguration
|
||||||
dictionary MediaConfiguration {
|
dictionary MediaConfiguration {
|
||||||
|
|
|
@ -105,6 +105,7 @@ libweb_js_bindings(DOMURL/URLSearchParams ITERABLE)
|
||||||
libweb_js_bindings(Encoding/TextDecoder)
|
libweb_js_bindings(Encoding/TextDecoder)
|
||||||
libweb_js_bindings(Encoding/TextEncoder)
|
libweb_js_bindings(Encoding/TextEncoder)
|
||||||
libweb_js_bindings(Encoding/TextEncoderStream)
|
libweb_js_bindings(Encoding/TextEncoderStream)
|
||||||
|
libweb_js_bindings(EncryptedMediaExtensions/MediaKeySystemAccess)
|
||||||
libweb_js_bindings(EntriesAPI/FileSystemEntry)
|
libweb_js_bindings(EntriesAPI/FileSystemEntry)
|
||||||
libweb_js_bindings(EventTiming/PerformanceEventTiming)
|
libweb_js_bindings(EventTiming/PerformanceEventTiming)
|
||||||
libweb_js_bindings(Fetch/Headers ITERABLE)
|
libweb_js_bindings(Fetch/Headers ITERABLE)
|
||||||
|
|
|
@ -85,6 +85,7 @@ static bool is_platform_object(Type const& type)
|
||||||
"Instance"sv,
|
"Instance"sv,
|
||||||
"IntersectionObserverEntry"sv,
|
"IntersectionObserverEntry"sv,
|
||||||
"KeyframeEffect"sv,
|
"KeyframeEffect"sv,
|
||||||
|
"MediaKeySystemAccess"sv,
|
||||||
"MediaList"sv,
|
"MediaList"sv,
|
||||||
"Memory"sv,
|
"Memory"sv,
|
||||||
"MessagePort"sv,
|
"MessagePort"sv,
|
||||||
|
@ -4889,6 +4890,7 @@ using namespace Web::CSS;
|
||||||
using namespace Web::DOM;
|
using namespace Web::DOM;
|
||||||
using namespace Web::DOMURL;
|
using namespace Web::DOMURL;
|
||||||
using namespace Web::Encoding;
|
using namespace Web::Encoding;
|
||||||
|
using namespace Web::EncryptedMediaExtensions;
|
||||||
using namespace Web::EntriesAPI;
|
using namespace Web::EntriesAPI;
|
||||||
using namespace Web::EventTiming;
|
using namespace Web::EventTiming;
|
||||||
using namespace Web::Fetch;
|
using namespace Web::Fetch;
|
||||||
|
|
|
@ -264,6 +264,7 @@ MathMLElement
|
||||||
MediaCapabilities
|
MediaCapabilities
|
||||||
MediaElementAudioSourceNode
|
MediaElementAudioSourceNode
|
||||||
MediaError
|
MediaError
|
||||||
|
MediaKeySystemAccess
|
||||||
MediaList
|
MediaList
|
||||||
MediaQueryList
|
MediaQueryList
|
||||||
MediaQueryListEvent
|
MediaQueryListEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue