blob: b5c1c6503d8a45fd05e93a503f1e5f852fe9bd03 [file] [log] [blame]
// 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,DedicatedWorker),
RuntimeEnabled=WebCodecs,
ActiveScriptWrappable
] 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, MeasureAs=WebCodecsAudioDecoder] 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;
// Which state the decoder is in, indicating which methods can be called.
readonly attribute CodecState state;
// 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(AudioDecoderConfig config);
// Request decoding of an input chunk.
//
// You must call configure() before calling decode() for the first time.
[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.
[RaisesException] void close();
// Call prior to configure() to determine whether config will be supported.
[CallWith=ScriptState, RaisesException]
static Promise<AudioDecoderSupport> isConfigSupported(AudioDecoderConfig config);
};