Commit c609bfa7 authored by Chris Cunningham's avatar Chris Cunningham Committed by Commit Bot

WebAudio AudioDecoder IDL definitions

Add IDL for AudioDecoder and associated IO/callbacks/init.

Bug: 1094087
Change-Id: I9dca7ab13a8feeaabb8714faa37df5c901789cc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255142
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Auto-Submit: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781598}
parent 058190b1
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
[
Exposed=(Window,Worker),
RuntimeEnabled=WebCodecs
] interface AudioDecoder {
// |init| includes an |output| callback for emitting AudioBuffers and an
// |error| callback for emitting decode errors. All errors are permanent;
// construct a new decoder to recover.
//
// TODO(sandersd): Consider adding a state or last error attribute.
[CallWith=ScriptState, RaisesException] constructor(AudioDecoderInit init);
// The number of pending decode requests. This does not include requests that
// have been sent to the underlying codec.
//
// Applications can minimize underflow by enqueueing decode requests until
// |decodeQueueSize| is greater than a constant.
readonly attribute long decodeQueueSize;
// Set the stream configuration for future decode() requests.
//
// The next decode request must be for a keyframe.
//
// TODO(chcunningham): Move the keyframe rule into the bytestream registry.
[RaisesException] void configure(EncodedAudioConfig config);
// Request decoding of an input chunk.
//
// You must call configure() before calling decode() for the first time.
//
// TODO(chcunningham): Change to a dictionary type.
[RaisesException] void decode(EncodedAudioChunk chunk);
// Request output from all previous decode requests.
//
// Resolved after all output for earlier decode requests has been emitted.
//
// The next decode request must be for a keyframe.
//
// TODO(chcunningham): Consider relaxing the keyframe requirement.
// TODO(chcunningham): Indicate whether the flush() completed successfully or due
// to a reset.
[RaisesException] Promise<void> flush();
// Reset all codec state, including all pending requests.
//
// You must call configure() before submitting the next decode.
[RaisesException] void reset();
// Immediately shut down the decoder and free its resources. All pending
// decode requests are aborted.
//
// Not recoverable: make a new AudioDecoder if needed.
void close();
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
dictionary AudioDecoderInit {
AudioFrameOutputCallback output;
WebCodecsErrorCallback error;
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
[
Exposed=(Window,Worker),
RuntimeEnabled=WebCodecs
] interface AudioFrame {
[RaisesException] constructor(AudioFrameInit init);
void close();
readonly attribute unsigned long long timestamp; // microseconds
readonly attribute AudioBuffer buffer;
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
dictionary AudioFrameInit {
unsigned long long timestamp; // microseconds
AudioBuffer buffer;
};
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
[RuntimeEnabled=WebCodecs]
callback AudioFrameOutputCallback = void(AudioFrame output);
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
enum EncodedAudioChunkType {
"key",
"delta",
};
[
Exposed=(Window,Worker),
RuntimeEnabled=WebCodecs
] interface EncodedAudioChunk {
constructor(EncodedAudioChunkType type, unsigned long long timestamp, BufferSource data);
readonly attribute EncodedAudioChunkType type;
readonly attribute unsigned long long timestamp; // microseconds
readonly attribute ArrayBuffer data;
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/web-codecs
dictionary EncodedAudioConfig {
// TODO(chcunningham): reference spec registry.
required DOMString codec;
// 44100, 48000, etc.
unsigned long samplesPerSecond;
// 1, 2, etc.
unsigned long numChannels;
// Optional byte data required to initialize audio decoders such as Vorbis
// codebooks.
BufferSource extraData;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment