blob: 863cf86d2abd223118e49da76d340b25a9629c05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2019 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
// A VideoDecoder processes a queue of configure, decode, and flush requests.
// Requests are taken from the queue sequentially but may be processed
// concurrently.
//
// TODO(sandersd): Specify a tune() implementation for changing decoder
// parameters (separate from stream parameters). This is more important for
// encoders.
[
Exposed=Window,
RuntimeEnabled=WebCodecs
] interface VideoDecoder {
// |init| includes an |output| callback for emitting VideoFrames and an
// |error| callback for emitting decode errors.
//
// When in an error state, methods other than reset() will fail.
//
// TODO(sandersd): Consider adding a state or last error attribute.
// TODO(sandersd): Consider aborting pending decodes on error, rather than
// waiting for reset().
[CallWith=ScriptState, RaisesException] constructor(VideoDecoderInit init);
// The number of queued decode requests. This does not include requests that
// have been taken for processing.
//
// Applications can minimize underflow by enqueueing decode requests until
// |decodeQueueSize| is greater than a constant.
readonly attribute long decodeQueueSize;
// The number of decode requests currently being processed.
//
// Applications can minimize resource consumption and decode latency by
// enqueueing decode requests only when |decodeQueueSize| and
// |decodeProcessingCount| are small.
//
// TODO(sandersd): Consider counting queued decode requests as well. This
// could be simpler for apps.
readonly attribute long decodeProcessingCount;
// Enqueue a request to set or change the stream configuration.
//
// The next enqueued decode request must be for a keyframe.
//
// Resolved after emitting output for all earlier decode requests.
//
// TODO(sandersd): Test that resolution (a microtask) interleaves between
// outputs callback calls in all cases.
// TODO(sandersd): Move the keyframe rule into the bytestream registry.
[RaisesException] Promise<void> configure(EncodedVideoConfig config);
// Enqueue a request to decode an input chunk.
//
// You must call configure() before calling enqueue() for the first time.
//
// Resolved after decoding of the input chunk has started (that is, after
// decreasing |decodeQueueSize|).
//
// TODO(sandersd): Change to a dictionary type.
// TODO(sandersd): Should we guarantee that resolution occurs in order?
// TODO(sandersd): Add status to result.
// TODO(sandersd): Buffer return.
[RaisesException] Promise<void> decode(EncodedVideoChunk chunk);
// Enqueue a request to finish decoding queued input chunks.
//
// The next enqueued input chunk must be a keyframe.
//
// Resolved after emitting output for all earlier decode requests.
//
// TODO(sandersd): Consider relaxing the keyframe requirement.
[RaisesException] Promise<void> flush();
// Discard all pending work.
//
// Output for earlier decode requests will not be emitted, even if processing
// has already started.
//
// The next enqueued input chunk must be a keyframe.
//
// Resolved after all earlier enqueue() promises have been resolved.
//
// TODO(sandersd): Require configure() after reset()?
[RaisesException] Promise<void> reset();
};
|