Skip to content

Commit

Permalink
Added WebCodecs API (#2840)
Browse files Browse the repository at this point in the history
* Added WebCodecs API

* Added missing files

* Added features to cargo.toml

* Fixed VideoFrame constructors
  • Loading branch information
Sixshaman authored Mar 21, 2022
1 parent 7993d91 commit bf45ff7
Show file tree
Hide file tree
Showing 54 changed files with 5,547 additions and 0 deletions.
52 changes: 52 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Algorithm = []
AlignSetting = []
AllowedBluetoothDevice = []
AllowedUsbDevice = []
AlphaOption = []
AnalyserNode = ["AudioNode", "EventTarget"]
AnalyserOptions = []
AngleInstancedArrays = []
Expand All @@ -68,13 +69,25 @@ AudioConfiguration = []
AudioContext = ["BaseAudioContext", "EventTarget"]
AudioContextOptions = []
AudioContextState = []
AudioData = []
AudioDataCopyToOptions = []
AudioDataInit = []
AudioDecoder = []
AudioDecoderConfig = []
AudioDecoderInit = []
AudioDecoderSupport = []
AudioDestinationNode = ["AudioNode", "EventTarget"]
AudioEncoder = []
AudioEncoderConfig = []
AudioEncoderInit = []
AudioEncoderSupport = []
AudioListener = []
AudioNode = ["EventTarget"]
AudioNodeOptions = []
AudioParam = []
AudioParamMap = []
AudioProcessingEvent = ["Event"]
AudioSampleFormat = []
AudioScheduledSourceNode = ["AudioNode", "EventTarget"]
AudioStreamTrack = ["EventTarget", "MediaStreamTrack"]
AudioTrack = []
Expand Down Expand Up @@ -178,6 +191,7 @@ ClipboardItemOptions = []
ClipboardPermissionDescriptor = []
CloseEvent = ["Event"]
CloseEventInit = []
CodecState = []
CollectedClientData = []
Comment = ["CharacterData", "EventTarget", "Node"]
CompositeOperation = []
Expand Down Expand Up @@ -316,6 +330,14 @@ EffectTiming = []
Element = ["EventTarget", "Node"]
ElementCreationOptions = []
ElementDefinitionOptions = []
EncodedAudioChunk = []
EncodedAudioChunkInit = []
EncodedAudioChunkMetadata = []
EncodedAudioChunkType = []
EncodedVideoChunk = []
EncodedVideoChunkInit = []
EncodedVideoChunkMetadata = []
EncodedVideoChunkType = []
EndingTypes = []
ErrorCallback = []
ErrorEvent = ["Event"]
Expand Down Expand Up @@ -528,6 +550,7 @@ GridDeclaration = []
GridTrackState = []
GroupedHistoryEventInit = []
HalfOpenInfoDict = []
HardwareAcceleration = []
HashChangeEvent = ["Event"]
HashChangeEventInit = []
Headers = []
Expand Down Expand Up @@ -666,6 +689,12 @@ ImageCaptureError = []
ImageCaptureErrorEvent = ["Event"]
ImageCaptureErrorEventInit = []
ImageData = []
ImageDecodeOptions = []
ImageDecodeResult = []
ImageDecoder = []
ImageDecoderInit = []
ImageTrack = ["EventTarget"]
ImageTrackList = []
InputEvent = ["Event", "UiEvent"]
InputEventInit = []
InstallTriggerData = []
Expand All @@ -687,6 +716,7 @@ KeyframeEffect = ["AnimationEffect"]
KeyframeEffectOptions = []
L10nElement = []
L10nValue = []
LatencyMode = []
LifecycleCallbacks = []
LineAlignSetting = []
ListBoxObject = []
Expand Down Expand Up @@ -865,6 +895,7 @@ PermissionName = []
PermissionState = []
PermissionStatus = ["EventTarget"]
Permissions = []
PlaneLayout = []
PlaybackDirection = []
Plugin = []
PluginArray = []
Expand Down Expand Up @@ -1071,6 +1102,7 @@ ServiceWorkerUpdateViaCache = []
ShadowRoot = ["DocumentFragment", "EventTarget", "Node"]
ShadowRootInit = []
ShadowRootMode = []
ShareData = []
SharedWorker = ["EventTarget"]
SharedWorkerGlobalScope = ["EventTarget", "WorkerGlobalScope"]
SignResponse = []
Expand Down Expand Up @@ -1116,6 +1148,7 @@ StyleSheetChangeEventInit = []
StyleSheetList = []
SubtleCrypto = []
SupportedType = []
SvcOutputMetadata = []
SvgAngle = []
SvgAnimateElement = ["Element", "EventTarget", "Node", "SvgAnimationElement", "SvgElement"]
SvgAnimateMotionElement = ["Element", "EventTarget", "Node", "SvgAnimationElement", "SvgElement"]
Expand Down Expand Up @@ -1314,12 +1347,31 @@ UserVerificationRequirement = []
ValidityState = []
ValueEvent = ["Event"]
ValueEventInit = []
VideoColorPrimaries = []
VideoColorSpace = []
VideoColorSpaceInit = []
VideoConfiguration = []
VideoDecoder = []
VideoDecoderConfig = []
VideoDecoderInit = []
VideoDecoderSupport = []
VideoEncoder = []
VideoEncoderConfig = []
VideoEncoderEncodeOptions = []
VideoEncoderInit = []
VideoEncoderSupport = []
VideoFacingModeEnum = []
VideoFrame = []
VideoFrameBufferInit = []
VideoFrameCopyToOptions = []
VideoFrameInit = []
VideoMatrixCoefficients = []
VideoPixelFormat = []
VideoPlaybackQuality = []
VideoStreamTrack = ["EventTarget", "MediaStreamTrack"]
VideoTrack = []
VideoTrackList = ["EventTarget"]
VideoTransferCharacteristics = []
VisibilityState = []
VoidCallback = []
VrDisplay = ["EventTarget"]
Expand Down
15 changes: 15 additions & 0 deletions crates/web-sys/src/features/gen_AlphaOption.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![allow(unused_imports)]
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
#[doc = "The `AlphaOption` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AlphaOption`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AlphaOption {
Keep = "keep",
Discard = "discard",
}
151 changes: 151 additions & 0 deletions crates/web-sys/src/features/gen_AudioData.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AudioData , typescript_type = "AudioData")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `AudioData` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type AudioData;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "AudioSampleFormat")]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = format)]
#[doc = "Getter for the `format` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/format)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`, `AudioSampleFormat`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn format(this: &AudioData) -> Option<AudioSampleFormat>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = sampleRate)]
#[doc = "Getter for the `sampleRate` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/sampleRate)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn sample_rate(this: &AudioData) -> f32;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = numberOfFrames)]
#[doc = "Getter for the `numberOfFrames` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/numberOfFrames)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn number_of_frames(this: &AudioData) -> u32;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = numberOfChannels)]
#[doc = "Getter for the `numberOfChannels` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/numberOfChannels)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn number_of_channels(this: &AudioData) -> u32;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = duration)]
#[doc = "Getter for the `duration` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/duration)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn duration(this: &AudioData) -> f64;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "AudioData" , js_name = timestamp)]
#[doc = "Getter for the `timestamp` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/timestamp)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn timestamp(this: &AudioData) -> f64;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "AudioDataCopyToOptions")]
# [wasm_bindgen (method , structural , js_class = "AudioData" , js_name = allocationSize)]
#[doc = "The `allocationSize()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/allocationSize)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`, `AudioDataCopyToOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn allocation_size(this: &AudioData, options: &AudioDataCopyToOptions) -> u32;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "AudioData" , js_name = clone)]
#[doc = "The `clone()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/clone)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn clone(this: &AudioData) -> AudioData;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "AudioData" , js_name = close)]
#[doc = "The `close()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/close)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn close(this: &AudioData);
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "AudioDataCopyToOptions")]
# [wasm_bindgen (method , structural , js_class = "AudioData" , js_name = copyTo)]
#[doc = "The `copyTo()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/copyTo)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`, `AudioDataCopyToOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn copy_to_with_buffer_source(
this: &AudioData,
destination: &::js_sys::Object,
options: &AudioDataCopyToOptions,
);
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "AudioDataCopyToOptions")]
# [wasm_bindgen (method , structural , js_class = "AudioData" , js_name = copyTo)]
#[doc = "The `copyTo()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/copyTo)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`, `AudioDataCopyToOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn copy_to_with_u8_array(
this: &AudioData,
destination: &mut [u8],
options: &AudioDataCopyToOptions,
);
}
Loading

0 comments on commit bf45ff7

Please sign in to comment.