Bug 1838984 - Add Serializable to EncodedVideoChunk r=emilio

This patch add Serializable to EncodedVideoChunk interface with some
dummy functions to make it buildable. The (de-)serialization function
will be implemented in the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D182844
This commit is contained in:
Chun-Min Chang 2023-07-21 00:44:54 +00:00
parent 57c0421214
commit 661e75ba53
4 changed files with 24 additions and 1 deletions

View file

@ -155,6 +155,8 @@ enum StructuredCloneTags : uint32_t {
SCTAG_DOM_VIDEOFRAME,
SCTAG_DOM_ENCODEDVIDEOCHUNK,
// IMPORTANT: If you plan to add an new IDB tag, it _must_ be add before the
// "less stable" tags!
};

View file

@ -160,6 +160,20 @@ uint8_t* EncodedVideoChunk::Data() {
return mBuffer->Data();
}
// https://w3c.github.io/webcodecs/#ref-for-deserialization-steps%E2%91%A0
/* static */
already_AddRefed<EncodedVideoChunk> EncodedVideoChunk::ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader) {
return nullptr;
}
// https://w3c.github.io/webcodecs/#ref-for-serialization-steps%E2%91%A0
bool EncodedVideoChunk::WriteStructuredClone(
JSContext* aCx, JSStructuredCloneWriter* aWriter) const {
return false;
}
#undef LOGW
#undef LOG_INTERNAL

View file

@ -73,6 +73,13 @@ class EncodedVideoChunk final : public nsISupports, public nsWrapperCache {
// Non-webidl method.
uint8_t* Data();
// [Serializable] implementations: {Read, Write}StructuredClone
static already_AddRefed<EncodedVideoChunk> ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
bool WriteStructuredClone(JSContext* aCx,
JSStructuredCloneWriter* aWriter) const;
private:
// EncodedVideoChunk can run on either main thread or worker thread.
void AssertIsOnOwningThread() const {

View file

@ -7,7 +7,7 @@
* https://w3c.github.io/webcodecs/#encodedvideochunk
*/
[Exposed=(Window,DedicatedWorker), Pref="dom.media.webcodecs.enabled"]
[Exposed=(Window,DedicatedWorker), Serializable, Pref="dom.media.webcodecs.enabled"]
interface EncodedVideoChunk {
[Throws]
constructor(EncodedVideoChunkInit init);