Bug 1838958 - Add a blank EncodedVideoChunk interface r=webidl,padenot,smaug

Differential Revision: https://phabricator.services.mozilla.com/D155892
This commit is contained in:
Chun-Min Chang 2023-06-27 17:33:14 +00:00
Родитель bc8b8dfa64
Коммит 2567528bf0
5 изменённых файлов: 162 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/EncodedVideoChunk.h"
#include "mozilla/dom/EncodedVideoChunkBinding.h"
namespace mozilla::dom {
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(EncodedVideoChunk)
NS_IMPL_CYCLE_COLLECTING_ADDREF(EncodedVideoChunk)
NS_IMPL_CYCLE_COLLECTING_RELEASE(EncodedVideoChunk)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EncodedVideoChunk)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
nsIGlobalObject* EncodedVideoChunk::GetParentObject() const { return nullptr; }
JSObject* EncodedVideoChunk::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return EncodedVideoChunk_Binding::Wrap(aCx, this, aGivenProto);
}
/* static */
already_AddRefed<EncodedVideoChunk> EncodedVideoChunk::Constructor(
const GlobalObject& global, const EncodedVideoChunkInit& init,
ErrorResult& aRv) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
EncodedVideoChunkType EncodedVideoChunk::Type() const {
return EncodedVideoChunkType::EndGuard_;
}
int64_t EncodedVideoChunk::Timestamp() const { return 0; }
Nullable<uint64_t> EncodedVideoChunk::GetDuration() const { return nullptr; }
uint32_t EncodedVideoChunk::ByteLength() const { return 0; }
void EncodedVideoChunk::CopyTo(
const MaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer& destination,
ErrorResult& aRv) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
}
} // namespace mozilla::dom

Просмотреть файл

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_EncodedVideoChunk_h
#define mozilla_dom_EncodedVideoChunk_h
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
class nsIGlobalObject;
namespace mozilla {
namespace dom {
class MaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer;
class OwningMaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer;
enum class EncodedVideoChunkType : uint8_t;
struct EncodedVideoChunkInit;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class EncodedVideoChunk final : public nsISupports, public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(EncodedVideoChunk)
public:
EncodedVideoChunk() = default;
protected:
~EncodedVideoChunk() = default;
public:
// This should return something that eventually allows finding a
// path to the global this object is associated with. Most simply,
// returning an actual global works.
nsIGlobalObject* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<EncodedVideoChunk> Constructor(
const GlobalObject& global, const EncodedVideoChunkInit& init,
ErrorResult& aRv);
EncodedVideoChunkType Type() const;
int64_t Timestamp() const;
Nullable<uint64_t> GetDuration() const;
uint32_t ByteLength() const;
void CopyTo(
const MaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer& destination,
ErrorResult& aRv);
};
} // namespace mozilla::dom
#endif // mozilla_dom_EncodedVideoChunk_h

Просмотреть файл

@ -7,11 +7,13 @@
MOCHITEST_MANIFESTS += ["test/mochitest.ini"]
EXPORTS.mozilla.dom += [
"EncodedVideoChunk.h",
"VideoColorSpace.h",
"VideoFrame.h",
]
UNIFIED_SOURCES += [
"EncodedVideoChunk.cpp",
"VideoColorSpace.cpp",
"VideoFrame.cpp",
]

Просмотреть файл

@ -0,0 +1,35 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://w3c.github.io/webcodecs/#encodedvideochunk
*/
[Exposed=(Window,DedicatedWorker), Pref="dom.media.webcodecs.enabled"]
interface EncodedVideoChunk {
[Throws]
constructor(EncodedVideoChunkInit init);
readonly attribute EncodedVideoChunkType type;
readonly attribute long long timestamp; // microseconds
readonly attribute unsigned long long? duration; // microseconds
readonly attribute unsigned long byteLength;
// bug 1696216: Should be `copyTo([AllowShared] BufferSource destination)`
[Throws]
undefined copyTo(([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) destination);
};
dictionary EncodedVideoChunkInit {
required EncodedVideoChunkType type;
required [EnforceRange] long long timestamp; // microseconds
[EnforceRange] unsigned long long duration; // microseconds
// bug 1696216: Should be `required BufferSource data`
required ([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) data;
};
enum EncodedVideoChunkType {
"key",
"delta",
};

Просмотреть файл

@ -532,6 +532,7 @@ WEBIDL_FILES = [
"DynamicsCompressorNode.webidl",
"Element.webidl",
"ElementInternals.webidl",
"EncodedVideoChunk.webidl",
"Event.webidl",
"EventHandler.webidl",
"EventListener.webidl",