|
99 | 99 |
|
100 | 100 | spec: webrtc-svc; urlPrefix: https://w3c.github.io/webrtc-svc/ |
101 | 101 | type: dfn; text: scalability mode identifier; url:#scalabilitymodes* |
| 102 | + |
| 103 | +spec: ECMASCRIPT; urlPrefix: https://tc39.es/ecma262/ |
| 104 | + type: dfn; text: the current Realm; url: #current-realm |
| 105 | + type: dfn; text: SetIntegrityLevel; url: #sec-setintegritylevel |
102 | 106 | </pre> |
103 | 107 |
|
104 | 108 | <pre class='biblio'> |
|
3182 | 3186 | readonly attribute long long? timestamp; // microseconds |
3183 | 3187 | readonly attribute VideoColorSpace colorSpace; |
3184 | 3188 |
|
| 3189 | + VideoFrameMetadata getMetadata(); |
| 3190 | + |
3185 | 3191 | unsigned long allocationSize( |
3186 | 3192 | optional VideoFrameCopyToOptions options = {}); |
3187 | 3193 | Promise<sequence<PlaneLayout>> copyTo( |
|
3204 | 3210 | // Default matches image unless visibleRect is provided. |
3205 | 3211 | [EnforceRange] unsigned long displayWidth; |
3206 | 3212 | [EnforceRange] unsigned long displayHeight; |
| 3213 | + |
| 3214 | + VideoFrameMetadata metadata; |
3207 | 3215 | }; |
3208 | 3216 |
|
3209 | 3217 | dictionary VideoFrameBufferInit { |
|
3225 | 3233 |
|
3226 | 3234 | VideoColorSpaceInit colorSpace; |
3227 | 3235 | }; |
| 3236 | + |
| 3237 | +dictionary VideoFrameMetadata { |
| 3238 | + any user; |
| 3239 | +}; |
3228 | 3240 | </xmp> |
3229 | 3241 |
|
3230 | 3242 | ### Internal Slots ###{#videoframe-internal-slots} |
|
3279 | 3291 | : <dfn attribute for=VideoFrame>[[color space]]</dfn> |
3280 | 3292 | :: The {{VideoColorSpace}} associated with this frame. |
3281 | 3293 |
|
| 3294 | +: <dfn attribute for=VideoFrame>\[[metadata]]</dfn> |
| 3295 | +:: The {{VideoFrameMetadata}} associated with this frame. |
| 3296 | + |
| 3297 | + |
3282 | 3298 | ### Constructors ###{#videoframe-constructors} |
3283 | 3299 |
|
3284 | 3300 | <dfn constructor for=VideoFrame title="VideoFrame(image, init)"> |
|
3291 | 3307 | with the [=webappapis/entry settings object=]'s |
3292 | 3308 | [=origin/origin=], then throw a {{SecurityError}} |
3293 | 3309 | {{DOMException}}. |
3294 | | -3. Let |frame| be a new {{VideoFrame}}. |
3295 | | -5. Switch on |image|: |
| 3310 | +3. Let |metadata| be the result of calling [=Copy VideoFrame metadata=] |
| 3311 | + with |init|'s {{VideoFrameInit/metadata}}. |
| 3312 | +4. Let |frame| be a new {{VideoFrame}}. |
| 3313 | +5. Assign |metadata| to |frame|'s {{VideoFrame/metadata}}. |
| 3314 | +6. Switch on |image|: |
3296 | 3315 | - {{HTMLImageElement}} |
3297 | 3316 | - {{SVGImageElement}} |
3298 | 3317 | 1. If {{VideoFrameInit/timestamp}} does not [=map/exist=] in |
|
3339 | 3358 | 1. Run the [=VideoFrame/Initialize Frame From Other Frame=] algorithm |
3340 | 3359 | with |init|, |frame|, and |image|. |
3341 | 3360 |
|
3342 | | -6. Return |frame|. |
| 3361 | +7. Return |frame|. |
3343 | 3362 |
|
3344 | 3363 |
|
3345 | 3364 | <dfn constructor for=VideoFrame title="VideoFrame(data, init)"> |
|
3365 | 3384 | Layout and Allocation Size=] algorithm with |parsedRect|, |
3366 | 3385 | |init|.{{VideoFrameBufferInit/format}}, and |optLayout|. |
3367 | 3386 | 9. If |combinedLayout| is an exception, throw |combinedLayout|. |
3368 | | -10. If `data.byteLength` is less than |combinedLayout|’s |
| 3387 | +10. Let |metadata| be the result of calling [=Copy VideoFrame metadata] |
| 3388 | + with |init|'s {{VideoFrameInit/metadata}}. |
| 3389 | +11. If `data.byteLength` is less than |combinedLayout|’s |
3369 | 3390 | [=combined buffer layout/allocationSize=], throw a {{TypeError}}. |
3370 | | -11. Let |resource| be a new [=media resource=] containing a copy of |data|. Use |
| 3391 | +12. Let |resource| be a new [=media resource=] containing a copy of |data|. Use |
3371 | 3392 | {{VideoFrameBufferInit/visibleRect}} and {{VideoFrameBufferInit/layout}} |
3372 | 3393 | to determine where in |data| the pixels for each plane reside. |
3373 | 3394 |
|
|
3380 | 3401 | reposition the visible rectangle within |resource|. The final position |
3381 | 3402 | will be reflected by {{VideoFrame/visibleRect}}. |
3382 | 3403 |
|
3383 | | -12. Let |resourceCodedWidth| be the coded width of |resource|. |
3384 | | -13. Let |resourceCodedHeight| be the coded height of |resource|. |
3385 | | -14. Let |resourceVisibleLeft| be the left offset for the visible rectangle of |
| 3404 | +13. Let |resourceCodedWidth| be the coded width of |resource|. |
| 3405 | +14. Let |resourceCodedHeight| be the coded height of |resource|. |
| 3406 | +15. Let |resourceVisibleLeft| be the left offset for the visible rectangle of |
3386 | 3407 | |resource|. |
3387 | | -15. Let |resourceVisibleTop| be the top offset for the visible rectangle of |
| 3408 | +16. Let |resourceVisibleTop| be the top offset for the visible rectangle of |
3388 | 3409 | |resource|. |
3389 | 3410 |
|
3390 | 3411 | ISSUE: The spec <em class="rfc2119">SHOULD</em> provide definitions (and |
3391 | 3412 | possibly diagrams) for coded size, visible rectangle, and display size. |
3392 | 3413 | See [#166](https://github.com/w3c/webcodecs/issues/166). |
3393 | 3414 |
|
3394 | | -16. Let |frame| be a new {{VideoFrame}} object initialized as follows: |
| 3415 | +17. Let |frame| be a new {{VideoFrame}} object initialized as follows: |
3395 | 3416 | 1. Assign |resourceCodedWidth|, |resourceCodedHeight|, |
3396 | 3417 | |resourceVisibleLeft|, and |resourceVisibleTop| to |
3397 | 3418 | {{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}}, |
|
3426 | 3447 | 9. Assign the result of running the [=VideoFrame/Pick Color Space=] |
3427 | 3448 | algorithm, with |colorSpace| and {{VideoFrame/[[format]]}}, to |
3428 | 3449 | {{VideoFrame/[[color space]]}}. |
3429 | | -17. Return |frame|. |
| 3450 | + 10. Assign |metadata| to {{VideoFrame/[[metadata]]}}. |
| 3451 | +18. Return |frame|. |
3430 | 3452 |
|
3431 | 3453 | ### Attributes ###{#videoframe-attributes} |
3432 | 3454 | : <dfn attribute for=VideoFrame>format</dfn> |
|
3624 | 3646 |
|
3625 | 3647 | When invoked, run the [=Close VideoFrame=] algorithm with [=this=]. |
3626 | 3648 |
|
| 3649 | +: <dfn method for=VideoFrame>getMetadata()</dfn> |
| 3650 | +:: Gets the {{VideoFrameMetadata}} associated with this frame. |
| 3651 | + |
| 3652 | + When invoked, return [=this=] {{VideoFrame/[[metadata]]}}. |
| 3653 | + |
3627 | 3654 | ### Algorithms ###{#videoframe-algorithms} |
3628 | 3655 | : <dfn>Create a VideoFrame</dfn> (with |output|, |timestamp|, |duration|, |displayAspectWidth|, |displayAspectHeight|, and |colorSpace|) |
3629 | 3656 | :: 1. Let |frame| be a new {{VideoFrame}}, constructed as follows: |
|
3825 | 3852 | and {{VideoFrame/[[display height]]}}. |
3826 | 3853 | 5. Assign `null` to |frame|'s {{VideoFrame/[[duration]]}} and |
3827 | 3854 | {{VideoFrame/[[timestamp]]}}. |
| 3855 | + 6. Assign `null` to |frame|'s {{VideoFrame/[[metadata]]}}. |
| 3856 | + |
3828 | 3857 |
|
3829 | 3858 | : <dfn for=VideoFrame>Parse VideoFrameCopyToOptions</dfn> (with |options|) |
3830 | 3859 | :: 1. Let |defaultRect| be the result of performing the getter steps for |
|
3998 | 4027 | [=combined buffer layout/allocationSize=]. |
3999 | 4028 | 9. Return |combinedLayout|. |
4000 | 4029 |
|
| 4030 | + |
| 4031 | +: <dfn for=VideoFrame>Copy VideoFrame metadata</dfn> (with |metadata|) |
| 4032 | +:: 1. Let |metadataCopySerialized| be [$StructuredSerialize$](|metadata|). |
| 4033 | + 2. Let |metadataCopy| be [$StructuredDeserialize$](|metadataCopySerialized|, [=the current Realm=]). |
| 4034 | + 3. Let |userMetadataCopy| be |metadataCopy|'s {{VideoFrameMetadata/user}}. |
| 4035 | + 4. Call [=SetIntegrityLevel=] with |userMetadataCopy| and frozen. |
| 4036 | + 5. return |metadataCopy|. |
| 4037 | + |
4001 | 4038 | ### Transfer and Serialization ###{#videoframe-transfer-serialization} |
4002 | 4039 |
|
4003 | 4040 | : The {{VideoFrame}} [=transfer steps=] (with |value| and |dataHolder|) are: |
4004 | 4041 | :: 1. If |value|'s {{platform object/[[Detached]]}} is `true`, throw a |
4005 | 4042 | {{DataCloneError}} {{DOMException}}. |
4006 | | - 2. For all {{VideoFrame}} internal slots in |value|, assign the value of |
| 4043 | + 2. Let |metadata| be |value|'s {{VideoFrame/metadata}}. |
| 4044 | + 3. Assign [$StructuredSerialize$](|metadata|) to |dataHolder|.[[metadata]]. |
| 4045 | + 4. For all other {{VideoFrame}} internal slots in |value|, assign the value of |
4007 | 4046 | each internal slot to a field in |dataHolder| with the same name as the |
4008 | 4047 | internal slot. |
4009 | | - 3. Run the [=Close VideoFrame=] algorithm with |value|. |
| 4048 | + 5. Run the [=Close VideoFrame=] algorithm with |value|. |
4010 | 4049 |
|
4011 | 4050 | : The {{VideoFrame}} [=transfer-receiving steps=] (with |dataHolder| and |
4012 | 4051 | |value|) are: |
4013 | | -:: 1. For all named fields in |dataHolder|, assign the value of each named |
| 4052 | +:: 1. For all other named fields in |dataHolder|, assign the value of each named |
4014 | 4053 | field to the {{VideoFrame}} internal slot in |value| with the same name |
4015 | 4054 | as the named field. |
4016 | 4055 |
|
|
4023 | 4062 | |value|'s {{VideoFrame/[[resource reference]]}}. |
4024 | 4063 | 4. Let |newReference| be a new reference to |resource|. |
4025 | 4064 | 5. Assign |newReference| to |serialized|.[[resource reference]]. |
4026 | | - 6. For all remaining {{VideoFrame}} internal slots (excluding |
4027 | | - {{VideoFrame/[[resource reference]]}}) in |value|, assign the value of |
| 4065 | + 6. Let |metadata| be |value|'s {{VideoFrame/metadata}}. |
| 4066 | + 7. Assign [$StructuredSerialize$](|metadata|) to |serialized|.[[metadata]]. |
| 4067 | + 8. For all remaining {{VideoFrame}} internal slots (excluding |
| 4068 | + {{VideoFrame/[[resource reference]]}} and {{VideoFrame/[[metadata]]}}) in |value|, assign the value of |
4028 | 4069 | each internal slot to a field in |serialized| with the same name as the |
4029 | 4070 | internal slot. |
4030 | 4071 |
|
4031 | 4072 | : The {{VideoFrame}} [=deserialization steps=] (with |serialized| and |value|) |
4032 | 4073 | are: |
4033 | | -:: 1. For all named fields in |serialized|, assign the value of each named |
| 4074 | +:: 1. Let |metadata| be [$StructuredDeserialize$](|serialized|.[[metadata]], [=the current Realm=]). |
| 4075 | + 2. Assign |metadata| to |value|'s {{VideoFrame/metadata}}. |
| 4076 | + 3. For all other named fields in |serialized|, assign the value of each named |
4034 | 4077 | field to the {{VideoFrame}} internal slot in |value| with the same name |
4035 | 4078 | as the named field. |
4036 | 4079 |
|
|
0 commit comments