forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Add stubbed Media Source Extensions API
Just the boilerplate :^)
- Loading branch information
Showing
30 changed files
with
549 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Meta/gn/secondary/Userland/Libraries/LibWeb/MediaSourceExtensions/BUILD.gn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
source_set("MediaSourceExtensions") { | ||
configs += [ "//Userland/Libraries/LibWeb:configs" ] | ||
deps = [ "//Userland/Libraries/LibWeb:all_generated" ] | ||
sources = [ | ||
"BufferedChangeEvent.cpp", | ||
"ManagedMediaSource.cpp", | ||
"ManagedSourceBuffer.cpp", | ||
"MediaSource.cpp", | ||
"MediaSourceHandle.cpp", | ||
"SourceBuffer.cpp", | ||
"SourceBufferList.cpp", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Userland/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/BufferedChangeEventPrototype.h> | ||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/MediaSourceExtensions/BufferedChangeEvent.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
JS_DEFINE_ALLOCATOR(BufferedChangeEvent); | ||
|
||
JS::NonnullGCPtr<BufferedChangeEvent> BufferedChangeEvent::construct_impl(JS::Realm& realm, AK::FlyString const& type, BufferedChangeEventInit const& event_init) | ||
{ | ||
return realm.heap().allocate<BufferedChangeEvent>(realm, realm, type, event_init); | ||
} | ||
|
||
BufferedChangeEvent::BufferedChangeEvent(JS::Realm& realm, AK::FlyString const& type, BufferedChangeEventInit const&) | ||
: DOM::Event(realm, type) | ||
{ | ||
} | ||
|
||
BufferedChangeEvent::~BufferedChangeEvent() = default; | ||
|
||
void BufferedChangeEvent::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(BufferedChangeEvent); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
Userland/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/DOM/Event.h> | ||
#include <LibWeb/HTML/TimeRanges.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
struct BufferedChangeEventInit : public DOM::EventInit { | ||
JS::GCPtr<HTML::TimeRanges> added_ranges; | ||
JS::GCPtr<HTML::TimeRanges> removed_ranges; | ||
}; | ||
|
||
// https://w3c.github.io/media-source/#bufferedchangeevent-interface | ||
class BufferedChangeEvent : public DOM::Event { | ||
WEB_PLATFORM_OBJECT(BufferedChangeEvent, DOM::Event); | ||
JS_DECLARE_ALLOCATOR(BufferedChangeEvent); | ||
|
||
public: | ||
[[nodiscard]] static JS::NonnullGCPtr<BufferedChangeEvent> construct_impl(JS::Realm&, FlyString const& type, BufferedChangeEventInit const& = {}); | ||
|
||
private: | ||
BufferedChangeEvent(JS::Realm&, FlyString const& type, BufferedChangeEventInit const& event_init); | ||
|
||
virtual ~BufferedChangeEvent() override; | ||
|
||
virtual void initialize(JS::Realm&) override; | ||
}; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
Userland/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#import <DOM/Event.idl> | ||
#import <HTML/TimeRanges.idl> | ||
|
||
// https://w3c.github.io/media-source/#dom-bufferedchangeevent | ||
[Exposed=(Window,DedicatedWorker)] | ||
interface BufferedChangeEvent : Event { | ||
constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {}); | ||
|
||
[FIXME,SameObject] readonly attribute TimeRanges addedRanges; | ||
[FIXME,SameObject] readonly attribute TimeRanges removedRanges; | ||
}; | ||
|
||
// https://w3c.github.io/media-source/#dom-bufferedchangeeventinit | ||
dictionary BufferedChangeEventInit : EventInit { | ||
TimeRanges addedRanges; | ||
TimeRanges removedRanges; | ||
}; |
23 changes: 23 additions & 0 deletions
23
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/ManagedMediaSourcePrototype.h> | ||
#include <LibWeb/MediaSourceExtensions/ManagedMediaSource.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
JS_DEFINE_ALLOCATOR(ManagedMediaSource); | ||
|
||
ManagedMediaSource::~ManagedMediaSource() = default; | ||
|
||
void ManagedMediaSource::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(ManagedMediaSource); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/MediaSourceExtensions/MediaSource.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
// https://w3c.github.io/media-source/#managedmediasource-interface | ||
class ManagedMediaSource : public MediaSource { | ||
WEB_PLATFORM_OBJECT(ManagedMediaSource, MediaSource); | ||
JS_DECLARE_ALLOCATOR(ManagedMediaSource); | ||
|
||
public: | ||
private: | ||
virtual ~ManagedMediaSource() override; | ||
|
||
virtual void initialize(JS::Realm&) override; | ||
}; | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#import <DOM/EventHandler.idl> | ||
#import <MediaSourceExtensions/MediaSource.idl> | ||
|
||
// https://w3c.github.io/media-source/#managedmediasource-interface | ||
[Exposed=(Window,DedicatedWorker)] | ||
interface ManagedMediaSource : MediaSource { | ||
[FIXME] constructor(); | ||
[FIXME] readonly attribute boolean streaming; | ||
[FIXME] attribute EventHandler onstartstreaming; | ||
[FIXME] attribute EventHandler onendstreaming; | ||
}; |
23 changes: 23 additions & 0 deletions
23
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedSourceBuffer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/ManagedSourceBufferPrototype.h> | ||
#include <LibWeb/MediaSourceExtensions/ManagedSourceBuffer.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
JS_DEFINE_ALLOCATOR(ManagedSourceBuffer); | ||
|
||
ManagedSourceBuffer::~ManagedSourceBuffer() = default; | ||
|
||
void ManagedSourceBuffer::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(ManagedSourceBuffer); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedSourceBuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/MediaSourceExtensions/SourceBuffer.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
// https://w3c.github.io/media-source/#managedsourcebuffer-interface | ||
class ManagedSourceBuffer : public SourceBuffer { | ||
WEB_PLATFORM_OBJECT(ManagedSourceBuffer, SourceBuffer); | ||
JS_DECLARE_ALLOCATOR(ManagedSourceBuffer); | ||
|
||
public: | ||
private: | ||
virtual ~ManagedSourceBuffer() override; | ||
|
||
virtual void initialize(JS::Realm&) override; | ||
}; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
Userland/Libraries/LibWeb/MediaSourceExtensions/ManagedSourceBuffer.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <DOM/EventHandler.idl> | ||
#import <MediaSourceExtensions/SourceBuffer.idl> | ||
|
||
// https://w3c.github.io/media-source/#managedsourcebuffer-interface | ||
[Exposed=(Window,DedicatedWorker)] | ||
interface ManagedSourceBuffer : SourceBuffer { | ||
[FIXME] attribute EventHandler onbufferedchange; | ||
}; |
23 changes: 23 additions & 0 deletions
23
Userland/Libraries/LibWeb/MediaSourceExtensions/MediaSource.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/MediaSourcePrototype.h> | ||
#include <LibWeb/MediaSourceExtensions/MediaSource.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
JS_DEFINE_ALLOCATOR(MediaSource); | ||
|
||
MediaSource::~MediaSource() = default; | ||
|
||
void MediaSource::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(MediaSource); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
Userland/Libraries/LibWeb/MediaSourceExtensions/MediaSource.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/DOM/EventTarget.h> | ||
|
||
namespace Web::MediaSourceExtensions { | ||
|
||
// https://w3c.github.io/media-source/#dom-mediasource | ||
class MediaSource : public DOM::EventTarget { | ||
WEB_PLATFORM_OBJECT(MediaSource, DOM::EventTarget); | ||
JS_DECLARE_ALLOCATOR(MediaSource); | ||
|
||
public: | ||
// https://w3c.github.io/media-source/#dom-mediasource-canconstructindedicatedworker | ||
static bool can_construct_in_dedicated_worker(JS::VM&) { return true; } | ||
|
||
protected: | ||
virtual ~MediaSource() override; | ||
|
||
virtual void initialize(JS::Realm&) override; | ||
|
||
private: | ||
}; | ||
|
||
} |
Oops, something went wrong.