Skip to content

Expose types for MediaStream Recording API #1015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ interface BiquadFilterOptions extends AudioNodeOptions {
type?: BiquadFilterType;
}

interface BlobEventInit {
data: Blob;
timecode?: number;
}

interface BlobPropertyBag {
endings?: EndingType;
type?: string;
Expand Down Expand Up @@ -692,6 +697,14 @@ interface MediaQueryListEventInit extends EventInit {
media?: string;
}

interface MediaRecorderOptions {
audioBitrateMode?: BitrateMode;
audioBitsPerSecond?: number;
bitsPerSecond?: number;
mimeType?: string;
videoBitsPerSecond?: number;
}

interface MediaStreamAudioSourceOptions {
mediaStream: MediaStream;
}
Expand Down Expand Up @@ -2559,6 +2572,15 @@ declare var Blob: {
new(blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
};

interface BlobEvent extends Event {
readonly data: Blob;
}

declare var BlobEvent: {
prototype: BlobEvent;
new(type: string, eventInitDict: BlobEventInit): BlobEvent;
};

interface Body {
readonly body: ReadableStream<Uint8Array> | null;
readonly bodyUsed: boolean;
Expand Down Expand Up @@ -4647,6 +4669,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
createEvent(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent;
createEvent(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent;
createEvent(eventInterface: "BeforeUnloadEvent"): BeforeUnloadEvent;
createEvent(eventInterface: "BlobEvent"): BlobEvent;
createEvent(eventInterface: "ClipboardEvent"): ClipboardEvent;
createEvent(eventInterface: "CloseEvent"): CloseEvent;
createEvent(eventInterface: "CompositionEvent"): CompositionEvent;
Expand Down Expand Up @@ -4891,6 +4914,7 @@ interface DocumentEvent {
createEvent(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent;
createEvent(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent;
createEvent(eventInterface: "BeforeUnloadEvent"): BeforeUnloadEvent;
createEvent(eventInterface: "BlobEvent"): BlobEvent;
createEvent(eventInterface: "ClipboardEvent"): ClipboardEvent;
createEvent(eventInterface: "CloseEvent"): CloseEvent;
createEvent(eventInterface: "CompositionEvent"): CompositionEvent;
Expand Down Expand Up @@ -10135,6 +10159,45 @@ declare var MediaQueryListEvent: {
new(type: string, eventInitDict?: MediaQueryListEventInit): MediaQueryListEvent;
};

interface MediaRecorderEventMap {
"dataavailable": Event;
"error": ErrorEvent;
"pause": Event;
"resume": SpeechSynthesisEvent;
"start": Event;
"stop": Event;
}

interface MediaRecorder extends EventTarget {
readonly audioBitrateMode: BitrateMode;
readonly audioBitsPerSecond: number;
readonly mimeType: string;
ondataavailable: ((this: MediaRecorder, ev: Event) => any) | null;
onerror: ((this: MediaRecorder, ev: ErrorEvent) => any) | null;
onpause: ((this: MediaRecorder, ev: Event) => any) | null;
onresume: ((this: MediaRecorder, ev: SpeechSynthesisEvent) => any) | null;
onstart: ((this: MediaRecorder, ev: Event) => any) | null;
onstop: ((this: MediaRecorder, ev: Event) => any) | null;
readonly state: RecordingState;
readonly stream: MediaStream;
readonly videoBitsPerSecond: number;
pause(): void;
requestData(): void;
resume(): void;
start(timeslice?: number): void;
stop(): void;
addEventListener<K extends keyof MediaRecorderEventMap>(type: K, listener: (this: MediaRecorder, ev: MediaRecorderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof MediaRecorderEventMap>(type: K, listener: (this: MediaRecorder, ev: MediaRecorderEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}

declare var MediaRecorder: {
prototype: MediaRecorder;
new(stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
isTypeSupported(type: string): boolean;
};

interface MediaSourceEventMap {
"sourceclose": Event;
"sourceended": Event;
Expand Down Expand Up @@ -19725,6 +19788,7 @@ type AutoKeyword = "auto";
type AutomationRate = "a-rate" | "k-rate";
type BinaryType = "arraybuffer" | "blob";
type BiquadFilterType = "allpass" | "bandpass" | "highpass" | "highshelf" | "lowpass" | "lowshelf" | "notch" | "peaking";
type BitrateMode = "constant" | "variable";
type CanPlayTypeResult = "" | "maybe" | "probably";
type CanvasDirection = "inherit" | "ltr" | "rtl";
type CanvasFillRule = "evenodd" | "nonzero";
Expand Down Expand Up @@ -19819,6 +19883,7 @@ type RTCStatsIceCandidatePairState = "failed" | "frozen" | "in-progress" | "succ
type RTCStatsIceCandidateType = "host" | "peerreflexive" | "relayed" | "serverreflexive";
type RTCStatsType = "candidate-pair" | "certificate" | "codec" | "csrc" | "data-channel" | "ice-server" | "inbound-rtp" | "local-candidate" | "media-source" | "outbound-rtp" | "peer-connection" | "receiver" | "remote-candidate" | "remote-inbound-rtp" | "remote-outbound-rtp" | "sctp-transport" | "sender" | "stream" | "track" | "transceiver" | "transport";
type ReadyState = "closed" | "ended" | "open";
type RecordingState = "inactive" | "paused" | "recording";
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
type RequestCache = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
type RequestCredentials = "include" | "omit" | "same-origin";
Expand Down
3 changes: 3 additions & 0 deletions inputfiles/idl/MediaStream Recording.commentmap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"domhighrestimestamp": "The difference between the timestamp of the first chunk in data and the timestamp of the first chunk in the first BlobEvent produced by this recorder as a DOMHighResTimeStamp [HR-TIME]. Note that the timecode in the first produced BlobEvent does not need to be zero."
}
65 changes: 65 additions & 0 deletions inputfiles/idl/MediaStream Recording.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[Exposed=Window]
interface MediaRecorder : EventTarget {
constructor(MediaStream stream, optional MediaRecorderOptions options = {});
readonly attribute MediaStream stream;
readonly attribute DOMString mimeType;
readonly attribute RecordingState state;
attribute EventHandler onstart;
attribute EventHandler onstop;
attribute EventHandler ondataavailable;
attribute EventHandler onpause;
attribute EventHandler onresume;
attribute EventHandler onerror;
readonly attribute unsigned long videoBitsPerSecond;
readonly attribute unsigned long audioBitsPerSecond;
readonly attribute BitrateMode audioBitrateMode;

undefined start(optional unsigned long timeslice);
undefined stop();
undefined pause();
undefined resume();
undefined requestData();

static boolean isTypeSupported(DOMString type);
};

dictionary MediaRecorderOptions {
DOMString mimeType = "";
unsigned long audioBitsPerSecond;
unsigned long videoBitsPerSecond;
unsigned long bitsPerSecond;
BitrateMode audioBitrateMode = "variable";
};

enum BitrateMode {
"constant",
"variable"
};

enum RecordingState {
"inactive",
"recording",
"paused"
};

[Exposed=Window]
interface BlobEvent : Event {
constructor(DOMString type, BlobEventInit eventInitDict);
[SameObject] readonly attribute Blob data;
readonly attribute DOMHighResTimeStamp timecode;
};

dictionary BlobEventInit {
required Blob data;
DOMHighResTimeStamp timecode;
};

dictionary MediaRecorderErrorEventInit : EventInit {
required DOMException error;
};

[Exposed=Window]
interface MediaRecorderErrorEvent : Event {
constructor(DOMString type, MediaRecorderErrorEventInit eventInitDict);
[SameObject] readonly attribute DOMException error;
};
4 changes: 4 additions & 0 deletions inputfiles/idlSources.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@
"url": "https://www.w3.org/TR/media-source/",
"title": "Media Source Extensions"
},
{
"url": "https://w3c.github.io/mediacapture-record/",
"title": "MediaStream Recording"
},
{
"url": "https://w3c.github.io/navigation-timing/",
"title": "Navigation Timing"
Expand Down