Bug 1774300 - Add a blank VideoColorSpace interface r=padenot,jgilbert,emilio

This patch creates a blank class for the VideoColorSpace interface. The
files are generated by running `./mach build-backend && ./mach
webidl-example VideoColorSpace` with necessary changes to make it
buildable.

The VideoColorSpace is a sub-interface of the VideoFrame interface,
which is the essential building block for W3C WebCodecs API.

The implementations are plain blank now. They will be filled out in the
following patches.

Additionally, this patch creates a `dom.media.webcodecs.enabled` pref
for W3C Webcodecs API. All the WebCodecs APIs will be hidden without
setting it to `true`.

Differential Revision: https://phabricator.services.mozilla.com/D144771
This commit is contained in:
Chun-Min Chang 2022-10-06 00:37:19 +00:00
parent eb363bd64e
commit a0c9d1d355
7 changed files with 210 additions and 0 deletions

View File

@ -50,6 +50,7 @@ DIRS += [
"utils",
"wave",
"webaudio",
"webcodecs",
"webm",
"webrtc",
"webspeech",

View File

@ -0,0 +1,64 @@
/* -*- 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/VideoColorSpace.h"
#include "mozilla/dom/VideoColorSpaceBinding.h"
namespace mozilla::dom {
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(VideoColorSpace)
NS_IMPL_CYCLE_COLLECTING_ADDREF(VideoColorSpace)
NS_IMPL_CYCLE_COLLECTING_RELEASE(VideoColorSpace)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(VideoColorSpace)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
VideoColorSpace::VideoColorSpace() {
// Add |MOZ_COUNT_CTOR(VideoColorSpace);| for a non-refcounted object.
}
VideoColorSpace::~VideoColorSpace() {
// Add |MOZ_COUNT_DTOR(VideoColorSpace);| for a non-refcounted object.
}
// Add to make it buildable.
nsIGlobalObject* VideoColorSpace::GetParentObject() const { return nullptr; }
JSObject* VideoColorSpace::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return VideoColorSpace_Binding::Wrap(aCx, this, aGivenProto);
}
// The followings are added to make it buildable.
/* static */
already_AddRefed<VideoColorSpace> VideoColorSpace::Constructor(
const GlobalObject& global, const VideoColorSpaceInit& init,
ErrorResult& aRv) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
Nullable<VideoColorPrimaries> VideoColorSpace::GetPrimaries() const {
return nullptr;
}
Nullable<VideoTransferCharacteristics> VideoColorSpace::GetTransfer() const {
return nullptr;
}
Nullable<VideoMatrixCoefficients> VideoColorSpace::GetMatrix() const {
return nullptr;
}
Nullable<bool> VideoColorSpace::GetFullRange() const { return nullptr; }
void VideoColorSpace::ToJSON(JSContext* cx,
JS::MutableHandle<JSObject*> aRetVal) {}
} // namespace mozilla::dom

View File

@ -0,0 +1,75 @@
/* -*- 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_VideoColorSpace_h
#define mozilla_dom_VideoColorSpace_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; // Add to make it buildable.
namespace mozilla {
namespace dom {
enum class VideoColorPrimaries : uint8_t; // Add to make it buildable.
enum class VideoTransferCharacteristics : uint8_t; // Add to make it buildable.
enum class VideoMatrixCoefficients : uint8_t; // Add to make it buildable.
struct VideoColorSpaceInit; // Add to make it buildable.
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class VideoColorSpace final
: public nsISupports /* or NonRefcountedDOMObject if this is a
non-refcounted object */
,
public nsWrapperCache /* Change wrapperCache in the binding configuration
if you don't want this */
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(VideoColorSpace)
public:
VideoColorSpace();
protected:
~VideoColorSpace();
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<VideoColorSpace> Constructor(
const GlobalObject& global, const VideoColorSpaceInit& init,
ErrorResult& aRv);
Nullable<VideoColorPrimaries> GetPrimaries() const;
Nullable<VideoTransferCharacteristics> GetTransfer() const;
Nullable<VideoMatrixCoefficients> GetMatrix() const;
Nullable<bool> GetFullRange() const;
void ToJSON(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal);
};
} // namespace mozilla::dom
#endif // mozilla_dom_VideoColorSpace_h

View File

@ -0,0 +1,15 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
EXPORTS.mozilla.dom += [
"VideoColorSpace.h",
]
UNIFIED_SOURCES += [
"VideoColorSpace.cpp",
]
FINAL_LIBRARY = "xul"

View File

@ -0,0 +1,48 @@
/* -*- 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/#videocolorspace
*/
[Exposed=(Window,DedicatedWorker), Pref="dom.media.webcodecs.enabled"]
interface VideoColorSpace {
[Throws]
constructor(optional VideoColorSpaceInit init = {});
readonly attribute VideoColorPrimaries? primaries;
readonly attribute VideoTransferCharacteristics? transfer;
readonly attribute VideoMatrixCoefficients? matrix;
readonly attribute boolean? fullRange;
// https://github.com/w3c/webcodecs/issues/486
[Default] object toJSON();
};
dictionary VideoColorSpaceInit {
VideoColorPrimaries primaries;
VideoTransferCharacteristics transfer;
VideoMatrixCoefficients matrix;
boolean fullRange;
};
enum VideoColorPrimaries {
"bt709", // BT.709, sRGB
"bt470bg", // BT.601 PAL
"smpte170m", // BT.601 NTSC
};
enum VideoTransferCharacteristics {
"bt709", // BT.709
"smpte170m", // BT.601 (functionally the same as bt709)
"iec61966-2-1", // sRGB
};
enum VideoMatrixCoefficients {
"rgb", // sRGB
"bt709", // BT.709
"bt470bg", // BT.601 PAL
"smpte170m", // BT.601 NTSC (functionally the same as bt470bg)
};

View File

@ -975,6 +975,7 @@ WEBIDL_FILES = [
"URL.webidl",
"URLSearchParams.webidl",
"ValidityState.webidl",
"VideoColorSpace.webidl",
"VideoPlaybackQuality.webidl",
"VideoTrack.webidl",
"VideoTrackList.webidl",

View File

@ -2945,6 +2945,12 @@
value: true
mirror: always
# WebCodecs API
- name: dom.media.webcodecs.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# Number of seconds of very quiet or silent audio before considering the audio
# inaudible.
- name: dom.media.silence_duration_for_audibility