Commit bbd2cd14 authored by Matt Wolenetz's avatar Matt Wolenetz Committed by Commit Bot

[webcodecs] Add 'required' where missing from IDL dicts

Updates a few WebCodecs IDL dictionary types to use the 'required'
attribute where the draft spec indicates. In particular, it updates
AudioFrameInit, EncodedAudioChunkInit, and EncodedVideoChunkInit to
enforce the required fields are populated.

I also looked at making similar change to VideoDecoderConfig, but the
codedWidth and codedHeight fields' usage in the implementation already
has notes that go deeper (AVCC coherence is TBD, for example).

Also includes a change to make EncodedVideoChunkInit.duration _not_
nullable. It is not required, so its absence is sufficient to indicate
it is unset. Retains the nullable attribute on the readonly
EncodedVideoChunk.duration field.

BUG=1149028

Change-Id: If82c495d94ed9532007dfda614ec97bc88e773ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2543126Reviewed-by: default avatarEugene Zemtsov <eugene@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828477}
parent ef910cba
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
// https://github.com/WICG/web-codecs // https://github.com/WICG/web-codecs
dictionary AudioFrameInit { dictionary AudioFrameInit {
unsigned long long timestamp; // microseconds required unsigned long long timestamp; // microseconds
AudioBuffer buffer; required AudioBuffer buffer;
}; };
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// https://github.com/WICG/web-codecs // https://github.com/WICG/web-codecs
dictionary EncodedAudioChunkInit { dictionary EncodedAudioChunkInit {
EncodedVideoChunkType type; required EncodedVideoChunkType type;
unsigned long long timestamp; // microseconds required unsigned long long timestamp; // microseconds
BufferSource data; required BufferSource data;
}; };
...@@ -17,9 +17,8 @@ EncodedVideoChunk* EncodedVideoChunk::Create(EncodedVideoChunkInit* init) { ...@@ -17,9 +17,8 @@ EncodedVideoChunk* EncodedVideoChunk::Create(EncodedVideoChunkInit* init) {
EncodedVideoMetadata metadata; EncodedVideoMetadata metadata;
metadata.timestamp = base::TimeDelta::FromMicroseconds(init->timestamp()); metadata.timestamp = base::TimeDelta::FromMicroseconds(init->timestamp());
metadata.key_frame = (init->type() == "key"); metadata.key_frame = (init->type() == "key");
if (init->hasDurationNonNull()) { if (init->hasDuration()) {
metadata.duration = metadata.duration = base::TimeDelta::FromMicroseconds(init->duration());
base::TimeDelta::FromMicroseconds(init->durationNonNull());
} }
DOMArrayPiece piece(init->data()); DOMArrayPiece piece(init->data());
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
// https://github.com/WICG/web-codecs // https://github.com/WICG/web-codecs
dictionary EncodedVideoChunkInit { dictionary EncodedVideoChunkInit {
EncodedVideoChunkType type; required EncodedVideoChunkType type;
unsigned long long timestamp; // microseconds required unsigned long long timestamp; // microseconds
unsigned long long? duration; // microseconds unsigned long long duration; // microseconds
BufferSource data; required BufferSource data;
}; };
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