Skip to content

Commit c683ac1

Browse files
dalecurtispadenot
andauthored
Implement orientation support for VideoEncoder. (#884)
* Implement orientation support for VideoEncoder. This implements the algorithm as discussed in the Media WG: * Orientation is locked-in upon the first call to encode(). * Mismatched orientation will trigger a non-fatal error by throwing an exception during encode(). * The orientation of the first frame is emitted on the VideoDecoderConfig attached to EncodedVideoChunkMetadata. Fixes: #351 * Accept suggestion to clarify active orientation setting. Co-authored-by: Paul Adenot <paul@paul.cx> --------- Co-authored-by: Paul Adenot <paul@paul.cx>
1 parent 011346f commit c683ac1

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

index.src.html

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,10 @@
14021402
: <dfn attribute for=VideoEncoder>[[dequeue event scheduled]]</dfn>
14031403
:: A boolean indicating whether a {{VideoEncoder/dequeue}} event is already
14041404
scheduled to fire. Used to avoid event spam.
1405+
: <dfn attribute for=VideoEncoder>[[active orientation]]</dfn>
1406+
:: An integer and boolean pair indicating the {{VideoFrame/[[flip]]}} and
1407+
{{VideoFrame/[[rotation]]}} of the first {{VideoFrame}} given to
1408+
{{VideoEncoder/encode()}} after {{VideoEncoder/configure()}}.
14051409

14061410
Constructors {#videoencoder-constructors}
14071411
-----------------------------------------
@@ -1461,8 +1465,9 @@
14611465
2. If {{VideoEncoder/[[state]]}} is `"closed"`, throw an
14621466
{{InvalidStateError}}.
14631467
3. Set {{VideoEncoder/[[state]]}} to `"configured"`.
1464-
4. [=Queue a control message=] to configure the encoder using |config|.
1465-
5. [=Process the control message queue=].
1468+
4. Set {{VideoEncoder/[[active orientation]]}} to `null`.
1469+
5. [=Queue a control message=] to configure the encoder using |config|.
1470+
6. [=Process the control message queue=].
14661471

14671472
[=Running a control message=] to configure the encoder means performing
14681473
these steps:
@@ -1491,11 +1496,16 @@
14911496
is `true`, throw a {{TypeError}}.
14921497
2. If {{VideoEncoder/[[state]]}} is not `"configured"`, throw an
14931498
{{InvalidStateError}}.
1494-
3. Let |frameClone| hold the result of running the [=Clone VideoFrame=]
1499+
3. If {{VideoEncoder/[[active orientation]]}} is not `null` and does not match
1500+
|frame|'s {{VideoFrame/[[rotation]]}} and {{VideoFrame/[[flip]]}} throw a
1501+
{{DataError}}.
1502+
4. If {{VideoEncoder/[[active orientation]]}} is `null`, set it to |frame|'s
1503+
{{VideoFrame/[[rotation]]}} and {{VideoFrame/[[flip]]}}.
1504+
5. Let |frameClone| hold the result of running the [=Clone VideoFrame=]
14951505
algorithm with |frame|.
1496-
4. Increment {{VideoEncoder/[[encodeQueueSize]]}}.
1497-
5. [=Queue a control message=] to encode |frameClone|.
1498-
6. [=Process the control message queue=].
1506+
6. Increment {{VideoEncoder/[[encodeQueueSize]]}}.
1507+
7. [=Queue a control message=] to encode |frameClone|.
1508+
8. [=Process the control message queue=].
14991509

15001510
[=Running a control message=] to encode the frame means performing these
15011511
steps:
@@ -1646,7 +1656,11 @@
16461656
`outputConfig.displayAspectWidth`.
16471657
5. Assign `encoderConfig.displayHeight` to
16481658
`outputConfig.displayAspectHeight`.
1649-
6. Assign the remaining keys of `outputConfig` as determined by
1659+
6. Assign {{VideoFrame/[[rotation]]}} from the {{VideoFrame}}
1660+
associated with |output| to `outputConfig.rotation`.
1661+
7. Assign {{VideoFrame/[[flip]]}} from the {{VideoFrame}}
1662+
associated with |output| to `outputConfig.flip`.
1663+
8. Assign the remaining keys of `outputConfig` as determined by
16501664
{{VideoEncoder/[[codec implementation]]}}. The User Agent
16511665
<em class="rfc2119">MUST</em> ensure that the configuration is
16521666
completely described such that |outputConfig| could be used to

0 commit comments

Comments
 (0)